qid
int64
1
74.7M
question
stringlengths
15
58.3k
date
stringlengths
10
10
metadata
list
response_j
stringlengths
4
30.2k
response_k
stringlengths
11
36.5k
44,080,790
I have a navigation with ul li in it ``` <nav> <ul> <li id="zero"></li> <li id="one"></li> <li id="two"></li> </ul> </nav> ``` for javascript I have event handler to detect the index I click on. But how do I write a if condition if the current click on the li is different from the previous one? ```...
2017/05/20
[ "https://Stackoverflow.com/questions/44080790", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7989405/" ]
Another possible option: ``` library(dplyr) x <- data_frame(x = c(1, 1, 2, 2, 3, 3, 4, 4, 1), y = c("a", "a", "b", "b", "c", "c", "d", "d", "z")) x %>% group_by(x,y) %>% summarise(y_list = list(y)) %>% group_by(x) %>% mutate(id = row_number()) %>% tidyr::unnest() %>% select(-y_list...
``` x %>% arrange(x) %>% mutate(xid = lag(x$x, default = 1), yid = lag(as.character(x$y), default = "a")) %>% group_by(x) %>% mutate(id = cumsum(x != xid | as.character(y) != yid) + 1) %>% mutate(xid = NULL, yid = NULL) ``` This yields: ``` x y id <dbl> <fctr> <dbl> 1 1 ...
44,080,790
I have a navigation with ul li in it ``` <nav> <ul> <li id="zero"></li> <li id="one"></li> <li id="two"></li> </ul> </nav> ``` for javascript I have event handler to detect the index I click on. But how do I write a if condition if the current click on the li is different from the previous one? ```...
2017/05/20
[ "https://Stackoverflow.com/questions/44080790", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7989405/" ]
Here is another solution using `factor`: ``` ## levels=unique(y) is so that levels of y are numbered according to their order of appearance and not alphabetical order df %>% group_by(x) %>% mutate(id=as.numeric(factor(y,levels=unique(y)))) ``` It returns: ``` x y id <dbl> <chr> <dbl> 1 1 a 1...
``` x %>% arrange(x) %>% mutate(xid = lag(x$x, default = 1), yid = lag(as.character(x$y), default = "a")) %>% group_by(x) %>% mutate(id = cumsum(x != xid | as.character(y) != yid) + 1) %>% mutate(xid = NULL, yid = NULL) ``` This yields: ``` x y id <dbl> <fctr> <dbl> 1 1 ...
44,080,790
I have a navigation with ul li in it ``` <nav> <ul> <li id="zero"></li> <li id="one"></li> <li id="two"></li> </ul> </nav> ``` for javascript I have event handler to detect the index I click on. But how do I write a if condition if the current click on the li is different from the previous one? ```...
2017/05/20
[ "https://Stackoverflow.com/questions/44080790", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7989405/" ]
Another option we can use is `match` ``` library(dplyr) x %>% group_by(x) %>% mutate(id = match(y, unique(y))) # A tibble: 9 x 3 # Groups: x [4] # x y id # <dbl> <fctr> <int> #1 1 a 1 #2 1 a 1 #3 2 b 1 #4 2 b 1 #5 3 c 1 #6 3 ...
``` x %>% arrange(x) %>% mutate(xid = lag(x$x, default = 1), yid = lag(as.character(x$y), default = "a")) %>% group_by(x) %>% mutate(id = cumsum(x != xid | as.character(y) != yid) + 1) %>% mutate(xid = NULL, yid = NULL) ``` This yields: ``` x y id <dbl> <fctr> <dbl> 1 1 ...
44,080,790
I have a navigation with ul li in it ``` <nav> <ul> <li id="zero"></li> <li id="one"></li> <li id="two"></li> </ul> </nav> ``` for javascript I have event handler to detect the index I click on. But how do I write a if condition if the current click on the li is different from the previous one? ```...
2017/05/20
[ "https://Stackoverflow.com/questions/44080790", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7989405/" ]
Here is another solution using `factor`: ``` ## levels=unique(y) is so that levels of y are numbered according to their order of appearance and not alphabetical order df %>% group_by(x) %>% mutate(id=as.numeric(factor(y,levels=unique(y)))) ``` It returns: ``` x y id <dbl> <chr> <dbl> 1 1 a 1...
Another possible option: ``` library(dplyr) x <- data_frame(x = c(1, 1, 2, 2, 3, 3, 4, 4, 1), y = c("a", "a", "b", "b", "c", "c", "d", "d", "z")) x %>% group_by(x,y) %>% summarise(y_list = list(y)) %>% group_by(x) %>% mutate(id = row_number()) %>% tidyr::unnest() %>% select(-y_list...
44,080,790
I have a navigation with ul li in it ``` <nav> <ul> <li id="zero"></li> <li id="one"></li> <li id="two"></li> </ul> </nav> ``` for javascript I have event handler to detect the index I click on. But how do I write a if condition if the current click on the li is different from the previous one? ```...
2017/05/20
[ "https://Stackoverflow.com/questions/44080790", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7989405/" ]
Here is another solution using `factor`: ``` ## levels=unique(y) is so that levels of y are numbered according to their order of appearance and not alphabetical order df %>% group_by(x) %>% mutate(id=as.numeric(factor(y,levels=unique(y)))) ``` It returns: ``` x y id <dbl> <chr> <dbl> 1 1 a 1...
Another option we can use is `match` ``` library(dplyr) x %>% group_by(x) %>% mutate(id = match(y, unique(y))) # A tibble: 9 x 3 # Groups: x [4] # x y id # <dbl> <fctr> <int> #1 1 a 1 #2 1 a 1 #3 2 b 1 #4 2 b 1 #5 3 c 1 #6 3 ...
54,907,451
I am trying to install puppeteer globally on macOS (Mojave) 10.14.3 1. First failure (in `sudo su` mode): `npm install -g puppeteer` ``` > puppeteer@1.12.2 install /usr/local/lib/node_modules/puppeteer > node install.js ERROR: Failed to download Chromium r624492! Set "PUPPETEER_SKIP_CHROMIUM_DOWNLOAD" env variable t...
2019/02/27
[ "https://Stackoverflow.com/questions/54907451", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5430088/" ]
Try with it: ``` npm config set user 0 npm config set unsafe-perm true npm install -g puppeteer ``` Option [unsafe-perm](https://docs.npmjs.com/misc/config#unsafe-perm): > > Set to true to suppress the UID/GID switching when running package > scripts. If set explicitly to false, then installing as a non-root > use...
This was working fine for me a matter of days ago, but am not getting exactly the same error
58,089,184
I'm having problems using TensorRT for python on windows. I want to use openpose on windows however it requires TensorRT for python. when I'm trying to execute file run\_webcam.py (openpose code), I have the following error: ``` ModuleNotFoundError: No module named "tensorflow.contrib.tensorrt" ``` I installed tens...
2019/09/24
[ "https://Stackoverflow.com/questions/58089184", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12115851/" ]
As far as I am concerned, the TensorRT python API is not supported in Windows as per the [official TensorRT documentation](https://docs.nvidia.com/deeplearning/sdk/tensorrt-install-guide/index.html#gettingstarted): > > *The Windows zip package for TensorRT does not provide Python support. > Python may be supported i...
Now there is official support for TensorRT Python API under windows. Have a look at the comment from NVIDIA moderator on the following issue: <https://github.com/NVIDIA/TensorRT/issues/1080#issuecomment-1038685416> To check the compatibility of the different versions of TensorRT, Tensorflow, cuDNN, and other librarie...
111,460
I installed [`syslog-ng`](http://www.campin.net/syslog-ng/expanded-syslog-ng.conf) to use on my desktop (Gentoo 64bit, upgraded to systemd i.e. was OpenRC [before](http://wiki.gentoo.org/wiki/Systemd), with Openbox and Slim only) with my normal user to *log all commands* I type in the shell (bash first, then eventually...
2014/01/29
[ "https://unix.stackexchange.com/questions/111460", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/-1/" ]
You have a lot going on there..... My best answer to this is to explain simply how I have seen session logging done in the past. Hopefully that will give you some options to explore. 1. As you have already mentioned, pulling the `bash history` from the user accounts. This only works after the session has ended. Not r...
This is solution which takes care of the first question, as well as introduces the use of auditd interactively, outside of the pam\_tty module solution provided in the other answer. **bash** First, as explained by a contributor, there might be syntax issues with the original setup and there is a better way to do this...
111,460
I installed [`syslog-ng`](http://www.campin.net/syslog-ng/expanded-syslog-ng.conf) to use on my desktop (Gentoo 64bit, upgraded to systemd i.e. was OpenRC [before](http://wiki.gentoo.org/wiki/Systemd), with Openbox and Slim only) with my normal user to *log all commands* I type in the shell (bash first, then eventually...
2014/01/29
[ "https://unix.stackexchange.com/questions/111460", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/-1/" ]
You have a lot going on there..... My best answer to this is to explain simply how I have seen session logging done in the past. Hopefully that will give you some options to explore. 1. As you have already mentioned, pulling the `bash history` from the user accounts. This only works after the session has ended. Not r...
Add the following line in /etc/profiles or ~/.bashrc ``` PROMPT_COMMAND='history -a >(tee -a ~/.bash_history | logger -t "$USER[$$] $SSH_CONNECTION")' ``` this will send the command along with ssh user/ip to /var/log/messages or /var/log/syslog
111,460
I installed [`syslog-ng`](http://www.campin.net/syslog-ng/expanded-syslog-ng.conf) to use on my desktop (Gentoo 64bit, upgraded to systemd i.e. was OpenRC [before](http://wiki.gentoo.org/wiki/Systemd), with Openbox and Slim only) with my normal user to *log all commands* I type in the shell (bash first, then eventually...
2014/01/29
[ "https://unix.stackexchange.com/questions/111460", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/-1/" ]
This is solution which takes care of the first question, as well as introduces the use of auditd interactively, outside of the pam\_tty module solution provided in the other answer. **bash** First, as explained by a contributor, there might be syntax issues with the original setup and there is a better way to do this...
Add the following line in /etc/profiles or ~/.bashrc ``` PROMPT_COMMAND='history -a >(tee -a ~/.bash_history | logger -t "$USER[$$] $SSH_CONNECTION")' ``` this will send the command along with ssh user/ip to /var/log/messages or /var/log/syslog
9,591,543
In the [K&R book](http://en.wikipedia.org/wiki/The_C_Programming_Language), it shows the following printf statement in the pointers chapter: ``` printf((argc > 1) ? "%s " : "%s", *++argv); ``` I don't understand this line - why are there two %s in here? Thanks!
2012/03/06
[ "https://Stackoverflow.com/questions/9591543", "https://Stackoverflow.com", "https://Stackoverflow.com/users/763029/" ]
The first argument to that `printf` is `(argc > 1) ? "%s " : "%s"`, which is a **ternary conditional expression** (see wikipedia's page on [?:](http://en.wikipedia.org/wiki/?%3a)) The condition is here `(argc > 1)` the *then* sub-expression is `"%s "` (a litteral constant string), the *else* sub-expression is `"%s"`. ...
You are using the [ternary operator](http://en.wikipedia.org/wiki/Ternary_operation). This causes `printf` to use `"%s"` as the format string if `argc` is less than or equal to 1 and `"%s "` if `argc` is greater than 1
9,591,543
In the [K&R book](http://en.wikipedia.org/wiki/The_C_Programming_Language), it shows the following printf statement in the pointers chapter: ``` printf((argc > 1) ? "%s " : "%s", *++argv); ``` I don't understand this line - why are there two %s in here? Thanks!
2012/03/06
[ "https://Stackoverflow.com/questions/9591543", "https://Stackoverflow.com", "https://Stackoverflow.com/users/763029/" ]
That's equivalent to: ``` if ( argc > 1 ) printf("%s ", *++argv); else printf("%s", *++argv); ``` That's the ternary conditional operator: ``` (condition) ? (subexpression1) : (subexpression2) ``` The expression evaluates to `subexpression1` if `condition` is `true` and `subexpression2` otherwise.
Because this expression `(condition) ? (if true) : (if false)` is [Ternary operator](http://en.wikipedia.org/wiki/Ternary_operation). And `"%s "` will run if condition will be `true`, and `"%s"` if `false`.
9,591,543
In the [K&R book](http://en.wikipedia.org/wiki/The_C_Programming_Language), it shows the following printf statement in the pointers chapter: ``` printf((argc > 1) ? "%s " : "%s", *++argv); ``` I don't understand this line - why are there two %s in here? Thanks!
2012/03/06
[ "https://Stackoverflow.com/questions/9591543", "https://Stackoverflow.com", "https://Stackoverflow.com/users/763029/" ]
The first argument to that `printf` is `(argc > 1) ? "%s " : "%s"`, which is a **ternary conditional expression** (see wikipedia's page on [?:](http://en.wikipedia.org/wiki/?%3a)) The condition is here `(argc > 1)` the *then* sub-expression is `"%s "` (a litteral constant string), the *else* sub-expression is `"%s"`. ...
In C, the ? denotes the conditional operator. The expression: ``` A ? B : C ``` evaluates to B if A is non-zero and evaluates to C if A evaluates to 0. So in your case, if argc > 1, it will output the current parameters with a space after it. Otherwise, it will output the current parameter with no space
9,591,543
In the [K&R book](http://en.wikipedia.org/wiki/The_C_Programming_Language), it shows the following printf statement in the pointers chapter: ``` printf((argc > 1) ? "%s " : "%s", *++argv); ``` I don't understand this line - why are there two %s in here? Thanks!
2012/03/06
[ "https://Stackoverflow.com/questions/9591543", "https://Stackoverflow.com", "https://Stackoverflow.com/users/763029/" ]
That's equivalent to: ``` if ( argc > 1 ) printf("%s ", *++argv); else printf("%s", *++argv); ``` That's the ternary conditional operator: ``` (condition) ? (subexpression1) : (subexpression2) ``` The expression evaluates to `subexpression1` if `condition` is `true` and `subexpression2` otherwise.
The first argument to that `printf` is `(argc > 1) ? "%s " : "%s"`, which is a **ternary conditional expression** (see wikipedia's page on [?:](http://en.wikipedia.org/wiki/?%3a)) The condition is here `(argc > 1)` the *then* sub-expression is `"%s "` (a litteral constant string), the *else* sub-expression is `"%s"`. ...
9,591,543
In the [K&R book](http://en.wikipedia.org/wiki/The_C_Programming_Language), it shows the following printf statement in the pointers chapter: ``` printf((argc > 1) ? "%s " : "%s", *++argv); ``` I don't understand this line - why are there two %s in here? Thanks!
2012/03/06
[ "https://Stackoverflow.com/questions/9591543", "https://Stackoverflow.com", "https://Stackoverflow.com/users/763029/" ]
That's equivalent to: ``` if ( argc > 1 ) printf("%s ", *++argv); else printf("%s", *++argv); ``` That's the ternary conditional operator: ``` (condition) ? (subexpression1) : (subexpression2) ``` The expression evaluates to `subexpression1` if `condition` is `true` and `subexpression2` otherwise.
This is a shorthand for the if statement, called "ternary operator". ``` (argc > 1) ? "%s " : "%s" ``` means ``` if (argc > 1) "%s " else "%s" ``` The nice thing about it is that while the above is invalid, the ternary operator is a statement and can be used anywhere an expression can be used, so you can,...
9,591,543
In the [K&R book](http://en.wikipedia.org/wiki/The_C_Programming_Language), it shows the following printf statement in the pointers chapter: ``` printf((argc > 1) ? "%s " : "%s", *++argv); ``` I don't understand this line - why are there two %s in here? Thanks!
2012/03/06
[ "https://Stackoverflow.com/questions/9591543", "https://Stackoverflow.com", "https://Stackoverflow.com/users/763029/" ]
The first argument to that `printf` is `(argc > 1) ? "%s " : "%s"`, which is a **ternary conditional expression** (see wikipedia's page on [?:](http://en.wikipedia.org/wiki/?%3a)) The condition is here `(argc > 1)` the *then* sub-expression is `"%s "` (a litteral constant string), the *else* sub-expression is `"%s"`. ...
So that you get a space after the name if there's at least one argument to follow. And mostly to demonstrate that you could also do: ``` const char *format = "%s"; if (argc > 1) format = "%s "; printf(format, *++argv); ``` Which makes it clearer that the format string can be a variable. However, you do need to ...
9,591,543
In the [K&R book](http://en.wikipedia.org/wiki/The_C_Programming_Language), it shows the following printf statement in the pointers chapter: ``` printf((argc > 1) ? "%s " : "%s", *++argv); ``` I don't understand this line - why are there two %s in here? Thanks!
2012/03/06
[ "https://Stackoverflow.com/questions/9591543", "https://Stackoverflow.com", "https://Stackoverflow.com/users/763029/" ]
The first argument to that `printf` is `(argc > 1) ? "%s " : "%s"`, which is a **ternary conditional expression** (see wikipedia's page on [?:](http://en.wikipedia.org/wiki/?%3a)) The condition is here `(argc > 1)` the *then* sub-expression is `"%s "` (a litteral constant string), the *else* sub-expression is `"%s"`. ...
Because this expression `(condition) ? (if true) : (if false)` is [Ternary operator](http://en.wikipedia.org/wiki/Ternary_operation). And `"%s "` will run if condition will be `true`, and `"%s"` if `false`.
9,591,543
In the [K&R book](http://en.wikipedia.org/wiki/The_C_Programming_Language), it shows the following printf statement in the pointers chapter: ``` printf((argc > 1) ? "%s " : "%s", *++argv); ``` I don't understand this line - why are there two %s in here? Thanks!
2012/03/06
[ "https://Stackoverflow.com/questions/9591543", "https://Stackoverflow.com", "https://Stackoverflow.com/users/763029/" ]
The first argument to that `printf` is `(argc > 1) ? "%s " : "%s"`, which is a **ternary conditional expression** (see wikipedia's page on [?:](http://en.wikipedia.org/wiki/?%3a)) The condition is here `(argc > 1)` the *then* sub-expression is `"%s "` (a litteral constant string), the *else* sub-expression is `"%s"`. ...
This is a shorthand for the if statement, called "ternary operator". ``` (argc > 1) ? "%s " : "%s" ``` means ``` if (argc > 1) "%s " else "%s" ``` The nice thing about it is that while the above is invalid, the ternary operator is a statement and can be used anywhere an expression can be used, so you can,...
9,591,543
In the [K&R book](http://en.wikipedia.org/wiki/The_C_Programming_Language), it shows the following printf statement in the pointers chapter: ``` printf((argc > 1) ? "%s " : "%s", *++argv); ``` I don't understand this line - why are there two %s in here? Thanks!
2012/03/06
[ "https://Stackoverflow.com/questions/9591543", "https://Stackoverflow.com", "https://Stackoverflow.com/users/763029/" ]
That's equivalent to: ``` if ( argc > 1 ) printf("%s ", *++argv); else printf("%s", *++argv); ``` That's the ternary conditional operator: ``` (condition) ? (subexpression1) : (subexpression2) ``` The expression evaluates to `subexpression1` if `condition` is `true` and `subexpression2` otherwise.
In C, the ? denotes the conditional operator. The expression: ``` A ? B : C ``` evaluates to B if A is non-zero and evaluates to C if A evaluates to 0. So in your case, if argc > 1, it will output the current parameters with a space after it. Otherwise, it will output the current parameter with no space
9,591,543
In the [K&R book](http://en.wikipedia.org/wiki/The_C_Programming_Language), it shows the following printf statement in the pointers chapter: ``` printf((argc > 1) ? "%s " : "%s", *++argv); ``` I don't understand this line - why are there two %s in here? Thanks!
2012/03/06
[ "https://Stackoverflow.com/questions/9591543", "https://Stackoverflow.com", "https://Stackoverflow.com/users/763029/" ]
That's equivalent to: ``` if ( argc > 1 ) printf("%s ", *++argv); else printf("%s", *++argv); ``` That's the ternary conditional operator: ``` (condition) ? (subexpression1) : (subexpression2) ``` The expression evaluates to `subexpression1` if `condition` is `true` and `subexpression2` otherwise.
You are using the [ternary operator](http://en.wikipedia.org/wiki/Ternary_operation). This causes `printf` to use `"%s"` as the format string if `argc` is less than or equal to 1 and `"%s "` if `argc` is greater than 1
41,229,402
I have a 3 digit number, let's say n = 135. I need to change the digits in the number so that I get a different number. Putting first number in the middle for the result of 315. I figured first thing i have to do is extract separate digits and I went with this ``` int n = 135; int a, b, c, x; a = n / 100; b = n % 1...
2016/12/19
[ "https://Stackoverflow.com/questions/41229402", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5419827/" ]
Multiplication is your friend. ``` x = b * 100 + a * 10 + c; ```
So, alright. The way I would do this, and please correct me if this doesn't work, would be to make it into a string, and then re-arrange stuff like that. To do that, we could use the string formatting library like this: ``` string number = to_string(135); ``` Then, you could do stuff like this: ``` char swap; swap ...
19,096,902
This is the jsfiddle: <http://jsfiddle.net/2QEdS/> I use this piece of JS code to do the hotkeys: <https://github.com/jeresig/jquery.hotkeys/blob/master/jquery.hotkeys.js> However, it works with keys like `f4`, but does not work like`a` or `Ctrl` + `a`. Can someone help to take a look? The code in the jsfiddle is: `...
2013/09/30
[ "https://Stackoverflow.com/questions/19096902", "https://Stackoverflow.com", "https://Stackoverflow.com/users/170931/" ]
You'll first need to get the array ``` String jsonStr = "{\"response\" : [ { \"id\" : \"1a\", \"name\" : \"foo\"},{ \"id\" : \"1b\",\"name\" : \"bar\" } ]}"; ObjectMapper mapper = new ObjectMapper(); JsonNode node = mapper.readTree(jsonStr); ArrayNode arrayNode = (ArrayNode) node.get("response"); System.out.println...
You can use the generic readTree with JsonNode: ``` ObjectMapper mapper = new ObjectMapper(); JsonNode root = mapper.readTree(json); JsonNode response = root.get("response"); List<Pojo> list = mapper.readValue(response, new TypeReference<List<Pojo>>() {}); ```
19,096,902
This is the jsfiddle: <http://jsfiddle.net/2QEdS/> I use this piece of JS code to do the hotkeys: <https://github.com/jeresig/jquery.hotkeys/blob/master/jquery.hotkeys.js> However, it works with keys like `f4`, but does not work like`a` or `Ctrl` + `a`. Can someone help to take a look? The code in the jsfiddle is: `...
2013/09/30
[ "https://Stackoverflow.com/questions/19096902", "https://Stackoverflow.com", "https://Stackoverflow.com/users/170931/" ]
You'll first need to get the array ``` String jsonStr = "{\"response\" : [ { \"id\" : \"1a\", \"name\" : \"foo\"},{ \"id\" : \"1b\",\"name\" : \"bar\" } ]}"; ObjectMapper mapper = new ObjectMapper(); JsonNode node = mapper.readTree(jsonStr); ArrayNode arrayNode = (ArrayNode) node.get("response"); System.out.println...
``` Pojo pojo; json = { "response" : [ { "id" : "1a", "name" : "foo" }, { "id" : "1b", "name" : "bar" } ] } ObjectMapper mapper = new ObjectMapper(); JsonNode root = objectMapper.readTree(json); pojo = objectMapper.readValue(root.p...
6,959
I have Parallels Desktop 5 for Mac. Does the upgrade to Parallels Desktop 6 means that I have to reinstall Windows 7 and all the other programs?
2011/01/25
[ "https://apple.stackexchange.com/questions/6959", "https://apple.stackexchange.com", "https://apple.stackexchange.com/users/1975/" ]
No, your Windows VM and all the programs installed on it are stored on a virtual hard drive file. Upgrading Parallels won't affect the VM.
To extend @Kyle's answer, which is correct by the way, you have to consider the fact that after the upgrade, you *might have* to re-authorize Windows. I really don't know what Windows is thinking or what Parallels is doing, but I've seen two people who had to re-authorize their Windows 7 Home Premium inside a VM after ...
6,959
I have Parallels Desktop 5 for Mac. Does the upgrade to Parallels Desktop 6 means that I have to reinstall Windows 7 and all the other programs?
2011/01/25
[ "https://apple.stackexchange.com/questions/6959", "https://apple.stackexchange.com", "https://apple.stackexchange.com/users/1975/" ]
No, your Windows VM and all the programs installed on it are stored on a virtual hard drive file. Upgrading Parallels won't affect the VM.
I had not trouble upgrading from 5 to 6 with Win 7 Enterprise.
6,959
I have Parallels Desktop 5 for Mac. Does the upgrade to Parallels Desktop 6 means that I have to reinstall Windows 7 and all the other programs?
2011/01/25
[ "https://apple.stackexchange.com/questions/6959", "https://apple.stackexchange.com", "https://apple.stackexchange.com/users/1975/" ]
To extend @Kyle's answer, which is correct by the way, you have to consider the fact that after the upgrade, you *might have* to re-authorize Windows. I really don't know what Windows is thinking or what Parallels is doing, but I've seen two people who had to re-authorize their Windows 7 Home Premium inside a VM after ...
I had not trouble upgrading from 5 to 6 with Win 7 Enterprise.
71,934,635
I have researched this and it seems it is complicated or at least not simple to use a variable declared in JavaScript in an HTML document multiple times. For instance, I have multiple (hundreds) of div's with IMG statements referencing different JPG files. I want to give a path to those files that is the same on each ...
2022/04/20
[ "https://Stackoverflow.com/questions/71934635", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3558926/" ]
You can use `purrr::reduce`(or `base::Reduce`) to do the iteration. ```r library(tidyverse) reduce(2:4, ~ mutate(.x, !!paste0("col1to", .y) := mean(c_across(1:.y))), .init = rowwise(a)) # A tibble: 3 x 7 # Rowwise: A B C D col1to2 col1to3 col1to4 <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> 1...
Using `data.table`: ``` setDT(a)[ , paste0("col", seq_len(ncol(a)-1)) := transpose(lapply(transpose(.SD), function(x) cummean(x)[-1])) ] ``` Using base R you can do something like: ``` cbind(a, t(apply(a, 1, function(x) cummean(x)[-1]))) ```
71,934,635
I have researched this and it seems it is complicated or at least not simple to use a variable declared in JavaScript in an HTML document multiple times. For instance, I have multiple (hundreds) of div's with IMG statements referencing different JPG files. I want to give a path to those files that is the same on each ...
2022/04/20
[ "https://Stackoverflow.com/questions/71934635", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3558926/" ]
You can use `purrr::reduce`(or `base::Reduce`) to do the iteration. ```r library(tidyverse) reduce(2:4, ~ mutate(.x, !!paste0("col1to", .y) := mean(c_across(1:.y))), .init = rowwise(a)) # A tibble: 3 x 7 # Rowwise: A B C D col1to2 col1to3 col1to4 <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> 1...
Here is another `tidyverse` option, which also uses `purrr`. We can iterate through the column names using `map` in order to select the range of columns and get the mean of the columns selected. Then, we can change the names of the new columns and bind the output back to the original dataframe. Here, I use `names(a)[-1...
71,934,635
I have researched this and it seems it is complicated or at least not simple to use a variable declared in JavaScript in an HTML document multiple times. For instance, I have multiple (hundreds) of div's with IMG statements referencing different JPG files. I want to give a path to those files that is the same on each ...
2022/04/20
[ "https://Stackoverflow.com/questions/71934635", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3558926/" ]
Using `data.table`: ``` setDT(a)[ , paste0("col", seq_len(ncol(a)-1)) := transpose(lapply(transpose(.SD), function(x) cummean(x)[-1])) ] ``` Using base R you can do something like: ``` cbind(a, t(apply(a, 1, function(x) cummean(x)[-1]))) ```
Here is another `tidyverse` option, which also uses `purrr`. We can iterate through the column names using `map` in order to select the range of columns and get the mean of the columns selected. Then, we can change the names of the new columns and bind the output back to the original dataframe. Here, I use `names(a)[-1...
8,966,155
if you dragg any hyperlink `<a href="go.php">` to an imput (for example a search input), the href attribute is append to the input's content, `<input type="text" value="http://domain.com/go.php" />` Is there a way to append the title attribute instead, or the `innerHtml`? I ask this because I want to avoid the use of...
2012/01/23
[ "https://Stackoverflow.com/questions/8966155", "https://Stackoverflow.com", "https://Stackoverflow.com/users/533941/" ]
Instead of appending, you could use insertBefore: <http://api.jquery.com/insertBefore/>
``` $('ul .last').removeClass('last'); $('ul').append('<li id="'+$('ul li').length+'" class="last">text</li>'); ```
8,966,155
if you dragg any hyperlink `<a href="go.php">` to an imput (for example a search input), the href attribute is append to the input's content, `<input type="text" value="http://domain.com/go.php" />` Is there a way to append the title attribute instead, or the `innerHtml`? I ask this because I want to avoid the use of...
2012/01/23
[ "https://Stackoverflow.com/questions/8966155", "https://Stackoverflow.com", "https://Stackoverflow.com/users/533941/" ]
Instead of appending, you could use insertBefore: <http://api.jquery.com/insertBefore/>
Try this: ``` ( function( $ ) { $( 'span' ).on( 'click', function( event ) { event.preventDefault(); var $ul = $( 'ul' ), $last = $ul.find( '.last' ), lastID = $last.attr( 'id' ); $last.attr( 'id', ( +lastID + 1) ); $( '<li id="' + lastID + '">Text</li>' ...
8,966,155
if you dragg any hyperlink `<a href="go.php">` to an imput (for example a search input), the href attribute is append to the input's content, `<input type="text" value="http://domain.com/go.php" />` Is there a way to append the title attribute instead, or the `innerHtml`? I ask this because I want to avoid the use of...
2012/01/23
[ "https://Stackoverflow.com/questions/8966155", "https://Stackoverflow.com", "https://Stackoverflow.com/users/533941/" ]
Try this: ``` ( function( $ ) { $( 'span' ).on( 'click', function( event ) { event.preventDefault(); var $ul = $( 'ul' ), $last = $ul.find( '.last' ), lastID = $last.attr( 'id' ); $last.attr( 'id', ( +lastID + 1) ); $( '<li id="' + lastID + '">Text</li>' ...
``` $('ul .last').removeClass('last'); $('ul').append('<li id="'+$('ul li').length+'" class="last">text</li>'); ```
3,202,797
UPDATED: I've simplified the code (tried to) I'm trying to download a series of images as set in an array, but something is clearly not right: ``` function savePhoto($remoteImage,$fname) { $ch = curl_init(); curl_setopt ($ch, CURLOPT_NOBODY, true); curl_setopt ($ch, CURLOPT_URL, $remoteImage); curl_se...
2010/07/08
[ "https://Stackoverflow.com/questions/3202797", "https://Stackoverflow.com", "https://Stackoverflow.com/users/386535/" ]
I ran into this problem, too. It happens in IE and Firefox but not Opera and Chrome. I thought of hiding the momentary jumps to the top by "[double-buffering](http://en.wikipedia.org/wiki/Multiple_buffering#Double_buffering_in_computer_graphics)" changes to the textarea: 1. Create two textareas with the exact same pr...
i thing that is problem of adding the content via the script, paste your code which append text to your textarea
6,369,868
How to validate a `TextBox` field against a *Natural Number*? User are restricted to input natural number (e.g. 1,2,3..99999) and if not, a `MessageBox` is shown. Currently I'm using the following code (assuming the natural number does not go beyond two digits): ``` Regex isPositiveNum2 = new Regex("[1-9]"); Regex is...
2011/06/16
[ "https://Stackoverflow.com/questions/6369868", "https://Stackoverflow.com", "https://Stackoverflow.com/users/529310/" ]
Use the built in [parsing](http://msdn.microsoft.com/en-us/library/system.int32.parse.aspx): ``` int.Parse(textbox1.Text) > 0 ``` This will throw an exception if `textbox1.Text` can't be parsed, so you may want to use [`TryParse`](http://msdn.microsoft.com/en-us/library/c846ws90.aspx) instead: ``` int test; if(int....
try this: ``` int myValue; if (int.TryParse(mNumTb1.Text, out myValue) && myValue > 0) { //natural } else { //not natural } ```
6,369,868
How to validate a `TextBox` field against a *Natural Number*? User are restricted to input natural number (e.g. 1,2,3..99999) and if not, a `MessageBox` is shown. Currently I'm using the following code (assuming the natural number does not go beyond two digits): ``` Regex isPositiveNum2 = new Regex("[1-9]"); Regex is...
2011/06/16
[ "https://Stackoverflow.com/questions/6369868", "https://Stackoverflow.com", "https://Stackoverflow.com/users/529310/" ]
Use the built in [parsing](http://msdn.microsoft.com/en-us/library/system.int32.parse.aspx): ``` int.Parse(textbox1.Text) > 0 ``` This will throw an exception if `textbox1.Text` can't be parsed, so you may want to use [`TryParse`](http://msdn.microsoft.com/en-us/library/c846ws90.aspx) instead: ``` int test; if(int....
``` int i = -1; int32.TryParse(textbox1.Text, out i); if (i > 0) { return true; } else { return false; } ```
6,369,868
How to validate a `TextBox` field against a *Natural Number*? User are restricted to input natural number (e.g. 1,2,3..99999) and if not, a `MessageBox` is shown. Currently I'm using the following code (assuming the natural number does not go beyond two digits): ``` Regex isPositiveNum2 = new Regex("[1-9]"); Regex is...
2011/06/16
[ "https://Stackoverflow.com/questions/6369868", "https://Stackoverflow.com", "https://Stackoverflow.com/users/529310/" ]
Use the built in [parsing](http://msdn.microsoft.com/en-us/library/system.int32.parse.aspx): ``` int.Parse(textbox1.Text) > 0 ``` This will throw an exception if `textbox1.Text` can't be parsed, so you may want to use [`TryParse`](http://msdn.microsoft.com/en-us/library/c846ws90.aspx) instead: ``` int test; if(int....
``` int number; if (int.TryParse (textbox1.Text, out number) && number >0) { /* Do something */ } else { MessageBox.Show("Hey! This is not a Natural Number"); textbox1.Text = "1"; } ```
6,369,868
How to validate a `TextBox` field against a *Natural Number*? User are restricted to input natural number (e.g. 1,2,3..99999) and if not, a `MessageBox` is shown. Currently I'm using the following code (assuming the natural number does not go beyond two digits): ``` Regex isPositiveNum2 = new Regex("[1-9]"); Regex is...
2011/06/16
[ "https://Stackoverflow.com/questions/6369868", "https://Stackoverflow.com", "https://Stackoverflow.com/users/529310/" ]
Use the built in [parsing](http://msdn.microsoft.com/en-us/library/system.int32.parse.aspx): ``` int.Parse(textbox1.Text) > 0 ``` This will throw an exception if `textbox1.Text` can't be parsed, so you may want to use [`TryParse`](http://msdn.microsoft.com/en-us/library/c846ws90.aspx) instead: ``` int test; if(int....
You can check the char while user entering: ``` Private void textBox1_KeyPress(object sender, KeyPressEventArgs e) { if(!char.IsDigit(e.KeyChar)&&!char.IsControl(e.KeyChar)) //only digit but still allow the user to use control key to Copy&Paste etc. But you need to apply validating with paste text as well { ...
6,369,868
How to validate a `TextBox` field against a *Natural Number*? User are restricted to input natural number (e.g. 1,2,3..99999) and if not, a `MessageBox` is shown. Currently I'm using the following code (assuming the natural number does not go beyond two digits): ``` Regex isPositiveNum2 = new Regex("[1-9]"); Regex is...
2011/06/16
[ "https://Stackoverflow.com/questions/6369868", "https://Stackoverflow.com", "https://Stackoverflow.com/users/529310/" ]
try this: ``` int myValue; if (int.TryParse(mNumTb1.Text, out myValue) && myValue > 0) { //natural } else { //not natural } ```
``` int i = -1; int32.TryParse(textbox1.Text, out i); if (i > 0) { return true; } else { return false; } ```
6,369,868
How to validate a `TextBox` field against a *Natural Number*? User are restricted to input natural number (e.g. 1,2,3..99999) and if not, a `MessageBox` is shown. Currently I'm using the following code (assuming the natural number does not go beyond two digits): ``` Regex isPositiveNum2 = new Regex("[1-9]"); Regex is...
2011/06/16
[ "https://Stackoverflow.com/questions/6369868", "https://Stackoverflow.com", "https://Stackoverflow.com/users/529310/" ]
try this: ``` int myValue; if (int.TryParse(mNumTb1.Text, out myValue) && myValue > 0) { //natural } else { //not natural } ```
``` int number; if (int.TryParse (textbox1.Text, out number) && number >0) { /* Do something */ } else { MessageBox.Show("Hey! This is not a Natural Number"); textbox1.Text = "1"; } ```
6,369,868
How to validate a `TextBox` field against a *Natural Number*? User are restricted to input natural number (e.g. 1,2,3..99999) and if not, a `MessageBox` is shown. Currently I'm using the following code (assuming the natural number does not go beyond two digits): ``` Regex isPositiveNum2 = new Regex("[1-9]"); Regex is...
2011/06/16
[ "https://Stackoverflow.com/questions/6369868", "https://Stackoverflow.com", "https://Stackoverflow.com/users/529310/" ]
try this: ``` int myValue; if (int.TryParse(mNumTb1.Text, out myValue) && myValue > 0) { //natural } else { //not natural } ```
You can check the char while user entering: ``` Private void textBox1_KeyPress(object sender, KeyPressEventArgs e) { if(!char.IsDigit(e.KeyChar)&&!char.IsControl(e.KeyChar)) //only digit but still allow the user to use control key to Copy&Paste etc. But you need to apply validating with paste text as well { ...
22,002,569
I'm trying to use a class variable on another class in on another script, but I'm not sure how that's possible. I've seen how to use methods or functions, but not variables. For example something like this ``` #old.py class Sassy: bbq = "nice" lol = "funny" def DoesNothing(self): #this is the...
2014/02/25
[ "https://Stackoverflow.com/questions/22002569", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1713366/" ]
That's almost right. Never do this: ``` from old import * ``` Instead do this: ``` from old import Sassy new = Sassy() print(new.bbq) ```
Yes, and since they are class variables, you can also do `Sassy.bbq`. PS: As tsroten told you, `import *` is considered bad practice, because it'll make it difficult to find out where an object came from once your module become larger. You can read [PEP8](http://legacy.python.org/dev/peps/pep-0008/) if you want to lea...
2,921,662
So far I inspected several proof assistant: 1.DC Proof. The closest to my ideal yet still not exactly what I want (although I still have some hope that maybe I'm missing something). I'm glad that it can handle propositional logic, predicate logic and set theory (for example, it can prove non-existence of the universal...
2018/09/18
[ "https://math.stackexchange.com/questions/2921662", "https://math.stackexchange.com", "https://math.stackexchange.com/users/161005/" ]
No, you cannot. First of all, not every non-empty subset of $\mathbb R$ has an infimum. Besides, if $A$ is an open subset of $\mathbb R$ (with respect to the usual topology) and if $x\in A$, then $A\supset(x-\varepsilon,x+\varepsilon)$, for some $\varepsilon>0$ and therefore $\inf A$ (if it exists) is *never* $x$. So, ...
You're thinking about the proof in the wrong way. The argument goes as follows: suppose that $\mathcal{B}$ is any base for the lower limit (a.k.a. Sorgenfrey) topology on $\mathbb{R}$. Then note that for each $x \in \mathbb{R}$ we have that $[x,x+1)$ is open in this topology and contains $x$ (this would already fail f...
3,553,432
> > A particle starts at $(0,0)$ and moves in one-unit independent steps with equal probabilities of $\frac{1}{4}$ in each of the four directions: north,south,east and west. Let S equal to the east-west position and T the north-south position after three steps. > > > Question:Define the joint PMF of S and T.. I ...
2020/02/20
[ "https://math.stackexchange.com/questions/3553432", "https://math.stackexchange.com", "https://math.stackexchange.com/users/750914/" ]
Hint: \begin{eqnarray\*} \left( 1- \frac{1}{n^2} \right)^n = 1+ n \left( - \frac{1}{n^2} \right) + \binom{n}{2} \left( - \frac{1}{n^2} \right)^2+ \cdots \end{eqnarray\*}
Note that, for $n \gt 1$, $$\frac{1}{1 - \frac{1}{n}} = \frac{n}{n - 1} = 1 + \frac{1}{n - 1} \tag{1}\label{eq1A}$$ Using \eqref{eq1A}, for $n \gt 1$, multiplying both sides of your proposed inequality by $\left(\frac{1}{1 - \frac{1}{n}}\right)^n$ gives $$\left(1-\frac{1}{n}\right)^n \left(1+\frac{1}{n}\right)^n \ge...
3,553,432
> > A particle starts at $(0,0)$ and moves in one-unit independent steps with equal probabilities of $\frac{1}{4}$ in each of the four directions: north,south,east and west. Let S equal to the east-west position and T the north-south position after three steps. > > > Question:Define the joint PMF of S and T.. I ...
2020/02/20
[ "https://math.stackexchange.com/questions/3553432", "https://math.stackexchange.com", "https://math.stackexchange.com/users/750914/" ]
Hint: \begin{eqnarray\*} \left( 1- \frac{1}{n^2} \right)^n = 1+ n \left( - \frac{1}{n^2} \right) + \binom{n}{2} \left( - \frac{1}{n^2} \right)^2+ \cdots \end{eqnarray\*}
If you want a neat proof, use the fact that $\left(1-\frac{1}{n}\right)^n$ is an increasing sequence, and that $$\left(1-\frac{1}{n}\right)\left(1+\frac{1}{n}\right) = \left(1-\frac{1}{n^2}\right).$$ We have that for some $n$: $$\left[\left(1-\frac{1}{n}\right)^n\left(1+\frac{1}{n}\right)^n\right]^n = \left(1-\frac{1}...
3,553,432
> > A particle starts at $(0,0)$ and moves in one-unit independent steps with equal probabilities of $\frac{1}{4}$ in each of the four directions: north,south,east and west. Let S equal to the east-west position and T the north-south position after three steps. > > > Question:Define the joint PMF of S and T.. I ...
2020/02/20
[ "https://math.stackexchange.com/questions/3553432", "https://math.stackexchange.com", "https://math.stackexchange.com/users/750914/" ]
Hint: \begin{eqnarray\*} \left( 1- \frac{1}{n^2} \right)^n = 1+ n \left( - \frac{1}{n^2} \right) + \binom{n}{2} \left( - \frac{1}{n^2} \right)^2+ \cdots \end{eqnarray\*}
Consider $$a\_n=\left(1-\frac{1}{n}\right)^n \left(1+\frac{1}{n}\right)^n=\left(1-\frac{1}{n^2}\right)^n\implies \log(a\_n)=n \log\left(1-\frac{1}{n^2}\right)$$ So, by Taylor $$\log(a\_n)=n\left(-\frac{1}{n^2}-\frac{1}{2 n^4}-\frac{1}{3 n^6}+O\left(\frac{1}{n^8}\right)\right)=-\frac{1}{n}-\frac{1}{2 n^3}-\frac{1}{3 n...
3,553,432
> > A particle starts at $(0,0)$ and moves in one-unit independent steps with equal probabilities of $\frac{1}{4}$ in each of the four directions: north,south,east and west. Let S equal to the east-west position and T the north-south position after three steps. > > > Question:Define the joint PMF of S and T.. I ...
2020/02/20
[ "https://math.stackexchange.com/questions/3553432", "https://math.stackexchange.com", "https://math.stackexchange.com/users/750914/" ]
Note that, for $n \gt 1$, $$\frac{1}{1 - \frac{1}{n}} = \frac{n}{n - 1} = 1 + \frac{1}{n - 1} \tag{1}\label{eq1A}$$ Using \eqref{eq1A}, for $n \gt 1$, multiplying both sides of your proposed inequality by $\left(\frac{1}{1 - \frac{1}{n}}\right)^n$ gives $$\left(1-\frac{1}{n}\right)^n \left(1+\frac{1}{n}\right)^n \ge...
If you want a neat proof, use the fact that $\left(1-\frac{1}{n}\right)^n$ is an increasing sequence, and that $$\left(1-\frac{1}{n}\right)\left(1+\frac{1}{n}\right) = \left(1-\frac{1}{n^2}\right).$$ We have that for some $n$: $$\left[\left(1-\frac{1}{n}\right)^n\left(1+\frac{1}{n}\right)^n\right]^n = \left(1-\frac{1}...
3,553,432
> > A particle starts at $(0,0)$ and moves in one-unit independent steps with equal probabilities of $\frac{1}{4}$ in each of the four directions: north,south,east and west. Let S equal to the east-west position and T the north-south position after three steps. > > > Question:Define the joint PMF of S and T.. I ...
2020/02/20
[ "https://math.stackexchange.com/questions/3553432", "https://math.stackexchange.com", "https://math.stackexchange.com/users/750914/" ]
Note that, for $n \gt 1$, $$\frac{1}{1 - \frac{1}{n}} = \frac{n}{n - 1} = 1 + \frac{1}{n - 1} \tag{1}\label{eq1A}$$ Using \eqref{eq1A}, for $n \gt 1$, multiplying both sides of your proposed inequality by $\left(\frac{1}{1 - \frac{1}{n}}\right)^n$ gives $$\left(1-\frac{1}{n}\right)^n \left(1+\frac{1}{n}\right)^n \ge...
Consider $$a\_n=\left(1-\frac{1}{n}\right)^n \left(1+\frac{1}{n}\right)^n=\left(1-\frac{1}{n^2}\right)^n\implies \log(a\_n)=n \log\left(1-\frac{1}{n^2}\right)$$ So, by Taylor $$\log(a\_n)=n\left(-\frac{1}{n^2}-\frac{1}{2 n^4}-\frac{1}{3 n^6}+O\left(\frac{1}{n^8}\right)\right)=-\frac{1}{n}-\frac{1}{2 n^3}-\frac{1}{3 n...
14,511,874
I have a list `[a,b,c,d,e]` and an initial value `u` (obviously `a,b,c,d,e` represent values). I want to apply a function to `e` and `u`, let's say `f(e,u)`. I then want to apply the function `f(d, f(e, u))` and then `f(c, f(d, f(e, u)))` etc. I have looked at "iterate", but I cannot work out how to apply iterate to ea...
2013/01/24
[ "https://Stackoverflow.com/questions/14511874", "https://Stackoverflow.com", "https://Stackoverflow.com/users/711601/" ]
The function you describe is called a "[fold](http://en.wikipedia.org/wiki/Fold_%28higher-order_function%29)", in this case a "right fold" because it is applied from right to left. It is implemented in the Prelude as the [`foldr`](http://hackage.haskell.org/packages/archive/base/latest/doc/html/Prelude.html#v%3afoldr) ...
Right fold looks good. ``` foo :: (a -> b -> b) -> b -> [a] -> b foo f u xs = foldr (\x acc -> f x acc) u xs ``` I find that when learning a language one often can have the question "Is there an easier way to do this?" The answer is almost always yes.
14,511,874
I have a list `[a,b,c,d,e]` and an initial value `u` (obviously `a,b,c,d,e` represent values). I want to apply a function to `e` and `u`, let's say `f(e,u)`. I then want to apply the function `f(d, f(e, u))` and then `f(c, f(d, f(e, u)))` etc. I have looked at "iterate", but I cannot work out how to apply iterate to ea...
2013/01/24
[ "https://Stackoverflow.com/questions/14511874", "https://Stackoverflow.com", "https://Stackoverflow.com/users/711601/" ]
The function you describe is called a "[fold](http://en.wikipedia.org/wiki/Fold_%28higher-order_function%29)", in this case a "right fold" because it is applied from right to left. It is implemented in the Prelude as the [`foldr`](http://hackage.haskell.org/packages/archive/base/latest/doc/html/Prelude.html#v%3afoldr) ...
Good job, you've discovered `foldr` on your own! (I hope that doesn't sound mocking or anything, it's not meant that way; most people find folds unnatural and have to think really hard to understand it!) The way I would suggest you handle these situations is to try writing the function you want on your own, and figuri...
14,511,874
I have a list `[a,b,c,d,e]` and an initial value `u` (obviously `a,b,c,d,e` represent values). I want to apply a function to `e` and `u`, let's say `f(e,u)`. I then want to apply the function `f(d, f(e, u))` and then `f(c, f(d, f(e, u)))` etc. I have looked at "iterate", but I cannot work out how to apply iterate to ea...
2013/01/24
[ "https://Stackoverflow.com/questions/14511874", "https://Stackoverflow.com", "https://Stackoverflow.com/users/711601/" ]
You want `foldr :: (a -> b -> b) -> b -> [a] -> b`. Which is the general fold of the list data structure. Think of it as replacing all the `(:)` and `[]` constructors in the list by the two supplied arguments. For example, if we were to sum the numbers of the list `[1, 2, 3]`, constructed as `1 : (2 : (3 : []))`, we c...
Right fold looks good. ``` foo :: (a -> b -> b) -> b -> [a] -> b foo f u xs = foldr (\x acc -> f x acc) u xs ``` I find that when learning a language one often can have the question "Is there an easier way to do this?" The answer is almost always yes.
14,511,874
I have a list `[a,b,c,d,e]` and an initial value `u` (obviously `a,b,c,d,e` represent values). I want to apply a function to `e` and `u`, let's say `f(e,u)`. I then want to apply the function `f(d, f(e, u))` and then `f(c, f(d, f(e, u)))` etc. I have looked at "iterate", but I cannot work out how to apply iterate to ea...
2013/01/24
[ "https://Stackoverflow.com/questions/14511874", "https://Stackoverflow.com", "https://Stackoverflow.com/users/711601/" ]
You want `foldr :: (a -> b -> b) -> b -> [a] -> b`. Which is the general fold of the list data structure. Think of it as replacing all the `(:)` and `[]` constructors in the list by the two supplied arguments. For example, if we were to sum the numbers of the list `[1, 2, 3]`, constructed as `1 : (2 : (3 : []))`, we c...
Good job, you've discovered `foldr` on your own! (I hope that doesn't sound mocking or anything, it's not meant that way; most people find folds unnatural and have to think really hard to understand it!) The way I would suggest you handle these situations is to try writing the function you want on your own, and figuri...
1,088,069
What i know is the following: Upon start-up, the BIOS goes through the following sequence: 1.Power-on self-test (POST) 2.Detect the video card’s (chip’s) BIOS and execute its code to initialize the video hardware. 3.Detect any other device BIOSes and invoke their initialize functions 4.Display the BIOS start...
2016/06/11
[ "https://superuser.com/questions/1088069", "https://superuser.com", "https://superuser.com/users/605114/" ]
As mentioned in the post above, the BIOS simply gives control to the bootloader by executing a jump instruction to 0x7C00. A non bootable device may have the INT 18 instruction (0xCD 0x18) in its first two bytes (and the 55aa at bytes 511, 512), which would then simply cause the BIOS to get to the next device in the ...
Since you mentioned 0x7C00, I'll focus on MBR booting (GPT is a different deal). As you said, once BIOS determines that a device is bootable (i.e. has 0x55AA as the last two bytes of the first sector), it reads that first sector from the disk into and loads it into memory starting at 0x7C00. Once it issues the jump in...
9,299,901
I will soon be writing a native iPhone app for my web site. The web site is already mobile optimised so could potentially just sit in a `UIWebView`. How does the Facebook app work? Does it do something similar? If I did use a `UIWebView` then how would I store user credentials so they don't have to log in every time a...
2012/02/15
[ "https://Stackoverflow.com/questions/9299901", "https://Stackoverflow.com", "https://Stackoverflow.com/users/94278/" ]
The facebook app is going to be a native app. It is different from the mobile website. There are two things you can do here. If you're going to make your native app just a UIWebView then don't bother! You can have an apple icon embedded in your website which will show if a user bookmarks your website on their home scr...
I would take a look at PhoneGap, you can get access to native device features through javascript <http://phonegap.com/>
9,455,129
I've got a FrameLayout which I want to grow as time continues. I've implemented a Runnable-Interface. ``` public void run() { time_value++; FrameLayout fl_dateTime = (FrameLayout)findViewById(R.id.game_DateTime); LayoutParams lp_fl_dateTime = fl_dateTime.getLayoutParams(); lp_fl_dateTime.width =...
2012/02/26
[ "https://Stackoverflow.com/questions/9455129", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1234088/" ]
You need to set the layout params back after modifying them. [`View#setLayoutParams(ViewGroup.LayoutParams lp)`](http://developer.android.com/reference/android/view/View.html#setLayoutParams%28android.view.ViewGroup.LayoutParams%29)
I was able to do this by setting the initial size of the frame to 0dp and then just setting the minWidth to whatever I wanted. ``` <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="0dp" android:layout_height="fill_...
16,708,533
i m trying to serialize an object that holds entitycollection in it. i can do simple serialization using ``` public string Serialize<T>(T item) { XmlSerializer mySerializer = new XmlSerializer(typeof(T)); StringWriter sww = new StringWriter(); XmlWriter writer = XmlWriter.Create(s...
2013/05/23
[ "https://Stackoverflow.com/questions/16708533", "https://Stackoverflow.com", "https://Stackoverflow.com/users/751959/" ]
Try this, ``` $(document).ready(function() { var data = '<?php echo isset($array) ? $array : json_encode(array("nothing in array data"));?>'; // if $array not set then it should return {"0":"nothing in array data"} alert(data); }); ```
you forgot to Quote Value of var data use this ``` var data = '<?php echo $array;?>'; ```
16,708,533
i m trying to serialize an object that holds entitycollection in it. i can do simple serialization using ``` public string Serialize<T>(T item) { XmlSerializer mySerializer = new XmlSerializer(typeof(T)); StringWriter sww = new StringWriter(); XmlWriter writer = XmlWriter.Create(s...
2013/05/23
[ "https://Stackoverflow.com/questions/16708533", "https://Stackoverflow.com", "https://Stackoverflow.com/users/751959/" ]
You are creating the array **in a completely different file!** The two variables are not in the same scope. What's more, the Javascript file is apparently not interpreted as PHP (and neither should it). So: 1. Javascript complains about the `<?` tag, which it should never see. 2. Even if you solved that, it won't work...
Try this, ``` $(document).ready(function() { var data = '<?php echo isset($array) ? $array : json_encode(array("nothing in array data"));?>'; // if $array not set then it should return {"0":"nothing in array data"} alert(data); }); ```
16,708,533
i m trying to serialize an object that holds entitycollection in it. i can do simple serialization using ``` public string Serialize<T>(T item) { XmlSerializer mySerializer = new XmlSerializer(typeof(T)); StringWriter sww = new StringWriter(); XmlWriter writer = XmlWriter.Create(s...
2013/05/23
[ "https://Stackoverflow.com/questions/16708533", "https://Stackoverflow.com", "https://Stackoverflow.com/users/751959/" ]
Your variable is in a different scope since you're not using the PHP `include` function. Here's the easiest way I know to achieve what you want: * Rename your JavaScript file to `main.js` * Since you cannot use PHP in a `.js` file, declare your JavaScript variable before you call your script, like this: ``` <script t...
Try this, ``` $(document).ready(function() { var data = '<?php echo isset($array) ? $array : json_encode(array("nothing in array data"));?>'; // if $array not set then it should return {"0":"nothing in array data"} alert(data); }); ```
16,708,533
i m trying to serialize an object that holds entitycollection in it. i can do simple serialization using ``` public string Serialize<T>(T item) { XmlSerializer mySerializer = new XmlSerializer(typeof(T)); StringWriter sww = new StringWriter(); XmlWriter writer = XmlWriter.Create(s...
2013/05/23
[ "https://Stackoverflow.com/questions/16708533", "https://Stackoverflow.com", "https://Stackoverflow.com/users/751959/" ]
You are creating the array **in a completely different file!** The two variables are not in the same scope. What's more, the Javascript file is apparently not interpreted as PHP (and neither should it). So: 1. Javascript complains about the `<?` tag, which it should never see. 2. Even if you solved that, it won't work...
you forgot to Quote Value of var data use this ``` var data = '<?php echo $array;?>'; ```
16,708,533
i m trying to serialize an object that holds entitycollection in it. i can do simple serialization using ``` public string Serialize<T>(T item) { XmlSerializer mySerializer = new XmlSerializer(typeof(T)); StringWriter sww = new StringWriter(); XmlWriter writer = XmlWriter.Create(s...
2013/05/23
[ "https://Stackoverflow.com/questions/16708533", "https://Stackoverflow.com", "https://Stackoverflow.com/users/751959/" ]
Your variable is in a different scope since you're not using the PHP `include` function. Here's the easiest way I know to achieve what you want: * Rename your JavaScript file to `main.js` * Since you cannot use PHP in a `.js` file, declare your JavaScript variable before you call your script, like this: ``` <script t...
you forgot to Quote Value of var data use this ``` var data = '<?php echo $array;?>'; ```
16,708,533
i m trying to serialize an object that holds entitycollection in it. i can do simple serialization using ``` public string Serialize<T>(T item) { XmlSerializer mySerializer = new XmlSerializer(typeof(T)); StringWriter sww = new StringWriter(); XmlWriter writer = XmlWriter.Create(s...
2013/05/23
[ "https://Stackoverflow.com/questions/16708533", "https://Stackoverflow.com", "https://Stackoverflow.com/users/751959/" ]
You are creating the array **in a completely different file!** The two variables are not in the same scope. What's more, the Javascript file is apparently not interpreted as PHP (and neither should it). So: 1. Javascript complains about the `<?` tag, which it should never see. 2. Even if you solved that, it won't work...
Your variable is in a different scope since you're not using the PHP `include` function. Here's the easiest way I know to achieve what you want: * Rename your JavaScript file to `main.js` * Since you cannot use PHP in a `.js` file, declare your JavaScript variable before you call your script, like this: ``` <script t...
55,228,182
How to compare items in two observables and then filter based on matches in RxJava2? I'm attempting to compare two observables. Both consist of Server objects with an id and a server\_address. The first observable represents the current server objects peristed in a database. `Observable1 = [{"id":1, "server_address":...
2019/03/18
[ "https://Stackoverflow.com/questions/55228182", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1781538/" ]
Go slices are implemented as a struct: `src/runtime/slice.go`: ``` type slice struct { array unsafe.Pointer len int cap int } ``` You are assigning/copying the slice struct, which does not copy the underlying array, only its pointer. --- A simple illustration: ``` package main import ( "fmt"...
1. No Slice is just a pointer to memory + `len` and `cap` see: [Why can not I duplicate a slice with `copy()` in Golang?](https://stackoverflow.com/questions/30182538/why-can-not-i-duplicate-a-slice-with-copy-in-golang) --- 2. Like so: ``` package main import ( "fmt" ) func main() { bigBuf := []byte{1,...
41,096,710
I have received this in a name field (so it should be a person's name) Игорќ What could that decode to? Is it UTF-8? What language does that translate to? Russian? If you can give me a hint or maybe links to websites that explain what meaningful letters I should get out of that would be helpful, thank you :)
2016/12/12
[ "https://Stackoverflow.com/questions/41096710", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3672795/" ]
I don't think you're including your scripts in the right order. When you loaded from the CDN, your order looked something like this: ``` <script src="http://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.2/summernote.js"></script> <script src="javascript/common.js" type="text/javascript"></script> ``` . . . which is...
For me, I wanted to use summer note with bootstrap4, I copied the below code from the official documentation but it didn't work, I realized afterwards that I was embedding a newer bootstrap version at the beginning of my page (I was reaching out to some bootstrap files located at the assets), I removed that line and ev...
34,893,166
I want to create a multidimensional array like; ``` $cars = array("brand"=>"toyota","type"=>"suv","color"=>"white"); ``` I have a string like; ``` $text = "brand => toyota,type => suv, color => white"; ``` How can I create the previous array from this text?
2016/01/20
[ "https://Stackoverflow.com/questions/34893166", "https://Stackoverflow.com", "https://Stackoverflow.com/users/484082/" ]
It is good to create a small function to do this, so that we can use it in future. Here is my function to do this: ``` function customArray($text) { $returnArray = array(); $explode1 = explode(',',$text); foreach ($explode1 as $key => $value) { $tempArray = explode('=>',$value); $returnArray[trim($t...
You can use like that: ``` // your string $string = "brand => toyota,type => suv, color => white"; // explode with "," $explodedArr = explode(",",$string); $newArr = array(); foreach ($explodedArr as $value) { // explode value with "=>" $explodedInner = explode("=>",$value); // also remove the white spac...
34,893,166
I want to create a multidimensional array like; ``` $cars = array("brand"=>"toyota","type"=>"suv","color"=>"white"); ``` I have a string like; ``` $text = "brand => toyota,type => suv, color => white"; ``` How can I create the previous array from this text?
2016/01/20
[ "https://Stackoverflow.com/questions/34893166", "https://Stackoverflow.com", "https://Stackoverflow.com/users/484082/" ]
This code will fulfill your requirements : ``` $text = "brand => toyota,type => suv, color => white"; $cars = array(); $str_explode = explode(",",$text); $count = count($str_explode); for($i=0;$i<$count;$i++){ $expl = explode("=>",$str_explode[$i]); $cars[$expl[0]] = $expl[1]; } print_r($cars); ``` **Output :** ...
Just another solution using [array\_walk](http://php.net/manual/en/function.array-walk.php) and [Anonymous function](http://php.net/manual/en/functions.anonymous.php) ``` $text = "brand => toyota,type => suv, color => white"; $cars = array(); $kv = explode(',',$text); array_walk($kv, function ($item) use (&$cars){ ...
34,893,166
I want to create a multidimensional array like; ``` $cars = array("brand"=>"toyota","type"=>"suv","color"=>"white"); ``` I have a string like; ``` $text = "brand => toyota,type => suv, color => white"; ``` How can I create the previous array from this text?
2016/01/20
[ "https://Stackoverflow.com/questions/34893166", "https://Stackoverflow.com", "https://Stackoverflow.com/users/484082/" ]
You can use like that: ``` // your string $string = "brand => toyota,type => suv, color => white"; // explode with "," $explodedArr = explode(",",$string); $newArr = array(); foreach ($explodedArr as $value) { // explode value with "=>" $explodedInner = explode("=>",$value); // also remove the white spac...
HI you can do this way ``` <?php $text = "brand => toyota,type => suv, color => white"; $cars = array(); while (strpos($text,'=>')!== false) { $p=strpos($text,'=>'); if ($p!=false) { $i=trim(substr($text,0,$p)); $text=substr($text,$p+2); $p=...
34,893,166
I want to create a multidimensional array like; ``` $cars = array("brand"=>"toyota","type"=>"suv","color"=>"white"); ``` I have a string like; ``` $text = "brand => toyota,type => suv, color => white"; ``` How can I create the previous array from this text?
2016/01/20
[ "https://Stackoverflow.com/questions/34893166", "https://Stackoverflow.com", "https://Stackoverflow.com/users/484082/" ]
This just requires you to double explode: ``` $text = "brand => toyota,type => suv, color => white"; $item = explode(",", $text); $data = array(); foreach($item as $elem): list($key, $value) = explode("=>", $elem); $data[trim($key)] = trim($value); endforeach; ``` *Note: the use of `trim()` on the `$key` & ...
``` <?php $text = "brand => toyota,type => suv, color => white"; $array1 = explode(',', $text); $newArray = array(); for ($i=0; $i < count($array1); $i++) { $array2=explode('=>', $array1[$i]); $newArray[$array2[0]] = $array2[1]; } echo "<pre>"; print_r($newArray);exit; ?> ```
34,893,166
I want to create a multidimensional array like; ``` $cars = array("brand"=>"toyota","type"=>"suv","color"=>"white"); ``` I have a string like; ``` $text = "brand => toyota,type => suv, color => white"; ``` How can I create the previous array from this text?
2016/01/20
[ "https://Stackoverflow.com/questions/34893166", "https://Stackoverflow.com", "https://Stackoverflow.com/users/484082/" ]
It is good to create a small function to do this, so that we can use it in future. Here is my function to do this: ``` function customArray($text) { $returnArray = array(); $explode1 = explode(',',$text); foreach ($explode1 as $key => $value) { $tempArray = explode('=>',$value); $returnArray[trim($t...
HI you can do this way ``` <?php $text = "brand => toyota,type => suv, color => white"; $cars = array(); while (strpos($text,'=>')!== false) { $p=strpos($text,'=>'); if ($p!=false) { $i=trim(substr($text,0,$p)); $text=substr($text,$p+2); $p=...
34,893,166
I want to create a multidimensional array like; ``` $cars = array("brand"=>"toyota","type"=>"suv","color"=>"white"); ``` I have a string like; ``` $text = "brand => toyota,type => suv, color => white"; ``` How can I create the previous array from this text?
2016/01/20
[ "https://Stackoverflow.com/questions/34893166", "https://Stackoverflow.com", "https://Stackoverflow.com/users/484082/" ]
This just requires you to double explode: ``` $text = "brand => toyota,type => suv, color => white"; $item = explode(",", $text); $data = array(); foreach($item as $elem): list($key, $value) = explode("=>", $elem); $data[trim($key)] = trim($value); endforeach; ``` *Note: the use of `trim()` on the `$key` & ...
Use this code: ``` $exploded_text = explode(",", $text); $new_array = array(); for($loop=0; $loop<count($exploded_text); $loop++){ $explode = explode("=>", $exploded_text[$loop]); $new_array[trim($explode[0])] = trim($explode[1]); } ```
34,893,166
I want to create a multidimensional array like; ``` $cars = array("brand"=>"toyota","type"=>"suv","color"=>"white"); ``` I have a string like; ``` $text = "brand => toyota,type => suv, color => white"; ``` How can I create the previous array from this text?
2016/01/20
[ "https://Stackoverflow.com/questions/34893166", "https://Stackoverflow.com", "https://Stackoverflow.com/users/484082/" ]
You can use like that: ``` // your string $string = "brand => toyota,type => suv, color => white"; // explode with "," $explodedArr = explode(",",$string); $newArr = array(); foreach ($explodedArr as $value) { // explode value with "=>" $explodedInner = explode("=>",$value); // also remove the white spac...
Use this code: ``` $exploded_text = explode(",", $text); $new_array = array(); for($loop=0; $loop<count($exploded_text); $loop++){ $explode = explode("=>", $exploded_text[$loop]); $new_array[trim($explode[0])] = trim($explode[1]); } ```
34,893,166
I want to create a multidimensional array like; ``` $cars = array("brand"=>"toyota","type"=>"suv","color"=>"white"); ``` I have a string like; ``` $text = "brand => toyota,type => suv, color => white"; ``` How can I create the previous array from this text?
2016/01/20
[ "https://Stackoverflow.com/questions/34893166", "https://Stackoverflow.com", "https://Stackoverflow.com/users/484082/" ]
Just another solution using [array\_walk](http://php.net/manual/en/function.array-walk.php) and [Anonymous function](http://php.net/manual/en/functions.anonymous.php) ``` $text = "brand => toyota,type => suv, color => white"; $cars = array(); $kv = explode(',',$text); array_walk($kv, function ($item) use (&$cars){ ...
Assuming the format specified following code should work. ``` <?php $text = "brand => toyota,type => suv, color => white"; $text = explode(',', $text); $arr = array(); foreach (array_chunk($text, 1) as $chk) { $temp = explode('=>', $chk[0]); $arr[trim($temp[0])] = trim($temp[1]); } echo "<pre>";print_r($arr);echo...
34,893,166
I want to create a multidimensional array like; ``` $cars = array("brand"=>"toyota","type"=>"suv","color"=>"white"); ``` I have a string like; ``` $text = "brand => toyota,type => suv, color => white"; ``` How can I create the previous array from this text?
2016/01/20
[ "https://Stackoverflow.com/questions/34893166", "https://Stackoverflow.com", "https://Stackoverflow.com/users/484082/" ]
This code will fulfill your requirements : ``` $text = "brand => toyota,type => suv, color => white"; $cars = array(); $str_explode = explode(",",$text); $count = count($str_explode); for($i=0;$i<$count;$i++){ $expl = explode("=>",$str_explode[$i]); $cars[$expl[0]] = $expl[1]; } print_r($cars); ``` **Output :** ...
Use this code: ``` $exploded_text = explode(",", $text); $new_array = array(); for($loop=0; $loop<count($exploded_text); $loop++){ $explode = explode("=>", $exploded_text[$loop]); $new_array[trim($explode[0])] = trim($explode[1]); } ```
34,893,166
I want to create a multidimensional array like; ``` $cars = array("brand"=>"toyota","type"=>"suv","color"=>"white"); ``` I have a string like; ``` $text = "brand => toyota,type => suv, color => white"; ``` How can I create the previous array from this text?
2016/01/20
[ "https://Stackoverflow.com/questions/34893166", "https://Stackoverflow.com", "https://Stackoverflow.com/users/484082/" ]
This just requires you to double explode: ``` $text = "brand => toyota,type => suv, color => white"; $item = explode(",", $text); $data = array(); foreach($item as $elem): list($key, $value) = explode("=>", $elem); $data[trim($key)] = trim($value); endforeach; ``` *Note: the use of `trim()` on the `$key` & ...
Just another solution using [array\_walk](http://php.net/manual/en/function.array-walk.php) and [Anonymous function](http://php.net/manual/en/functions.anonymous.php) ``` $text = "brand => toyota,type => suv, color => white"; $cars = array(); $kv = explode(',',$text); array_walk($kv, function ($item) use (&$cars){ ...
2,133,017
Given in a triangle $ABC$, $A+B=135^\circ$ ,i have to find value of $\sin^2A+\sin^2B$ **ATTEMPT** i write as $\sin^2A+\sin^2(135^\circ-A)$ $\sin^2A+\sin^2(45+A)$ $1-cos^2(A)+\sin^2(45+A)$ $1 - (cos(45+2A)(cos45))$ $1- \frac{1}{\sqrt2}cos(45+2A)$ Now $0 <A< 135$\ $0 <2A< 270$ $45 <2A+45< 315$ $\cos45 <cos(2...
2017/02/07
[ "https://math.stackexchange.com/questions/2133017", "https://math.stackexchange.com", "https://math.stackexchange.com/users/225132/" ]
Your $$Q=1-{1\over\sqrt{2}}\cos\left(2A+{\pi\over4}\right)$$ is correct. But in the formulation of the problem there were no further restrictions on $A$ and $B$. If $A$ and $B$ are supposed to be angles of a triangle then $0<A<{3\pi\over4}$, and $\phi:=2A+{\pi\over4}$ satisfies ${\pi\over4}<\phi<{7\pi\over4}$, hence $-...
So you have $\sin^2A+\sin^2(135^\circ-A)=\sin^2A+\sin^2(45+A)$ At maximum and minimum values of this expression, we have $$\frac{\text{d}}{\text{d}A}(\sin^2A+\sin^2(45^{\circ}+A))=0$$ $$2\sin(A)\cos(A)+2\sin(A+45^{\circ})\cos(A+45^{\circ})=0$$ $$\sin(2A)+\sin(2A+90^{\circ})=0$$ $$\sin(2A)+\cos(2A)=0$$ $$\sqrt{2}\sin(2...
52,647
In One Punch Man, taking out Saitama and Tatsumaki (who is very powerful due to her esper powers and not her physical strength), who is the strongest hero physically? Bang and Bomb might be very powerful, but they rely on martial art techniques and hitting vital points, so I'm not sure if all their power could be attri...
2019/04/24
[ "https://anime.stackexchange.com/questions/52647", "https://anime.stackexchange.com", "https://anime.stackexchange.com/users/3028/" ]
There doesn't seem to be a lot of information regarding this, but we have at the least this premise about the Potara Fusion technique: At the end of the time limit, the two fused together will be returned to their original selves, so long as neither of those fused was a Kai. We have this as a premise because Goku and V...
In the Dragon Ball Z anime, fusion of two characters do NOT result in either characters learning each other's moves and abilities. Example: When Gotenks ran out of time, neither Gotenks or Trunks knew each other's moves. Hope this answers your question.
10,726
I'm using Spacemacs. I noticed that in `help-mode`, `q` quits, which is exactly what I want. However, in certain other modes, `customize-mode`, for example, `q` is bound to `evil-record-macro`. (I set it to start in normal state rather than in emacs state because I like the vim navigation keybindings.) I tried `(evil-d...
2015/04/16
[ "https://emacs.stackexchange.com/questions/10726", "https://emacs.stackexchange.com", "https://emacs.stackexchange.com/users/6761/" ]
[Customize](http://www.gnu.org/software/emacs/manual/html_node/emacs/Easy-Customization.html) appears to be [autoloaded](http://www.gnu.org/software/emacs/manual/html_node/elisp/Autoload.html), so Emacs won't know about `custom-mode-map` until after you run `customize`. The following should rebind `q` to run `test` in ...
Customize the mode to use `motion` state instead of `normal` state to keep motion keybindings while leaving out `q` for quitting: ``` (evil-set-initial-state 'Custom-mode 'motion) ```
24,375,220
I'm adapting Lesson 5 from [here](https://github.com/xtk/X#readme), which takes a skull vtk object and displays it rotating in a circle. I want to change it so instead of accessing the `.vtk` object at `http://x.babymri.org/?skull.vtk`, it reads from a local file. Is this possible? I downloaded an exact copy of the sku...
2014/06/23
[ "https://Stackoverflow.com/questions/24375220", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3175137/" ]
Can you share some code? I think the easiest is to run a local server on your machine: [Set up Python simpleHTTPserver on Windows](https://stackoverflow.com/questions/17351016/set-up-python-simplehttpserver-on-windows) If your project directory contains the following files: ``` Project index.html file.vtk ...
The easyest / lazyest way to do that : 1-Copy downloadedSkull.nrrd and downloadedSkull.vtk in the root directory (with index.html) 2- skull.file = 'downloadedSkull.vtk'; 3-Use Firefox rather than Chrome : Firefox accept to open local file, chrome need a local server
13,355,150
I am creating a graphing application that will display several graphs. The graphs will need access to some global data and some graph-specific data. For example, I want the colors consistent, so that would be global, but the specific graphs can have different grid spacing (per graph). I created a "master object" with ...
2012/11/13
[ "https://Stackoverflow.com/questions/13355150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/891856/" ]
One common approach to have a single object instance shared among many objects is the Singleton Pattern. <http://en.wikipedia.org/wiki/Singleton_pattern> With the Singleton Pattern, any object can request the singleton object and will be returned the same singleton object instance as any other object that requests th...
Why use inheritance at all? Why not just have a GlobalGraphSettings object which you pass to all of your Graph objects, then you can just do ``` MyColor = Graph.GlobalSettings.Color; ```
67,390,075
Sorry for the confusing question. I have a list called switch that contains randomly chosen numbers between 10 and 30. I am trying to use these numbers in the following function (this is just the start): ``` def rewardfunc(y, switch): left_reward = [] right_reward = [] for x in range(switch[0]): left_re...
2021/05/04
[ "https://Stackoverflow.com/questions/67390075", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15749189/" ]
``` for i, x in enumerate(switch): for _ in range(x): if i % 2 == 0: left_reward.append(prob(y)) right_reward.append(prob(1-y)) else: left_reward.append(prob(1-y)) right_reward.append(prob(y)) ```
On each iteration, just swap references to `left_reward` and `right_reward`. Something like ``` def rewardfunc(y, switch): l = left_reward = [] r = right_reward = [] for x1 in switch: for x2 in x1: l.append(prob(y)) r.append(prob(1-y)) l, r = r, l ```
67,390,075
Sorry for the confusing question. I have a list called switch that contains randomly chosen numbers between 10 and 30. I am trying to use these numbers in the following function (this is just the start): ``` def rewardfunc(y, switch): left_reward = [] right_reward = [] for x in range(switch[0]): left_re...
2021/05/04
[ "https://Stackoverflow.com/questions/67390075", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15749189/" ]
``` for i, x in enumerate(switch): for _ in range(x): if i % 2 == 0: left_reward.append(prob(y)) right_reward.append(prob(1-y)) else: left_reward.append(prob(1-y)) right_reward.append(prob(y)) ```
If you are a fan of comprehensions: ``` left_reward = [prob(1-y if i % 2 else y) for i in range(len(switch))] right_reward = [prob(y if i % 2 else 1-y) for i in range(len(switch))] ``` If `prob(e)` is expensive at all then consider precalculating: ``` prob_y, prob_inv_y = prob(y), prob(1-y) left_reward = [prob_inv_...
29,561,797
I have a string ``` Hobbies#14285723739878005#reading#Reading ``` I need the count of number of occurrence of '#' in the string. How to get that?
2015/04/10
[ "https://Stackoverflow.com/questions/29561797", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4324808/" ]
try this code: ``` <?php echo substr_count("Hobbies#14285723739878005#reading#Reading","#"); ?> ``` **Output:-** ``` 3 ``` For your reference [Click Here](http://codepad.viper-7.com/Ja7s4k)
substr\_count() should do what you need: <http://www.w3schools.com/php/func_string_substr_count.asp>
33,302,012
This code is practice code for pointers. But I am not understanding the `(int**)&p;` means in this code. ``` void fun(void *p); int i; int main() { void *vptr; vptr = &i; fun(vptr); return 0; } void fun(void *p) { int **q; q = (int**)&p; printf("%d\n", **q); } ``` Please elaborate how it is eva...
2015/10/23
[ "https://Stackoverflow.com/questions/33302012", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5406870/" ]
There are many options. One way is using `substr` to get the first 4 character elements from 'Date' column (assuming that we are not going back to > 1000 ) ``` df1$Year <- substr(df1$Date, 1,4) ``` Or we match the substring that begins from `-` followed by one or more characters to the end of the string, replace wi...
If you make `date` a Date variable, `format` can pull out the year quite easily. ``` D <- data.frame(service = rep("disconnected", 3), date = c("2013-01-14", "2013-03-15", "2012-02-24")) D$year <- format(as.Date(D$date), format = "%Y") D service date year 1 disconnected 2013-01-14 2013 ...
228,588
Magento ver. 2.2.3 Seems today fixer.io stopped working. It was the only service that still works for currency rates. If I try to reach the url from web browser I get this ``` 0 "#################################################################################################################################" 1 "#...
2018/06/05
[ "https://magento.stackexchange.com/questions/228588", "https://magento.stackexchange.com", "https://magento.stackexchange.com/users/15051/" ]
The Free Currency Converter API module: > > app/code/MyCompany/FreeCurrencyConverter/etc/module.xml > > > ``` <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> <module name="MyCompany_FreeCurrencyCon...
It seems we need to subscribe Basic **$10/month** plan because Fixer new free plan offers only Euro base currency. If you purchase $10/month plan, you can fix this issue editing: > > [root]/vendor/magento/module-directory/Model/Currency/Import/FixerIo.php > > > line 16 replace ``` const CURRENCY_CONVERTER_URL = ...
228,588
Magento ver. 2.2.3 Seems today fixer.io stopped working. It was the only service that still works for currency rates. If I try to reach the url from web browser I get this ``` 0 "#################################################################################################################################" 1 "#...
2018/06/05
[ "https://magento.stackexchange.com/questions/228588", "https://magento.stackexchange.com", "https://magento.stackexchange.com/users/15051/" ]
It seems we need to subscribe Basic **$10/month** plan because Fixer new free plan offers only Euro base currency. If you purchase $10/month plan, you can fix this issue editing: > > [root]/vendor/magento/module-directory/Model/Currency/Import/FixerIo.php > > > line 16 replace ``` const CURRENCY_CONVERTER_URL = ...
To extend on @lizenial's answer: Modifying core code is never a good idea, that's why you can override the original class, though (as far as I know) it requires overriding the entire class as it mostly consists of private methods, which we cannot modify using plugins. > > app/code/[Vendor]/[Module]/etc/di.xml > > ...
228,588
Magento ver. 2.2.3 Seems today fixer.io stopped working. It was the only service that still works for currency rates. If I try to reach the url from web browser I get this ``` 0 "#################################################################################################################################" 1 "#...
2018/06/05
[ "https://magento.stackexchange.com/questions/228588", "https://magento.stackexchange.com", "https://magento.stackexchange.com/users/15051/" ]
It seems we need to subscribe Basic **$10/month** plan because Fixer new free plan offers only Euro base currency. If you purchase $10/month plan, you can fix this issue editing: > > [root]/vendor/magento/module-directory/Model/Currency/Import/FixerIo.php > > > line 16 replace ``` const CURRENCY_CONVERTER_URL = ...
I tried the solution of updating the fixerIo.php file and for the sake of testing I even changed the store base currency to EUR, however, I get the following error after I have amended the code: > > Fatal error: Namespace declaration statement has to be the very first statement or after any declare call in the script...
228,588
Magento ver. 2.2.3 Seems today fixer.io stopped working. It was the only service that still works for currency rates. If I try to reach the url from web browser I get this ``` 0 "#################################################################################################################################" 1 "#...
2018/06/05
[ "https://magento.stackexchange.com/questions/228588", "https://magento.stackexchange.com", "https://magento.stackexchange.com/users/15051/" ]
The Free Currency Converter API module: > > app/code/MyCompany/FreeCurrencyConverter/etc/module.xml > > > ``` <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> <module name="MyCompany_FreeCurrencyCon...
Thanks for the module code! Don't forget the following file to get it all going properly: > > app/code/MyCompany/FreeCurrencyConverter/registration.php > > > ``` <?php \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::MODULE, 'MyCompany_FreeCurr...
228,588
Magento ver. 2.2.3 Seems today fixer.io stopped working. It was the only service that still works for currency rates. If I try to reach the url from web browser I get this ``` 0 "#################################################################################################################################" 1 "#...
2018/06/05
[ "https://magento.stackexchange.com/questions/228588", "https://magento.stackexchange.com", "https://magento.stackexchange.com/users/15051/" ]
The Free Currency Converter API module: > > app/code/MyCompany/FreeCurrencyConverter/etc/module.xml > > > ``` <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> <module name="MyCompany_FreeCurrencyCon...
To extend on @lizenial's answer: Modifying core code is never a good idea, that's why you can override the original class, though (as far as I know) it requires overriding the entire class as it mostly consists of private methods, which we cannot modify using plugins. > > app/code/[Vendor]/[Module]/etc/di.xml > > ...
228,588
Magento ver. 2.2.3 Seems today fixer.io stopped working. It was the only service that still works for currency rates. If I try to reach the url from web browser I get this ``` 0 "#################################################################################################################################" 1 "#...
2018/06/05
[ "https://magento.stackexchange.com/questions/228588", "https://magento.stackexchange.com", "https://magento.stackexchange.com/users/15051/" ]
The Free Currency Converter API module: > > app/code/MyCompany/FreeCurrencyConverter/etc/module.xml > > > ``` <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> <module name="MyCompany_FreeCurrencyCon...
I tried the solution of updating the fixerIo.php file and for the sake of testing I even changed the store base currency to EUR, however, I get the following error after I have amended the code: > > Fatal error: Namespace declaration statement has to be the very first statement or after any declare call in the script...
228,588
Magento ver. 2.2.3 Seems today fixer.io stopped working. It was the only service that still works for currency rates. If I try to reach the url from web browser I get this ``` 0 "#################################################################################################################################" 1 "#...
2018/06/05
[ "https://magento.stackexchange.com/questions/228588", "https://magento.stackexchange.com", "https://magento.stackexchange.com/users/15051/" ]
Thanks for the module code! Don't forget the following file to get it all going properly: > > app/code/MyCompany/FreeCurrencyConverter/registration.php > > > ``` <?php \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::MODULE, 'MyCompany_FreeCurr...
To extend on @lizenial's answer: Modifying core code is never a good idea, that's why you can override the original class, though (as far as I know) it requires overriding the entire class as it mostly consists of private methods, which we cannot modify using plugins. > > app/code/[Vendor]/[Module]/etc/di.xml > > ...
228,588
Magento ver. 2.2.3 Seems today fixer.io stopped working. It was the only service that still works for currency rates. If I try to reach the url from web browser I get this ``` 0 "#################################################################################################################################" 1 "#...
2018/06/05
[ "https://magento.stackexchange.com/questions/228588", "https://magento.stackexchange.com", "https://magento.stackexchange.com/users/15051/" ]
Thanks for the module code! Don't forget the following file to get it all going properly: > > app/code/MyCompany/FreeCurrencyConverter/registration.php > > > ``` <?php \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::MODULE, 'MyCompany_FreeCurr...
I tried the solution of updating the fixerIo.php file and for the sake of testing I even changed the store base currency to EUR, however, I get the following error after I have amended the code: > > Fatal error: Namespace declaration statement has to be the very first statement or after any declare call in the script...
228,588
Magento ver. 2.2.3 Seems today fixer.io stopped working. It was the only service that still works for currency rates. If I try to reach the url from web browser I get this ``` 0 "#################################################################################################################################" 1 "#...
2018/06/05
[ "https://magento.stackexchange.com/questions/228588", "https://magento.stackexchange.com", "https://magento.stackexchange.com/users/15051/" ]
To extend on @lizenial's answer: Modifying core code is never a good idea, that's why you can override the original class, though (as far as I know) it requires overriding the entire class as it mostly consists of private methods, which we cannot modify using plugins. > > app/code/[Vendor]/[Module]/etc/di.xml > > ...
I tried the solution of updating the fixerIo.php file and for the sake of testing I even changed the store base currency to EUR, however, I get the following error after I have amended the code: > > Fatal error: Namespace declaration statement has to be the very first statement or after any declare call in the script...
46,665,143
I have two loopback models: `user` and `backendUser`. One (user) is stored with loopback and the other one (backendUser) is stored on a distant mysql database. They have a relation togerther based on a field `user` has (`backendUserId`) corresponding to the `ID` field of `backendUser` There is a case where I get every...
2017/10/10
[ "https://Stackoverflow.com/questions/46665143", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6468719/" ]
Use the following: ```js { where: { role: 4, include: { relation: "backendUser", scope: { where: { "role": 4 } } } } } ```
```js { where: { // here specific object of query user }, include: [ { relation: 'backendUser', scope: { where: { role: 4, }, }, }, ], } ```
31,241,308
I have an `Activity` which extends `ActionBarActivity`. Whenever I try to create an `AlertDialog` in it, crashes at the the line where dialog is created giving this error ``` java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. ``` But I'm already using `Appcom...
2015/07/06
[ "https://Stackoverflow.com/questions/31241308", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4460846/" ]
It can be resolved by passing. `Activityname.this` in place of `getApplicationContext();` like in your case `alertDialog = new AlertDialog.Builder(MyActivity.this)).create();`
Use AppCompatActivity instead of ActionBarActivity ``` public class MyActivity extends AppCompatActivity ```
31,241,308
I have an `Activity` which extends `ActionBarActivity`. Whenever I try to create an `AlertDialog` in it, crashes at the the line where dialog is created giving this error ``` java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. ``` But I'm already using `Appcom...
2015/07/06
[ "https://Stackoverflow.com/questions/31241308", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4460846/" ]
I couldn't reproduce the same exact error. However, I think that the problem is the context passed to AlertDialog.Builder constructor. In fact, an activity Context should be passed to it. Try replacing this line ``` alertDialog = new AlertDialog.Builder(getApplicationContext()).create(); ``` with t...
Change ``` new AlertDialog.Builder(this) ``` to ``` new AlertDialog.Builder(MainActivity.this) ```
31,241,308
I have an `Activity` which extends `ActionBarActivity`. Whenever I try to create an `AlertDialog` in it, crashes at the the line where dialog is created giving this error ``` java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. ``` But I'm already using `Appcom...
2015/07/06
[ "https://Stackoverflow.com/questions/31241308", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4460846/" ]
If you are using alertDialog in adapter and in OnBindViewHolder() method as shown in below code: ``` @Override public void onBindViewHolder(final UserListAdapter.ViewHolder holder, final int position) { //long click for delete the record holder.itemView.setOnLongClickListener(new View.OnLongClickListener() { @Ove...
Use AppCompatActivity instead of ActionBarActivity ``` public class MyActivity extends AppCompatActivity ```
31,241,308
I have an `Activity` which extends `ActionBarActivity`. Whenever I try to create an `AlertDialog` in it, crashes at the the line where dialog is created giving this error ``` java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. ``` But I'm already using `Appcom...
2015/07/06
[ "https://Stackoverflow.com/questions/31241308", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4460846/" ]
It can be resolved by passing. `Activityname.this` in place of `getApplicationContext();` like in your case `alertDialog = new AlertDialog.Builder(MyActivity.this)).create();`
Add this line to your `<application>` in the `AndroidManifest.xml` file ``` android:theme="@style/Theme.AppCompat.Light" ```
31,241,308
I have an `Activity` which extends `ActionBarActivity`. Whenever I try to create an `AlertDialog` in it, crashes at the the line where dialog is created giving this error ``` java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. ``` But I'm already using `Appcom...
2015/07/06
[ "https://Stackoverflow.com/questions/31241308", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4460846/" ]
I couldn't reproduce the same exact error. However, I think that the problem is the context passed to AlertDialog.Builder constructor. In fact, an activity Context should be passed to it. Try replacing this line ``` alertDialog = new AlertDialog.Builder(getApplicationContext()).create(); ``` with t...
Use AppCompatActivity instead of ActionBarActivity ``` public class MyActivity extends AppCompatActivity ```
31,241,308
I have an `Activity` which extends `ActionBarActivity`. Whenever I try to create an `AlertDialog` in it, crashes at the the line where dialog is created giving this error ``` java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. ``` But I'm already using `Appcom...
2015/07/06
[ "https://Stackoverflow.com/questions/31241308", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4460846/" ]
Change ``` new AlertDialog.Builder(this) ``` to ``` new AlertDialog.Builder(MainActivity.this) ```
Add this line to your `<application>` in the `AndroidManifest.xml` file ``` android:theme="@style/Theme.AppCompat.Light" ```
31,241,308
I have an `Activity` which extends `ActionBarActivity`. Whenever I try to create an `AlertDialog` in it, crashes at the the line where dialog is created giving this error ``` java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. ``` But I'm already using `Appcom...
2015/07/06
[ "https://Stackoverflow.com/questions/31241308", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4460846/" ]
Change ``` new AlertDialog.Builder(this) ``` to ``` new AlertDialog.Builder(MainActivity.this) ```
Use AppCompatActivity instead of ActionBarActivity ``` public class MyActivity extends AppCompatActivity ```
31,241,308
I have an `Activity` which extends `ActionBarActivity`. Whenever I try to create an `AlertDialog` in it, crashes at the the line where dialog is created giving this error ``` java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. ``` But I'm already using `Appcom...
2015/07/06
[ "https://Stackoverflow.com/questions/31241308", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4460846/" ]
If you are using alertDialog in adapter and in OnBindViewHolder() method as shown in below code: ``` @Override public void onBindViewHolder(final UserListAdapter.ViewHolder holder, final int position) { //long click for delete the record holder.itemView.setOnLongClickListener(new View.OnLongClickListener() { @Ove...
Add this line to your `<application>` in the `AndroidManifest.xml` file ``` android:theme="@style/Theme.AppCompat.Light" ```
31,241,308
I have an `Activity` which extends `ActionBarActivity`. Whenever I try to create an `AlertDialog` in it, crashes at the the line where dialog is created giving this error ``` java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. ``` But I'm already using `Appcom...
2015/07/06
[ "https://Stackoverflow.com/questions/31241308", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4460846/" ]
I solved this issue by changing the import : ``` android.support.v7.app.AlertDialog to android.app.AlertDialog ```
Change ``` new AlertDialog.Builder(this) ``` to ``` new AlertDialog.Builder(MainActivity.this) ```