qid
int64
1
74.7M
question
stringlengths
15
58.3k
date
stringlengths
10
10
metadata
list
response_j
stringlengths
4
30.2k
response_k
stringlengths
11
36.5k
11,823,894
I need to pass data to Neural Net operator. Some attributes are binomial and Neural Net does not accept binomial data type, however it accepts integer. There is no Binomial to Integer (Numerical) type conversion operator. So how can I convert this ? Thanks for an answers
2012/08/06
[ "https://Stackoverflow.com/questions/11823894", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1578496/" ]
replace ``` String input = keyboard.next(); ``` with ``` input = keyboard.next(); ``` If you put a `String` before the variable name it is a declaration. And you can declare a variable name only once in a scope.
As far as I know, this is not how you hide the variables. Here is what I mean ``` private static String input = null; public static void main(String [] args){ Scanner keyboard = new Scanner(System.in); do { System.out.println("Enter 'A' for option A or 'B' for option B."); String input ...
11,823,894
I need to pass data to Neural Net operator. Some attributes are binomial and Neural Net does not accept binomial data type, however it accepts integer. There is no Binomial to Integer (Numerical) type conversion operator. So how can I convert this ? Thanks for an answers
2012/08/06
[ "https://Stackoverflow.com/questions/11823894", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1578496/" ]
replace ``` String input = keyboard.next(); ``` with ``` input = keyboard.next(); ``` If you put a `String` before the variable name it is a declaration. And you can declare a variable name only once in a scope.
You have declared the `input` variable twice . Inside the `main` method declare `input` only once. Use the following code inside `do {}`: ``` input = keyboard.next(); instead of String input = keyboard.next(); ```
11,823,894
I need to pass data to Neural Net operator. Some attributes are binomial and Neural Net does not accept binomial data type, however it accepts integer. There is no Binomial to Integer (Numerical) type conversion operator. So how can I convert this ? Thanks for an answers
2012/08/06
[ "https://Stackoverflow.com/questions/11823894", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1578496/" ]
Yoy've duplicated `String input` declaration. Once is enough.
You have declared the `input` variable twice . Inside the `main` method declare `input` only once. Use the following code inside `do {}`: ``` input = keyboard.next(); instead of String input = keyboard.next(); ```
11,823,894
I need to pass data to Neural Net operator. Some attributes are binomial and Neural Net does not accept binomial data type, however it accepts integer. There is no Binomial to Integer (Numerical) type conversion operator. So how can I convert this ? Thanks for an answers
2012/08/06
[ "https://Stackoverflow.com/questions/11823894", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1578496/" ]
You have declared the `input` variable twice. You will need to change this line: ``` String input = keyboard.next(); ``` to this: ``` input = keyboard.next(); ``` Also, this code will most likely not work: ``` ((input != "a") || (input != "b")) ``` In Java, Strings are compared using the `.equals()` method,...
Yoy've duplicated `String input` declaration. Once is enough.
11,823,894
I need to pass data to Neural Net operator. Some attributes are binomial and Neural Net does not accept binomial data type, however it accepts integer. There is no Binomial to Integer (Numerical) type conversion operator. So how can I convert this ? Thanks for an answers
2012/08/06
[ "https://Stackoverflow.com/questions/11823894", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1578496/" ]
replace ``` String input = keyboard.next(); ``` with ``` input = keyboard.next(); ``` If you put a `String` before the variable name it is a declaration. And you can declare a variable name only once in a scope.
You will get a duplicate local variable if you have declared the variable twice, here in your code you have declared the **input variable** twice. That is why you received that error.
11,823,894
I need to pass data to Neural Net operator. Some attributes are binomial and Neural Net does not accept binomial data type, however it accepts integer. There is no Binomial to Integer (Numerical) type conversion operator. So how can I convert this ? Thanks for an answers
2012/08/06
[ "https://Stackoverflow.com/questions/11823894", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1578496/" ]
replace ``` String input = keyboard.next(); ``` with ``` input = keyboard.next(); ``` If you put a `String` before the variable name it is a declaration. And you can declare a variable name only once in a scope.
You have declared the `input` variable twice. You will need to change this line: ``` String input = keyboard.next(); ``` to this: ``` input = keyboard.next(); ``` Also, this code will most likely not work: ``` ((input != "a") || (input != "b")) ``` In Java, Strings are compared using the `.equals()` method,...
11,823,894
I need to pass data to Neural Net operator. Some attributes are binomial and Neural Net does not accept binomial data type, however it accepts integer. There is no Binomial to Integer (Numerical) type conversion operator. So how can I convert this ? Thanks for an answers
2012/08/06
[ "https://Stackoverflow.com/questions/11823894", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1578496/" ]
You have declared the `input` variable twice. You will need to change this line: ``` String input = keyboard.next(); ``` to this: ``` input = keyboard.next(); ``` Also, this code will most likely not work: ``` ((input != "a") || (input != "b")) ``` In Java, Strings are compared using the `.equals()` method,...
As far as I know, this is not how you hide the variables. Here is what I mean ``` private static String input = null; public static void main(String [] args){ Scanner keyboard = new Scanner(System.in); do { System.out.println("Enter 'A' for option A or 'B' for option B."); String input ...
11,823,894
I need to pass data to Neural Net operator. Some attributes are binomial and Neural Net does not accept binomial data type, however it accepts integer. There is no Binomial to Integer (Numerical) type conversion operator. So how can I convert this ? Thanks for an answers
2012/08/06
[ "https://Stackoverflow.com/questions/11823894", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1578496/" ]
You have declared the `input` variable twice. You will need to change this line: ``` String input = keyboard.next(); ``` to this: ``` input = keyboard.next(); ``` Also, this code will most likely not work: ``` ((input != "a") || (input != "b")) ``` In Java, Strings are compared using the `.equals()` method,...
You have declared the `input` variable twice . Inside the `main` method declare `input` only once. Use the following code inside `do {}`: ``` input = keyboard.next(); instead of String input = keyboard.next(); ```
11,823,894
I need to pass data to Neural Net operator. Some attributes are binomial and Neural Net does not accept binomial data type, however it accepts integer. There is no Binomial to Integer (Numerical) type conversion operator. So how can I convert this ? Thanks for an answers
2012/08/06
[ "https://Stackoverflow.com/questions/11823894", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1578496/" ]
You have declared the `input` variable twice. You will need to change this line: ``` String input = keyboard.next(); ``` to this: ``` input = keyboard.next(); ``` Also, this code will most likely not work: ``` ((input != "a") || (input != "b")) ``` In Java, Strings are compared using the `.equals()` method,...
You will get a duplicate local variable if you have declared the variable twice, here in your code you have declared the **input variable** twice. That is why you received that error.
11,823,894
I need to pass data to Neural Net operator. Some attributes are binomial and Neural Net does not accept binomial data type, however it accepts integer. There is no Binomial to Integer (Numerical) type conversion operator. So how can I convert this ? Thanks for an answers
2012/08/06
[ "https://Stackoverflow.com/questions/11823894", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1578496/" ]
Yoy've duplicated `String input` declaration. Once is enough.
You will get a duplicate local variable if you have declared the variable twice, here in your code you have declared the **input variable** twice. That is why you received that error.
50,668
I know very little about Arduino and even less about programming one. Before I purchase a board, and learn how to program it, I was wondering if my idea is feasible. I want to program the Arduino to sequentially open one after another irrigation valve. There would be approximately eight 24 volt solenoid valves. Each o...
2018/03/12
[ "https://arduino.stackexchange.com/questions/50668", "https://arduino.stackexchange.com", "https://arduino.stackexchange.com/users/43674/" ]
An Arduino can control (at least) 8 devices. Instead of a transistor, it might be much easier to use an 8 way relay controller, something like this: [8 relay module](https://rads.stackoverflow.com/amzn/click/B0057OC5WK) Just connect all 8 valves to the relays, you power the relay with a separate source for the valves...
There are 2 wires to a solenoid, and 2 ways to operate them: 1- Closing a relay sends 24V out, with return wires going to 0 volts. 2- 24V Always goes out, and a relay can short the return wire to 0 volts. Either way, test 2 by running the wires to a control board, and manually activating solenoids. When that works...
50,668
I know very little about Arduino and even less about programming one. Before I purchase a board, and learn how to program it, I was wondering if my idea is feasible. I want to program the Arduino to sequentially open one after another irrigation valve. There would be approximately eight 24 volt solenoid valves. Each o...
2018/03/12
[ "https://arduino.stackexchange.com/questions/50668", "https://arduino.stackexchange.com", "https://arduino.stackexchange.com/users/43674/" ]
There are 2 wires to a solenoid, and 2 ways to operate them: 1- Closing a relay sends 24V out, with return wires going to 0 volts. 2- 24V Always goes out, and a relay can short the return wire to 0 volts. Either way, test 2 by running the wires to a control board, and manually activating solenoids. When that works...
An alternative method is to use an I2c port expander such as a PCF8574. These are available as break out boards. By selecting a different I2C address on each break out board up to 64 relays can be controlled using opto isolated relay modules. Thus 64 0utputs or inputs with just two Arduino pins.
50,668
I know very little about Arduino and even less about programming one. Before I purchase a board, and learn how to program it, I was wondering if my idea is feasible. I want to program the Arduino to sequentially open one after another irrigation valve. There would be approximately eight 24 volt solenoid valves. Each o...
2018/03/12
[ "https://arduino.stackexchange.com/questions/50668", "https://arduino.stackexchange.com", "https://arduino.stackexchange.com/users/43674/" ]
An Arduino can control (at least) 8 devices. Instead of a transistor, it might be much easier to use an 8 way relay controller, something like this: [8 relay module](https://rads.stackoverflow.com/amzn/click/B0057OC5WK) Just connect all 8 valves to the relays, you power the relay with a separate source for the valves...
An Arduino board is merely a microcontroller with the stuff around it that is necessary to keep it running. By stufff, I mean thinks such as the voltage regulator that provides the power, the oscillator that provides the frequency for the controller, the GPIO pin connectors, and so on. This is a very simple applicatio...
50,668
I know very little about Arduino and even less about programming one. Before I purchase a board, and learn how to program it, I was wondering if my idea is feasible. I want to program the Arduino to sequentially open one after another irrigation valve. There would be approximately eight 24 volt solenoid valves. Each o...
2018/03/12
[ "https://arduino.stackexchange.com/questions/50668", "https://arduino.stackexchange.com", "https://arduino.stackexchange.com/users/43674/" ]
An Arduino can control (at least) 8 devices. Instead of a transistor, it might be much easier to use an 8 way relay controller, something like this: [8 relay module](https://rads.stackoverflow.com/amzn/click/B0057OC5WK) Just connect all 8 valves to the relays, you power the relay with a separate source for the valves...
Yes, you will need something to drive 24 volt solenoids, because the Arduino cannot do it alone. My preferred method would be to use a ULN2803 device, which will allow you to drive all those eight solenoids (assuming they take less than 500mA or current) and has inbuilt protection against the voltage spike when the so...
50,668
I know very little about Arduino and even less about programming one. Before I purchase a board, and learn how to program it, I was wondering if my idea is feasible. I want to program the Arduino to sequentially open one after another irrigation valve. There would be approximately eight 24 volt solenoid valves. Each o...
2018/03/12
[ "https://arduino.stackexchange.com/questions/50668", "https://arduino.stackexchange.com", "https://arduino.stackexchange.com/users/43674/" ]
Most irrigation valves are AC operated, typically using 24VAC at about 250mA (Double that to 500mA for the inrush current). The best way to drive these is via a triac. If you want isolation between your controller and the valve voltage an opto coupler with a triac output is the best way to go. A good choice given the t...
Yes, Arduino can control eight transistors. Each solenoid will need a transistor. Ideal would be to use logic level N-channel MOSFETs that the Arduino 0/5V output can drive directly. IRFL540 is mentioned a lot, you can get them at digikey.com. Drive the gate thru a 150 ohm resistor, and have a 10K resistor from the g...
50,668
I know very little about Arduino and even less about programming one. Before I purchase a board, and learn how to program it, I was wondering if my idea is feasible. I want to program the Arduino to sequentially open one after another irrigation valve. There would be approximately eight 24 volt solenoid valves. Each o...
2018/03/12
[ "https://arduino.stackexchange.com/questions/50668", "https://arduino.stackexchange.com", "https://arduino.stackexchange.com/users/43674/" ]
There are 2 wires to a solenoid, and 2 ways to operate them: 1- Closing a relay sends 24V out, with return wires going to 0 volts. 2- 24V Always goes out, and a relay can short the return wire to 0 volts. Either way, test 2 by running the wires to a control board, and manually activating solenoids. When that works...
Yes, Arduino can control eight transistors. Each solenoid will need a transistor. Ideal would be to use logic level N-channel MOSFETs that the Arduino 0/5V output can drive directly. IRFL540 is mentioned a lot, you can get them at digikey.com. Drive the gate thru a 150 ohm resistor, and have a 10K resistor from the g...
50,668
I know very little about Arduino and even less about programming one. Before I purchase a board, and learn how to program it, I was wondering if my idea is feasible. I want to program the Arduino to sequentially open one after another irrigation valve. There would be approximately eight 24 volt solenoid valves. Each o...
2018/03/12
[ "https://arduino.stackexchange.com/questions/50668", "https://arduino.stackexchange.com", "https://arduino.stackexchange.com/users/43674/" ]
An Arduino board is merely a microcontroller with the stuff around it that is necessary to keep it running. By stufff, I mean thinks such as the voltage regulator that provides the power, the oscillator that provides the frequency for the controller, the GPIO pin connectors, and so on. This is a very simple applicatio...
Yes, Arduino can control eight transistors. Each solenoid will need a transistor. Ideal would be to use logic level N-channel MOSFETs that the Arduino 0/5V output can drive directly. IRFL540 is mentioned a lot, you can get them at digikey.com. Drive the gate thru a 150 ohm resistor, and have a 10K resistor from the g...
50,668
I know very little about Arduino and even less about programming one. Before I purchase a board, and learn how to program it, I was wondering if my idea is feasible. I want to program the Arduino to sequentially open one after another irrigation valve. There would be approximately eight 24 volt solenoid valves. Each o...
2018/03/12
[ "https://arduino.stackexchange.com/questions/50668", "https://arduino.stackexchange.com", "https://arduino.stackexchange.com/users/43674/" ]
An Arduino can control (at least) 8 devices. Instead of a transistor, it might be much easier to use an 8 way relay controller, something like this: [8 relay module](https://rads.stackoverflow.com/amzn/click/B0057OC5WK) Just connect all 8 valves to the relays, you power the relay with a separate source for the valves...
Most irrigation valves are AC operated, typically using 24VAC at about 250mA (Double that to 500mA for the inrush current). The best way to drive these is via a triac. If you want isolation between your controller and the valve voltage an opto coupler with a triac output is the best way to go. A good choice given the t...
50,668
I know very little about Arduino and even less about programming one. Before I purchase a board, and learn how to program it, I was wondering if my idea is feasible. I want to program the Arduino to sequentially open one after another irrigation valve. There would be approximately eight 24 volt solenoid valves. Each o...
2018/03/12
[ "https://arduino.stackexchange.com/questions/50668", "https://arduino.stackexchange.com", "https://arduino.stackexchange.com/users/43674/" ]
An Arduino can control (at least) 8 devices. Instead of a transistor, it might be much easier to use an 8 way relay controller, something like this: [8 relay module](https://rads.stackoverflow.com/amzn/click/B0057OC5WK) Just connect all 8 valves to the relays, you power the relay with a separate source for the valves...
An alternative method is to use an I2c port expander such as a PCF8574. These are available as break out boards. By selecting a different I2C address on each break out board up to 64 relays can be controlled using opto isolated relay modules. Thus 64 0utputs or inputs with just two Arduino pins.
50,668
I know very little about Arduino and even less about programming one. Before I purchase a board, and learn how to program it, I was wondering if my idea is feasible. I want to program the Arduino to sequentially open one after another irrigation valve. There would be approximately eight 24 volt solenoid valves. Each o...
2018/03/12
[ "https://arduino.stackexchange.com/questions/50668", "https://arduino.stackexchange.com", "https://arduino.stackexchange.com/users/43674/" ]
Most irrigation valves are AC operated, typically using 24VAC at about 250mA (Double that to 500mA for the inrush current). The best way to drive these is via a triac. If you want isolation between your controller and the valve voltage an opto coupler with a triac output is the best way to go. A good choice given the t...
An alternative method is to use an I2c port expander such as a PCF8574. These are available as break out boards. By selecting a different I2C address on each break out board up to 64 relays can be controlled using opto isolated relay modules. Thus 64 0utputs or inputs with just two Arduino pins.
132,746
I am trying to add a custom product attribute to the list of items on the summary section in the checkout in Magento 2. The template file is at `Magento_Checkout/web/template/summary/item/details.html` and looking to display the value of the custom attribute before the product name. Any idea on how this value is added ...
2016/08/24
[ "https://magento.stackexchange.com/questions/132746", "https://magento.stackexchange.com", "https://magento.stackexchange.com/users/43501/" ]
You will have to create a plugin for that. I wanted to add product flavor to order summary. This is the way I created a plugin and achieved what I wanted. **Vendor = Sejal** Files you need to create: 1. Registration.php : `app\code\Sejal\Flavor\registration.php` 2. di.xml : `app\code\Sejal\Flavor\etc\di.xml` 3. modu...
if you want to add your custom attribute in order summary you need to override: (Layouts) 1) checkout\_cart\_index : ``` <referenceBlock name="checkout.cart.totals"> <arguments> <argument name="jsLayout" xsi:type="array"> <item name="components" xsi:type="array"> ...
132,746
I am trying to add a custom product attribute to the list of items on the summary section in the checkout in Magento 2. The template file is at `Magento_Checkout/web/template/summary/item/details.html` and looking to display the value of the custom attribute before the product name. Any idea on how this value is added ...
2016/08/24
[ "https://magento.stackexchange.com/questions/132746", "https://magento.stackexchange.com", "https://magento.stackexchange.com/users/43501/" ]
if you want to add your custom attribute in order summary you need to override: (Layouts) 1) checkout\_cart\_index : ``` <referenceBlock name="checkout.cart.totals"> <arguments> <argument name="jsLayout" xsi:type="array"> <item name="components" xsi:type="array"> ...
I need to display simple product name of the configurable. So I used code as below. But same simple name is displaying when I choose same configurable options in the checkout order summary. So How I display correct simple product names? ``` public function afterGetConfig(\Magento\Checkout\Model\DefaultConfigProvider $...
132,746
I am trying to add a custom product attribute to the list of items on the summary section in the checkout in Magento 2. The template file is at `Magento_Checkout/web/template/summary/item/details.html` and looking to display the value of the custom attribute before the product name. Any idea on how this value is added ...
2016/08/24
[ "https://magento.stackexchange.com/questions/132746", "https://magento.stackexchange.com", "https://magento.stackexchange.com/users/43501/" ]
if you want to add your custom attribute in order summary you need to override: (Layouts) 1) checkout\_cart\_index : ``` <referenceBlock name="checkout.cart.totals"> <arguments> <argument name="jsLayout" xsi:type="array"> <item name="components" xsi:type="array"> ...
For me was *$result['totalsData']['items']* empty. I have used following implementation instead: ``` public function afterGetConfig( \Magento\Checkout\Model\DefaultConfigProvider $subject, array $result ) { foreach ($result['quoteItemData'] as $index => $itemData) { $product = $this->productRepo...
132,746
I am trying to add a custom product attribute to the list of items on the summary section in the checkout in Magento 2. The template file is at `Magento_Checkout/web/template/summary/item/details.html` and looking to display the value of the custom attribute before the product name. Any idea on how this value is added ...
2016/08/24
[ "https://magento.stackexchange.com/questions/132746", "https://magento.stackexchange.com", "https://magento.stackexchange.com/users/43501/" ]
You will have to create a plugin for that. I wanted to add product flavor to order summary. This is the way I created a plugin and achieved what I wanted. **Vendor = Sejal** Files you need to create: 1. Registration.php : `app\code\Sejal\Flavor\registration.php` 2. di.xml : `app\code\Sejal\Flavor\etc\di.xml` 3. modu...
I need to display simple product name of the configurable. So I used code as below. But same simple name is displaying when I choose same configurable options in the checkout order summary. So How I display correct simple product names? ``` public function afterGetConfig(\Magento\Checkout\Model\DefaultConfigProvider $...
132,746
I am trying to add a custom product attribute to the list of items on the summary section in the checkout in Magento 2. The template file is at `Magento_Checkout/web/template/summary/item/details.html` and looking to display the value of the custom attribute before the product name. Any idea on how this value is added ...
2016/08/24
[ "https://magento.stackexchange.com/questions/132746", "https://magento.stackexchange.com", "https://magento.stackexchange.com/users/43501/" ]
You will have to create a plugin for that. I wanted to add product flavor to order summary. This is the way I created a plugin and achieved what I wanted. **Vendor = Sejal** Files you need to create: 1. Registration.php : `app\code\Sejal\Flavor\registration.php` 2. di.xml : `app\code\Sejal\Flavor\etc\di.xml` 3. modu...
For me was *$result['totalsData']['items']* empty. I have used following implementation instead: ``` public function afterGetConfig( \Magento\Checkout\Model\DefaultConfigProvider $subject, array $result ) { foreach ($result['quoteItemData'] as $index => $itemData) { $product = $this->productRepo...
132,746
I am trying to add a custom product attribute to the list of items on the summary section in the checkout in Magento 2. The template file is at `Magento_Checkout/web/template/summary/item/details.html` and looking to display the value of the custom attribute before the product name. Any idea on how this value is added ...
2016/08/24
[ "https://magento.stackexchange.com/questions/132746", "https://magento.stackexchange.com", "https://magento.stackexchange.com/users/43501/" ]
For me was *$result['totalsData']['items']* empty. I have used following implementation instead: ``` public function afterGetConfig( \Magento\Checkout\Model\DefaultConfigProvider $subject, array $result ) { foreach ($result['quoteItemData'] as $index => $itemData) { $product = $this->productRepo...
I need to display simple product name of the configurable. So I used code as below. But same simple name is displaying when I choose same configurable options in the checkout order summary. So How I display correct simple product names? ``` public function afterGetConfig(\Magento\Checkout\Model\DefaultConfigProvider $...
22,307,581
I'm looking for the regex statement in python that will remove all occurances of [1] or [17] or basically [\*] from a string. The occurances are as follows where \* equals some number: ``` [*] [ * ] [ *] [* ] ``` Currently I have: ``` re.sub(r'\[*\]', '', origional_string) ``` Which raises `invalid expression` ...
2014/03/10
[ "https://Stackoverflow.com/questions/22307581", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1541314/" ]
I guess something like that should work: ``` import re origional_string = "makeup of organisms.[10] In 1997, while working at the University of Tennessee, Pigliucci received the Theodosius Dobzhansky Prize,[11]" result = re.sub(r'\[ *[0-9]+ *\]', '', origional_string) print(result) ``` `[0-9]+` matches one or mor...
`\d` means digit in regex. And I have also added option `\s` around the digits here. ``` re.sub(r'\[\s*\d+\s*\]', '', origional_string) ```
22,307,581
I'm looking for the regex statement in python that will remove all occurances of [1] or [17] or basically [\*] from a string. The occurances are as follows where \* equals some number: ``` [*] [ * ] [ *] [* ] ``` Currently I have: ``` re.sub(r'\[*\]', '', origional_string) ``` Which raises `invalid expression` ...
2014/03/10
[ "https://Stackoverflow.com/questions/22307581", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1541314/" ]
I guess something like that should work: ``` import re origional_string = "makeup of organisms.[10] In 1997, while working at the University of Tennessee, Pigliucci received the Theodosius Dobzhansky Prize,[11]" result = re.sub(r'\[ *[0-9]+ *\]', '', origional_string) print(result) ``` `[0-9]+` matches one or mor...
``` >>> import re >>> re.sub(r'\[\s*\d+\s*\]', '', original_string) ```
287
As somebody who is spending the majority of his time programming in JavaScript, what's the best route to get into small-robotics without needing to deviate too much from my current language focus? Are there any project kits or tools that make use of the JavaScript language that might make the field more approachable f...
2012/11/07
[ "https://robotics.stackexchange.com/questions/287", "https://robotics.stackexchange.com", "https://robotics.stackexchange.com/users/250/" ]
[Microsoft Robotics](http://www.microsoft.com/robotics/) uses a protocol called [Decentralized Software Services Protocol (DSSP)](http://social.msdn.microsoft.com/Forums/en-US/roboticsdss/thread/babf3e90-8196-40b2-a4a1-5f2ecc4e9b47) and they [released the specs](https://docs.microsoft.com/en-us/archive/blogs/msrobotics...
There is also a project called [Espruino](http://www.espruino.com/), which is a JavaScript interpreter for low power ARM microcontrollers. It is a rewrite of the [tiny-js](https://code.google.com/p/tiny-js/) project, a small C++ interpreter for Javascript.
287
As somebody who is spending the majority of his time programming in JavaScript, what's the best route to get into small-robotics without needing to deviate too much from my current language focus? Are there any project kits or tools that make use of the JavaScript language that might make the field more approachable f...
2012/11/07
[ "https://robotics.stackexchange.com/questions/287", "https://robotics.stackexchange.com", "https://robotics.stackexchange.com/users/250/" ]
Programming the [AR.Drone 2.0](http://en.wikipedia.org/wiki/Parrot_AR.Drone) with Javascript is super fun. Here's an example that makes a drone take off, move around, do a flip, then land, all using the [node-ar-drone](https://github.com/felixge/node-ar-drone) library: ``` var arDrone = require('ar-drone'); var client...
It might be helpful to look for javascript-based robotics projects online as javascript-based robotics community has been growing rapidly since this question was asked. For examples, the blogger behind <https://burningservos.com> documented processes of building a four-legged robot from scratch and discuss multiple lib...
287
As somebody who is spending the majority of his time programming in JavaScript, what's the best route to get into small-robotics without needing to deviate too much from my current language focus? Are there any project kits or tools that make use of the JavaScript language that might make the field more approachable f...
2012/11/07
[ "https://robotics.stackexchange.com/questions/287", "https://robotics.stackexchange.com", "https://robotics.stackexchange.com/users/250/" ]
There are a couple of projects out there that mate the Arduino platform to the Node.js javascript execution engine. Take a look at [Johnny-Five](https://github.com/rwldrn/johnny-five), which is a library on top of the Arduino Firmata remote control protocol or [node-reflecta](https://github.com/JayBeavers/node-reflecta...
It might be helpful to look for javascript-based robotics projects online as javascript-based robotics community has been growing rapidly since this question was asked. For examples, the blogger behind <https://burningservos.com> documented processes of building a four-legged robot from scratch and discuss multiple lib...
287
As somebody who is spending the majority of his time programming in JavaScript, what's the best route to get into small-robotics without needing to deviate too much from my current language focus? Are there any project kits or tools that make use of the JavaScript language that might make the field more approachable f...
2012/11/07
[ "https://robotics.stackexchange.com/questions/287", "https://robotics.stackexchange.com", "https://robotics.stackexchange.com/users/250/" ]
Programming the [AR.Drone 2.0](http://en.wikipedia.org/wiki/Parrot_AR.Drone) with Javascript is super fun. Here's an example that makes a drone take off, move around, do a flip, then land, all using the [node-ar-drone](https://github.com/felixge/node-ar-drone) library: ``` var arDrone = require('ar-drone'); var client...
The approach I took to this in my project, <https://github.com/Ezward/Esp32CameraRover2>, was to develop a small core for the robot in C++; enough to do closed loop speed control on motors, provide a command interpreter so the client can control the robot and to serve an html/css/js client application over http. The cl...
287
As somebody who is spending the majority of his time programming in JavaScript, what's the best route to get into small-robotics without needing to deviate too much from my current language focus? Are there any project kits or tools that make use of the JavaScript language that might make the field more approachable f...
2012/11/07
[ "https://robotics.stackexchange.com/questions/287", "https://robotics.stackexchange.com", "https://robotics.stackexchange.com/users/250/" ]
There are a couple of projects out there that mate the Arduino platform to the Node.js javascript execution engine. Take a look at [Johnny-Five](https://github.com/rwldrn/johnny-five), which is a library on top of the Arduino Firmata remote control protocol or [node-reflecta](https://github.com/JayBeavers/node-reflecta...
[Robot Operating System](http://ros.org) (ROS) offers the ability to use Javascript to control your robots. Specifically you will want to look at [rosbridge](http://ros.org/wiki/rosbridge/Tutorials/Using%20Javascript%20to%20control%20ROS%20via%20rosjs). You will then need to use [rosserial](http://www.ros.org/wiki/ross...
287
As somebody who is spending the majority of his time programming in JavaScript, what's the best route to get into small-robotics without needing to deviate too much from my current language focus? Are there any project kits or tools that make use of the JavaScript language that might make the field more approachable f...
2012/11/07
[ "https://robotics.stackexchange.com/questions/287", "https://robotics.stackexchange.com", "https://robotics.stackexchange.com/users/250/" ]
There are a couple of projects out there that mate the Arduino platform to the Node.js javascript execution engine. Take a look at [Johnny-Five](https://github.com/rwldrn/johnny-five), which is a library on top of the Arduino Firmata remote control protocol or [node-reflecta](https://github.com/JayBeavers/node-reflecta...
Programming the [AR.Drone 2.0](http://en.wikipedia.org/wiki/Parrot_AR.Drone) with Javascript is super fun. Here's an example that makes a drone take off, move around, do a flip, then land, all using the [node-ar-drone](https://github.com/felixge/node-ar-drone) library: ``` var arDrone = require('ar-drone'); var client...
287
As somebody who is spending the majority of his time programming in JavaScript, what's the best route to get into small-robotics without needing to deviate too much from my current language focus? Are there any project kits or tools that make use of the JavaScript language that might make the field more approachable f...
2012/11/07
[ "https://robotics.stackexchange.com/questions/287", "https://robotics.stackexchange.com", "https://robotics.stackexchange.com/users/250/" ]
Hmm, interesting question! I personally would suggest that you take a look at the Arduino platform. It's programmed in C, so the syntax is going to be... familiar, to a JavaScript writer. In my humble opinion, knowing how the syntax (while loops, if/than blocks, etc) is laid out is 70% of the battle, once you're famili...
There is also a project called [Espruino](http://www.espruino.com/), which is a JavaScript interpreter for low power ARM microcontrollers. It is a rewrite of the [tiny-js](https://code.google.com/p/tiny-js/) project, a small C++ interpreter for Javascript.
287
As somebody who is spending the majority of his time programming in JavaScript, what's the best route to get into small-robotics without needing to deviate too much from my current language focus? Are there any project kits or tools that make use of the JavaScript language that might make the field more approachable f...
2012/11/07
[ "https://robotics.stackexchange.com/questions/287", "https://robotics.stackexchange.com", "https://robotics.stackexchange.com/users/250/" ]
[Microsoft Robotics](http://www.microsoft.com/robotics/) uses a protocol called [Decentralized Software Services Protocol (DSSP)](http://social.msdn.microsoft.com/Forums/en-US/roboticsdss/thread/babf3e90-8196-40b2-a4a1-5f2ecc4e9b47) and they [released the specs](https://docs.microsoft.com/en-us/archive/blogs/msrobotics...
The approach I took to this in my project, <https://github.com/Ezward/Esp32CameraRover2>, was to develop a small core for the robot in C++; enough to do closed loop speed control on motors, provide a command interpreter so the client can control the robot and to serve an html/css/js client application over http. The cl...
287
As somebody who is spending the majority of his time programming in JavaScript, what's the best route to get into small-robotics without needing to deviate too much from my current language focus? Are there any project kits or tools that make use of the JavaScript language that might make the field more approachable f...
2012/11/07
[ "https://robotics.stackexchange.com/questions/287", "https://robotics.stackexchange.com", "https://robotics.stackexchange.com/users/250/" ]
Generally there are many ways to use node.js with a platform, like [this one for the RPi](http://blog.tomg.co/post/21322413373/how-to-install-node-js-on-your-raspberry-pi). There are a lot more similar ones [if you just search for them](https://www.google.co.in/search?sugexp=chrome,mod=3&sourceid=chrome&client=ubuntu&c...
A new compiler is available through the Microsoft App Store called "Robot JavaScript". This compiler works in Windows10 and compiles code for EV3 Mindstorms robots. If you have a Lego Mindstorms EV3, check out: https://www.microsoft.com/en-us/p/robot-javascript/9nb6w06lpx68
287
As somebody who is spending the majority of his time programming in JavaScript, what's the best route to get into small-robotics without needing to deviate too much from my current language focus? Are there any project kits or tools that make use of the JavaScript language that might make the field more approachable f...
2012/11/07
[ "https://robotics.stackexchange.com/questions/287", "https://robotics.stackexchange.com", "https://robotics.stackexchange.com/users/250/" ]
[Robot Operating System](http://ros.org) (ROS) offers the ability to use Javascript to control your robots. Specifically you will want to look at [rosbridge](http://ros.org/wiki/rosbridge/Tutorials/Using%20Javascript%20to%20control%20ROS%20via%20rosjs). You will then need to use [rosserial](http://www.ros.org/wiki/ross...
[Microsoft Robotics](http://www.microsoft.com/robotics/) uses a protocol called [Decentralized Software Services Protocol (DSSP)](http://social.msdn.microsoft.com/Forums/en-US/roboticsdss/thread/babf3e90-8196-40b2-a4a1-5f2ecc4e9b47) and they [released the specs](https://docs.microsoft.com/en-us/archive/blogs/msrobotics...
183,349
I am new to the mechanics of the $\epsilon$-$\delta$ definition of continuity of a function at a point, and so I am having trouble selecting my $\delta$ for the following question: > > Suppose a function $f$ is continuous at a point $c$ and $f(c) > 0$. Prove that there is a $\delta > 0$ such that for all $x \in \math...
2012/08/16
[ "https://math.stackexchange.com/questions/183349", "https://math.stackexchange.com", "https://math.stackexchange.com/users/34736/" ]
Let $\epsilon = \frac{f(c)}{2}$. Since $f(c) > 0$, you have that $\epsilon > 0$. By continuity, there exists a $\delta$ such that for all $x$ such that $|x - c| < \delta$, you have that $|f(x) - f(c)| < \epsilon$. This implies that $f(c) - \epsilon < f(x) < f(c) + \epsilon$ we only care about the left side. Remember...
Let me suggest a two-steps proof: * Use the fact that $f$ is continuous at $c$ to show that, for every $z\lt f(c)$, there exists a $\delta > 0$ such that $|x -c| \leqslant \delta$ implies $f(x)\geqslant z$. * Use the fact that $f(c)\gt0$ to show that $z=\frac12f(c)$ is such that $z\lt f(c)$.
22,722,161
I am working on a project that requires drawing a lot of data as it is acquired by an ADC...something like 50,000 lines per frame on a monitor 1600 pixels wide. It runs great on a system with a 2007-ish Quadro FX 570, but basically can't keep up with the data on machines with Intel HD 4000 class chips. The data load is...
2014/03/28
[ "https://Stackoverflow.com/questions/22722161", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3293584/" ]
Mapping a VBO might slow you down due to the driver might require to sync the GPU with the CPU. A more performant way is to just throw your data onto the GPU, so the CPU and GPU can run more independently. * Recreate the VBO every time, do create it with STATIC\_DRAW * If you need to map your data, do NOT map as reada...
If you're just scrolling a line graph (GDI style), just draw the new column on the CPU and use glTexSubImage2D to update a single column in the texture. Draw it as a pair of quads and update the st coordinates to handle scrolling/wrapping. If you need to update all the lines all the time, use a VBO created with GL\_DY...
22,722,161
I am working on a project that requires drawing a lot of data as it is acquired by an ADC...something like 50,000 lines per frame on a monitor 1600 pixels wide. It runs great on a system with a 2007-ish Quadro FX 570, but basically can't keep up with the data on machines with Intel HD 4000 class chips. The data load is...
2014/03/28
[ "https://Stackoverflow.com/questions/22722161", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3293584/" ]
Thanks, everyone. I finally settled on blitting between framebuffers backed by renderbuffers. Works well enough. Many suggested using textures, and I may go that route in the future if I eventually need to draw behind the data.
If you're just scrolling a line graph (GDI style), just draw the new column on the CPU and use glTexSubImage2D to update a single column in the texture. Draw it as a pair of quads and update the st coordinates to handle scrolling/wrapping. If you need to update all the lines all the time, use a VBO created with GL\_DY...
10,636,288
I'm using a jquery scroll path in the link below. [jquery scroll path](http://joelb.me/scrollpath/) Few buttons in the below of the screen to control the scrolling. Instead of those buttons I would like to use few buttons developed in flash. But the click events are not working and unable to communicate from flash t...
2012/05/17
[ "https://Stackoverflow.com/questions/10636288", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1303274/" ]
you can write a regular expression that does the trick. Than you can use that regular expression to validate your string ``` ^ ---->Start of a string. $ ---->End of a string. . ----> Any character (except \n newline) {...}----> Explicit quantifier notation. [...] ---->Explicit set of characters to match. (...) -...
Regular expression is probably the way to go this might help: <http://www.regular-expressions.info/creditcard.html>
10,636,288
I'm using a jquery scroll path in the link below. [jquery scroll path](http://joelb.me/scrollpath/) Few buttons in the below of the screen to control the scrolling. Instead of those buttons I would like to use few buttons developed in flash. But the click events are not working and unable to communicate from flash t...
2012/05/17
[ "https://Stackoverflow.com/questions/10636288", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1303274/" ]
This regexp should do the trick. It uses a negative [lookbehind](http://www.regular-expressions.info/lookaround.html) to avoid matching multiple dashes in a row. ``` ^\d(\d|(?<!-)-)*\d$|^\d$ ^ ^ ^ ^ | | | -- is a single digit, or | | ------- ends with a digit | ...
you can write a regular expression that does the trick. Than you can use that regular expression to validate your string ``` ^ ---->Start of a string. $ ---->End of a string. . ----> Any character (except \n newline) {...}----> Explicit quantifier notation. [...] ---->Explicit set of characters to match. (...) -...
10,636,288
I'm using a jquery scroll path in the link below. [jquery scroll path](http://joelb.me/scrollpath/) Few buttons in the below of the screen to control the scrolling. Instead of those buttons I would like to use few buttons developed in flash. But the click events are not working and unable to communicate from flash t...
2012/05/17
[ "https://Stackoverflow.com/questions/10636288", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1303274/" ]
This regexp should do the trick. It uses a negative [lookbehind](http://www.regular-expressions.info/lookaround.html) to avoid matching multiple dashes in a row. ``` ^\d(\d|(?<!-)-)*\d$|^\d$ ^ ^ ^ ^ | | | -- is a single digit, or | | ------- ends with a digit | ...
Regular expression is probably the way to go this might help: <http://www.regular-expressions.info/creditcard.html>
10,636,288
I'm using a jquery scroll path in the link below. [jquery scroll path](http://joelb.me/scrollpath/) Few buttons in the below of the screen to control the scrolling. Instead of those buttons I would like to use few buttons developed in flash. But the click events are not working and unable to communicate from flash t...
2012/05/17
[ "https://Stackoverflow.com/questions/10636288", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1303274/" ]
Use a regular expression. ``` ^\d[-0-9]+\d$ ``` This assumes the string is at least three characters long. Breakdown: ``` ^ - match start of string \d - match a digit [ - start of character class containing: - - a dash 0-9 - 0 to 9 ] - end of character class + - match one or more of the previ...
Regular expression is probably the way to go this might help: <http://www.regular-expressions.info/creditcard.html>
10,636,288
I'm using a jquery scroll path in the link below. [jquery scroll path](http://joelb.me/scrollpath/) Few buttons in the below of the screen to control the scrolling. Instead of those buttons I would like to use few buttons developed in flash. But the click events are not working and unable to communicate from flash t...
2012/05/17
[ "https://Stackoverflow.com/questions/10636288", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1303274/" ]
This regexp should do the trick. It uses a negative [lookbehind](http://www.regular-expressions.info/lookaround.html) to avoid matching multiple dashes in a row. ``` ^\d(\d|(?<!-)-)*\d$|^\d$ ^ ^ ^ ^ | | | -- is a single digit, or | | ------- ends with a digit | ...
Use a regular expression. ``` ^\d[-0-9]+\d$ ``` This assumes the string is at least three characters long. Breakdown: ``` ^ - match start of string \d - match a digit [ - start of character class containing: - - a dash 0-9 - 0 to 9 ] - end of character class + - match one or more of the previ...
3,582,582
Now, I know that I'm supposed to somehow show how it is that $\vec v$ spans $\mathbb{R}^1$, but this is precisely what I don't know how to do. I know that if $\mathbb{R}^1$ is a subspace of $\text{span}({\vec v})$, then any $k\vec v$ will be able to attain any $\vec r$ in $\mathbb{R}^1$. But how exactly do I write thi...
2020/03/16
[ "https://math.stackexchange.com/questions/3582582", "https://math.stackexchange.com", "https://math.stackexchange.com/users/755010/" ]
You have $$3^{15a} = 5^{5b} = 15^{3c} = 3^{3c}5^{3c} \tag{1}\label{eq1A}$$ Taking natural logarithms (although any other logarithm base, e.g., common (i.e., base $10$), will also work) gives $$15a\ln(3) = 5b\ln(5) = 3c\ln(3) + 3c\ln(5) \tag{2}\label{eq2A}$$ This gives, using the left & right and then the middle & r...
Let $$3^{15a}=5^{5b}=15^{3c}=k$$ What if $k=1$ Else $3=k^{1/15a}$ etc. As $15=3\cdot5$ $k^{1/3c}=k^{1/5b}\cdot k^{1/15a}=k^{1/5b+1/15a}$ $\implies\dfrac1{3c}=\dfrac1{5b}+\dfrac1{15a}=\dfrac{3a+b}{15ab}$
3,582,582
Now, I know that I'm supposed to somehow show how it is that $\vec v$ spans $\mathbb{R}^1$, but this is precisely what I don't know how to do. I know that if $\mathbb{R}^1$ is a subspace of $\text{span}({\vec v})$, then any $k\vec v$ will be able to attain any $\vec r$ in $\mathbb{R}^1$. But how exactly do I write thi...
2020/03/16
[ "https://math.stackexchange.com/questions/3582582", "https://math.stackexchange.com", "https://math.stackexchange.com/users/755010/" ]
You have $$3^{15a} = 5^{5b} = 15^{3c} = 3^{3c}5^{3c} \tag{1}\label{eq1A}$$ Taking natural logarithms (although any other logarithm base, e.g., common (i.e., base $10$), will also work) gives $$15a\ln(3) = 5b\ln(5) = 3c\ln(3) + 3c\ln(5) \tag{2}\label{eq2A}$$ This gives, using the left & right and then the middle & r...
Take $$3^{15a}=5^{5b}=15^{3c}=K \implies a=\frac{\log k}{15\log 3}, b=\frac{\log K}{5\log 5}, c=\frac{\log K}{3 \log 15} $$ Then $$ F=5 ab-bc-3ac=abc(5/c-1/a-3/b)=anc\left(\frac {15 \log 15}{\log K}-\frac{15 \log 3}{\log K}-\frac{15 \log 5}{\log K}\right)$$ $$=abc\frac{15 \log(15/15)}{\log K}=0.$$
3,582,582
Now, I know that I'm supposed to somehow show how it is that $\vec v$ spans $\mathbb{R}^1$, but this is precisely what I don't know how to do. I know that if $\mathbb{R}^1$ is a subspace of $\text{span}({\vec v})$, then any $k\vec v$ will be able to attain any $\vec r$ in $\mathbb{R}^1$. But how exactly do I write thi...
2020/03/16
[ "https://math.stackexchange.com/questions/3582582", "https://math.stackexchange.com", "https://math.stackexchange.com/users/755010/" ]
You have $$3^{15a} = 5^{5b} = 15^{3c} = 3^{3c}5^{3c} \tag{1}\label{eq1A}$$ Taking natural logarithms (although any other logarithm base, e.g., common (i.e., base $10$), will also work) gives $$15a\ln(3) = 5b\ln(5) = 3c\ln(3) + 3c\ln(5) \tag{2}\label{eq2A}$$ This gives, using the left & right and then the middle & r...
To get the variables directly take logarithms. (Doesn't matter which base). $\log 3^{15a} = \log 5^{5b} = \log 15^{3c}$ so $15a \log 3 = 5b \log 5 = 3c \log 15$. So flip a coin and choose which one we should express the others in. I pick ... $b$. $a = \frac {\log 5}{3\log 3} b$ and $c = \frac {5\log 5}{3\log 15} b...
37,757,249
``` Array ( [0] => Array ( [0] => Array ( [masteryId] => 6111 [rank] => 5 ) [1] => Array ( [masteryId] => 6122 [rank] => 1 ) ...
2016/06/10
[ "https://Stackoverflow.com/questions/37757249", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6446125/" ]
Try this : ``` $output = array(); foreach($array as $value) { $s = ""; foreach($value as $v) $s .= $v['masteryId'].' xx '.$v['rank'].' ++ '; $output[] = rtrim($s,' ++ '); } ``` I hope that will help you.
Magic one-liner: ``` array_walk($array,function(&$a){$a=array_reduce($a,function($b,$c){return($b?"$b ++ ":"")."$c[masteryId] xx $c[rank]";},"");}); ``` This calls an anonymous function for each element in the outer array. Because of the `&` before `$a` a reference to the element is passed and we can modify it withi...
52,375,240
I am trying to create a magic 8 ball. I've added the answers at the top in an array, added the code to choose a random answer, and when the button is clicked, it's supposed to place said random answer in a p tag in a div. It actually worked very well a few times in codePen and then stopped. I didn't change a thing. Can...
2018/09/17
[ "https://Stackoverflow.com/questions/52375240", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10297847/" ]
Try reordering the placement of your `<script>` tag in you HTML , so that the script is run after the DOM is loaded/parsed. When your script is run, the `button` that you're trying to add a click listener to is not going to be present because the script is run from the `<head>` tag before the `<body>` DOM contents are...
The problem is that your `randomAnswer` needs to be defined **inside** of the function, so that the answer gets decided upon each time you press the button. Outside of the function it gets defined on page load, and the answer will be the same each time. Here's an updated snippet: ```js var answers = ["Yes!", "Absolut...
52,375,240
I am trying to create a magic 8 ball. I've added the answers at the top in an array, added the code to choose a random answer, and when the button is clicked, it's supposed to place said random answer in a p tag in a div. It actually worked very well a few times in codePen and then stopped. I didn't change a thing. Can...
2018/09/17
[ "https://Stackoverflow.com/questions/52375240", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10297847/" ]
Try reordering the placement of your `<script>` tag in you HTML , so that the script is run after the DOM is loaded/parsed. When your script is run, the `button` that you're trying to add a click listener to is not going to be present because the script is run from the `<head>` tag before the `<body>` DOM contents are...
Your script is loaded in the header. It's executed whereas the page didnt finished to load, so you're trying to attach a listener to the button element that doesnt exist yet. Move it to the bottom of the body section: ``` <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" cont...
52,375,240
I am trying to create a magic 8 ball. I've added the answers at the top in an array, added the code to choose a random answer, and when the button is clicked, it's supposed to place said random answer in a p tag in a div. It actually worked very well a few times in codePen and then stopped. I didn't change a thing. Can...
2018/09/17
[ "https://Stackoverflow.com/questions/52375240", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10297847/" ]
Try reordering the placement of your `<script>` tag in you HTML , so that the script is run after the DOM is loaded/parsed. When your script is run, the `button` that you're trying to add a click listener to is not going to be present because the script is run from the `<head>` tag before the `<body>` DOM contents are...
Move `//random answer function displays random in the output id var randomAnswer = answers[Math.floor(Math.random()*answers.length)];` inside of your function like this: `function myFunction(){ var randomAnswer = answers[Math.floor(Math.random()*answers.length)]; document.getElementById('output').innerHTML = ran...
52,375,240
I am trying to create a magic 8 ball. I've added the answers at the top in an array, added the code to choose a random answer, and when the button is clicked, it's supposed to place said random answer in a p tag in a div. It actually worked very well a few times in codePen and then stopped. I didn't change a thing. Can...
2018/09/17
[ "https://Stackoverflow.com/questions/52375240", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10297847/" ]
Try reordering the placement of your `<script>` tag in you HTML , so that the script is run after the DOM is loaded/parsed. When your script is run, the `button` that you're trying to add a click listener to is not going to be present because the script is run from the `<head>` tag before the `<body>` DOM contents are...
``` document.getElementById('button').addEventListener('click', myFunction=()=>{ //[UPDATE] Move the random answer computation inside of myFunction() var randomAnswer = answers[Math.floor(Math.random()*answers.length)]; document.getElementById('output').innerHTML = randomAnswer; }); ``` Place the logic inside...
52,375,240
I am trying to create a magic 8 ball. I've added the answers at the top in an array, added the code to choose a random answer, and when the button is clicked, it's supposed to place said random answer in a p tag in a div. It actually worked very well a few times in codePen and then stopped. I didn't change a thing. Can...
2018/09/17
[ "https://Stackoverflow.com/questions/52375240", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10297847/" ]
Your script is loaded in the header. It's executed whereas the page didnt finished to load, so you're trying to attach a listener to the button element that doesnt exist yet. Move it to the bottom of the body section: ``` <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" cont...
The problem is that your `randomAnswer` needs to be defined **inside** of the function, so that the answer gets decided upon each time you press the button. Outside of the function it gets defined on page load, and the answer will be the same each time. Here's an updated snippet: ```js var answers = ["Yes!", "Absolut...
52,375,240
I am trying to create a magic 8 ball. I've added the answers at the top in an array, added the code to choose a random answer, and when the button is clicked, it's supposed to place said random answer in a p tag in a div. It actually worked very well a few times in codePen and then stopped. I didn't change a thing. Can...
2018/09/17
[ "https://Stackoverflow.com/questions/52375240", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10297847/" ]
The problem is that your `randomAnswer` needs to be defined **inside** of the function, so that the answer gets decided upon each time you press the button. Outside of the function it gets defined on page load, and the answer will be the same each time. Here's an updated snippet: ```js var answers = ["Yes!", "Absolut...
``` document.getElementById('button').addEventListener('click', myFunction=()=>{ //[UPDATE] Move the random answer computation inside of myFunction() var randomAnswer = answers[Math.floor(Math.random()*answers.length)]; document.getElementById('output').innerHTML = randomAnswer; }); ``` Place the logic inside...
52,375,240
I am trying to create a magic 8 ball. I've added the answers at the top in an array, added the code to choose a random answer, and when the button is clicked, it's supposed to place said random answer in a p tag in a div. It actually worked very well a few times in codePen and then stopped. I didn't change a thing. Can...
2018/09/17
[ "https://Stackoverflow.com/questions/52375240", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10297847/" ]
Your script is loaded in the header. It's executed whereas the page didnt finished to load, so you're trying to attach a listener to the button element that doesnt exist yet. Move it to the bottom of the body section: ``` <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" cont...
Move `//random answer function displays random in the output id var randomAnswer = answers[Math.floor(Math.random()*answers.length)];` inside of your function like this: `function myFunction(){ var randomAnswer = answers[Math.floor(Math.random()*answers.length)]; document.getElementById('output').innerHTML = ran...
52,375,240
I am trying to create a magic 8 ball. I've added the answers at the top in an array, added the code to choose a random answer, and when the button is clicked, it's supposed to place said random answer in a p tag in a div. It actually worked very well a few times in codePen and then stopped. I didn't change a thing. Can...
2018/09/17
[ "https://Stackoverflow.com/questions/52375240", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10297847/" ]
Your script is loaded in the header. It's executed whereas the page didnt finished to load, so you're trying to attach a listener to the button element that doesnt exist yet. Move it to the bottom of the body section: ``` <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" cont...
``` document.getElementById('button').addEventListener('click', myFunction=()=>{ //[UPDATE] Move the random answer computation inside of myFunction() var randomAnswer = answers[Math.floor(Math.random()*answers.length)]; document.getElementById('output').innerHTML = randomAnswer; }); ``` Place the logic inside...
52,375,240
I am trying to create a magic 8 ball. I've added the answers at the top in an array, added the code to choose a random answer, and when the button is clicked, it's supposed to place said random answer in a p tag in a div. It actually worked very well a few times in codePen and then stopped. I didn't change a thing. Can...
2018/09/17
[ "https://Stackoverflow.com/questions/52375240", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10297847/" ]
Move `//random answer function displays random in the output id var randomAnswer = answers[Math.floor(Math.random()*answers.length)];` inside of your function like this: `function myFunction(){ var randomAnswer = answers[Math.floor(Math.random()*answers.length)]; document.getElementById('output').innerHTML = ran...
``` document.getElementById('button').addEventListener('click', myFunction=()=>{ //[UPDATE] Move the random answer computation inside of myFunction() var randomAnswer = answers[Math.floor(Math.random()*answers.length)]; document.getElementById('output').innerHTML = randomAnswer; }); ``` Place the logic inside...
166,722
I was watching a video about food and I feel that "lettuce" and "let us"are pronounced the same way, Am I right? If yes, what can I do to prevent confusion especially while dealing with customers? I'm not a native English speaker but I serve native speakers.
2018/05/17
[ "https://ell.stackexchange.com/questions/166722", "https://ell.stackexchange.com", "https://ell.stackexchange.com/users/10425/" ]
I am British and I speak what is sometimes called Received Pronunciation or "BBC English", and for me, "lettuce" and "let us" are definitely not homophones. The final syllable of 'lettuce" rhymes with the -ice parts of justice, notice, avarice, etc, while 'us' is spoken to rhyme with bus, fuss, pus, etc. This is also t...
Yes, they do have the same pronunciation (at least by many people from California). It's actually the basis of many puns. To prevent confusion use "let us" or "lettuce" in the correct context.
166,722
I was watching a video about food and I feel that "lettuce" and "let us"are pronounced the same way, Am I right? If yes, what can I do to prevent confusion especially while dealing with customers? I'm not a native English speaker but I serve native speakers.
2018/05/17
[ "https://ell.stackexchange.com/questions/166722", "https://ell.stackexchange.com", "https://ell.stackexchange.com/users/10425/" ]
Yes, they do have the same pronunciation (at least by many people from California). It's actually the basis of many puns. To prevent confusion use "let us" or "lettuce" in the correct context.
In my idiolect, the last vowel in "lettuce" is \ɪ\, while the vowel in "us" is \ʌ\, so they aren't perfect homophones. Even if they were, context should help distinguish them; for one thing, they are different parts of speech. Also, "let us" in the sense of presenting a suggestion is generally contracted to "let's". If...
166,722
I was watching a video about food and I feel that "lettuce" and "let us"are pronounced the same way, Am I right? If yes, what can I do to prevent confusion especially while dealing with customers? I'm not a native English speaker but I serve native speakers.
2018/05/17
[ "https://ell.stackexchange.com/questions/166722", "https://ell.stackexchange.com", "https://ell.stackexchange.com/users/10425/" ]
I am British and I speak what is sometimes called Received Pronunciation or "BBC English", and for me, "lettuce" and "let us" are definitely not homophones. The final syllable of 'lettuce" rhymes with the -ice parts of justice, notice, avarice, etc, while 'us' is spoken to rhyme with bus, fuss, pus, etc. This is also t...
In my idiolect, the last vowel in "lettuce" is \ɪ\, while the vowel in "us" is \ʌ\, so they aren't perfect homophones. Even if they were, context should help distinguish them; for one thing, they are different parts of speech. Also, "let us" in the sense of presenting a suggestion is generally contracted to "let's". If...
13,995,233
I've a notification bar, when I click on it, starts a new activity with same data (a string array). I have a problem passing data from onReceive.class to new Activity (Notify). When I click I see new activity but crashes with nullPointerE. not1[x] is a array of string My code AlarmReceiver: ``` Intent notificationI...
2012/12/21
[ "https://Stackoverflow.com/questions/13995233", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1749744/" ]
Try this ``` String[] getArray=getIntent().getStringArrayExtra("notify"); ``` In between not1[x] is a string not an array. ``` private NotificationManager mNotificationManager; private int SIMPLE_NOTFICATION_ID; mNotificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE); notifyDeta...
Is this `not1[x]` a String Array? It looks like an element of a String Array that is actually a String.
13,995,233
I've a notification bar, when I click on it, starts a new activity with same data (a string array). I have a problem passing data from onReceive.class to new Activity (Notify). When I click I see new activity but crashes with nullPointerE. not1[x] is a array of string My code AlarmReceiver: ``` Intent notificationI...
2012/12/21
[ "https://Stackoverflow.com/questions/13995233", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1749744/" ]
Try this ``` String[] getArray=getIntent().getStringArrayExtra("notify"); ``` In between not1[x] is a string not an array. ``` private NotificationManager mNotificationManager; private int SIMPLE_NOTFICATION_ID; mNotificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE); notifyDeta...
Just replace below code in **AlarmReceiver** class. its works for me... ``` PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); ``` if we use 0 instead of **PendingIntent.FLAG\_UPDATE\_CURRENT** flag, on the Receiver side i.e getIntent().getExtr...
95,209
Say I have a table called `People` into which people are inserted from the moment they are born. Now lets say I want some subclasses of people based on their job. So there are also tables for `Plumber`, `Carpenter` and `Electrician`. Now, when a person is born, I don't know if they're going to grow up to be plumbers, o...
2015/03/13
[ "https://dba.stackexchange.com/questions/95209", "https://dba.stackexchange.com", "https://dba.stackexchange.com/users/61293/" ]
Try searching "single table inheritance" or "class table inheritance". Especially the web pages from Martin Fowler. Also, if you use a technique called "shared primary key", you can reference a person by that person's personid regardless of what occupation the person eventually chooses. In the Plumber table, the prima...
It seems to me the this is a zero to many relationship. It could be that you need one primary key with ansi date of birth as part of it (pk,fk) and then associate this with the age on an occupation or position table. Or have two separate tables.
43,715,511
I have downloaded the `Yelp` data set from <https://www.yelp.com/dataset_challenge>. The file that downloaded is called `yelp_dataset_challenge_round9.tar` However, the file that is extracted from the `tar` file has no extension. I have checked <https://github.com/Yelp/dataset-examples>, however it assumes that the fi...
2017/05/01
[ "https://Stackoverflow.com/questions/43715511", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7770484/" ]
Turns out that the file inside the tar (the one without the extension) is a tar file as well - so the download is basically a tar file inside a tar file. After extracting the original file, add the tar extension to it, and then extract that. After extracting that, you'll have all the different json files for the data s...
Extract the file and then again rename the file to .tar extension and extract the file again, thus you get access to the dataset ! Step 1: yelp\_dataset\_challenge\_round9.tar extract this file that you downloaded. Step 2: You need to rename the extracted file to .tar extension Step 3: Again extract your renamed fil...
15,980,359
I am having a simple but weird issue about post and form elements. I have a form ``` <form id='form' name='form' method='post' action='test.php'> <?php foreach ($tests as $test){ echo $test['ID']."<br>"; //output 1 2 3 4 5 6 echo $_POST['testSelect'].'<br>'; //outpu...
2013/04/12
[ "https://Stackoverflow.com/questions/15980359", "https://Stackoverflow.com", "https://Stackoverflow.com/users/401147/" ]
Let's assume that you mean that for some reason you either want to return the DisplayNameAttribute from the getter or use it for something in the setter. Then this should do it ``` MemberInfo property = typeof(YourClass).GetProperty("PropertyName"); var attribute = property.GetCustomAttributes(typeof(MyCustomAttri...
I just wanted to put my actual implementation in here so it hopefully helps someone. Lemme know if you see a deficiency or area for improvement. ``` // Custom attribute might be something like this [AttributeUsage(AttributeTargets.Property, AllowMultiple = false)] public class BrandedAttribute : Attribute { privat...
22,813,860
I'm using a MagnificPopup with a beforeClose callback and I'd like to cancel its opening depending on a condition. How can I do that ? I tried a return `false`, or a `$.magnificPopup.close();` but it still opens... I'm sure there is a basic solution ! Thanks
2014/04/02
[ "https://Stackoverflow.com/questions/22813860", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2273884/" ]
It's a little bit tricky, but you can do it by opening the popup directly at initialization: ``` var popupDefaults = { type: 'inline', fixedContentPos: false, fixedBgPos: true, overflowY: 'auto', closeBtnInside: true, } $('.open-popup-link').on("click", function(){ var condition = false; i...
what you can do is to overwrite the javascript function that creates the popup if your condition is true. like: ``` var originalOpen = window.open; if (condition) { //prevent open new window window.open = function(){return null;}; } // after window open attempt window.open = originalOpen ``` you could do th...
22,813,860
I'm using a MagnificPopup with a beforeClose callback and I'd like to cancel its opening depending on a condition. How can I do that ? I tried a return `false`, or a `$.magnificPopup.close();` but it still opens... I'm sure there is a basic solution ! Thanks
2014/04/02
[ "https://Stackoverflow.com/questions/22813860", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2273884/" ]
It's a little bit tricky, but you can do it by opening the popup directly at initialization: ``` var popupDefaults = { type: 'inline', fixedContentPos: false, fixedBgPos: true, overflowY: 'auto', closeBtnInside: true, } $('.open-popup-link').on("click", function(){ var condition = false; i...
Use **[disableOn](http://dimsemenov.com/plugins/magnific-popup/documentation.html#disableon)** ``` disableOn: function(){ if ($(window).width() <= 768){ return false; } return true; } ``` (Optional): This won't stop the default behavior of the DOM element triggering the popup. **If you're using ...
13,813,132
<http://bit.ly/Z7YPj7> It works fine on the desktop everywhere, and also on Android. But on the iPhone Simulator, the culprit appears to be in the file: `js/the-anim36.js` (which queues a whole bunch of Raphael SVG animations). I'm monkeying around with Safari 6's "Develop" menu, which can now log info from the XCode...
2012/12/11
[ "https://Stackoverflow.com/questions/13813132", "https://Stackoverflow.com", "https://Stackoverflow.com/users/776121/" ]
You can run out of memory really fast on iOS. Run it through the Chrome profiler and see what you're memory usage looks like. I bet it's using > 10mb of ram. In which case you're probably toast! Check out this informative article, that claims after about 6mb of ram, you will crash mobile safari: <http://cubiq.org/test...
I observe that when I open that page my laptop fan run on high. The thing is consuming a lot of CPU (and likely a lot of RAM) and may simply be exceeding the allowable resource limits on iOS. If not running out of RAM it could be causing the foreground process to run too long, triggering the logic that cancels "looping...
50,024
As I understood AES GCM mode of operation gets good performance result because parallel execution of both encryption and hashing part. Why AES and SHA-2 computation cannot be pipelined ?
2017/07/10
[ "https://crypto.stackexchange.com/questions/50024", "https://crypto.stackexchange.com", "https://crypto.stackexchange.com/users/49555/" ]
They can be computed in parallel. But what would still make AES-GCM faster than AES-SHA2 is GCM itself. GCM is a universal hash function: it can be very fast, especially on CPUs supporting carry-less multiplications. But it doesn't satisfy the same properties as a hash function such as SHA2. In particular, not encryp...
AES and GCM are both encryption algorithms meant to protect the contents of whatever the input is with a provided secret key from the user. AES can certainly be deciphered given the same key if the receiving party also has it. SHA-2 is a hashing algorithm that is meant to serve a one-way purpose. This means it is not ...
40,543,136
I'm using **Kentor.AuthService.Idp** project as a starting point. The SAML enabled service provider I am attempting to single sign on to requires the following attributes be part of the metadata file: *login-id, partner-id, platform, user-email* **How do I add these to an existing metadata or create a new metadata t...
2016/11/11
[ "https://Stackoverflow.com/questions/40543136", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2004532/" ]
This is all available callbacks of iCheck: [Callbacks](https://github.com/fronteed/icheck#callbacks) you can use `ifChanged` event instead
You can use ifChanged event for icheck ``` //copy address from correspondence address to permanent address $('#same_address').on('ifChanged', function(event){ if(this.checked) // if changed state is "CHECKED" { var correspondence_address = $('#correspondence_address').val(); $('#permanent_addre...
39,663,984
After reading [this](http://useyourloaf.com/blog/unregistering-nsnotificationcenter-observers-in-ios-9/) post for iOS 9, I know that you don't need to removeObserver anymore. However for iOS 8, you [needed](https://www.natashatherobot.com/ios8-where-to-remove-observer-for-nsnotification-in-swift/) to *removeObserver* ...
2016/09/23
[ "https://Stackoverflow.com/questions/39663984", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5175709/" ]
It's fully explained in the article you linked: > > The notification center now keeps a zeroing reference to the observer: > > > If the observer is able to be stored as a zeroing-weak reference the underlying storage will store the observer as a zeroing weak reference, alternatively if the object cannot be stored w...
> > It being an observer is much like calling a dead person who will never pick up the phone > > > Exactly! Your phone number in this case is a memory address, which will be dereferenced once the notification center tries to call the observer. Now, what do you expect to be at this memory address once the View Con...
58,198,756
I am currently working on a web application project as part of my developer training. Its principle is quite simple, it is a search engine dedicated to listing the results of SQL queries on a database belonging to a customer, and previously migrated. I have a particular problem, indeed, on some browsers (those based on...
2019/10/02
[ "https://Stackoverflow.com/questions/58198756", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12152803/" ]
I've tested it on your site by modifying the CSS and it seemed to work for me :/ Nomatter, I found the real problem, you've a `margin-top: 0px` on your CSS and if you remove it, it seems to show without blur, hope this answer will help you resolve this annoying bug... Here are some proofs : Your page with the `margi...
I think I've found something for you, here's the [source](https://stackoverflow.com/a/35955074/12130402) ``` #yourDiv { -webkit-filter: blur(0.000001px); } ``` ``` #yourDiv { -webkit-font-smoothing: antialiased; } ``` Hope it'll help you ;)
44,578,943
I have three `divs` within a div like this: ``` <div class="row second-top-margin"> <div class="col-md-12 center"> <div class="center-text">Responsive</div> <div class="center-text">Clean</div> <div class="center-text">Powerful</div> </div> </div> ``` What I'm trying to do is get line...
2017/06/16
[ "https://Stackoverflow.com/questions/44578943", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3546086/" ]
~~Don't use `display:table` to center items. It stopped being ok 20 years ago~~. I tend to regard `display:table` as misused (a dirty hack) when used for centering (it's better than just using a `<table>` element for the task, which is far worse, but still a misuse). A simple... ``` .between-lines { display: flex...
Try this one: ```css .center { text-align: center; } .center-text { color: #ffffff; display: inherit; font-family: 'proxima_nova_ltsemibold'; text-transform: uppercase; font-size: 52px; } .table { display:table; } .clean { display: -webkit...
44,578,943
I have three `divs` within a div like this: ``` <div class="row second-top-margin"> <div class="col-md-12 center"> <div class="center-text">Responsive</div> <div class="center-text">Clean</div> <div class="center-text">Powerful</div> </div> </div> ``` What I'm trying to do is get line...
2017/06/16
[ "https://Stackoverflow.com/questions/44578943", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3546086/" ]
~~Don't use `display:table` to center items. It stopped being ok 20 years ago~~. I tend to regard `display:table` as misused (a dirty hack) when used for centering (it's better than just using a `<table>` element for the task, which is far worse, but still a misuse). A simple... ``` .between-lines { display: flex...
One thing to consider is semantics. Use `span` elements for this kind of content, rather than `div` elements because, although the three lines of content are on different lines, they are part of the same thought/idea. So, they should all be contained in a `div`, but each part *spans* part of that `div`. Usually, the le...
4,799,785
how could i change `[('a', 1), ('c', 3), ('b', 2)]` to `['a',1,'c',3,'b',2]` and vice versa? Thanks
2011/01/25
[ "https://Stackoverflow.com/questions/4799785", "https://Stackoverflow.com", "https://Stackoverflow.com/users/589837/" ]
Going in the first direction from `[('a', 1), ('c', 3), ('b', 2)]` to `['a',1,'c',3,'b',2]` is [flattening a list](https://stackoverflow.com/questions/406121/flattening-a-shallow-list-in-python). Taking the accepted answer from there and modifying for this example: ``` >>> L = [('a', 1), ('c', 3), ('b', 2)] >>> list(i...
Here it's my take on it (assuming a contains first list and b second): ``` b = [] for i in a: b.extend(i) ``` And reverse: ``` c = [] for i in range(0, len(b) - 1, 2): c.append((b[i], b[i+1])) ```
4,799,785
how could i change `[('a', 1), ('c', 3), ('b', 2)]` to `['a',1,'c',3,'b',2]` and vice versa? Thanks
2011/01/25
[ "https://Stackoverflow.com/questions/4799785", "https://Stackoverflow.com", "https://Stackoverflow.com/users/589837/" ]
Going in the first direction from `[('a', 1), ('c', 3), ('b', 2)]` to `['a',1,'c',3,'b',2]` is [flattening a list](https://stackoverflow.com/questions/406121/flattening-a-shallow-list-in-python). Taking the accepted answer from there and modifying for this example: ``` >>> L = [('a', 1), ('c', 3), ('b', 2)] >>> list(i...
``` L = [('a', 1), ('c', 3), ('b', 2)] flat = [x for p in L for x in p] assert flat == ['a', 1, 'c', 3, 'b', 2] it = iter(flat) L2 = zip(it, it) assert L2 == L print "Success" ```
4,799,785
how could i change `[('a', 1), ('c', 3), ('b', 2)]` to `['a',1,'c',3,'b',2]` and vice versa? Thanks
2011/01/25
[ "https://Stackoverflow.com/questions/4799785", "https://Stackoverflow.com", "https://Stackoverflow.com/users/589837/" ]
Going in the first direction from `[('a', 1), ('c', 3), ('b', 2)]` to `['a',1,'c',3,'b',2]` is [flattening a list](https://stackoverflow.com/questions/406121/flattening-a-shallow-list-in-python). Taking the accepted answer from there and modifying for this example: ``` >>> L = [('a', 1), ('c', 3), ('b', 2)] >>> list(i...
There are already plenty of correct answers here, so this is just a reminder ***not*** to use sum() to flatten lists as although it looks like a neat solution **unfortunately the performance is quadratic** ``` In [1]: L=[('a',x) for x in range(10)] In [2]: timeit sum(L,()) 100000 loops, best of 3: 2.78 us per loop I...
4,799,785
how could i change `[('a', 1), ('c', 3), ('b', 2)]` to `['a',1,'c',3,'b',2]` and vice versa? Thanks
2011/01/25
[ "https://Stackoverflow.com/questions/4799785", "https://Stackoverflow.com", "https://Stackoverflow.com/users/589837/" ]
Here it's my take on it (assuming a contains first list and b second): ``` b = [] for i in a: b.extend(i) ``` And reverse: ``` c = [] for i in range(0, len(b) - 1, 2): c.append((b[i], b[i+1])) ```
``` L = [('a', 1), ('c', 3), ('b', 2)] flat = [x for p in L for x in p] assert flat == ['a', 1, 'c', 3, 'b', 2] it = iter(flat) L2 = zip(it, it) assert L2 == L print "Success" ```
4,799,785
how could i change `[('a', 1), ('c', 3), ('b', 2)]` to `['a',1,'c',3,'b',2]` and vice versa? Thanks
2011/01/25
[ "https://Stackoverflow.com/questions/4799785", "https://Stackoverflow.com", "https://Stackoverflow.com/users/589837/" ]
Here it's my take on it (assuming a contains first list and b second): ``` b = [] for i in a: b.extend(i) ``` And reverse: ``` c = [] for i in range(0, len(b) - 1, 2): c.append((b[i], b[i+1])) ```
There are already plenty of correct answers here, so this is just a reminder ***not*** to use sum() to flatten lists as although it looks like a neat solution **unfortunately the performance is quadratic** ``` In [1]: L=[('a',x) for x in range(10)] In [2]: timeit sum(L,()) 100000 loops, best of 3: 2.78 us per loop I...
23,532,211
I have the following sequence of events: ``` for(int i = 0; i < 4; i++) { int seqNum; int ackNum; int pldSize; char* payload = (char*)malloc(DEFINED_SIZE); //buffer updated each loop, assume: 140hello! Packet::decap(buffer, seqNum, ackNum, pldSize, payload); Packet p = Packet(seqNum, ackN...
2014/05/08
[ "https://Stackoverflow.com/questions/23532211", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1143724/" ]
This line appears to be the culprit, ``` memcpy(pyld, &datagram[12], bytes); ``` Print the value of `bytes` before this line.
`memcpy(pld, &payload, sz);` I suspect you want this... `payload = pld`
23,532,211
I have the following sequence of events: ``` for(int i = 0; i < 4; i++) { int seqNum; int ackNum; int pldSize; char* payload = (char*)malloc(DEFINED_SIZE); //buffer updated each loop, assume: 140hello! Packet::decap(buffer, seqNum, ackNum, pldSize, payload); Packet p = Packet(seqNum, ackN...
2014/05/08
[ "https://Stackoverflow.com/questions/23532211", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1143724/" ]
C++11 example using automatic memory management: ``` typedef std::array<char, DEFINED_SIZE> packet_t; typedef std::shared_ptr<packet_t> shared_packet_t; for(int i = 0; i < 4; i++) { int seqNum; int ackNum; int pldSize; // memory allocated here as new packet_t() but owned by shared_packet_t shared_...
`memcpy(pld, &payload, sz);` I suspect you want this... `payload = pld`
16,321,516
I'm trying to get Enquire.js working for legacy browsers. I'm using the Deep support method from the docs: ``` Modernizr.load([ { test: window.matchMedia, nope: "media.match.min.js" }, "enquire-2.0.0.min.js", "plugins.js", // jquery plugins "main.js" // enquire-triggered functions ...
2013/05/01
[ "https://Stackoverflow.com/questions/16321516", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1530196/" ]
I ran into the same problem with Enquire v2.0.2. My workaround was to remove the inclusion of matchMedia from respond.js, and then load media.match and enquire.js after loading respond.js. I haven't tested this with modernizr yet, but I was able to get media query support and enquire.js to work in IE7 and 8 with no JS ...
Tim, A little late but did you see this yet? I think it's what you are looking for. [enquire.js legacy support](https://stackoverflow.com/questions/14402932/enquire-js-legacy-support)
16,321,516
I'm trying to get Enquire.js working for legacy browsers. I'm using the Deep support method from the docs: ``` Modernizr.load([ { test: window.matchMedia, nope: "media.match.min.js" }, "enquire-2.0.0.min.js", "plugins.js", // jquery plugins "main.js" // enquire-triggered functions ...
2013/05/01
[ "https://Stackoverflow.com/questions/16321516", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1530196/" ]
I guess the actual problem is that in respond.js you do have the matchMedia polyfill but without the [matchMedia.addListener plugin](https://github.com/paulirish/matchMedia.js/blob/master/matchMedia.addListener.js). So the modernizr test for plain matchMedia succeeds but then results in the error you probably get with ...
Tim, A little late but did you see this yet? I think it's what you are looking for. [enquire.js legacy support](https://stackoverflow.com/questions/14402932/enquire-js-legacy-support)
16,321,516
I'm trying to get Enquire.js working for legacy browsers. I'm using the Deep support method from the docs: ``` Modernizr.load([ { test: window.matchMedia, nope: "media.match.min.js" }, "enquire-2.0.0.min.js", "plugins.js", // jquery plugins "main.js" // enquire-triggered functions ...
2013/05/01
[ "https://Stackoverflow.com/questions/16321516", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1530196/" ]
I ran into the same problem with Enquire v2.0.2. My workaround was to remove the inclusion of matchMedia from respond.js, and then load media.match and enquire.js after loading respond.js. I haven't tested this with modernizr yet, but I was able to get media query support and enquire.js to work in IE7 and 8 with no JS ...
I guess the actual problem is that in respond.js you do have the matchMedia polyfill but without the [matchMedia.addListener plugin](https://github.com/paulirish/matchMedia.js/blob/master/matchMedia.addListener.js). So the modernizr test for plain matchMedia succeeds but then results in the error you probably get with ...
199,863
I am looking for a command to create multiple (thousands of) files containing at least 1KB of random data. For example, ``` Name size file1.01 2K file2.02 3K file3.03 5K etc. ``` How can I create many files like this?
2015/05/01
[ "https://unix.stackexchange.com/questions/199863", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/105827/" ]
A variation with `seq`, `xargs`, `dd` and `shuf`: ``` seq -w 1 10 | xargs -n1 -I% sh -c 'dd if=/dev/urandom of=file.% bs=$(shuf -i1-10 -n1) count=1024' ``` Explanation as requested per comments: `seq -w 1 10` prints a sequence of numbers from *01* to *10* `xargs -n1 -I%` executes the command `sh -c 'dd ... % ...'`...
This uses a single pipeline and seems fairly fast, but has the limitation that all of the files are the same size ``` dd if=/dev/urandom bs=1024 count=10240 | split -a 4 -b 1k - file. ``` Explanation: Use dd to create 10240\*1024 bytes of data; split that into 10240 separate files of 1k each (names will run from 'fi...
199,863
I am looking for a command to create multiple (thousands of) files containing at least 1KB of random data. For example, ``` Name size file1.01 2K file2.02 3K file3.03 5K etc. ``` How can I create many files like this?
2015/05/01
[ "https://unix.stackexchange.com/questions/199863", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/105827/" ]
This will create 15 files each contains 1MB of random data: ``` for i in {001..015}; do head -c 1M </dev/urandom >randfile$i; done ```
You can do something like this: ``` #!/bin/bash filecount=0 while [ $filecount -lt 10000 ] ; do filesize=$RANDOM filesize=$(($filesize+1024)) base64 /dev/urandom | head -c "$filesize" > /tmp/file${filecount}.$RANDOM ((filecount++)) done ```
199,863
I am looking for a command to create multiple (thousands of) files containing at least 1KB of random data. For example, ``` Name size file1.01 2K file2.02 3K file3.03 5K etc. ``` How can I create many files like this?
2015/05/01
[ "https://unix.stackexchange.com/questions/199863", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/105827/" ]
Since you don't have any other requirements, something like this should work: ```bash #! /bin/bash for n in {1..1000}; do dd if=/dev/urandom of=file$( printf %03d "$n" ).bin bs=1 count=$(( RANDOM + 1024 )) done ``` (this needs `bash` at least for `{1..1000}`).
Similar to lcd047's answer (it works with bash, even git bash on Windows), with the addition that the names are also randomized and of 1MB in size (might be more efficient disk-wise): ``` #! /bin/bash s=$(hostname).$(pwd).${RANDOM} for n in {1..1000}; do x=$( printf %04d "$n" ) dd if=/dev/urandom of=$(echo "${...
199,863
I am looking for a command to create multiple (thousands of) files containing at least 1KB of random data. For example, ``` Name size file1.01 2K file2.02 3K file3.03 5K etc. ``` How can I create many files like this?
2015/05/01
[ "https://unix.stackexchange.com/questions/199863", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/105827/" ]
This uses a single pipeline and seems fairly fast, but has the limitation that all of the files are the same size ``` dd if=/dev/urandom bs=1024 count=10240 | split -a 4 -b 1k - file. ``` Explanation: Use dd to create 10240\*1024 bytes of data; split that into 10240 separate files of 1k each (names will run from 'fi...
Similar to lcd047's answer (it works with bash, even git bash on Windows), with the addition that the names are also randomized and of 1MB in size (might be more efficient disk-wise): ``` #! /bin/bash s=$(hostname).$(pwd).${RANDOM} for n in {1..1000}; do x=$( printf %04d "$n" ) dd if=/dev/urandom of=$(echo "${...
199,863
I am looking for a command to create multiple (thousands of) files containing at least 1KB of random data. For example, ``` Name size file1.01 2K file2.02 3K file3.03 5K etc. ``` How can I create many files like this?
2015/05/01
[ "https://unix.stackexchange.com/questions/199863", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/105827/" ]
This uses a single pipeline and seems fairly fast, but has the limitation that all of the files are the same size ``` dd if=/dev/urandom bs=1024 count=10240 | split -a 4 -b 1k - file. ``` Explanation: Use dd to create 10240\*1024 bytes of data; split that into 10240 separate files of 1k each (names will run from 'fi...
You can do something like this: ``` #!/bin/bash filecount=0 while [ $filecount -lt 10000 ] ; do filesize=$RANDOM filesize=$(($filesize+1024)) base64 /dev/urandom | head -c "$filesize" > /tmp/file${filecount}.$RANDOM ((filecount++)) done ```
199,863
I am looking for a command to create multiple (thousands of) files containing at least 1KB of random data. For example, ``` Name size file1.01 2K file2.02 3K file3.03 5K etc. ``` How can I create many files like this?
2015/05/01
[ "https://unix.stackexchange.com/questions/199863", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/105827/" ]
This will create 15 files each contains 1MB of random data: ``` for i in {001..015}; do head -c 1M </dev/urandom >randfile$i; done ```
Similar to lcd047's answer (it works with bash, even git bash on Windows), with the addition that the names are also randomized and of 1MB in size (might be more efficient disk-wise): ``` #! /bin/bash s=$(hostname).$(pwd).${RANDOM} for n in {1..1000}; do x=$( printf %04d "$n" ) dd if=/dev/urandom of=$(echo "${...
199,863
I am looking for a command to create multiple (thousands of) files containing at least 1KB of random data. For example, ``` Name size file1.01 2K file2.02 3K file3.03 5K etc. ``` How can I create many files like this?
2015/05/01
[ "https://unix.stackexchange.com/questions/199863", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/105827/" ]
A variation with `seq`, `xargs`, `dd` and `shuf`: ``` seq -w 1 10 | xargs -n1 -I% sh -c 'dd if=/dev/urandom of=file.% bs=$(shuf -i1-10 -n1) count=1024' ``` Explanation as requested per comments: `seq -w 1 10` prints a sequence of numbers from *01* to *10* `xargs -n1 -I%` executes the command `sh -c 'dd ... % ...'`...
Similar to lcd047's answer (it works with bash, even git bash on Windows), with the addition that the names are also randomized and of 1MB in size (might be more efficient disk-wise): ``` #! /bin/bash s=$(hostname).$(pwd).${RANDOM} for n in {1..1000}; do x=$( printf %04d "$n" ) dd if=/dev/urandom of=$(echo "${...
199,863
I am looking for a command to create multiple (thousands of) files containing at least 1KB of random data. For example, ``` Name size file1.01 2K file2.02 3K file3.03 5K etc. ``` How can I create many files like this?
2015/05/01
[ "https://unix.stackexchange.com/questions/199863", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/105827/" ]
A variation with `seq`, `xargs`, `dd` and `shuf`: ``` seq -w 1 10 | xargs -n1 -I% sh -c 'dd if=/dev/urandom of=file.% bs=$(shuf -i1-10 -n1) count=1024' ``` Explanation as requested per comments: `seq -w 1 10` prints a sequence of numbers from *01* to *10* `xargs -n1 -I%` executes the command `sh -c 'dd ... % ...'`...
You can do something like this: ``` #!/bin/bash filecount=0 while [ $filecount -lt 10000 ] ; do filesize=$RANDOM filesize=$(($filesize+1024)) base64 /dev/urandom | head -c "$filesize" > /tmp/file${filecount}.$RANDOM ((filecount++)) done ```
199,863
I am looking for a command to create multiple (thousands of) files containing at least 1KB of random data. For example, ``` Name size file1.01 2K file2.02 3K file3.03 5K etc. ``` How can I create many files like this?
2015/05/01
[ "https://unix.stackexchange.com/questions/199863", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/105827/" ]
Since you don't have any other requirements, something like this should work: ```bash #! /bin/bash for n in {1..1000}; do dd if=/dev/urandom of=file$( printf %03d "$n" ).bin bs=1 count=$(( RANDOM + 1024 )) done ``` (this needs `bash` at least for `{1..1000}`).
You can do something like this: ``` #!/bin/bash filecount=0 while [ $filecount -lt 10000 ] ; do filesize=$RANDOM filesize=$(($filesize+1024)) base64 /dev/urandom | head -c "$filesize" > /tmp/file${filecount}.$RANDOM ((filecount++)) done ```
199,863
I am looking for a command to create multiple (thousands of) files containing at least 1KB of random data. For example, ``` Name size file1.01 2K file2.02 3K file3.03 5K etc. ``` How can I create many files like this?
2015/05/01
[ "https://unix.stackexchange.com/questions/199863", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/105827/" ]
Since you don't have any other requirements, something like this should work: ```bash #! /bin/bash for n in {1..1000}; do dd if=/dev/urandom of=file$( printf %03d "$n" ).bin bs=1 count=$(( RANDOM + 1024 )) done ``` (this needs `bash` at least for `{1..1000}`).
A variation with `seq`, `xargs`, `dd` and `shuf`: ``` seq -w 1 10 | xargs -n1 -I% sh -c 'dd if=/dev/urandom of=file.% bs=$(shuf -i1-10 -n1) count=1024' ``` Explanation as requested per comments: `seq -w 1 10` prints a sequence of numbers from *01* to *10* `xargs -n1 -I%` executes the command `sh -c 'dd ... % ...'`...
55,109,736
I get the error message below. If you haven't installed orca yet, you can do so using conda as follows: ``` $ conda install -c plotly plotly-orca ``` Alternatively, see other installation methods in the orca project README at <https://github.com/plotly/orca>. I tried: `!pip install plotly-orca`, but that throws an...
2019/03/11
[ "https://Stackoverflow.com/questions/55109736", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1380254/" ]
As a workaround put: ``` from matplotlib.axes._axes import _log as matplotlib_axes_logger matplotlib_axes_logger.setLevel('ERROR') ```
In the latest version of matplotlib (3.0.3), argument 'c' should be a 2-D array. If the length of 'c' matches with the length of 'x' and 'y', the color of each point corresponds to the element of the 'c'. If you want to make every point show the same color, 'c' should be a 2-D array with a single row, such as c=np.arra...
55,109,736
I get the error message below. If you haven't installed orca yet, you can do so using conda as follows: ``` $ conda install -c plotly plotly-orca ``` Alternatively, see other installation methods in the orca project README at <https://github.com/plotly/orca>. I tried: `!pip install plotly-orca`, but that throws an...
2019/03/11
[ "https://Stackoverflow.com/questions/55109736", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1380254/" ]
First produce data and define a color: ``` import numpy import matplotlib import matplotlib.pyplot #Make the color you actually want: Color = numpy.array([.5, .6, .7]) #Make some data: Vals = numpy.random.uniform( size = (10, 3) ) PointCount = Vals.shape[0] Xvals = Vals[:, 0] Yvals = Vals[:, 1] Zvals = Vals[:, 2] `...
In the latest version of matplotlib (3.0.3), argument 'c' should be a 2-D array. If the length of 'c' matches with the length of 'x' and 'y', the color of each point corresponds to the element of the 'c'. If you want to make every point show the same color, 'c' should be a 2-D array with a single row, such as c=np.arra...
55,109,736
I get the error message below. If you haven't installed orca yet, you can do so using conda as follows: ``` $ conda install -c plotly plotly-orca ``` Alternatively, see other installation methods in the orca project README at <https://github.com/plotly/orca>. I tried: `!pip install plotly-orca`, but that throws an...
2019/03/11
[ "https://Stackoverflow.com/questions/55109736", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1380254/" ]
You can also make your c argument 2D with: ``` c=color.reshape(1,-1) ``` or ``` c=np.array([color]) ``` or just change your original color array to 2D: ``` color = cm.nipy_spectral(float(i) / n_clusters).reshape(1,-1) ``` p.s.: As I need 50 reputation to comment, I just open a new answer, though th...
In the latest version of matplotlib (3.0.3), argument 'c' should be a 2-D array. If the length of 'c' matches with the length of 'x' and 'y', the color of each point corresponds to the element of the 'c'. If you want to make every point show the same color, 'c' should be a 2-D array with a single row, such as c=np.arra...
55,109,736
I get the error message below. If you haven't installed orca yet, you can do so using conda as follows: ``` $ conda install -c plotly plotly-orca ``` Alternatively, see other installation methods in the orca project README at <https://github.com/plotly/orca>. I tried: `!pip install plotly-orca`, but that throws an...
2019/03/11
[ "https://Stackoverflow.com/questions/55109736", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1380254/" ]
You can also make your c argument 2D with: ``` c=color.reshape(1,-1) ``` or ``` c=np.array([color]) ``` or just change your original color array to 2D: ``` color = cm.nipy_spectral(float(i) / n_clusters).reshape(1,-1) ``` p.s.: As I need 50 reputation to comment, I just open a new answer, though th...
As a workaround put: ``` from matplotlib.axes._axes import _log as matplotlib_axes_logger matplotlib_axes_logger.setLevel('ERROR') ```