State specific product offering – Best practice

To build an e-commerce site that offers a specific set of products for each state of a country, what would be the best practice to be followed to create the product catalog.

Approaches

  1. Define each state as root category and then create products under desired subcategories
  2. Define a single root category and then create products under desired subcategories. Define a custom multi-select “Available State” attribute and tag the product to respective state.
  3. Create a multi-store site where each state is represented as a store and then create desired products for each store.

How to convert this DFA with multiple final states to a regular expression? (State elimination method)

So I have a DFA which I would like to convert to a regular expression. As you can see it has multiple accepting states and the start state has incoming input ‘a’ from q2 and ‘b’ from q4.

DFA

I want to convert this into a regular expression using State elimination, and I know that I need to first create a new state call it ‘s’ which replaces q0 as the start state, and then create another new state (call it ‘f’) which will be the new final state, and make q1, q2, q3, and q4 non-accepting states, and make epsilon transitions from the former accepting states to the new final state.

My question is, when I eliminate say q1, I don’t know what the regular expression will be as a result. Now since q1 has 2 outgoing transitions ‘a’ to a2 and epsilon to f, what would be that regular expression? I know that for q2 it would be a(ba)a(ba) … then q0 to f will be a(ba)*.. so far it doesn’t make sense to me how this will end up becoming the correct regular expression. Am I on the right track?

Como faço para setar o state com json dinâmico local?


Como faço para colocar os dados do json dentro do array “receitas[]” que está no state?

 import recipes from '../receitas/recipes.json'   constructor(props) {     super(props);      this.recipes = recipes.results;  //json dinâmico local        this.state = {        receitas: [],            searchString: ''             };   }     componentDidMount(){          this.loadReceitas();   }    loadReceitas = async () => {     const recipesList = await this.props.recipes.results;        this.setState({ receitas: recipesList.recipes.results });   } 

Desde já agradeço quem puder me ajudar.

Centos7, firewall-cmd –reload, “COMMAND_FAILED –state requires an argument” How to give state an argument?

I am using Centos7 and have just made some changes to the firewall. I am trying to configure my firewall to filter my ssh connection. I am following the How To documentation on Centos7 How Tos, Securing OpenSSh: Filter SSH at the Firewall. Essentially these fire wall settings are recording access to port 22, and limiting the number of times the ip can access the port to 4 times in 60 seconds. These are the commands I have just ran.

iptables -A INPUT -p tcp --dport 22 -m state --state NEW -m recent --set --name ssh --rsource iptables -A INPUT -p tcp --dport 22 -m state --state NEW -m recent ! --rcheck --seconds 60 --hitcount 4 --name ssh --rsource -j ACCEPT   firewall-cmd --permanent --direct --add-rule ipv4 filter INPUT_direct 0 -p tcp --dport 22 -m state --state NEW -m recent --set firewall-cmd --permanent --direct --add-rule ipv4 filter INPUT_direct 1 -p tcp --dport 22 -m state --state NEW -m recent --update --seconds 30 --hitcount 4 -j REJECT --reject-with tcp-reset firewall-cmd --reload  

On firewall-cmd –reload I recive an the error

Error: COMMAND_FAILED: Direct: '/usr/sbin/iptables-restore -w -n' failed: iptables-restore v1.4.21: option "--state" requires an argument Error occured at line: 2 Try 'iptables-restore -h' or 'iptables-restore --help' for more infomation. 

Not sure what to do next. How do i give state an argument?

Disk Utility First Aid in recovery failed to restore volume to original state

I was trying to repair permissions today on my Mac so I ran the Disk Utility’s First Aid on my drive and it said that there was an Invalid Index Key and that my disk was corrupt and I needed to run the first aid in Recovery mode.

So I opened in recovery mode and ran the first aid and it tried to fix the B-Tree of the catalog file, however there wasn’t enough disk space to do this.

Then it tried to restore the disk to it’s original state on mount but it couldn’t do this either, I’m guessing because of lack of disk space.

(I had about 13GB of free space at this time)

Sorry I didn’t get any screenshots or anything but that is basically what happened.

Now the disk is greyed out in disk utility and I can’t reinstall mac os x because I would need to erase all of the data on the drive and I don’t want to lose the files I have on it.

So what I thought I could try is delete my BOOTCAMP partition, which is about 100GB, and then merge the free space into the problem partition so that I can run fsck -fy in single user mode to try to repair the volume which now will have enough space to complete the operation.

However the option to delete the BOOTCAMP partition is disabled in Disk Utility. So I did some research and found another post on AskDifferent that explained how to delete a partition from terminal (in recovery mode) by first unmounting the physical disk using diskutil unmountDisk /dev/disk0 and then deleting the partition using gpt remove.

Now I tried to unmount the disk using that command and even with the force wildcard but it said:

Forced unmount of disk0 failed: at least one volume could not be unmounted Unmount was dissented by PID 0 

The volume with PID 0 from the list provided by diskutil list is called GUID_partition_scheme.

This is as far as I got through searching for solutions online. I need help deleting the BOOTCAMP partition and merging with the greyed out Mac HD partition so that I can run fsck to hopefully restore my mac os to working order. At the moment I can’t boot into the OS and can only boot into recovery mode or single user mode. Hopefully I will atleast be able to retrieve files from the HD if all else fails.

Are “I’m writing android applications” and “follow open-closed principles” reasons to allow global state?

For example, suppose I have an android application, in simple, there are 3 activities :

MainActivity -> Main2Activity -> Main3Activity 

,which user can visit them in sequence (eg: by button click), also there is some global data to show:

public class GlobalData{     public static String userId; }  public class MainActivity extends AppCompatActivity {     //button click listener     public void toMain2Activity(View view){         Intent i = new Intent(this, Main2Activity.class);         this.startActivity(i);     } }  public class Main2Activity extends AppCompatActivity {     //button click listener     public void toMain3Activity(View view){         Intent i = new Intent(this,Main3Activity.class);         this.startActivity(i);     } }  public class Main3Activity extends AppCompatActivity {     @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_main3);     } } 

One day, Main3Activity needs to display userId in GlobalData, so I modify Main3Activity:

public class Main3Activity extends AppCompatActivity {     @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_main3);          Toast.makeText(this,GlobalData.userId, Toast.LENGTH_LONG).show();     } } 

