qid
int64
1
74.7M
question
stringlengths
0
58.3k
date
stringlengths
10
10
metadata
list
response_j
stringlengths
2
48.3k
response_k
stringlengths
2
40.5k
53,369
When someone says: `chotto matte te`, why does the `te` mean "... and I'll be back shortly". What's **the logic** behind it? Why aren't there special expressions such as `chotto matte X`, where X could mean "I'll give food to my cat" or "I'll need sign an important document for Toyota" or "I'll fix my laptop which wa...
2017/09/20
[ "https://japanese.stackexchange.com/questions/53369", "https://japanese.stackexchange.com", "https://japanese.stackexchange.com/users/25785/" ]
ちょっと待ってて (chotto matte te) literally means "Keep waiting for a while (please)." That て (te) at the end does **not** mean "I'll be back shortly", at least grammatically. ちょっと (chotto) just means "for a while", "a little", etc. 待ってて (matte te) is constructed as follows: * **待つ** (matsu): simple intransitive verb, "to w...
* ちょっと待っていてください -> ちょっと待っていて -> ちょっと待ってて(chotto matte te) * ちょっと待ってと言っているでしょう -> ちょっと待ってと -> ちょっと待ってって(chotto matte tte) These two phrase are similar, but not the same.
53,369
When someone says: `chotto matte te`, why does the `te` mean "... and I'll be back shortly". What's **the logic** behind it? Why aren't there special expressions such as `chotto matte X`, where X could mean "I'll give food to my cat" or "I'll need sign an important document for Toyota" or "I'll fix my laptop which wa...
2017/09/20
[ "https://japanese.stackexchange.com/questions/53369", "https://japanese.stackexchange.com", "https://japanese.stackexchange.com/users/25785/" ]
ちょっと待ってて (chotto matte te) literally means "Keep waiting for a while (please)." That て (te) at the end does **not** mean "I'll be back shortly", at least grammatically. ちょっと (chotto) just means "for a while", "a little", etc. 待ってて (matte te) is constructed as follows: * **待つ** (matsu): simple intransitive verb, "to w...
It's short for ちょっと待っていて, literally "wait and stay there". There's nothing about coming back, but of course it is inferred.
53,369
When someone says: `chotto matte te`, why does the `te` mean "... and I'll be back shortly". What's **the logic** behind it? Why aren't there special expressions such as `chotto matte X`, where X could mean "I'll give food to my cat" or "I'll need sign an important document for Toyota" or "I'll fix my laptop which wa...
2017/09/20
[ "https://japanese.stackexchange.com/questions/53369", "https://japanese.stackexchange.com", "https://japanese.stackexchange.com/users/25785/" ]
* ちょっと待っていてください -> ちょっと待っていて -> ちょっと待ってて(chotto matte te) * ちょっと待ってと言っているでしょう -> ちょっと待ってと -> ちょっと待ってって(chotto matte tte) These two phrase are similar, but not the same.
It's short for ちょっと待っていて, literally "wait and stay there". There's nothing about coming back, but of course it is inferred.
17,118,231
I'm using clock(), and I'm wondering whether it ever resets or maxes out. all I'm using it for is just too subject it from a previous function call and find the difference. Thanks for the help so far but I'm not really able to get the chrono thing working in VS '12 but its fine because I think its a little more than I...
2013/06/14
[ "https://Stackoverflow.com/questions/17118231", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2487683/" ]
As far as the standard is concerned, > > The range and precision of times representable in `clock_t` and `time_t` are implementation-defined. > > > (C99, §7.23.1 ¶4) so there are no guarantees of range; the definition of `clock()` does not say anything about wrapping around, although it says that > > If the ...
Depends on what system you are on. It may use a 32+ or a 64-bit `clock_t`. It will definitely roll over, but if it's 64-bit, it will be OK for quite some time before it rolls over - 264 microseconds is still an awful long time (approx 244 seconds, and there is around 216 seconds per day, so 228 days - which is about 22...
17,118,231
I'm using clock(), and I'm wondering whether it ever resets or maxes out. all I'm using it for is just too subject it from a previous function call and find the difference. Thanks for the help so far but I'm not really able to get the chrono thing working in VS '12 but its fine because I think its a little more than I...
2013/06/14
[ "https://Stackoverflow.com/questions/17118231", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2487683/" ]
As far as the standard is concerned, > > The range and precision of times representable in `clock_t` and `time_t` are implementation-defined. > > > (C99, §7.23.1 ¶4) so there are no guarantees of range; the definition of `clock()` does not say anything about wrapping around, although it says that > > If the ...
The simple answer is that if you're just using it to time a function, it will probably not wrap around. It may also be too slow and chances are you might see a function duration of zero. If you want accurate timing for a function that executes fast, you're probably better using an OS level call like [this one on Window...
17,118,231
I'm using clock(), and I'm wondering whether it ever resets or maxes out. all I'm using it for is just too subject it from a previous function call and find the difference. Thanks for the help so far but I'm not really able to get the chrono thing working in VS '12 but its fine because I think its a little more than I...
2013/06/14
[ "https://Stackoverflow.com/questions/17118231", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2487683/" ]
Depends on what system you are on. It may use a 32+ or a 64-bit `clock_t`. It will definitely roll over, but if it's 64-bit, it will be OK for quite some time before it rolls over - 264 microseconds is still an awful long time (approx 244 seconds, and there is around 216 seconds per day, so 228 days - which is about 22...
The simple answer is that if you're just using it to time a function, it will probably not wrap around. It may also be too slow and chances are you might see a function duration of zero. If you want accurate timing for a function that executes fast, you're probably better using an OS level call like [this one on Window...
8,563,304
My below code is working fine when used in HTML. The same code I tried to place it inside a form and it stopped working. How to fix this issue? ``` <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head...
2011/12/19
[ "https://Stackoverflow.com/questions/8563304", "https://Stackoverflow.com", "https://Stackoverflow.com/users/985736/" ]
For .NET 4.0 add **ClientIDMode Static** for tags to appear on client side the sameway they appear on server side. Something like ``` <form id="form1" runat="server" ClientIDMode="Static"> ``` For old .net use '<%= Control.ClientID %>' in your jQuery/Javascript code whenever you are refering to a ...
Hint: Look at the ID's of the code in the final HTML. This should give you an idea of what's going. There are a number of solutions to this, but that depends on what version of .net you are using.
8,563,304
My below code is working fine when used in HTML. The same code I tried to place it inside a form and it stopped working. How to fix this issue? ``` <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head...
2011/12/19
[ "https://Stackoverflow.com/questions/8563304", "https://Stackoverflow.com", "https://Stackoverflow.com/users/985736/" ]
When you have a inside a automatically submits the form. Replace the ``` <button>Add a line</button> ``` with a ``` <input type="button" value="Add a line" /> ``` and that way the browser doesn't post the form when it's clicked. Remember also to change the jQuery selector from ``` $('button').click(function (...
Hint: Look at the ID's of the code in the final HTML. This should give you an idea of what's going. There are a number of solutions to this, but that depends on what version of .net you are using.
11,441,936
I want to simulate a click, > > $("#genStats").trigger("click"); > > > every time I refresh the page > > window.location.reload() > > > but not on the initial page load. What's the easiest way of doing this?
2012/07/11
[ "https://Stackoverflow.com/questions/11441936", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1350177/" ]
Check out this other SO post: [Check if page gets reloaded or refreshed in Javascript](https://stackoverflow.com/questions/5004978/check-if-page-reloaded-or-refresh-in-js) The catch here is that this detects if it is the *first time* the user has landed on the page. So if they land there and refresh, you will get the ...
Within your javascript code place $(document).ready() function that once the page completely load, it will trigger your click.
104,214
Chat just took a dive, everything operational or are we headed for bad news? <https://chat.stackoverflow.com> is "[not loading](http://www.downforeveryoneorjustme.com/chat.stackexchange.com)" and pinging chat.so times out. ![Down for me or everyone?](https://i.stack.imgur.com/FR8xO.png)
2011/08/28
[ "https://meta.stackexchange.com/questions/104214", "https://meta.stackexchange.com", "https://meta.stackexchange.com/users/146986/" ]
I would love to blame Irene for this, but I fear we have to blame ourselves… We recently made some major changes to the network architecture, and there are still a few things to iron out, especially when it comes to commuication between our two datacenters in Oregon (where chat is hosted) and New York (where the main ...
Could it be this? ![Irene](https://i.stack.imgur.com/m1qJx.jpg)
40,620,353
I'm learning javascript. I have written a none recursive function which I want to return the factorial of a given number. ``` function factorialize(n) { for(var i = 0; i < n; i++) { n *= i; } return n; } factorialize(5); ``` so result should be `120` I keep getting `0`
2016/11/15
[ "https://Stackoverflow.com/questions/40620353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5974935/" ]
You are looping from 0 to n ...Multiplyin any number with 0 will be 0 another thing ,you are looping it till n and incrementing with i in every loop ,it goes into infinite loop change it to the following ```js function factorialize(n) { var length=n; if(n==0) return 1; for(var i = 1; i < length; i++) { ...
You are actually doing this n = (5 \* 0 \* 1 \* 2\* 3 \* 4 \* 5 \* 6)
40,620,353
I'm learning javascript. I have written a none recursive function which I want to return the factorial of a given number. ``` function factorialize(n) { for(var i = 0; i < n; i++) { n *= i; } return n; } factorialize(5); ``` so result should be `120` I keep getting `0`
2016/11/15
[ "https://Stackoverflow.com/questions/40620353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5974935/" ]
You are looping from 0 to n ...Multiplyin any number with 0 will be 0 another thing ,you are looping it till n and incrementing with i in every loop ,it goes into infinite loop change it to the following ```js function factorialize(n) { var length=n; if(n==0) return 1; for(var i = 1; i < length; i++) { ...
You should start from 1 to n. ``` function factorialize(n) { var ret = 1; for(var i = 1; i <= n; i++) { ret *= i; } return ret; } ``` In the original code, `i` started from `0`. The result will always be `0` as `0 * (any number)` will result in `0`.
40,620,353
I'm learning javascript. I have written a none recursive function which I want to return the factorial of a given number. ``` function factorialize(n) { for(var i = 0; i < n; i++) { n *= i; } return n; } factorialize(5); ``` so result should be `120` I keep getting `0`
2016/11/15
[ "https://Stackoverflow.com/questions/40620353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5974935/" ]
With your code: * loop1: n = 5 \* 0 | n = 0 * loop2: n = 0 \* 1 | n = 0 * loop3: n = 0 \* 2 | n = 0 * loop4: n = 0 \* 3 | n = 0 * loop5: n = 0 \* 4 | n = 0 and then you return 0 "**i**" must start from 1, otherwise, in every loop you multiply by 0. I don't provide a solution, because you have already received a lot...
You are actually doing this n = (5 \* 0 \* 1 \* 2\* 3 \* 4 \* 5 \* 6)
40,620,353
I'm learning javascript. I have written a none recursive function which I want to return the factorial of a given number. ``` function factorialize(n) { for(var i = 0; i < n; i++) { n *= i; } return n; } factorialize(5); ``` so result should be `120` I keep getting `0`
2016/11/15
[ "https://Stackoverflow.com/questions/40620353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5974935/" ]
You have two (well, three) mistakes in your code: First `i` must start from `1` (instead of `0`) and go up to `f - 1` otherwise at the first iteration it will be set to `0` (where `f` is the number you need to factorialized - note I changed the argument of the function) Second, you cannot use `n` for both the upper b...
Please try this : ``` function factorialize(n) { var p=1; for(var i = 1; i <=n; i++) { p*=i; } return p; } ```
40,620,353
I'm learning javascript. I have written a none recursive function which I want to return the factorial of a given number. ``` function factorialize(n) { for(var i = 0; i < n; i++) { n *= i; } return n; } factorialize(5); ``` so result should be `120` I keep getting `0`
2016/11/15
[ "https://Stackoverflow.com/questions/40620353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5974935/" ]
You have two (well, three) mistakes in your code: First `i` must start from `1` (instead of `0`) and go up to `f - 1` otherwise at the first iteration it will be set to `0` (where `f` is the number you need to factorialized - note I changed the argument of the function) Second, you cannot use `n` for both the upper b...
You are actually doing this n = (5 \* 0 \* 1 \* 2\* 3 \* 4 \* 5 \* 6)
40,620,353
I'm learning javascript. I have written a none recursive function which I want to return the factorial of a given number. ``` function factorialize(n) { for(var i = 0; i < n; i++) { n *= i; } return n; } factorialize(5); ``` so result should be `120` I keep getting `0`
2016/11/15
[ "https://Stackoverflow.com/questions/40620353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5974935/" ]
You are looping from 0 to n ...Multiplyin any number with 0 will be 0 another thing ,you are looping it till n and incrementing with i in every loop ,it goes into infinite loop change it to the following ```js function factorialize(n) { var length=n; if(n==0) return 1; for(var i = 1; i < length; i++) { ...
You have two (well, three) mistakes in your code: First `i` must start from `1` (instead of `0`) and go up to `f - 1` otherwise at the first iteration it will be set to `0` (where `f` is the number you need to factorialized - note I changed the argument of the function) Second, you cannot use `n` for both the upper b...
40,620,353
I'm learning javascript. I have written a none recursive function which I want to return the factorial of a given number. ``` function factorialize(n) { for(var i = 0; i < n; i++) { n *= i; } return n; } factorialize(5); ``` so result should be `120` I keep getting `0`
2016/11/15
[ "https://Stackoverflow.com/questions/40620353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5974935/" ]
You should start from 1 to n. ``` function factorialize(n) { var ret = 1; for(var i = 1; i <= n; i++) { ret *= i; } return ret; } ``` In the original code, `i` started from `0`. The result will always be `0` as `0 * (any number)` will result in `0`.
You are actually doing this n = (5 \* 0 \* 1 \* 2\* 3 \* 4 \* 5 \* 6)
40,620,353
I'm learning javascript. I have written a none recursive function which I want to return the factorial of a given number. ``` function factorialize(n) { for(var i = 0; i < n; i++) { n *= i; } return n; } factorialize(5); ``` so result should be `120` I keep getting `0`
2016/11/15
[ "https://Stackoverflow.com/questions/40620353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5974935/" ]
You are looping from 0 to n ...Multiplyin any number with 0 will be 0 another thing ,you are looping it till n and incrementing with i in every loop ,it goes into infinite loop change it to the following ```js function factorialize(n) { var length=n; if(n==0) return 1; for(var i = 1; i < length; i++) { ...
Please try this : ``` function factorialize(n) { var p=1; for(var i = 1; i <=n; i++) { p*=i; } return p; } ```
40,620,353
I'm learning javascript. I have written a none recursive function which I want to return the factorial of a given number. ``` function factorialize(n) { for(var i = 0; i < n; i++) { n *= i; } return n; } factorialize(5); ``` so result should be `120` I keep getting `0`
2016/11/15
[ "https://Stackoverflow.com/questions/40620353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5974935/" ]
You should start from 1 to n. ``` function factorialize(n) { var ret = 1; for(var i = 1; i <= n; i++) { ret *= i; } return ret; } ``` In the original code, `i` started from `0`. The result will always be `0` as `0 * (any number)` will result in `0`.
Please try this : ``` function factorialize(n) { var p=1; for(var i = 1; i <=n; i++) { p*=i; } return p; } ```
40,620,353
I'm learning javascript. I have written a none recursive function which I want to return the factorial of a given number. ``` function factorialize(n) { for(var i = 0; i < n; i++) { n *= i; } return n; } factorialize(5); ``` so result should be `120` I keep getting `0`
2016/11/15
[ "https://Stackoverflow.com/questions/40620353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5974935/" ]
With your code: * loop1: n = 5 \* 0 | n = 0 * loop2: n = 0 \* 1 | n = 0 * loop3: n = 0 \* 2 | n = 0 * loop4: n = 0 \* 3 | n = 0 * loop5: n = 0 \* 4 | n = 0 and then you return 0 "**i**" must start from 1, otherwise, in every loop you multiply by 0. I don't provide a solution, because you have already received a lot...
Please try this : ``` function factorialize(n) { var p=1; for(var i = 1; i <=n; i++) { p*=i; } return p; } ```
18,219,952
In an Android project I needed a way to retrieve a string value not from a Context but from a static method. For this, I've implemented the solution [How can I get a resource content from a static context?](https://stackoverflow.com/questions/4391720/how-can-i-get-a-esource-content-from-a-static-context) and I've adde...
2013/08/13
[ "https://Stackoverflow.com/questions/18219952", "https://Stackoverflow.com", "https://Stackoverflow.com/users/901046/" ]
The answer is no. You can't put the authentication details into the program and make it impossible for users to get those same authentication details. You can try to obfuscate them, but it is not possible to ensure that they cannot be read. Compiling the code will not even obfuscate them very much. One approach to th...
to add onto jmh's comments and answer another part of your question, it is possible to decompile the java from the .class byte code and get almost exactly what the .java file contains so that won't help you. C is more difficult to piece back together but again, its certainly possible.
18,219,952
In an Android project I needed a way to retrieve a string value not from a Context but from a static method. For this, I've implemented the solution [How can I get a resource content from a static context?](https://stackoverflow.com/questions/4391720/how-can-i-get-a-esource-content-from-a-static-context) and I've adde...
2013/08/13
[ "https://Stackoverflow.com/questions/18219952", "https://Stackoverflow.com", "https://Stackoverflow.com/users/901046/" ]
The answer is no. You can't put the authentication details into the program and make it impossible for users to get those same authentication details. You can try to obfuscate them, but it is not possible to ensure that they cannot be read. Compiling the code will not even obfuscate them very much. One approach to th...
I sometimes compress credentials with zlib and compile to pyo file. It protect from "open in editor and press ctrl+f" and from not-programmers only. Sometimes I used PGP cryptography.)
18,219,952
In an Android project I needed a way to retrieve a string value not from a Context but from a static method. For this, I've implemented the solution [How can I get a resource content from a static context?](https://stackoverflow.com/questions/4391720/how-can-i-get-a-esource-content-from-a-static-context) and I've adde...
2013/08/13
[ "https://Stackoverflow.com/questions/18219952", "https://Stackoverflow.com", "https://Stackoverflow.com/users/901046/" ]
Just set the name to "username" and password to "password", and then when you give it to your friends, provision an account/credential that's only for them, and tell them to change the script and be done with it. That's the best/easiest way to do this.
to add onto jmh's comments and answer another part of your question, it is possible to decompile the java from the .class byte code and get almost exactly what the .java file contains so that won't help you. C is more difficult to piece back together but again, its certainly possible.
18,219,952
In an Android project I needed a way to retrieve a string value not from a Context but from a static method. For this, I've implemented the solution [How can I get a resource content from a static context?](https://stackoverflow.com/questions/4391720/how-can-i-get-a-esource-content-from-a-static-context) and I've adde...
2013/08/13
[ "https://Stackoverflow.com/questions/18219952", "https://Stackoverflow.com", "https://Stackoverflow.com/users/901046/" ]
to add onto jmh's comments and answer another part of your question, it is possible to decompile the java from the .class byte code and get almost exactly what the .java file contains so that won't help you. C is more difficult to piece back together but again, its certainly possible.
I sometimes compress credentials with zlib and compile to pyo file. It protect from "open in editor and press ctrl+f" and from not-programmers only. Sometimes I used PGP cryptography.)
18,219,952
In an Android project I needed a way to retrieve a string value not from a Context but from a static method. For this, I've implemented the solution [How can I get a resource content from a static context?](https://stackoverflow.com/questions/4391720/how-can-i-get-a-esource-content-from-a-static-context) and I've adde...
2013/08/13
[ "https://Stackoverflow.com/questions/18219952", "https://Stackoverflow.com", "https://Stackoverflow.com/users/901046/" ]
Just set the name to "username" and password to "password", and then when you give it to your friends, provision an account/credential that's only for them, and tell them to change the script and be done with it. That's the best/easiest way to do this.
I sometimes compress credentials with zlib and compile to pyo file. It protect from "open in editor and press ctrl+f" and from not-programmers only. Sometimes I used PGP cryptography.)
10,317
I have twenty LEDs that I want to light up. I planned out a few possible circuits, which I describe below along with a few questions. Would any of them not work, and why? Anything else I should be taking into consideration but haven't? The LED has the following specs: ``` Vmin: 2.8V Vmax: 3.5V If: 20 mA ``` From wha...
2011/02/17
[ "https://electronics.stackexchange.com/questions/10317", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/2836/" ]
The most efficient method to do this would be with a boost converter, preferably one that has current control. Hundreds of LED drivers which are essentially modified power ICs are available nowadays, including ones that operate from single alkaline cells down to 0.9 V e.g. the [Micrel MIC2282](http://www.micrel.com/_PD...
56 V is inconveniently high, and in reality, your 20 \* 2.8 V will vary as the LEDs heat up. You could do it with a switching voltage converter, but it's not the easiest way. Your plan of putting many LEDs in parallel is good as long as you include the resistors you describe. As the battery discharges, the voltage wil...
10,317
I have twenty LEDs that I want to light up. I planned out a few possible circuits, which I describe below along with a few questions. Would any of them not work, and why? Anything else I should be taking into consideration but haven't? The LED has the following specs: ``` Vmin: 2.8V Vmax: 3.5V If: 20 mA ``` From wha...
2011/02/17
[ "https://electronics.stackexchange.com/questions/10317", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/2836/" ]
The most efficient method to do this would be with a boost converter, preferably one that has current control. Hundreds of LED drivers which are essentially modified power ICs are available nowadays, including ones that operate from single alkaline cells down to 0.9 V e.g. the [Micrel MIC2282](http://www.micrel.com/_PD...
There are [specialized ICs](http://www.marktechopto.com/Engineering-Services/toshiba-constant-current-led-drivers.cfm) on the market that act like constant-current sinks, ensuring uniform LED brightness even with varying power supplies. I would suggest going with the 15V adapter and driver ICs for the best performance...
10,317
I have twenty LEDs that I want to light up. I planned out a few possible circuits, which I describe below along with a few questions. Would any of them not work, and why? Anything else I should be taking into consideration but haven't? The LED has the following specs: ``` Vmin: 2.8V Vmax: 3.5V If: 20 mA ``` From wha...
2011/02/17
[ "https://electronics.stackexchange.com/questions/10317", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/2836/" ]
The most efficient method to do this would be with a boost converter, preferably one that has current control. Hundreds of LED drivers which are essentially modified power ICs are available nowadays, including ones that operate from single alkaline cells down to 0.9 V e.g. the [Micrel MIC2282](http://www.micrel.com/_PD...
I haven't tried this myself, but I read an application note saying it is practicable to connect strings of LEDs in parallel and omit all those load-sharing resistors providing there are AT LEAST 4 LEDs in each string. It said that, when connected like this, LEDs tend to naturally share the current. (Of course, we are t...
14,493,373
I'm working on a problem that asks to generate a sequence using prime numbers 2, 3, and 5, and then displaying then nth number in the sequence. So, if I ask the program to display the 1000th number, it should display it. I can't be using arrays or anything like that, just basic decisions and loops. I started working ...
2013/01/24
[ "https://Stackoverflow.com/questions/14493373", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2006048/" ]
This is a famous problem, called Hamming's problem after Richard Hamming, and it's covered in the famous book *A Discipline of Programming* by Dijkstra. Mathematicians call these numbers (if you include 1) 5-smooth numbers, since their prime factorisations only contain primes less than or equal to 5. What you're suppo...
This code will do it. Breaking a problem down into smaller problems is often a good plan. ``` int main() { unsigned int n=23; unsigned int counter=0; unsigned int answer; for ( answer = 2; counter < n; ++answer ) { if ( isNotDivisibleByAPrimeGreaterThan5( i ) { ++counter; } ...
14,493,373
I'm working on a problem that asks to generate a sequence using prime numbers 2, 3, and 5, and then displaying then nth number in the sequence. So, if I ask the program to display the 1000th number, it should display it. I can't be using arrays or anything like that, just basic decisions and loops. I started working ...
2013/01/24
[ "https://Stackoverflow.com/questions/14493373", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2006048/" ]
This code will do it. Breaking a problem down into smaller problems is often a good plan. ``` int main() { unsigned int n=23; unsigned int counter=0; unsigned int answer; for ( answer = 2; counter < n; ++answer ) { if ( isNotDivisibleByAPrimeGreaterThan5( i ) { ++counter; } ...
Check this. ``` #include <iostream> using namespace std; int IsPrime(int var); int CheckifPrimeGreaterThaFive(int Num); int GetFactors(int Num) { int i =0,j=0; for (i =2,j=0; i <= Num; i++) { if (Num%i == 0) { if (1 == CheckifPrimeGreaterThaFive(i)) { ...
14,493,373
I'm working on a problem that asks to generate a sequence using prime numbers 2, 3, and 5, and then displaying then nth number in the sequence. So, if I ask the program to display the 1000th number, it should display it. I can't be using arrays or anything like that, just basic decisions and loops. I started working ...
2013/01/24
[ "https://Stackoverflow.com/questions/14493373", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2006048/" ]
This is a famous problem, called Hamming's problem after Richard Hamming, and it's covered in the famous book *A Discipline of Programming* by Dijkstra. Mathematicians call these numbers (if you include 1) 5-smooth numbers, since their prime factorisations only contain primes less than or equal to 5. What you're suppo...
``` #include <type_traits> #include <utility> #include <iostream> template<int... s> struct seq {}; template<int n, typename seq, typename=void> struct can_be_factored_into; template<int n, int first, int... rest> struct can_be_factored_into< n, seq<first, rest...>, typename std::enable_if< (n > 1) && (n%first) >::t...
14,493,373
I'm working on a problem that asks to generate a sequence using prime numbers 2, 3, and 5, and then displaying then nth number in the sequence. So, if I ask the program to display the 1000th number, it should display it. I can't be using arrays or anything like that, just basic decisions and loops. I started working ...
2013/01/24
[ "https://Stackoverflow.com/questions/14493373", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2006048/" ]
This is a famous problem, called Hamming's problem after Richard Hamming, and it's covered in the famous book *A Discipline of Programming* by Dijkstra. Mathematicians call these numbers (if you include 1) 5-smooth numbers, since their prime factorisations only contain primes less than or equal to 5. What you're suppo...
Check this. ``` #include <iostream> using namespace std; int IsPrime(int var); int CheckifPrimeGreaterThaFive(int Num); int GetFactors(int Num) { int i =0,j=0; for (i =2,j=0; i <= Num; i++) { if (Num%i == 0) { if (1 == CheckifPrimeGreaterThaFive(i)) { ...
14,493,373
I'm working on a problem that asks to generate a sequence using prime numbers 2, 3, and 5, and then displaying then nth number in the sequence. So, if I ask the program to display the 1000th number, it should display it. I can't be using arrays or anything like that, just basic decisions and loops. I started working ...
2013/01/24
[ "https://Stackoverflow.com/questions/14493373", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2006048/" ]
``` #include <type_traits> #include <utility> #include <iostream> template<int... s> struct seq {}; template<int n, typename seq, typename=void> struct can_be_factored_into; template<int n, int first, int... rest> struct can_be_factored_into< n, seq<first, rest...>, typename std::enable_if< (n > 1) && (n%first) >::t...
Check this. ``` #include <iostream> using namespace std; int IsPrime(int var); int CheckifPrimeGreaterThaFive(int Num); int GetFactors(int Num) { int i =0,j=0; for (i =2,j=0; i <= Num; i++) { if (Num%i == 0) { if (1 == CheckifPrimeGreaterThaFive(i)) { ...
43,276,363
How to correctly update hosts in saltstack? **cmd.run "apt update && apt upgrade -y"** sometimes asks confirmation to overwrite config files with new version, how automatically preserve the current config file? "**Y/N**" or there are better way to update entire system via salt-stack?
2017/04/07
[ "https://Stackoverflow.com/questions/43276363", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5248605/" ]
There is the [pkg module](https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.pkg.html). Use it like that: ``` salt '*' pkg.upgrade --refresh=True ```
You can use the pkg.upgrade module, or you could schedule a pkg.uptodate state. <https://docs.saltstack.com/en/latest/ref/states/all/salt.states.pkg.html#salt.states.pkg.uptodate> And use the salt scheduler to run it periodically. <https://docs.saltstack.com/en/latest/topics/jobs/#scheduling-jobs>
49,244,283
I have a C# Asp.Net Core (1.x) project, implementing a web REST API, and its related integration test project, where before any test there's a setup similar to: ```cs // ... IWebHostBuilder webHostBuilder = GetWebHostBuilderSimilarToRealOne() .UseStartup<MyTestStartup>(); TestServer server = new TestServer(webHo...
2018/03/12
[ "https://Stackoverflow.com/questions/49244283", "https://Stackoverflow.com", "https://Stackoverflow.com/users/540776/" ]
You can write middleware to set custom IP Address since this property is writable: ```cs public class FakeRemoteIpAddressMiddleware { private readonly RequestDelegate next; private readonly IPAddress fakeIpAddress = IPAddress.Parse("127.168.1.32"); public FakeRemoteIpAddressMiddleware(RequestDelegate next...
As per this answer [in ASP.NET Core, is there any way to set up middleware from Program.cs?](https://stackoverflow.com/questions/43603568/in-asp-net-core-is-there-any-way-to-set-up-middleware-from-program-cs) It's also possible to configure the middleware from ConfigureServices, which allows you to create a custom Web...
49,244,283
I have a C# Asp.Net Core (1.x) project, implementing a web REST API, and its related integration test project, where before any test there's a setup similar to: ```cs // ... IWebHostBuilder webHostBuilder = GetWebHostBuilderSimilarToRealOne() .UseStartup<MyTestStartup>(); TestServer server = new TestServer(webHo...
2018/03/12
[ "https://Stackoverflow.com/questions/49244283", "https://Stackoverflow.com", "https://Stackoverflow.com/users/540776/" ]
You can write middleware to set custom IP Address since this property is writable: ```cs public class FakeRemoteIpAddressMiddleware { private readonly RequestDelegate next; private readonly IPAddress fakeIpAddress = IPAddress.Parse("127.168.1.32"); public FakeRemoteIpAddressMiddleware(RequestDelegate next...
Using WebHost.CreateDefaultBuilder can mess up with your app configuration. And there's no need to change Product code just to accommodate for testing, unless absolutely necessary. The simplest way to add your own middleware, without overriding Startup class methods, is to add the middleware through a `IStartupFilter...
49,244,283
I have a C# Asp.Net Core (1.x) project, implementing a web REST API, and its related integration test project, where before any test there's a setup similar to: ```cs // ... IWebHostBuilder webHostBuilder = GetWebHostBuilderSimilarToRealOne() .UseStartup<MyTestStartup>(); TestServer server = new TestServer(webHo...
2018/03/12
[ "https://Stackoverflow.com/questions/49244283", "https://Stackoverflow.com", "https://Stackoverflow.com/users/540776/" ]
You can write middleware to set custom IP Address since this property is writable: ```cs public class FakeRemoteIpAddressMiddleware { private readonly RequestDelegate next; private readonly IPAddress fakeIpAddress = IPAddress.Parse("127.168.1.32"); public FakeRemoteIpAddressMiddleware(RequestDelegate next...
I used [Elliott's answer](https://stackoverflow.com/a/54943385/798781) within an ASP.NET Core 2.2 project. However, updating to ASP.NET 5.0, I had to replace the override of `CreateWebHostBuilder` with the below override of `CreateHostBuilder`: ```cs protected override IHostBuilder CreateHostBuilder() { return Hos...
49,244,283
I have a C# Asp.Net Core (1.x) project, implementing a web REST API, and its related integration test project, where before any test there's a setup similar to: ```cs // ... IWebHostBuilder webHostBuilder = GetWebHostBuilderSimilarToRealOne() .UseStartup<MyTestStartup>(); TestServer server = new TestServer(webHo...
2018/03/12
[ "https://Stackoverflow.com/questions/49244283", "https://Stackoverflow.com", "https://Stackoverflow.com/users/540776/" ]
As per this answer [in ASP.NET Core, is there any way to set up middleware from Program.cs?](https://stackoverflow.com/questions/43603568/in-asp-net-core-is-there-any-way-to-set-up-middleware-from-program-cs) It's also possible to configure the middleware from ConfigureServices, which allows you to create a custom Web...
Using WebHost.CreateDefaultBuilder can mess up with your app configuration. And there's no need to change Product code just to accommodate for testing, unless absolutely necessary. The simplest way to add your own middleware, without overriding Startup class methods, is to add the middleware through a `IStartupFilter...
49,244,283
I have a C# Asp.Net Core (1.x) project, implementing a web REST API, and its related integration test project, where before any test there's a setup similar to: ```cs // ... IWebHostBuilder webHostBuilder = GetWebHostBuilderSimilarToRealOne() .UseStartup<MyTestStartup>(); TestServer server = new TestServer(webHo...
2018/03/12
[ "https://Stackoverflow.com/questions/49244283", "https://Stackoverflow.com", "https://Stackoverflow.com/users/540776/" ]
As per this answer [in ASP.NET Core, is there any way to set up middleware from Program.cs?](https://stackoverflow.com/questions/43603568/in-asp-net-core-is-there-any-way-to-set-up-middleware-from-program-cs) It's also possible to configure the middleware from ConfigureServices, which allows you to create a custom Web...
I used [Elliott's answer](https://stackoverflow.com/a/54943385/798781) within an ASP.NET Core 2.2 project. However, updating to ASP.NET 5.0, I had to replace the override of `CreateWebHostBuilder` with the below override of `CreateHostBuilder`: ```cs protected override IHostBuilder CreateHostBuilder() { return Hos...
49,244,283
I have a C# Asp.Net Core (1.x) project, implementing a web REST API, and its related integration test project, where before any test there's a setup similar to: ```cs // ... IWebHostBuilder webHostBuilder = GetWebHostBuilderSimilarToRealOne() .UseStartup<MyTestStartup>(); TestServer server = new TestServer(webHo...
2018/03/12
[ "https://Stackoverflow.com/questions/49244283", "https://Stackoverflow.com", "https://Stackoverflow.com/users/540776/" ]
Using WebHost.CreateDefaultBuilder can mess up with your app configuration. And there's no need to change Product code just to accommodate for testing, unless absolutely necessary. The simplest way to add your own middleware, without overriding Startup class methods, is to add the middleware through a `IStartupFilter...
I used [Elliott's answer](https://stackoverflow.com/a/54943385/798781) within an ASP.NET Core 2.2 project. However, updating to ASP.NET 5.0, I had to replace the override of `CreateWebHostBuilder` with the below override of `CreateHostBuilder`: ```cs protected override IHostBuilder CreateHostBuilder() { return Hos...
5,085,094
I have the sql query below. I want to take the results and insert it into another table using the insert below. Is this a good choice for a stored procedure. It doesn't need to run very often, so no need to attach it to a trigger... I'll probably just write a php script to trigger it via an hourly cron job. (or maybe ...
2011/02/22
[ "https://Stackoverflow.com/questions/5085094", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13704/" ]
Activity monitor will show you what is executing. `DBCC OPENTRAN` will show the oldest open transaction. There is also the dynamic management view [`sys.dm_tran_active_transactions`](http://msdn.microsoft.com/en-us/library/ms174302.aspx). For example, here's a query that shows you log file usage by process: ``` -- T...
You can use sql server profiler which show every transaction executed and it's start time and end time and many things and i think you can see what causing your problem. I hope this help you.
5,085,094
I have the sql query below. I want to take the results and insert it into another table using the insert below. Is this a good choice for a stored procedure. It doesn't need to run very often, so no need to attach it to a trigger... I'll probably just write a php script to trigger it via an hourly cron job. (or maybe ...
2011/02/22
[ "https://Stackoverflow.com/questions/5085094", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13704/" ]
If you transaction log has grown so much is such a short time this means that a lot of statements that make data or structure changes have been executed. If your database works with large blob records you can try looking there first. Profiler won't help you much in finding out what happened previously but it can help...
You can use sql server profiler which show every transaction executed and it's start time and end time and many things and i think you can see what causing your problem. I hope this help you.
5,085,094
I have the sql query below. I want to take the results and insert it into another table using the insert below. Is this a good choice for a stored procedure. It doesn't need to run very often, so no need to attach it to a trigger... I'll probably just write a php script to trigger it via an hourly cron job. (or maybe ...
2011/02/22
[ "https://Stackoverflow.com/questions/5085094", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13704/" ]
Activity monitor will show you what is executing. `DBCC OPENTRAN` will show the oldest open transaction. There is also the dynamic management view [`sys.dm_tran_active_transactions`](http://msdn.microsoft.com/en-us/library/ms174302.aspx). For example, here's a query that shows you log file usage by process: ``` -- T...
If you transaction log has grown so much is such a short time this means that a lot of statements that make data or structure changes have been executed. If your database works with large blob records you can try looking there first. Profiler won't help you much in finding out what happened previously but it can help...
28,510,697
I'm working on my first (C++/IwNUI) Marmalade app, which so far works fine, but on Monday one of my devices (an HTC One Android phone, Credo Mobile) had a system update, after which my app, and only my app, now shows what seems to be a "settings" control on top of my app, which can be moved around, but does nothing but...
2015/02/13
[ "https://Stackoverflow.com/questions/28510697", "https://Stackoverflow.com", "https://Stackoverflow.com/users/471736/" ]
I found a way to make it go away: "Add android:targetSdkVersion="11" (or higher) to your element." in the settings file which in my Marmalade project is called AndroidManifest.xml. It seems like this may be a bug where it thinks there is an "overflow" of a title/menu-bar which isn't even there in these apps. By target...
I am guessing you created a new project. Are you seeing this "settings"? ![enter image description here](https://i.stack.imgur.com/hlZZa.png) This is automatically added in every new app. Check your `res` -> `menu` folder. You can remove the "fake" options menu if you like. Samsung will show this menu if you hit the...
2,862,648
I have a teacher model which has\_many students. When I render a student (as json) I want to strip out the teacher\_id property and replace it with the name of the teacher in my representation. What is the best way to achieve this? Cheers, Chris
2010/05/19
[ "https://Stackoverflow.com/questions/2862648", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37196/" ]
Define a method called `teacher_name`. ``` class Student < ActiveRecord::Base def teacher_name self.teacher.name end end ``` Include the `teacher_name` method while invoking `to_json`: ``` teacher.to_json(:include => {:students => {:methods=> :teacher_name, :excep...
You can always redefine the to\_json method on the model to do whatever you want: ``` class Student < ActiveRecord::Base def to_json self.attributes.merge( 'teacher_id' => self.teacher.name ).to_json end end ``` **Update:** Based on feedback from [kandadaboggu](https://stackoverflow.com/users/16320...
37,403,889
in redis.conf , client-output-buffer-limit vs repl-backlog-size ? redis master allocate replication buffer for each slave , i can set client-output-buffer-limit 500M . repl-buff notes master commands and runid'offset. i don't know backlog effect in redis master role . backlog notes globals offset, each slave running ...
2016/05/24
[ "https://Stackoverflow.com/questions/37403889", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6127610/" ]
Replication buffer keeps the new updates to the master, till the RDB snapshot of master is transferred to the slave and is loaded into its memory. After this the data in the replication buffer is transferred to the slave. Client-output-buffer-limit is the max size we allow a replication buffer to grow. Backlog stores...
The `client-output-buffer-limit` is used to force disconnection of slow clients. The `repl-backlog-size` is memory used to keep track of recent changes. This buffer is used by slaves to catch up fast after a reconnect instead of transferring the whole database. See <http://download.redis.io/redis-stable/redis.conf>
70,898,307
I want to upload an image to s3 with lambda and Api gateway when i submit form how can i do it in python. currently i am getting this error while i am trying to upload image through PostMan ``` Could not parse request body into json: Could not parse payload into json: Unexpected character (\'-\' (code 45)) ``` my c...
2022/01/28
[ "https://Stackoverflow.com/questions/70898307", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16875055/" ]
Doing an upload through API Gateway and Lambda has its limitations: You can not handle large files and there is an execution timeout of 30 seconds as I recall. I would go with creating a presigned url that is requested by the client through API gateway, then use it as the endpoint to put the file. Something like this ...
You don't need Lambda for this. You can proxy S3 API with API Gateway <https://docs.aws.amazon.com/apigateway/latest/developerguide/integrating-api-with-aws-services-s3.html>
70,898,307
I want to upload an image to s3 with lambda and Api gateway when i submit form how can i do it in python. currently i am getting this error while i am trying to upload image through PostMan ``` Could not parse request body into json: Could not parse payload into json: Unexpected character (\'-\' (code 45)) ``` my c...
2022/01/28
[ "https://Stackoverflow.com/questions/70898307", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16875055/" ]
Doing an upload through API Gateway and Lambda has its limitations: You can not handle large files and there is an execution timeout of 30 seconds as I recall. I would go with creating a presigned url that is requested by the client through API gateway, then use it as the endpoint to put the file. Something like this ...
Ooops it's over engineering. anyways, it's seems like your are getting error from API-gateway, first check the lambda through "test lambda" using aws console, if it's working fine and getting the response back from lambda then please check with API-gateway side. i doubt you are using some mapping templates in gateway...
53,219,599
I'm trying to figure out how to notify user with alert that comes from top of the screen like normal push notification does. How can I alert user from top of the screen. `AlertDialog` is not customizable so I'm stuck with this. Is there any way to show something like alert or snack bar from top of the screen?
2018/11/09
[ "https://Stackoverflow.com/questions/53219599", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8698490/" ]
Flutter gives you the possiblity to create notifications with the help of the class [Overlay](https://docs.flutter.io/flutter/widgets/Overlay-class.html). To animate these entering the screen from the top you can use the [SlideTransition](https://docs.flutter.io/flutter/widgets/SlideTransition-class.html) in combinatio...
Here **you can dismiss notifications using the swipe up or down**. This is the perfect notification for promotion in-app. ``` class Home extends StatefulWidget { @override _HomeState createState() => _HomeState(); } class _HomeState extends State<Home> with TickerProviderStateMixin { bool _fromTop = true; @o...
31,833,257
I have... **manifest.json**: ``` "background": { "scripts": ["background.js"], "persistent": false } ``` **popup.js**: ``` console.log("before send message"); chrome.runtime.sendMessage({greeting: "hello"}, function(reply) { console.log("before print reply"); console...
2015/08/05
[ "https://Stackoverflow.com/questions/31833257", "https://Stackoverflow.com", "https://Stackoverflow.com/users/145684/" ]
If `words9.txt` doesn't have regexes try using a fixed string search (`fgrep` or `grep -F`) instead of using the extended regex search (`egrep`). ``` cat words.txt | egrep "^[A-Z]" | fgrep -f words9.txt ```
So you want to improve on `egrep ^"[A-Z]" words.txt | egrep -f words9.txt` Your `words9.txt` is **not** a file of regex patterns, it's only fixed strings, so treating it as such (`grep -F`) will generally be much faster, as @KurzedMetal said. Mind you, if its contents had a lot of overlap near-duplicates, you could m...
9,183,823
I am trying to refresh Ajax content into a jQuery UI tab. i've seen lots of folks ask, and lots of solutions suggested (albeit all of them incomplete or non working) so once more... how is this done? Here is what i've got: ``` <script> $(function() { $( "#tabs" ).tabs({ ajaxOptions: { ...
2012/02/07
[ "https://Stackoverflow.com/questions/9183823", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1179666/" ]
Ok putting things together I have this for the click event of the jquery tabs, the surrounding div has an id of tabs, like this: ``` <div id="tabs"> ``` The following gets executed in the document ready function: ``` $('#tabs > ul > li > a').each(function (index, element) { $(element).click(function () { ...
If I'm understanding the question correctly, you should be able to use jQuery's `.load( )` method and use the content element of the tab as the target. ``` var tab = $('div.ui-tabs-panel').eq(0); tab.find( 'a' ).bind( 'click', function( event ) { var link = $(this); tab.load(link.attr( 'href' )); event.preven...
9,183,823
I am trying to refresh Ajax content into a jQuery UI tab. i've seen lots of folks ask, and lots of solutions suggested (albeit all of them incomplete or non working) so once more... how is this done? Here is what i've got: ``` <script> $(function() { $( "#tabs" ).tabs({ ajaxOptions: { ...
2012/02/07
[ "https://Stackoverflow.com/questions/9183823", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1179666/" ]
Ok putting things together I have this for the click event of the jquery tabs, the surrounding div has an id of tabs, like this: ``` <div id="tabs"> ``` The following gets executed in the document ready function: ``` $('#tabs > ul > li > a').each(function (index, element) { $(element).click(function () { ...
I ended up using the 'hijax' method outlined in the docs here is the code I used: ``` <script> $(function() { $( "#tabs" ).tabs({ //define ajax options, since they do it in the demo! // not sure why,what, or if its needed <br> //commented examples sure wouuld eilimate half of the forum posts! ajaxO...
57,924,522
I am creating an authentication system with the express now i have authenticated user and saved his email in cookies from the controller file as soon as user get authenticate now in another controller i need that cookie value but i am not able to aceess it Authenticate-controller.js ``` var Cryptr = require('cryptr')...
2019/09/13
[ "https://Stackoverflow.com/questions/57924522", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Ok, regarding your second code snippet there are several things that I noticed. You are using the cookie-parser package that you affected to the cookieParser variable but after you use `Cookies.get` but I don't see where `Cookies` is coming from? so maybe what you want to do is `cookieParser.get` but by checking the c...
Let me say you that if you want to store a JWT into a cookie and other extra information it could be stored or not depending on the size of your cookie. For more information about max size for cookies check this: <https://www.quora.com/What-Is-The-Maximum-Size-Of-Cookie-In-A-Web-Browser> On another hand, I saw a prob...
5,339,762
After using strcpy source is getting corrupted and getting correct destination. Following is my code please suggest me why my source is getting corrupted? If i keep a fixed size to second character array q[] then my source is not being changed. Why is this strange behaviour. - I am using MSVC 2005 ``` void function...
2011/03/17
[ "https://Stackoverflow.com/questions/5339762", "https://Stackoverflow.com", "https://Stackoverflow.com/users/664356/" ]
`q` has only space for 1 character which is the terminating `\0`. Please read a book about C - you need to learn something about memory management. Most likely your memory looks like this (simplified): `Qpppppppppppp`. So when you strcpy to `q`, you will overwrite parts of `p`'s memory. Since you are using C++: Simpl...
`char q[] = "";` creates a character array with exactly 1 element - copying more data into it won't reserve more memory for it. So, what happens is that when you write past the space reserved for q, you start overwriting what's in p - the two variables are next to each other in memory.
5,339,762
After using strcpy source is getting corrupted and getting correct destination. Following is my code please suggest me why my source is getting corrupted? If i keep a fixed size to second character array q[] then my source is not being changed. Why is this strange behaviour. - I am using MSVC 2005 ``` void function...
2011/03/17
[ "https://Stackoverflow.com/questions/5339762", "https://Stackoverflow.com", "https://Stackoverflow.com/users/664356/" ]
`q` has only space for 1 character which is the terminating `\0`. Please read a book about C - you need to learn something about memory management. Most likely your memory looks like this (simplified): `Qpppppppppppp`. So when you strcpy to `q`, you will overwrite parts of `p`'s memory. Since you are using C++: Simpl...
In your code, `q`, is an one-element array (basing on the length of `""`, which is equal to one due to the null terminator), so it cannot contain the whole string. Hence you can't do a `strcpy` because it writes over invalid memory location (tries to write too much data to an array). Declare `q` to be big enough to co...
5,339,762
After using strcpy source is getting corrupted and getting correct destination. Following is my code please suggest me why my source is getting corrupted? If i keep a fixed size to second character array q[] then my source is not being changed. Why is this strange behaviour. - I am using MSVC 2005 ``` void function...
2011/03/17
[ "https://Stackoverflow.com/questions/5339762", "https://Stackoverflow.com", "https://Stackoverflow.com/users/664356/" ]
`q` has only space for 1 character which is the terminating `\0`. Please read a book about C - you need to learn something about memory management. Most likely your memory looks like this (simplified): `Qpppppppppppp`. So when you strcpy to `q`, you will overwrite parts of `p`'s memory. Since you are using C++: Simpl...
The array "q" is just one byte long; it definitely doesn't have room for the string "Hello, World"! When you try to copy "Hello, World" to q, you end up exceeding the bounds of q and overwriting p, which is adjacent to it on the stack. I imagine drawing a diagram of how these things are laid out on the stack, you could...
5,339,762
After using strcpy source is getting corrupted and getting correct destination. Following is my code please suggest me why my source is getting corrupted? If i keep a fixed size to second character array q[] then my source is not being changed. Why is this strange behaviour. - I am using MSVC 2005 ``` void function...
2011/03/17
[ "https://Stackoverflow.com/questions/5339762", "https://Stackoverflow.com", "https://Stackoverflow.com/users/664356/" ]
`q` has only space for 1 character which is the terminating `\0`. Please read a book about C - you need to learn something about memory management. Most likely your memory looks like this (simplified): `Qpppppppppppp`. So when you strcpy to `q`, you will overwrite parts of `p`'s memory. Since you are using C++: Simpl...
strcpy expects you to provide an allocated storage buffer, not just a char\* pointer. If you change `char q[]="";` to `char q[50];` it will work. Since you're only giving strcpy a pointer to a zero length string it doesn't have enough space to store the copied string and overwrites aka corrupts the memory.
5,339,762
After using strcpy source is getting corrupted and getting correct destination. Following is my code please suggest me why my source is getting corrupted? If i keep a fixed size to second character array q[] then my source is not being changed. Why is this strange behaviour. - I am using MSVC 2005 ``` void function...
2011/03/17
[ "https://Stackoverflow.com/questions/5339762", "https://Stackoverflow.com", "https://Stackoverflow.com/users/664356/" ]
`q` has only space for 1 character which is the terminating `\0`. Please read a book about C - you need to learn something about memory management. Most likely your memory looks like this (simplified): `Qpppppppppppp`. So when you strcpy to `q`, you will overwrite parts of `p`'s memory. Since you are using C++: Simpl...
What everyone is saying is half correct. The code is failing because space is not reserved for the copy as others have pointed out correctly. The part that's missing is that your objects are on the stack, not the heap. Therefore it is not only likely, but inevitable that your code will get corrupted as the stack can no...
5,339,762
After using strcpy source is getting corrupted and getting correct destination. Following is my code please suggest me why my source is getting corrupted? If i keep a fixed size to second character array q[] then my source is not being changed. Why is this strange behaviour. - I am using MSVC 2005 ``` void function...
2011/03/17
[ "https://Stackoverflow.com/questions/5339762", "https://Stackoverflow.com", "https://Stackoverflow.com/users/664356/" ]
`strcpy` does not allocate memory required to store the string. You must allocate enough memory in `str2` before you do the `strcpy`. Otherwise, you get undefined behaviour as you are overwriting some non-allocated memory.
`char q[] = "";` creates a character array with exactly 1 element - copying more data into it won't reserve more memory for it. So, what happens is that when you write past the space reserved for q, you start overwriting what's in p - the two variables are next to each other in memory.
5,339,762
After using strcpy source is getting corrupted and getting correct destination. Following is my code please suggest me why my source is getting corrupted? If i keep a fixed size to second character array q[] then my source is not being changed. Why is this strange behaviour. - I am using MSVC 2005 ``` void function...
2011/03/17
[ "https://Stackoverflow.com/questions/5339762", "https://Stackoverflow.com", "https://Stackoverflow.com/users/664356/" ]
`strcpy` does not allocate memory required to store the string. You must allocate enough memory in `str2` before you do the `strcpy`. Otherwise, you get undefined behaviour as you are overwriting some non-allocated memory.
In your code, `q`, is an one-element array (basing on the length of `""`, which is equal to one due to the null terminator), so it cannot contain the whole string. Hence you can't do a `strcpy` because it writes over invalid memory location (tries to write too much data to an array). Declare `q` to be big enough to co...
5,339,762
After using strcpy source is getting corrupted and getting correct destination. Following is my code please suggest me why my source is getting corrupted? If i keep a fixed size to second character array q[] then my source is not being changed. Why is this strange behaviour. - I am using MSVC 2005 ``` void function...
2011/03/17
[ "https://Stackoverflow.com/questions/5339762", "https://Stackoverflow.com", "https://Stackoverflow.com/users/664356/" ]
`strcpy` does not allocate memory required to store the string. You must allocate enough memory in `str2` before you do the `strcpy`. Otherwise, you get undefined behaviour as you are overwriting some non-allocated memory.
The array "q" is just one byte long; it definitely doesn't have room for the string "Hello, World"! When you try to copy "Hello, World" to q, you end up exceeding the bounds of q and overwriting p, which is adjacent to it on the stack. I imagine drawing a diagram of how these things are laid out on the stack, you could...
5,339,762
After using strcpy source is getting corrupted and getting correct destination. Following is my code please suggest me why my source is getting corrupted? If i keep a fixed size to second character array q[] then my source is not being changed. Why is this strange behaviour. - I am using MSVC 2005 ``` void function...
2011/03/17
[ "https://Stackoverflow.com/questions/5339762", "https://Stackoverflow.com", "https://Stackoverflow.com/users/664356/" ]
`strcpy` does not allocate memory required to store the string. You must allocate enough memory in `str2` before you do the `strcpy`. Otherwise, you get undefined behaviour as you are overwriting some non-allocated memory.
strcpy expects you to provide an allocated storage buffer, not just a char\* pointer. If you change `char q[]="";` to `char q[50];` it will work. Since you're only giving strcpy a pointer to a zero length string it doesn't have enough space to store the copied string and overwrites aka corrupts the memory.
5,339,762
After using strcpy source is getting corrupted and getting correct destination. Following is my code please suggest me why my source is getting corrupted? If i keep a fixed size to second character array q[] then my source is not being changed. Why is this strange behaviour. - I am using MSVC 2005 ``` void function...
2011/03/17
[ "https://Stackoverflow.com/questions/5339762", "https://Stackoverflow.com", "https://Stackoverflow.com/users/664356/" ]
`strcpy` does not allocate memory required to store the string. You must allocate enough memory in `str2` before you do the `strcpy`. Otherwise, you get undefined behaviour as you are overwriting some non-allocated memory.
What everyone is saying is half correct. The code is failing because space is not reserved for the copy as others have pointed out correctly. The part that's missing is that your objects are on the stack, not the heap. Therefore it is not only likely, but inevitable that your code will get corrupted as the stack can no...
470,185
On a wiki proof site, I've seen these formulas used for the mean and variance: $E[X] = \frac{rp}{1-p}$ and $Var[X] = \frac{rp}{(1-p)^2}$. Yet on the Penn State site, they have these two different formulas: $E[X] = \frac{r}{p}$ and $Var[X] = \frac{r(1-p)}{p^2}$.
2013/08/18
[ "https://math.stackexchange.com/questions/470185", "https://math.stackexchange.com", "https://math.stackexchange.com/users/90819/" ]
**Two** issues are involved: * Is the negative binomial the distribution of the waiting time until a specified number of "successes" or until a specified number of "failures"? * Is it the number of trials needed to get the specified number of "successes" (or, as the case may be, of "failures") or is it the number of t...
It's a matter of semantics about the meaning of "success" (typically $p$ in the context of a binomial distribution) and "failure" (typically $q=1-p$). If the meaning is reversed in the context of the negative binomial, you'll get the same result, once you interchange $p$ with $1-p$. So, you saw the same thing (assumi...
498,143
I have resources (e.g. GPU) I can only use once at a time. When performing experiments I always need to know on time of a batch files creation, what experiments I want to execute in the future. But I am a person who likes to change its mind, but I hate to quit jobs. Is there something like Slurm, that runs only on one...
2019/02/01
[ "https://unix.stackexchange.com/questions/498143", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/166629/" ]
I found a solution that perfectly fits my needs. I have the issue, that I have only one GPU, but want to have a queue to add jobs to, see their status and, if needed, delete it from the queue again. After some research on Google, I found [task-spooler (tsp)](http://vicerveza.homeunix.net/~viric/soft/ts/). With this co...
Would it be acceptable to have the jobs run through a simple queue manager of your own? ``` #!/bin/bash while ! mkdir /tmp/my_gpu_lockdir; do sleep $((RANDOM)) done trap 'rmdir /tmp/my_gnu_lockdir' ERR EXIT .... your actual task here ... ```
1,471,432
Find $\displaystyle \int\_0^{\pi/2} f(x)\,dx$ if$$f(x)=\begin{cases} \sin(x), & \text{if } \cos(x)\in \mathbb{Q}\\\sin^2(x), & \text{if } \cos(x) \notin \mathbb{Q} \end{cases}$$ I am not able to solve this problem. This problem is from Real analysis by royden.
2015/10/09
[ "https://math.stackexchange.com/questions/1471432", "https://math.stackexchange.com", "https://math.stackexchange.com/users/-1/" ]
The integral of the function you provide is equivalent to $\int\_0^{\pi/2} \sin^2x\,dx$, as Michael Hardy points out in the comments above. The reason for this lies in the difference between being "countably infinite" and "uncountably infinite". This is a very deep topic and is generally studied using set theory. What ...
**Theorem :** If $g$ is Riemann integrable in $[a,b]$ and $f=g$ **almost everywhere** in $[a,b]$ then $f$ is Lebesgue integrable and $\displaystyle (L)\int\_a^bf(x)\,dx=(L)\int\_a^bg(x)\,dx=(R)\int\_a^bg(x)\,dx$. Here , consider $g(x)=\sin^2(x)$. Then , as $m(\mathbb Q\cap [0,\pi/2])=0$ , $f=g$ almost everywhere in $[...
1,627,225
I have an array of Customer[] objects, and I want to use it to create a Dictionary<Customer, string>. What is the easiest way to examine the array for duplicates before I load the Dictionary? I want to avoid "ArgumentException: An item with the same key has already been added". Thanks.
2009/10/26
[ "https://Stackoverflow.com/questions/1627225", "https://Stackoverflow.com", "https://Stackoverflow.com/users/196897/" ]
The most efficient way of doing that, from BOTH PERFORMANCE and CODE points of view, is this: ``` dict[key] = value ``` This way the exception mentioned by you will never get thrown, and the key lookup will not happen twice
Why not this?? ``` Customers.Distinct.ToDictionary(o=>o, GenerateString(o)); ```
1,627,225
I have an array of Customer[] objects, and I want to use it to create a Dictionary<Customer, string>. What is the easiest way to examine the array for duplicates before I load the Dictionary? I want to avoid "ArgumentException: An item with the same key has already been added". Thanks.
2009/10/26
[ "https://Stackoverflow.com/questions/1627225", "https://Stackoverflow.com", "https://Stackoverflow.com/users/196897/" ]
You could use LINQ to do both: ``` Customer[] customers; // initialized somehow... var customerDictionary = customers.Distinct().ToDictionary( cust => cust.SomeKey ); ``` If you will build the dictionary in a less straightforward fashion, you can just use the `Distinct()` extension method to get a unique array like ...
What is your definition of duplicate in this case? If its simply the same object instance (the same pointer) then that's simple, you can use any of the methods in the other answers given here. Sometimes though the concept of equality is not so straight forward, is a different object instance with the ***same data**...
1,627,225
I have an array of Customer[] objects, and I want to use it to create a Dictionary<Customer, string>. What is the easiest way to examine the array for duplicates before I load the Dictionary? I want to avoid "ArgumentException: An item with the same key has already been added". Thanks.
2009/10/26
[ "https://Stackoverflow.com/questions/1627225", "https://Stackoverflow.com", "https://Stackoverflow.com/users/196897/" ]
How big is the array? and how likely is it that there will be duplicates? Checking each element of the array against all the others is quite a expensive operation. It would be quicker to call `Dictionary.ContainsKey(key)` before adding each item. **NOTE:** If duplicates are rare then you could use exception handling...
Why not this?? ``` Customers.Distinct.ToDictionary(o=>o, GenerateString(o)); ```
1,627,225
I have an array of Customer[] objects, and I want to use it to create a Dictionary<Customer, string>. What is the easiest way to examine the array for duplicates before I load the Dictionary? I want to avoid "ArgumentException: An item with the same key has already been added". Thanks.
2009/10/26
[ "https://Stackoverflow.com/questions/1627225", "https://Stackoverflow.com", "https://Stackoverflow.com/users/196897/" ]
How big is the array? and how likely is it that there will be duplicates? Checking each element of the array against all the others is quite a expensive operation. It would be quicker to call `Dictionary.ContainsKey(key)` before adding each item. **NOTE:** If duplicates are rare then you could use exception handling...
What is your definition of duplicate in this case? If its simply the same object instance (the same pointer) then that's simple, you can use any of the methods in the other answers given here. Sometimes though the concept of equality is not so straight forward, is a different object instance with the ***same data**...
1,627,225
I have an array of Customer[] objects, and I want to use it to create a Dictionary<Customer, string>. What is the easiest way to examine the array for duplicates before I load the Dictionary? I want to avoid "ArgumentException: An item with the same key has already been added". Thanks.
2009/10/26
[ "https://Stackoverflow.com/questions/1627225", "https://Stackoverflow.com", "https://Stackoverflow.com/users/196897/" ]
Just call Dictionary.ContainsKey(key) before you add your Customers.
How big is the array? and how likely is it that there will be duplicates? Checking each element of the array against all the others is quite a expensive operation. It would be quicker to call `Dictionary.ContainsKey(key)` before adding each item. **NOTE:** If duplicates are rare then you could use exception handling...
1,627,225
I have an array of Customer[] objects, and I want to use it to create a Dictionary<Customer, string>. What is the easiest way to examine the array for duplicates before I load the Dictionary? I want to avoid "ArgumentException: An item with the same key has already been added". Thanks.
2009/10/26
[ "https://Stackoverflow.com/questions/1627225", "https://Stackoverflow.com", "https://Stackoverflow.com/users/196897/" ]
You could use LINQ to do both: ``` Customer[] customers; // initialized somehow... var customerDictionary = customers.Distinct().ToDictionary( cust => cust.SomeKey ); ``` If you will build the dictionary in a less straightforward fashion, you can just use the `Distinct()` extension method to get a unique array like ...
Why not this?? ``` Customers.Distinct.ToDictionary(o=>o, GenerateString(o)); ```
1,627,225
I have an array of Customer[] objects, and I want to use it to create a Dictionary<Customer, string>. What is the easiest way to examine the array for duplicates before I load the Dictionary? I want to avoid "ArgumentException: An item with the same key has already been added". Thanks.
2009/10/26
[ "https://Stackoverflow.com/questions/1627225", "https://Stackoverflow.com", "https://Stackoverflow.com/users/196897/" ]
You could use LINQ to do both: ``` Customer[] customers; // initialized somehow... var customerDictionary = customers.Distinct().ToDictionary( cust => cust.SomeKey ); ``` If you will build the dictionary in a less straightforward fashion, you can just use the `Distinct()` extension method to get a unique array like ...
The most efficient way of doing that, from BOTH PERFORMANCE and CODE points of view, is this: ``` dict[key] = value ``` This way the exception mentioned by you will never get thrown, and the key lookup will not happen twice
1,627,225
I have an array of Customer[] objects, and I want to use it to create a Dictionary<Customer, string>. What is the easiest way to examine the array for duplicates before I load the Dictionary? I want to avoid "ArgumentException: An item with the same key has already been added". Thanks.
2009/10/26
[ "https://Stackoverflow.com/questions/1627225", "https://Stackoverflow.com", "https://Stackoverflow.com/users/196897/" ]
You could use LINQ to do both: ``` Customer[] customers; // initialized somehow... var customerDictionary = customers.Distinct().ToDictionary( cust => cust.SomeKey ); ``` If you will build the dictionary in a less straightforward fashion, you can just use the `Distinct()` extension method to get a unique array like ...
How big is the array? and how likely is it that there will be duplicates? Checking each element of the array against all the others is quite a expensive operation. It would be quicker to call `Dictionary.ContainsKey(key)` before adding each item. **NOTE:** If duplicates are rare then you could use exception handling...
1,627,225
I have an array of Customer[] objects, and I want to use it to create a Dictionary<Customer, string>. What is the easiest way to examine the array for duplicates before I load the Dictionary? I want to avoid "ArgumentException: An item with the same key has already been added". Thanks.
2009/10/26
[ "https://Stackoverflow.com/questions/1627225", "https://Stackoverflow.com", "https://Stackoverflow.com/users/196897/" ]
What is your definition of duplicate in this case? If its simply the same object instance (the same pointer) then that's simple, you can use any of the methods in the other answers given here. Sometimes though the concept of equality is not so straight forward, is a different object instance with the ***same data**...
Why not this?? ``` Customers.Distinct.ToDictionary(o=>o, GenerateString(o)); ```
1,627,225
I have an array of Customer[] objects, and I want to use it to create a Dictionary<Customer, string>. What is the easiest way to examine the array for duplicates before I load the Dictionary? I want to avoid "ArgumentException: An item with the same key has already been added". Thanks.
2009/10/26
[ "https://Stackoverflow.com/questions/1627225", "https://Stackoverflow.com", "https://Stackoverflow.com/users/196897/" ]
Just call Dictionary.ContainsKey(key) before you add your Customers.
Why not this?? ``` Customers.Distinct.ToDictionary(o=>o, GenerateString(o)); ```
11,808,074
Expectation Maximization (EM) is a kind of probabilistic method to classify data. Please correct me if I am wrong if it is not a classifier. What is an intuitive explanation of this EM technique? What is `expectation` here and what is being `maximized`?
2012/08/04
[ "https://Stackoverflow.com/questions/11808074", "https://Stackoverflow.com", "https://Stackoverflow.com/users/492372/" ]
*Note: the code behind this answer can be found [here](https://github.com/ajcr/em-explanation/blob/master/em-notebook-2.ipynb).* --- Suppose we have some data sampled from two different groups, red and blue: [![enter image description here](https://i.stack.imgur.com/JDJ1n.png)](https://i.stack.imgur.com/JDJ1n.png) ...
Here is a straight-forward recipe to understand the Expectation Maximisation algorithm: **1-** Read this [EM tutorial paper](http://ai.stanford.edu/~chuongdo/papers/em_tutorial.pdf) by Do and Batzoglou. **2-** You may have question marks in your head, have a look at the explanations on this maths stack exchange [page...
11,808,074
Expectation Maximization (EM) is a kind of probabilistic method to classify data. Please correct me if I am wrong if it is not a classifier. What is an intuitive explanation of this EM technique? What is `expectation` here and what is being `maximized`?
2012/08/04
[ "https://Stackoverflow.com/questions/11808074", "https://Stackoverflow.com", "https://Stackoverflow.com/users/492372/" ]
The accepted answer references the [Chuong EM Paper](http://ai.stanford.edu/~chuongdo/papers/em_tutorial.pdf), which does a decent job explaining EM. There is also a [youtube video](https://www.youtube.com/watch?v=7e65vXZEv5Q) that explains the paper in more detail. To recap, here is the scenario: ``` 1st: {H,T,T,T...
Using the same article by Do and Batzoglou cited in Zhubarb's answer, I implemented EM for that problem in **Java**. The comments to his answer show that the algorithm gets stuck at a local optimum, which also occurs with my implementation if the parameters thetaA and thetaB are the same. Below is the standard output ...
11,808,074
Expectation Maximization (EM) is a kind of probabilistic method to classify data. Please correct me if I am wrong if it is not a classifier. What is an intuitive explanation of this EM technique? What is `expectation` here and what is being `maximized`?
2012/08/04
[ "https://Stackoverflow.com/questions/11808074", "https://Stackoverflow.com", "https://Stackoverflow.com/users/492372/" ]
Here is a straight-forward recipe to understand the Expectation Maximisation algorithm: **1-** Read this [EM tutorial paper](http://ai.stanford.edu/~chuongdo/papers/em_tutorial.pdf) by Do and Batzoglou. **2-** You may have question marks in your head, have a look at the explanations on this maths stack exchange [page...
Technically the term "EM" is a bit underspecified, but I assume you refer to the Gaussian Mixture Modelling cluster analysis technique, that is an *instance* of the general EM principle. Actually, **EM cluster analysis is not a classifier**. I know that some people consider clustering to be "unsupervised classificatio...
11,808,074
Expectation Maximization (EM) is a kind of probabilistic method to classify data. Please correct me if I am wrong if it is not a classifier. What is an intuitive explanation of this EM technique? What is `expectation` here and what is being `maximized`?
2012/08/04
[ "https://Stackoverflow.com/questions/11808074", "https://Stackoverflow.com", "https://Stackoverflow.com/users/492372/" ]
*Note: the code behind this answer can be found [here](https://github.com/ajcr/em-explanation/blob/master/em-notebook-2.ipynb).* --- Suppose we have some data sampled from two different groups, red and blue: [![enter image description here](https://i.stack.imgur.com/JDJ1n.png)](https://i.stack.imgur.com/JDJ1n.png) ...
Technically the term "EM" is a bit underspecified, but I assume you refer to the Gaussian Mixture Modelling cluster analysis technique, that is an *instance* of the general EM principle. Actually, **EM cluster analysis is not a classifier**. I know that some people consider clustering to be "unsupervised classificatio...
11,808,074
Expectation Maximization (EM) is a kind of probabilistic method to classify data. Please correct me if I am wrong if it is not a classifier. What is an intuitive explanation of this EM technique? What is `expectation` here and what is being `maximized`?
2012/08/04
[ "https://Stackoverflow.com/questions/11808074", "https://Stackoverflow.com", "https://Stackoverflow.com/users/492372/" ]
Technically the term "EM" is a bit underspecified, but I assume you refer to the Gaussian Mixture Modelling cluster analysis technique, that is an *instance* of the general EM principle. Actually, **EM cluster analysis is not a classifier**. I know that some people consider clustering to be "unsupervised classificatio...
Using the same article by Do and Batzoglou cited in Zhubarb's answer, I implemented EM for that problem in **Java**. The comments to his answer show that the algorithm gets stuck at a local optimum, which also occurs with my implementation if the parameters thetaA and thetaB are the same. Below is the standard output ...
11,808,074
Expectation Maximization (EM) is a kind of probabilistic method to classify data. Please correct me if I am wrong if it is not a classifier. What is an intuitive explanation of this EM technique? What is `expectation` here and what is being `maximized`?
2012/08/04
[ "https://Stackoverflow.com/questions/11808074", "https://Stackoverflow.com", "https://Stackoverflow.com/users/492372/" ]
Here is a straight-forward recipe to understand the Expectation Maximisation algorithm: **1-** Read this [EM tutorial paper](http://ai.stanford.edu/~chuongdo/papers/em_tutorial.pdf) by Do and Batzoglou. **2-** You may have question marks in your head, have a look at the explanations on this maths stack exchange [page...
Using the same article by Do and Batzoglou cited in Zhubarb's answer, I implemented EM for that problem in **Java**. The comments to his answer show that the algorithm gets stuck at a local optimum, which also occurs with my implementation if the parameters thetaA and thetaB are the same. Below is the standard output ...
11,808,074
Expectation Maximization (EM) is a kind of probabilistic method to classify data. Please correct me if I am wrong if it is not a classifier. What is an intuitive explanation of this EM technique? What is `expectation` here and what is being `maximized`?
2012/08/04
[ "https://Stackoverflow.com/questions/11808074", "https://Stackoverflow.com", "https://Stackoverflow.com/users/492372/" ]
EM is an algorithm for maximizing a likelihood function when some of the variables in your model are unobserved (i.e. when you have latent variables). You might fairly ask, if we're just trying to maximize a function, why don't we just use the existing machinery for maximizing a function. Well, if you try to maximize...
EM is used to maximize the likelihood of a model Q with latent variables Z. It's an iterative optimization. ``` theta <- initial guess for hidden parameters while not converged: #e-step Q(theta'|theta) = E[log L(theta|Z)] #m-step theta <- argmax_theta' Q(theta'|theta) ``` e-step: given current estim...
11,808,074
Expectation Maximization (EM) is a kind of probabilistic method to classify data. Please correct me if I am wrong if it is not a classifier. What is an intuitive explanation of this EM technique? What is `expectation` here and what is being `maximized`?
2012/08/04
[ "https://Stackoverflow.com/questions/11808074", "https://Stackoverflow.com", "https://Stackoverflow.com/users/492372/" ]
Here is a straight-forward recipe to understand the Expectation Maximisation algorithm: **1-** Read this [EM tutorial paper](http://ai.stanford.edu/~chuongdo/papers/em_tutorial.pdf) by Do and Batzoglou. **2-** You may have question marks in your head, have a look at the explanations on this maths stack exchange [page...
The accepted answer references the [Chuong EM Paper](http://ai.stanford.edu/~chuongdo/papers/em_tutorial.pdf), which does a decent job explaining EM. There is also a [youtube video](https://www.youtube.com/watch?v=7e65vXZEv5Q) that explains the paper in more detail. To recap, here is the scenario: ``` 1st: {H,T,T,T...
11,808,074
Expectation Maximization (EM) is a kind of probabilistic method to classify data. Please correct me if I am wrong if it is not a classifier. What is an intuitive explanation of this EM technique? What is `expectation` here and what is being `maximized`?
2012/08/04
[ "https://Stackoverflow.com/questions/11808074", "https://Stackoverflow.com", "https://Stackoverflow.com/users/492372/" ]
*Note: the code behind this answer can be found [here](https://github.com/ajcr/em-explanation/blob/master/em-notebook-2.ipynb).* --- Suppose we have some data sampled from two different groups, red and blue: [![enter image description here](https://i.stack.imgur.com/JDJ1n.png)](https://i.stack.imgur.com/JDJ1n.png) ...
The accepted answer references the [Chuong EM Paper](http://ai.stanford.edu/~chuongdo/papers/em_tutorial.pdf), which does a decent job explaining EM. There is also a [youtube video](https://www.youtube.com/watch?v=7e65vXZEv5Q) that explains the paper in more detail. To recap, here is the scenario: ``` 1st: {H,T,T,T...
11,808,074
Expectation Maximization (EM) is a kind of probabilistic method to classify data. Please correct me if I am wrong if it is not a classifier. What is an intuitive explanation of this EM technique? What is `expectation` here and what is being `maximized`?
2012/08/04
[ "https://Stackoverflow.com/questions/11808074", "https://Stackoverflow.com", "https://Stackoverflow.com/users/492372/" ]
Other answers being good, i will try to provide another perspective and tackle the intuitive part of the question. [EM (Expectation-Maximization) algorithm](http://en.wikipedia.org/wiki/Expectation%E2%80%93maximization_algorithm) is a variant of a class of iterative algorithms using [duality](http://en.wikipedia.org/w...
EM is used to maximize the likelihood of a model Q with latent variables Z. It's an iterative optimization. ``` theta <- initial guess for hidden parameters while not converged: #e-step Q(theta'|theta) = E[log L(theta|Z)] #m-step theta <- argmax_theta' Q(theta'|theta) ``` e-step: given current estim...
3,969
One of the main problems I had to deal with, when I started to meditate and study the Dhamma, was the consequence of giving up attachment to reputation and pride. Of course this is an extremelly positive thing to do, you simply become stronger when you stop caring about how other people see you, you just care about yo...
2014/10/03
[ "https://buddhism.stackexchange.com/questions/3969", "https://buddhism.stackexchange.com", "https://buddhism.stackexchange.com/users/533/" ]
I don't exactly have an answer or advice to this, as I have a similar experience to a certain extent, but I understand that even though others might see the external us and base an opinion on it, the mind development that's going on for Buddhists may always be misunderstood by those not familiar with it and thus, dukkh...
In buddhism, what is referred as attachment is the type of attachment which keeps wheel of dependent origination. In each case when a through arrives in your mind you get a sensation. When you react to this sensation with liking then it is attachement. If you do it with dislike it is aversion. All this because you do ...
3,969
One of the main problems I had to deal with, when I started to meditate and study the Dhamma, was the consequence of giving up attachment to reputation and pride. Of course this is an extremelly positive thing to do, you simply become stronger when you stop caring about how other people see you, you just care about yo...
2014/10/03
[ "https://buddhism.stackexchange.com/questions/3969", "https://buddhism.stackexchange.com", "https://buddhism.stackexchange.com/users/533/" ]
I don't exactly have an answer or advice to this, as I have a similar experience to a certain extent, but I understand that even though others might see the external us and base an opinion on it, the mind development that's going on for Buddhists may always be misunderstood by those not familiar with it and thus, dukkh...
Maybe don't try to balance anything, just experience. Wanting things to be a certain way is always dukkha. Ideally, we should do what is appropriate to the situation(this is easy for Arahants, hard for beginners). So if they think they are being ignored, maybe use the misunderstanding as an opportunity to tell them ab...
3,969
One of the main problems I had to deal with, when I started to meditate and study the Dhamma, was the consequence of giving up attachment to reputation and pride. Of course this is an extremelly positive thing to do, you simply become stronger when you stop caring about how other people see you, you just care about yo...
2014/10/03
[ "https://buddhism.stackexchange.com/questions/3969", "https://buddhism.stackexchange.com", "https://buddhism.stackexchange.com/users/533/" ]
I don't exactly have an answer or advice to this, as I have a similar experience to a certain extent, but I understand that even though others might see the external us and base an opinion on it, the mind development that's going on for Buddhists may always be misunderstood by those not familiar with it and thus, dukkh...
I too have felt some resistance, although it did eventually resolve. For one, try being more compassionate. For a long while I simply desired wisdom, and did so in a way that was neither mindful of the consequences of my actions(and how people felt about them) and had a sense of pride. Now I am practising more compassi...
3,969
One of the main problems I had to deal with, when I started to meditate and study the Dhamma, was the consequence of giving up attachment to reputation and pride. Of course this is an extremelly positive thing to do, you simply become stronger when you stop caring about how other people see you, you just care about yo...
2014/10/03
[ "https://buddhism.stackexchange.com/questions/3969", "https://buddhism.stackexchange.com", "https://buddhism.stackexchange.com/users/533/" ]
I don't exactly have an answer or advice to this, as I have a similar experience to a certain extent, but I understand that even though others might see the external us and base an opinion on it, the mind development that's going on for Buddhists may always be misunderstood by those not familiar with it and thus, dukkh...
The right fix, in my personal opinion, would be to respond as best as you can when people tell you such things. Try to see what it is about your reaction that gets on these people's nerves. It's not the case that you have to suffer when making use of social norms and conventions in order to maintain a dignified convers...
3,969
One of the main problems I had to deal with, when I started to meditate and study the Dhamma, was the consequence of giving up attachment to reputation and pride. Of course this is an extremelly positive thing to do, you simply become stronger when you stop caring about how other people see you, you just care about yo...
2014/10/03
[ "https://buddhism.stackexchange.com/questions/3969", "https://buddhism.stackexchange.com", "https://buddhism.stackexchange.com/users/533/" ]
I too have felt some resistance, although it did eventually resolve. For one, try being more compassionate. For a long while I simply desired wisdom, and did so in a way that was neither mindful of the consequences of my actions(and how people felt about them) and had a sense of pride. Now I am practising more compassi...
In buddhism, what is referred as attachment is the type of attachment which keeps wheel of dependent origination. In each case when a through arrives in your mind you get a sensation. When you react to this sensation with liking then it is attachement. If you do it with dislike it is aversion. All this because you do ...
3,969
One of the main problems I had to deal with, when I started to meditate and study the Dhamma, was the consequence of giving up attachment to reputation and pride. Of course this is an extremelly positive thing to do, you simply become stronger when you stop caring about how other people see you, you just care about yo...
2014/10/03
[ "https://buddhism.stackexchange.com/questions/3969", "https://buddhism.stackexchange.com", "https://buddhism.stackexchange.com/users/533/" ]
In buddhism, what is referred as attachment is the type of attachment which keeps wheel of dependent origination. In each case when a through arrives in your mind you get a sensation. When you react to this sensation with liking then it is attachement. If you do it with dislike it is aversion. All this because you do ...
The right fix, in my personal opinion, would be to respond as best as you can when people tell you such things. Try to see what it is about your reaction that gets on these people's nerves. It's not the case that you have to suffer when making use of social norms and conventions in order to maintain a dignified convers...
3,969
One of the main problems I had to deal with, when I started to meditate and study the Dhamma, was the consequence of giving up attachment to reputation and pride. Of course this is an extremelly positive thing to do, you simply become stronger when you stop caring about how other people see you, you just care about yo...
2014/10/03
[ "https://buddhism.stackexchange.com/questions/3969", "https://buddhism.stackexchange.com", "https://buddhism.stackexchange.com/users/533/" ]
I too have felt some resistance, although it did eventually resolve. For one, try being more compassionate. For a long while I simply desired wisdom, and did so in a way that was neither mindful of the consequences of my actions(and how people felt about them) and had a sense of pride. Now I am practising more compassi...
Maybe don't try to balance anything, just experience. Wanting things to be a certain way is always dukkha. Ideally, we should do what is appropriate to the situation(this is easy for Arahants, hard for beginners). So if they think they are being ignored, maybe use the misunderstanding as an opportunity to tell them ab...
3,969
One of the main problems I had to deal with, when I started to meditate and study the Dhamma, was the consequence of giving up attachment to reputation and pride. Of course this is an extremelly positive thing to do, you simply become stronger when you stop caring about how other people see you, you just care about yo...
2014/10/03
[ "https://buddhism.stackexchange.com/questions/3969", "https://buddhism.stackexchange.com", "https://buddhism.stackexchange.com/users/533/" ]
Maybe don't try to balance anything, just experience. Wanting things to be a certain way is always dukkha. Ideally, we should do what is appropriate to the situation(this is easy for Arahants, hard for beginners). So if they think they are being ignored, maybe use the misunderstanding as an opportunity to tell them ab...
The right fix, in my personal opinion, would be to respond as best as you can when people tell you such things. Try to see what it is about your reaction that gets on these people's nerves. It's not the case that you have to suffer when making use of social norms and conventions in order to maintain a dignified convers...
3,969
One of the main problems I had to deal with, when I started to meditate and study the Dhamma, was the consequence of giving up attachment to reputation and pride. Of course this is an extremelly positive thing to do, you simply become stronger when you stop caring about how other people see you, you just care about yo...
2014/10/03
[ "https://buddhism.stackexchange.com/questions/3969", "https://buddhism.stackexchange.com", "https://buddhism.stackexchange.com/users/533/" ]
I too have felt some resistance, although it did eventually resolve. For one, try being more compassionate. For a long while I simply desired wisdom, and did so in a way that was neither mindful of the consequences of my actions(and how people felt about them) and had a sense of pride. Now I am practising more compassi...
The right fix, in my personal opinion, would be to respond as best as you can when people tell you such things. Try to see what it is about your reaction that gets on these people's nerves. It's not the case that you have to suffer when making use of social norms and conventions in order to maintain a dignified convers...
3,803,301
I've been trying to integrate the following expression: $$\int\_{0}^{\infty} (1- \exp(-a e^{-bx})) dx$$ I started to solve this integral by first using the substitution method. With $t = e^{-bx}$, then the integral is: $$\frac{1}{b} \int\_{0}^{1} \frac{1}{t}(1-e^{-at})dt$$ The only thing that comes to my mind is solvin...
2020/08/25
[ "https://math.stackexchange.com/questions/3803301", "https://math.stackexchange.com", "https://math.stackexchange.com/users/622230/" ]
You are taking a derivative with respect to $x$. You seem to have use the product rule, but there are not two expressions containing $x$ multiplied here. \begin{align\*} \frac{\mathrm{d}}{\mathrm{d}x} g^{(n)}(x) &= \frac{\mathrm{d}}{\mathrm{d}x} \left( (-1)^n \frac{n!}{x^{n+1}} \right) \\ &= \frac{\mathrm{d}}{\math...
$$(g^{(n)})'=(-1)^{n}\*n!\*(x^{-(n+1)})'=(-1)^n\*n!\*(-(n+1)))(x^{-(n+2)}=(-1)^{(n+1)}\*(n+1)!\*x^{-(n+2)}$$ your derivative $$(g^{(n)})'$$ is wrong.
3,803,301
I've been trying to integrate the following expression: $$\int\_{0}^{\infty} (1- \exp(-a e^{-bx})) dx$$ I started to solve this integral by first using the substitution method. With $t = e^{-bx}$, then the integral is: $$\frac{1}{b} \int\_{0}^{1} \frac{1}{t}(1-e^{-at})dt$$ The only thing that comes to my mind is solvin...
2020/08/25
[ "https://math.stackexchange.com/questions/3803301", "https://math.stackexchange.com", "https://math.stackexchange.com/users/622230/" ]
You are taking a derivative with respect to $x$. You seem to have use the product rule, but there are not two expressions containing $x$ multiplied here. \begin{align\*} \frac{\mathrm{d}}{\mathrm{d}x} g^{(n)}(x) &= \frac{\mathrm{d}}{\mathrm{d}x} \left( (-1)^n \frac{n!}{x^{n+1}} \right) \\ &= \frac{\mathrm{d}}{\math...
**Hint**: It can be done in a much simpler way, if you know this elementary formula, parallel to $\;(x^n)'=nx^{n-1}$: $$\biggl(\frac1{x^n}\biggr)'=-\frac n{x^{n+1}}.$$ Therefore $$\Bigl(g^{(n)}(x)\Bigr)'=\biggl(\frac{(-1)^n n!}{x^{n+1}}\biggr)'=(-1)^n n!\biggl(\frac{1}{x^{n+1}}\biggr)'. $$ Can you proceed?
3,803,301
I've been trying to integrate the following expression: $$\int\_{0}^{\infty} (1- \exp(-a e^{-bx})) dx$$ I started to solve this integral by first using the substitution method. With $t = e^{-bx}$, then the integral is: $$\frac{1}{b} \int\_{0}^{1} \frac{1}{t}(1-e^{-at})dt$$ The only thing that comes to my mind is solvin...
2020/08/25
[ "https://math.stackexchange.com/questions/3803301", "https://math.stackexchange.com", "https://math.stackexchange.com/users/622230/" ]
You are taking a derivative with respect to $x$. You seem to have use the product rule, but there are not two expressions containing $x$ multiplied here. \begin{align\*} \frac{\mathrm{d}}{\mathrm{d}x} g^{(n)}(x) &= \frac{\mathrm{d}}{\mathrm{d}x} \left( (-1)^n \frac{n!}{x^{n+1}} \right) \\ &= \frac{\mathrm{d}}{\math...
For the inductive step we have $$g^{n+1}(x)=(-1)^{n+1} \frac{(n+1)!}{x^{n+2}}=-\frac{n+1}{x}g^n(x)$$ which is true indeed $$(g^n(x))'=\left(-\frac{n}{x}g^{n-1}(x)\right)'=\frac{n}{x^2}g^{n-1}(x)-\frac{n}{x}g^{n}(x)=-\frac{1}{x}g^{n}(x)-\frac{n}{x}g^{n}(x)=-\frac{n+1}{x}g^n(x)$$
62,795,522
I want to uninstall mysql completely from ubuntu 20.04. `sudo apt-get remove --purge mysql-server mysql-client mysql-common -y` But every time got errors. dpkg: error processing package mysql-server-8.0 (--remove): package is in a very bad inconsistent state; you should reinstall it before attempting a removal dpkg: ...
2020/07/08
[ "https://Stackoverflow.com/questions/62795522", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11311646/" ]
I had the same challenge in `xubuntu 20.04`. This is what worked for me after several attempts. I hope it helps someone in future. 1. list all files associated with mysql-server ``` sudo ls -l /var/lib/dpkg/info | grep -i mysql-server ``` 2. Remove the different file groups. ``` sudo rm -r /var/lib/dpkg/info/mysq...
The correct way to deal with such problem is to follow the instructions dpkg gives. One problem is that apt will refuse to act on such actions in those cases, so what you'd need to do is to `apt download` the required packages and reinstall them manually with `dpkg -i`. After the packages have been reinstalled, then y...
62,795,522
I want to uninstall mysql completely from ubuntu 20.04. `sudo apt-get remove --purge mysql-server mysql-client mysql-common -y` But every time got errors. dpkg: error processing package mysql-server-8.0 (--remove): package is in a very bad inconsistent state; you should reinstall it before attempting a removal dpkg: ...
2020/07/08
[ "https://Stackoverflow.com/questions/62795522", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11311646/" ]
I had the same challenge in `xubuntu 20.04`. This is what worked for me after several attempts. I hope it helps someone in future. 1. list all files associated with mysql-server ``` sudo ls -l /var/lib/dpkg/info | grep -i mysql-server ``` 2. Remove the different file groups. ``` sudo rm -r /var/lib/dpkg/info/mysq...
Regarding your current issue. In order to completely get rid of your MySQL installation you could run the following: Make sure MySQL is not running: ``` sudo systemctl stop mysql ``` Then purge all of the MySQL packages: ``` sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-cor...