But according to Why is Global State so Evil?, I should avoid global state, so I try to pass the original data object instead of allowing global state, so I try to pass the global object to Main3Activity instead of share it everywhere:

public class GlobalData implements Serializable {     public String userId="user_67890"; }  public class MainActivity extends AppCompatActivity {     private GlobalData globalData=new GlobalData();      public void toMain2Activity(View view){         Intent i = new Intent(this, Main2Activity.class);         i.putExtra("global",this.globalData);         this.startActivity(i);     } }  public class Main2Activity extends AppCompatActivity {     private GlobalData globalData;     @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_main2);          this.globalData=(GlobalData)this.getIntent().getSerializableExtra("global");     }      public void toMain3Activity(View view){         Intent i = new Intent(this, Main3Activity.class);         i.putExtra("global",this.globalData);         this.startActivity(i);     } }  public class Main3Activity extends AppCompatActivity {     @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_main3);         GlobalData globalData=(GlobalData) this.getIntent().getSerializableExtra("global");         Toast.makeText(this,globalData.userId, Toast.LENGTH_LONG).show();     } } 

But I think avoiding global state is less maintainable and more unpredictable in my case because:

  1. With global state, I don’t need to modify Main2Activity, which seems more fit the open closed principle, but if I want to avoid global state, I need to modify all intermediate (eg:Main2Activity) UI from start(source of GlobalData) to terminal (UI that uses GlobalData), which my android application is usually one UI component is included by another UI in depth.

  2. If I pass the GlobalData only when I need it, it means I may have many functions need to add something like “GlobalData globaldata=this.getIntent().getSerializableExtra…” and “Intent i=…” everywhere, which I think it is less readable

  3. In the modified version, it is possible that the this.getIntent().getSerializableExtra is failed because I may forget to put the object into the intent, and I need to handle if I get GlobalData failed, which I think it is less maintainable

  4. Usually the GlobalData is not involved in Unit Test because the GlobalData is usually displayed directly, so I think sharing GlobalData doesn’t make the app harder to test

  5. Using intent let me need to think how to write additional codes to pass data between same level UI components (eg:same Activity, from EditText to error message detail label)

As above, I think avoid global state is more evil than having global state in my case. So my question is, are “I’m writing android applications” and “follow open-closed principles” reasons to allow global state?

FSM (Finite State Automaton and PDA (Push Down Automaton

Say we have the following language, some number of a’s and b’s followed by three a’s followed by some number of a’s and b’s

Show how you can create a finite state machine that will accept the words in the language and reject words, not in the language. Show the transition rules.

Show how you can create a PDA or push down automata that will accept the words in the language and reject words, not in the language. Show the transition rules.

State of the art on testing system architecture [on hold]

I work in a lab containing a system of computers and simulators interacting with each other in order to recreate a complete and accurate boat simulation.

The software used on these machines receives an update from our development team every 3 or 4 months and we run the software through a big batch of tests to make sure it works properly (~100+ tests each time)

Around 80% of these tests can be easily automated but we have no means to do that yet.

My project is to come up with an architecture for a system allowing us to run automated tests on our computers (several at once). In order to begin I’m looking to get an idea of the state of the art in the domain of systems set up to run automated tests.

I have a vague idea of what I’m looking for : examples and ideas of computers set up on a network with all the SUT’s (System Under Test) and how they interact.

Would you have any sources of information, documents and papers I could look into in order to get an idea of what already exists?

Thank you very much and sorry for the imprecision of what I’m asking, I’m only just starting, trying to figure things out.

How to use setState to push API data to empty array inside my state?

Inside my class based component I’m trying to push the fetched data to my empty state array “ondernemen”.

I have this function filterData where I’m directly mapping through the data.

What i would to accomplish is to first push the data to the state and afterwards loop/map through the changed state.

When i directly try to use setState({ ondernemen: FilterMap}} i get an error “Maximum depth reached”.

How can i solve this?

My code:

import React, { Component } from 'react'; import Moment from 'moment';  // React components import CheckBox from '../checkboxes/checkbox'; import OpendagenScrollbar from 'react-perfect-scrollbar';  class Opendagen extends Component {     state = {         opendagen: [],     };      filterData = () => {         const { opendagen, filter, checks } = this.props;          const concatOpendagen = [             [{ title: 'Food' }, ...opendagen.food_group.opendagen],             [{ title: 'Techniek' }, ...opendagen.techniek_group.opendagen],             [{ title: 'Bouw' }, ...opendagen.bouw_group.opendagen],             [{ title: 'Zorg' }, ...opendagen.zorg_group.opendagen],             [                 { title: '' },                 ...opendagen.zorg_group.opendagen,                 ...opendagen.food_group.opendagen,                 ...opendagen.bouw_group.opendagen,                 ...opendagen.techniek_group.opendagen,             ],         ];         const filteredData = concatOpendagen.filter(([{ title }]) =>             filter.includes(title)         );         const filterMap = filteredData[0].slice(1);          const data = [];          filterMap.sort(function(a, b) {             return (                 Date.parse(                     new Date(                         a.opendag_data                             .split('/')                             .reverse()                             .join('-')                     )                 ) -                 Date.parse(                     new Date(                         b.opendag_data                             .split('/')                             .reverse()                             .join('-')                     )                 )             );         });          filterMap.map((value, index) => {             const concatData = [                 ...(value.opendag_department + ' - '),                 ...(value.opendag_data + ' - '),                 ...value.opendag_link,             ];              // const date = Moment(value.opendag_data);             // const now = Moment();              return data.push(                 <tr key={index}>                     <td data-th="Datum">{value.opendag_data}</td>                     <td data-th="Opleiding">                         <strong>{value.opendag_department}</strong>                     </td>                     <td data-th="Link">                         <a                             target="_blank"                             rel="noopener noreferrer"                             href={value.opendag_link}>                             bekijk website                         </a>                     </td>                     <td data-th="Select">                         <CheckBox                             thisClassName="data__checkbox checkbox__input"                             value={concatData.join('')}                             id={'string_' + index}                             onChange={checks}                         />                     </td>                 </tr>             );         });         return data;     };      render() {         const settings = {             className: 'content__scrollbar',         };          return (             <React.Fragment>                 <h2 className="content__title">{this.props.filter}</h2>                 <OpendagenScrollbar {...settings}>                     <table className="adb__table">                         <tbody>                             <tr>                                 <th>Datum</th>                                 <th>Opleiding</th>                                 <th>Link</th>                                 <th />                             </tr>                             {this.filterData()}                         </tbody>                     </table>                 </OpendagenScrollbar>             </React.Fragment>         );     } }  export default Opendagen;