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
12,053,954
I'm making a game in PHP with MySQL and I was wondering what is the best way for me to store the items the users have purchased so it is linked with their account. I plan to have a database with the items information in and the only ways I could think of doing it was: 1. Having a table for the users items in a serial...
2012/08/21
[ "https://Stackoverflow.com/questions/12053954", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1020244/" ]
I think that you know at the beginning which items a user can buy, so in my opinion you should have three tables * **USERS** table, in which you store user data (`PRIMARY KEY` is **user\_id**) * **ITEMS** table, in which you store items with their cost and data (`PRIMARY KEY` is **item\_id**) * **USERITEMS** table, in...
As per your question, the No.3 is suitable.I prefer @Marco suggestion.
74,183,421
I have a Data Frame with 4 columns. I want to calculate the log form of three columns values and then make a new Data Frame. my problem is that after getting the log form of values, their type become as series. My question is that how I can create a new dataframe with these new series. Here is my dataset: ``` yea...
2022/10/24
[ "https://Stackoverflow.com/questions/74183421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15638149/" ]
here is one way to do it Simpler approach ``` # using applymap, take log for the three columns # concat with the year column df2=pd.concat([df['year'], df[['gnp', 'labor','capital']].applymap(np.log)], axis=1) df2 ``` ``` year gnp labor capital 0 1955 11.64433...
Considering the following simple dataset: ``` df = pd.DataFrame({'year':[1,2,3,4,5], 'gnp':[100, 200, 300, 400, 500], 'labor':[1000, 2000, 3000, 4000, 5000], 'capital':[1e4, 2e4, 3e4, 4e4, 5e4]}, ) df ``` [![enter image description here](https:...
74,183,421
I have a Data Frame with 4 columns. I want to calculate the log form of three columns values and then make a new Data Frame. my problem is that after getting the log form of values, their type become as series. My question is that how I can create a new dataframe with these new series. Here is my dataset: ``` yea...
2022/10/24
[ "https://Stackoverflow.com/questions/74183421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15638149/" ]
Considering the following simple dataset: ``` df = pd.DataFrame({'year':[1,2,3,4,5], 'gnp':[100, 200, 300, 400, 500], 'labor':[1000, 2000, 3000, 4000, 5000], 'capital':[1e4, 2e4, 3e4, 4e4, 5e4]}, ) df ``` [![enter image description here](https:...
Another possible solution: ``` df['ln_' + df.columns[1:]] = np.log(df.iloc[:,1:]) ``` Output: ``` year gnp labor capital ln_gnp ln_labor ln_capital 0 1955 114043 8310 182113 11.644331 9.025215 12.112383 1 1956 120410 8529 193745 11.698658 9.051227 12.174298 2 1957 129187 8738 ...
74,183,421
I have a Data Frame with 4 columns. I want to calculate the log form of three columns values and then make a new Data Frame. my problem is that after getting the log form of values, their type become as series. My question is that how I can create a new dataframe with these new series. Here is my dataset: ``` yea...
2022/10/24
[ "https://Stackoverflow.com/questions/74183421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15638149/" ]
here is one way to do it Simpler approach ``` # using applymap, take log for the three columns # concat with the year column df2=pd.concat([df['year'], df[['gnp', 'labor','capital']].applymap(np.log)], axis=1) df2 ``` ``` year gnp labor capital 0 1955 11.64433...
Another possible solution: ``` df['ln_' + df.columns[1:]] = np.log(df.iloc[:,1:]) ``` Output: ``` year gnp labor capital ln_gnp ln_labor ln_capital 0 1955 114043 8310 182113 11.644331 9.025215 12.112383 1 1956 120410 8529 193745 11.698658 9.051227 12.174298 2 1957 129187 8738 ...
19,662,957
When i tap on my button, my function was called ``` [myBtn addTarget:self action:@selector(myFunction) forControlEvents:UIControlEventTouchUpInside]; ``` In my function, a collection of complex statement will be executed and take a litte bit time to run, so i want to show Loading (UIActivityIndicatorView) as the fol...
2013/10/29
[ "https://Stackoverflow.com/questions/19662957", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2590406/" ]
If your complex statements do not any UI animations or UI related code, then you can execute that part in a different thread(other than the mainThread). Once the statements are done(or in completion block), you can remove the loadingOverlay there.
Put myFunction to run on a background queue as it probably makes the system hang: ``` - (void)myFunction { dispatch_queue_t myQueue = dispatch_queue_create("myQueue", NULL); // execute a task on that queue asynchronously dispatch_async(myQueue, ^{ // Put the current myFunction code here. }); } ...
19,662,957
When i tap on my button, my function was called ``` [myBtn addTarget:self action:@selector(myFunction) forControlEvents:UIControlEventTouchUpInside]; ``` In my function, a collection of complex statement will be executed and take a litte bit time to run, so i want to show Loading (UIActivityIndicatorView) as the fol...
2013/10/29
[ "https://Stackoverflow.com/questions/19662957", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2590406/" ]
A correct way to perform a tasks in background, and in your case showing an activity indicator, is : ``` -(void)myBackGroundTask { //here showing the 'loading' and blocking interaction if you want so dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ //here everything you...
Put myFunction to run on a background queue as it probably makes the system hang: ``` - (void)myFunction { dispatch_queue_t myQueue = dispatch_queue_create("myQueue", NULL); // execute a task on that queue asynchronously dispatch_async(myQueue, ^{ // Put the current myFunction code here. }); } ...
19,662,957
When i tap on my button, my function was called ``` [myBtn addTarget:self action:@selector(myFunction) forControlEvents:UIControlEventTouchUpInside]; ``` In my function, a collection of complex statement will be executed and take a litte bit time to run, so i want to show Loading (UIActivityIndicatorView) as the fol...
2013/10/29
[ "https://Stackoverflow.com/questions/19662957", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2590406/" ]
A correct way to perform a tasks in background, and in your case showing an activity indicator, is : ``` -(void)myBackGroundTask { //here showing the 'loading' and blocking interaction if you want so dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ //here everything you...
If your complex statements do not any UI animations or UI related code, then you can execute that part in a different thread(other than the mainThread). Once the statements are done(or in completion block), you can remove the loadingOverlay there.
24,081,477
what is the syntax error `(error code-ORA-00911)` in this below code: ``` Insert into ctl_infa_parm select ‘201405’, scen_id, infa_wkf_id, sess_parm_file_nm, sess_nm, parm_nm, parm_value, parm_type, wklt_nm, actv_flag, updtd_by, sysdate, sysdate from ctl_infa_parm where dmth_id=201404; ```
2014/06/06
[ "https://Stackoverflow.com/questions/24081477", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3382890/" ]
`code-ORA-00911` represents an invalid character (see <http://www.dba-oracle.com/sf_ora_00911_invalid_character.htm>). Your `select ‘201405’` is not the same as `select '201405'`. Use `'` instead of `’`.
It's the semi colon at the end. You have to remove it.
721,107
Why classical mechanics is not able to explain the net magnetization in ferromagnets? why does exchange interaction can explain net magnetization in Ferromagnets, which is purely quantum mechanics??
2022/08/02
[ "https://physics.stackexchange.com/questions/721107", "https://physics.stackexchange.com", "https://physics.stackexchange.com/users/342241/" ]
Often, a statement like in the question is linked to the [Bohr-van Leeuwen theorem](https://en.wikipedia.org/wiki/Bohr%E2%80%93Van_Leeuwen_theorem). However, such a theorem does not say that classical electromagnetism can't explain any form of magnetism in materials. Should we need QED to explain magnets? What the theo...
Short answer follows from [Bohr-Van Leeuwen theorem](https://en.wikipedia.org/wiki/Bohr%E2%80%93Van_Leeuwen_theorem) which showed that classical electromagnetism can't explain any form of magnetism in materials. Formal proof is long, but in short it reduces to the fact that averaged thermal magnetic moment of electron ...
20,021,075
This problem occur after I try to use the script to install Maya 2014 and because I failed with some libraries, I used synaptic package manager to completely remove Maya and I used ``` sudo rm -r /usr/autodesk ``` After that I used Terminal to install Skype and get this error message ``` Setting up composite-2014 (...
2013/11/16
[ "https://Stackoverflow.com/questions/20021075", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Even when the code is cleaned up in presentation: ``` #include <stdio.h> #include <string.h> void countingsort(char *str); void countingsort(char *str) { int count[256]; int i; char output[20]; memset(count, 0, 256); for (i = 0; str[i]; i++) ++count[str[i]]; for (i = 1; i < 256; i++) ...
The given program runs fine when the length of input string is <= 20 When string length is > 20, array access happens outside the boundary which leads to unhandled exception.
52,998,576
I'm trying to make the below code work but the toolbar doesn't collapse when using a recyclerView; however, it does't collapse when I surround the recyclerView with a NestedScrollView. Is there something I should change to avoid having to add the NestedScrollView? ``` <?xml version="1.0" encoding="utf-8"?> <layout ...
2018/10/25
[ "https://Stackoverflow.com/questions/52998576", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6736139/" ]
In my case, it was because I mistakenly had `android:nestedScrollingEnabled="false"` in my XML for the Recycler View. Maybe you had it set programmatically? After removing that line, it works as expected.
Change your RecyclerView's layout height to match\_parent as @BenP. said and move your RecyclerView out of AppBarLayout. So, it will be: ``` <?xml version="1.0" encoding="utf-8"?> <layout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmln...
52,998,576
I'm trying to make the below code work but the toolbar doesn't collapse when using a recyclerView; however, it does't collapse when I surround the recyclerView with a NestedScrollView. Is there something I should change to avoid having to add the NestedScrollView? ``` <?xml version="1.0" encoding="utf-8"?> <layout ...
2018/10/25
[ "https://Stackoverflow.com/questions/52998576", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6736139/" ]
For my case it turned out that I needed to set `recycler.nestedScrollingEnabled = true` not on this top level recycler, but instead on a recycler that was inside one of the views being inflated within the top level recycler.
Change your RecyclerView's layout height to match\_parent as @BenP. said and move your RecyclerView out of AppBarLayout. So, it will be: ``` <?xml version="1.0" encoding="utf-8"?> <layout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmln...
52,998,576
I'm trying to make the below code work but the toolbar doesn't collapse when using a recyclerView; however, it does't collapse when I surround the recyclerView with a NestedScrollView. Is there something I should change to avoid having to add the NestedScrollView? ``` <?xml version="1.0" encoding="utf-8"?> <layout ...
2018/10/25
[ "https://Stackoverflow.com/questions/52998576", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6736139/" ]
In my case, it was because I mistakenly had `android:nestedScrollingEnabled="false"` in my XML for the Recycler View. Maybe you had it set programmatically? After removing that line, it works as expected.
For my case it turned out that I needed to set `recycler.nestedScrollingEnabled = true` not on this top level recycler, but instead on a recycler that was inside one of the views being inflated within the top level recycler.
20,785,275
How to terminate an application which is launched from my current application in android? For eg: Suppose I am starting YouTube from my own application then is there any way to terminate the YouTube application programatically from my app.
2013/12/26
[ "https://Stackoverflow.com/questions/20785275", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2508581/" ]
Finally, I've done it this way: * uninstalled entire platform with `sudo /Library/Haskell/bin/uninstall-hs` (<https://stackoverflow.com/a/6996284/1749901>) * then following [this tutorial](http://haskell-workshop.github.io/tutorials/osx/2013-10-23-mavericks-ghc.html) first installed apple-gcc42 via `brew install appl...
This is a known preprocessor issue on Mavericks. Look [here](http://www.haskell.org/platform/mac.html) for the solution. The reasons why this looks like a preprocessor issue are: 1. The line mentioned in the error message contains a CPP macro 2. There's a known issue with CPP on Mavericks 3. The package compiles fine...
20,785,275
How to terminate an application which is launched from my current application in android? For eg: Suppose I am starting YouTube from my own application then is there any way to terminate the YouTube application programatically from my app.
2013/12/26
[ "https://Stackoverflow.com/questions/20785275", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2508581/" ]
This is a known preprocessor issue on Mavericks. Look [here](http://www.haskell.org/platform/mac.html) for the solution. The reasons why this looks like a preprocessor issue are: 1. The line mentioned in the error message contains a CPP macro 2. There's a known issue with CPP on Mavericks 3. The package compiles fine...
All you need to do is add the cabal install directory to you path! Just add this to your .bash\_profile:export PATH="$HOME/Library/Haskell/bin:$PATH" export PATH="$HOME/Library/Haskell/bin:$PATH" I was about to uninstall the entire platform, but then I found this to work on Mavericks.
20,785,275
How to terminate an application which is launched from my current application in android? For eg: Suppose I am starting YouTube from my own application then is there any way to terminate the YouTube application programatically from my app.
2013/12/26
[ "https://Stackoverflow.com/questions/20785275", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2508581/" ]
Finally, I've done it this way: * uninstalled entire platform with `sudo /Library/Haskell/bin/uninstall-hs` (<https://stackoverflow.com/a/6996284/1749901>) * then following [this tutorial](http://haskell-workshop.github.io/tutorials/osx/2013-10-23-mavericks-ghc.html) first installed apple-gcc42 via `brew install appl...
All you need to do is add the cabal install directory to you path! Just add this to your .bash\_profile:export PATH="$HOME/Library/Haskell/bin:$PATH" export PATH="$HOME/Library/Haskell/bin:$PATH" I was about to uninstall the entire platform, but then I found this to work on Mavericks.
8,615,695
I need to parse a string which is more or less a url.. for example i have a string which is a URL ``` tempString = "?var1=somevalue1&var2=somevalue2&var3=somevalue3" ``` i need to parse the string `tempString` and get the value of `var1 var2` and `var3` from it. What's the best way to get the value.
2011/12/23
[ "https://Stackoverflow.com/questions/8615695", "https://Stackoverflow.com", "https://Stackoverflow.com/users/896872/" ]
Use [`urlparse.parse_qs`](http://docs.python.org/library/urlparse.html#urlparse.parse_qs).
This is a quick way, but you'd need to prepend a host and path to your example string. ``` import urlparse scheme, netloc, path, query, fragment = urlparse.urlsplit( url ) parameters = urlparse.parse_qs( query ) ```
8,615,695
I need to parse a string which is more or less a url.. for example i have a string which is a URL ``` tempString = "?var1=somevalue1&var2=somevalue2&var3=somevalue3" ``` i need to parse the string `tempString` and get the value of `var1 var2` and `var3` from it. What's the best way to get the value.
2011/12/23
[ "https://Stackoverflow.com/questions/8615695", "https://Stackoverflow.com", "https://Stackoverflow.com/users/896872/" ]
Use [`urlparse.parse_qs`](http://docs.python.org/library/urlparse.html#urlparse.parse_qs).
Use urlparse. For example, [see this](http://www.saltycrane.com/blog/2008/09/python-urlparse-example/).
8,615,695
I need to parse a string which is more or less a url.. for example i have a string which is a URL ``` tempString = "?var1=somevalue1&var2=somevalue2&var3=somevalue3" ``` i need to parse the string `tempString` and get the value of `var1 var2` and `var3` from it. What's the best way to get the value.
2011/12/23
[ "https://Stackoverflow.com/questions/8615695", "https://Stackoverflow.com", "https://Stackoverflow.com/users/896872/" ]
Use [`urlparse.parse_qs`](http://docs.python.org/library/urlparse.html#urlparse.parse_qs).
Well if it were really a URL ... or a URL query string (which looks closer to your example) then I suppose you could use the urlparse module's .parse\_qsl() function. For example: ``` import urlparse ... qry = dict(urlparse.parse_qsl(tempString)) ## parse_qsl returns a tuple of tuples suitable for instantiating or u...
64,919,454
I'm trying to preform a poly fit of roughly parabolic data. I run the following line: ``` fit = np.polynomial.polynomial.Polynomial.fit(x, y, 2) fit ``` which produces the output: ``` ↦ 300.76 − 2.38(-5.67+33.36) + 4.84(-5.67+33.36)2 ``` I'm interested in a polynomial of the form: y(x) = a + bx + cx\*\*2. I real...
2020/11/19
[ "https://Stackoverflow.com/questions/64919454", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11875503/" ]
Try with `fit.coef`, which is an array with the coefficients. So `fit.coef[0]`, `fit.coef[1]` and so on.
Use [numpy.polynomial.polynomial.polyfit](https://numpy.org/doc/stable/reference/generated/numpy.polynomial.polynomial.polyfit.html) instead - returns the coefficients directly as a numpy array. The arguments passed to this function are still the same.
64,919,454
I'm trying to preform a poly fit of roughly parabolic data. I run the following line: ``` fit = np.polynomial.polynomial.Polynomial.fit(x, y, 2) fit ``` which produces the output: ``` ↦ 300.76 − 2.38(-5.67+33.36) + 4.84(-5.67+33.36)2 ``` I'm interested in a polynomial of the form: y(x) = a + bx + cx\*\*2. I real...
2020/11/19
[ "https://Stackoverflow.com/questions/64919454", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11875503/" ]
Try with `fit.coef`, which is an array with the coefficients. So `fit.coef[0]`, `fit.coef[1]` and so on.
Check the [documentation](https://numpy.org/doc/stable/reference/generated/numpy.polyfit.html) ``` z = np.polyfit(x, y, 3) p = np.poly1d(z) p(0.5) ``` `z[0],z[1]` etc. is what you need. You can use the variable `p` to plug in any number to the polynom.
64,919,454
I'm trying to preform a poly fit of roughly parabolic data. I run the following line: ``` fit = np.polynomial.polynomial.Polynomial.fit(x, y, 2) fit ``` which produces the output: ``` ↦ 300.76 − 2.38(-5.67+33.36) + 4.84(-5.67+33.36)2 ``` I'm interested in a polynomial of the form: y(x) = a + bx + cx\*\*2. I real...
2020/11/19
[ "https://Stackoverflow.com/questions/64919454", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11875503/" ]
Use [numpy.polynomial.polynomial.polyfit](https://numpy.org/doc/stable/reference/generated/numpy.polynomial.polynomial.polyfit.html) instead - returns the coefficients directly as a numpy array. The arguments passed to this function are still the same.
Check the [documentation](https://numpy.org/doc/stable/reference/generated/numpy.polyfit.html) ``` z = np.polyfit(x, y, 3) p = np.poly1d(z) p(0.5) ``` `z[0],z[1]` etc. is what you need. You can use the variable `p` to plug in any number to the polynom.
69,640,453
I am working with a data set on Pokemon from [Kaggle](https://www.kaggle.com/abcsds/pokemon) - and I wanted to plot the stats against each type. I created a colors constant dictionary with the type names and the associated colors. ``` COLORS = {'Normal' : '#AAAA77', 'Fire': '#ff4422', 'Water': '#3399ff', ...
2021/10/20
[ "https://Stackoverflow.com/questions/69640453", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6885605/" ]
The initial confusion with the blog post was because it was pointing to a different problem in the wikipedia link. Retaking a look at `change`, it's trying to find the number of "ordered" ways of making change for a given value. This means that the ordering of coins matters. The correct value of `change 10` should be ...
I see two problems with this program. One of them I know how to fix, but the other apparently requires more knowledge of recursion schemes than I have. The one I can fix is that it's looking up the wrong values in its cache. When `given = 10`, of course `validCoins = [10,5,1]`, and so we find `(zeroes, toProcess) = ([...
69,640,453
I am working with a data set on Pokemon from [Kaggle](https://www.kaggle.com/abcsds/pokemon) - and I wanted to plot the stats against each type. I created a colors constant dictionary with the type names and the associated colors. ``` COLORS = {'Normal' : '#AAAA77', 'Fire': '#ff4422', 'Water': '#3399ff', ...
2021/10/20
[ "https://Stackoverflow.com/questions/69640453", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6885605/" ]
I put some more thought into encoding this problem with recursion schemes. Maybe there's a good way to solve the unordered problem (i.e., considering 5c + 1c to be different from 1c + 5c) using a histomorphism to cache the undirected recursive calls, but I don't know what it is. Instead, I looked for a way to use recur...
I see two problems with this program. One of them I know how to fix, but the other apparently requires more knowledge of recursion schemes than I have. The one I can fix is that it's looking up the wrong values in its cache. When `given = 10`, of course `validCoins = [10,5,1]`, and so we find `(zeroes, toProcess) = ([...
69,640,453
I am working with a data set on Pokemon from [Kaggle](https://www.kaggle.com/abcsds/pokemon) - and I wanted to plot the stats against each type. I created a colors constant dictionary with the type names and the associated colors. ``` COLORS = {'Normal' : '#AAAA77', 'Fire': '#ff4422', 'Water': '#3399ff', ...
2021/10/20
[ "https://Stackoverflow.com/questions/69640453", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6885605/" ]
I put some more thought into encoding this problem with recursion schemes. Maybe there's a good way to solve the unordered problem (i.e., considering 5c + 1c to be different from 1c + 5c) using a histomorphism to cache the undirected recursive calls, but I don't know what it is. Instead, I looked for a way to use recur...
The initial confusion with the blog post was because it was pointing to a different problem in the wikipedia link. Retaking a look at `change`, it's trying to find the number of "ordered" ways of making change for a given value. This means that the ordering of coins matters. The correct value of `change 10` should be ...
2,157
I'm a fan of the way that Atom and Sublime Text handle line folding, where the first line of each fold is visible (complete with syntax highlighting), and a marker is appended to the end of the line that indicates the fold. See the screenshot below comparing Vim's indent folding (top) versus Atom's (bottom):![Vim vs. ...
2015/02/24
[ "https://vi.stackexchange.com/questions/2157", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/1019/" ]
Two lines vs. one line ====================== In Vim, all lines within a fold will be collapsed to a *single* line, and the `'foldtext'` option then determines the synopsis of those lines (usually dashes, the number of folded lines, and content from the first (or all) lines). In your example, in Vim only the `{...}` ...
Vim already displays folds as a single line. However, in Vim's `indent` folding, all the lines that have the *same* indent are included in a fold. So in your screenshot, the lines you are referring to as "headers" (e.g., the one starting `collection_base_url`) are *not* within the folds. You can achieve something simi...
45,526,814
I have a log file which has data separated with "|" symbol. Like ``` "Username|servername|access|password|group" "Username|servername|access|password|group" ``` I need to validate the data. And, If the group column(record) is missing information or empty. I need to write only that row into another file. Please hel...
2017/08/05
[ "https://Stackoverflow.com/questions/45526814", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5252430/" ]
If you're just checking for missing data, you can run a quick check using a `regex` of '(\S+\|){4}\S+'. Use `Get-Content` with the `-ReadCount` parameter, and you can work in batches of a few thousand records at a time, minimizing disk i/o and memory usage without going through them one record at a time. ``` Get-Conte...
If your group column is always in the same place, which it looks like it is, you could use the split method. You can certainly neaten the code up. I have used the below as an example as to how you could use split. The foreach statement is to iterate through each line in your file. if (!$($groupstring.Split('|')[4])) ...
45,526,814
I have a log file which has data separated with "|" symbol. Like ``` "Username|servername|access|password|group" "Username|servername|access|password|group" ``` I need to validate the data. And, If the group column(record) is missing information or empty. I need to write only that row into another file. Please hel...
2017/08/05
[ "https://Stackoverflow.com/questions/45526814", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5252430/" ]
You could use `'Import-CSV` with `-Delimiter '|'`. If your file doesn't have a header line, you would also need to use `-Header` to define it. You could then use `Where` to filter for the empty Group lines and `Export-CSV` with `-Delimiter` again to create a new file of just those lines. For example: ``` Import-CSV '...
If your group column is always in the same place, which it looks like it is, you could use the split method. You can certainly neaten the code up. I have used the below as an example as to how you could use split. The foreach statement is to iterate through each line in your file. if (!$($groupstring.Split('|')[4])) ...
45,526,814
I have a log file which has data separated with "|" symbol. Like ``` "Username|servername|access|password|group" "Username|servername|access|password|group" ``` I need to validate the data. And, If the group column(record) is missing information or empty. I need to write only that row into another file. Please hel...
2017/08/05
[ "https://Stackoverflow.com/questions/45526814", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5252430/" ]
You could use `'Import-CSV` with `-Delimiter '|'`. If your file doesn't have a header line, you would also need to use `-Header` to define it. You could then use `Where` to filter for the empty Group lines and `Export-CSV` with `-Delimiter` again to create a new file of just those lines. For example: ``` Import-CSV '...
If you're just checking for missing data, you can run a quick check using a `regex` of '(\S+\|){4}\S+'. Use `Get-Content` with the `-ReadCount` parameter, and you can work in batches of a few thousand records at a time, minimizing disk i/o and memory usage without going through them one record at a time. ``` Get-Conte...
3,366
I'm trying to figure out a way to create an image on my SD card. My SD card is 16 GB but I have not changed the original partition size. All the software that I use to create an IMG file with always creates a 16 GB file and not a 2 GB as I would expect. ``` # df -H Filesystem Size Used Avail Use% Mounted on roo...
2012/10/26
[ "https://raspberrypi.stackexchange.com/questions/3366", "https://raspberrypi.stackexchange.com", "https://raspberrypi.stackexchange.com/users/3043/" ]
You need to install the mono-complete package (which includes the mscorlib.dll file); to do this enter the following at the command line. ``` sudo apt-get install mono-complete ```
In my case I was writing the wrong name of the HelloWord.exe file. When I wrote correctly i.e. mono Helloword.exe, it worked fine. However the error was the same one
19,268,406
In Java, if I have a lot of local objects, would it run faster if I define them as instance variables? For example, if my func1() is called many times, say in a loop, would the JVM keep instantiating and garbage collecting the list2 every time the function is invoked? Should I, instead, reuse the same list1 object to p...
2013/10/09
[ "https://Stackoverflow.com/questions/19268406", "https://Stackoverflow.com", "https://Stackoverflow.com/users/237575/" ]
GC optimization is not the right way to decide `Local` vs `Instance` variable. If a variable required be to used by multiple instance methods then it makes sense to use a instance variable. You are right, local variable use may increase GC activity.
There could be various use cases which you might need to consider before deciding upon whether to use local or instance variables. Performance may vary based on the use case. One good example can be found in [Effective Java](http://c2.com/cgi/wiki?EffectiveJava) : [Item 5](http://my.safaribooksonline.com/book/program...
19,268,406
In Java, if I have a lot of local objects, would it run faster if I define them as instance variables? For example, if my func1() is called many times, say in a loop, would the JVM keep instantiating and garbage collecting the list2 every time the function is invoked? Should I, instead, reuse the same list1 object to p...
2013/10/09
[ "https://Stackoverflow.com/questions/19268406", "https://Stackoverflow.com", "https://Stackoverflow.com/users/237575/" ]
GC optimization is not the right way to decide `Local` vs `Instance` variable. If a variable required be to used by multiple instance methods then it makes sense to use a instance variable. You are right, local variable use may increase GC activity.
Also think about the thread-safety of instance variable values. Two threads of same object needs to have synchronize access to instance variable data, but here it would always be a new local variable data object.
19,268,406
In Java, if I have a lot of local objects, would it run faster if I define them as instance variables? For example, if my func1() is called many times, say in a loop, would the JVM keep instantiating and garbage collecting the list2 every time the function is invoked? Should I, instead, reuse the same list1 object to p...
2013/10/09
[ "https://Stackoverflow.com/questions/19268406", "https://Stackoverflow.com", "https://Stackoverflow.com/users/237575/" ]
GC optimization is not the right way to decide `Local` vs `Instance` variable. If a variable required be to used by multiple instance methods then it makes sense to use a instance variable. You are right, local variable use may increase GC activity.
If - **and only if** - you have **proven** you have an issue with GC because of object creation, you should think of pooling the objects that are **proven** to be created costly. For this, you don't have to reinvent any wheels, you can achieve it for example using Javolutions utils, [FastList](http://javolution.org/ta...
19,268,406
In Java, if I have a lot of local objects, would it run faster if I define them as instance variables? For example, if my func1() is called many times, say in a loop, would the JVM keep instantiating and garbage collecting the list2 every time the function is invoked? Should I, instead, reuse the same list1 object to p...
2013/10/09
[ "https://Stackoverflow.com/questions/19268406", "https://Stackoverflow.com", "https://Stackoverflow.com/users/237575/" ]
I wrote a little test program with jdk1.6, below Results: \* 594ms for dostuff (which creates a local) \* 58ms for dostuff2 (which uses the instance) ``` public class Test { static long counter=0; public static void main(String[] args) { long t1 = System.nanoTime(); Test test = new Test(); for (in...
There could be various use cases which you might need to consider before deciding upon whether to use local or instance variables. Performance may vary based on the use case. One good example can be found in [Effective Java](http://c2.com/cgi/wiki?EffectiveJava) : [Item 5](http://my.safaribooksonline.com/book/program...
19,268,406
In Java, if I have a lot of local objects, would it run faster if I define them as instance variables? For example, if my func1() is called many times, say in a loop, would the JVM keep instantiating and garbage collecting the list2 every time the function is invoked? Should I, instead, reuse the same list1 object to p...
2013/10/09
[ "https://Stackoverflow.com/questions/19268406", "https://Stackoverflow.com", "https://Stackoverflow.com/users/237575/" ]
I wrote a little test program with jdk1.6, below Results: \* 594ms for dostuff (which creates a local) \* 58ms for dostuff2 (which uses the instance) ``` public class Test { static long counter=0; public static void main(String[] args) { long t1 = System.nanoTime(); Test test = new Test(); for (in...
Also think about the thread-safety of instance variable values. Two threads of same object needs to have synchronize access to instance variable data, but here it would always be a new local variable data object.
19,268,406
In Java, if I have a lot of local objects, would it run faster if I define them as instance variables? For example, if my func1() is called many times, say in a loop, would the JVM keep instantiating and garbage collecting the list2 every time the function is invoked? Should I, instead, reuse the same list1 object to p...
2013/10/09
[ "https://Stackoverflow.com/questions/19268406", "https://Stackoverflow.com", "https://Stackoverflow.com/users/237575/" ]
I wrote a little test program with jdk1.6, below Results: \* 594ms for dostuff (which creates a local) \* 58ms for dostuff2 (which uses the instance) ``` public class Test { static long counter=0; public static void main(String[] args) { long t1 = System.nanoTime(); Test test = new Test(); for (in...
If - **and only if** - you have **proven** you have an issue with GC because of object creation, you should think of pooling the objects that are **proven** to be created costly. For this, you don't have to reinvent any wheels, you can achieve it for example using Javolutions utils, [FastList](http://javolution.org/ta...
57,822,364
I installed .NET Core 3 Runtime and SDK Preview 9 today to make a WPF application. However, when I try to create it, I get the following error: "To create this project type, go to Tools | Options | Environment | Preview Features and check "Use previews of the .NET Core SDK" (similar to [Cannot create a WPF .NET core ap...
2019/09/06
[ "https://Stackoverflow.com/questions/57822364", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9513080/" ]
Had the exact issue. What worked for me was to update Visual Studio 2019 (was a couple of updates behind). Confirmed it works on v.16.3.0
I had a similar issue even after installing the latest updates. My PATH Environmental Variable at the System Level was missing the CORE directory `C:\Program Files\dotnet`
206,671
A firewall in my company was triggered by a DNS query from one of our laptops. Specifically, the exact reason was `MALWARE-CNC Win.Trojan.Zeus v3 DGA DNS query detected`. Now, I could just follow this blindly and nuke the laptop in question from orbit, but this is disruptive and time-consuming. Ideally, I'd like to ge...
2019/04/03
[ "https://security.stackexchange.com/questions/206671", "https://security.stackexchange.com", "https://security.stackexchange.com/users/30459/" ]
I experienced this exact problem and my Sophos firewall also indicated the same warning two times in close succession. After that, there has been no further warning. Two additional observations here that really confuse me: 1). The laptop in question is a macbook running macOS 10.14.3, and 2). The laptop was not running...
I would advise to put the local windows firewall of the laptop logging. If get confirmation that it is the machine that is doing the queries try to identify the process. If so then try to check the process that is doing a call with netstat or using the process explorer tool from sysinternals. Probably the best tool ...
9,503,771
I ran into a strange issue. Here is a snippet of code that describes it: ``` DateTimeZone dtz = DateTimeZone.forOffsetHours(0); DateTime dt = new DateTime(dtz); System.out.println(dt); System.out.println(dt.toDate()); ``` the output is: ``` 2012-02-29T17:24:39.055Z Wed Feb 29 19:24:39 EET 2012 ``` I'm located U...
2012/02/29
[ "https://Stackoverflow.com/questions/9503771", "https://Stackoverflow.com", "https://Stackoverflow.com/users/917432/" ]
`Date` doesn't *know* about a time zone at all - it only represents an instant in time (like Joda Time's `Instant` type). It's just a number of milliseconds since the Unix epoch. When you call `Date.toString()`, it *always* uses the system local time zone for converting that into a readable text form. So there's nothi...
The behaviour you want is this: Date jdkDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(dt.toString("yyyy-MM-dd HH:mm:ss")); Like Jon noted, JDK date is time zone agnostic. Hope this helps someone.
9,503,771
I ran into a strange issue. Here is a snippet of code that describes it: ``` DateTimeZone dtz = DateTimeZone.forOffsetHours(0); DateTime dt = new DateTime(dtz); System.out.println(dt); System.out.println(dt.toDate()); ``` the output is: ``` 2012-02-29T17:24:39.055Z Wed Feb 29 19:24:39 EET 2012 ``` I'm located U...
2012/02/29
[ "https://Stackoverflow.com/questions/9503771", "https://Stackoverflow.com", "https://Stackoverflow.com/users/917432/" ]
`Date` doesn't *know* about a time zone at all - it only represents an instant in time (like Joda Time's `Instant` type). It's just a number of milliseconds since the Unix epoch. When you call `Date.toString()`, it *always* uses the system local time zone for converting that into a readable text form. So there's nothi...
To get a JDK `Date` that matches Joda's `DateTime`convert to `LocalDateTime`first. As explained in the other answers, the time in milliseconds does not change depending on the timezone: ``` DateTime local = DateTime.now() Date localJDK = local.toDate() assert localJDK.getTime() == local.toInstant().getMillis() Date...
9,503,771
I ran into a strange issue. Here is a snippet of code that describes it: ``` DateTimeZone dtz = DateTimeZone.forOffsetHours(0); DateTime dt = new DateTime(dtz); System.out.println(dt); System.out.println(dt.toDate()); ``` the output is: ``` 2012-02-29T17:24:39.055Z Wed Feb 29 19:24:39 EET 2012 ``` I'm located U...
2012/02/29
[ "https://Stackoverflow.com/questions/9503771", "https://Stackoverflow.com", "https://Stackoverflow.com/users/917432/" ]
To get a JDK `Date` that matches Joda's `DateTime`convert to `LocalDateTime`first. As explained in the other answers, the time in milliseconds does not change depending on the timezone: ``` DateTime local = DateTime.now() Date localJDK = local.toDate() assert localJDK.getTime() == local.toInstant().getMillis() Date...
The behaviour you want is this: Date jdkDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(dt.toString("yyyy-MM-dd HH:mm:ss")); Like Jon noted, JDK date is time zone agnostic. Hope this helps someone.
20,670,065
Following [this tutorial](http://net.tutsplus.com/tutorials/ruby/singing-with-sinatra/) to create the route for the POST: ``` post '/secret' do params[:secret].reverse end ``` When I view this on the local server I get my secret message in reverse. But if I want to print another line, below the reverse line, t...
2013/12/18
[ "https://Stackoverflow.com/questions/20670065", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3116998/" ]
In your first example you're seeing your secret in reverse because Sinatra is handed the reversed string from the block and displays it. In your second bit of code you're printing the reversed strings to the local output, which is where you'd expect to see the logs displayed. You're seeing a messed up string because t...
It's just how Sinatra works. The return value of the `post` block is sent as response. The return value of the block is always the return value of the last statement inside the block. So your `p` is actually useless, it will only print the secret to the log. It just happens that `p` returns the value it was passed afte...
20,670,065
Following [this tutorial](http://net.tutsplus.com/tutorials/ruby/singing-with-sinatra/) to create the route for the POST: ``` post '/secret' do params[:secret].reverse end ``` When I view this on the local server I get my secret message in reverse. But if I want to print another line, below the reverse line, t...
2013/12/18
[ "https://Stackoverflow.com/questions/20670065", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3116998/" ]
In your first example you're seeing your secret in reverse because Sinatra is handed the reversed string from the block and displays it. In your second bit of code you're printing the reversed strings to the local output, which is where you'd expect to see the logs displayed. You're seeing a messed up string because t...
Oh, I see. You're using `p`. Unlike PHP, Sinatra does not capture standard output. Rather, what is returned as the content .of the page is what is returned from the function. In the first example, you return the result of `reverse`. In the first example, you return `nil`, which is the result of the second `p` call. ...
924
I am trying to render smoke in cycles, but the relevant blender [manual page](http://wiki.blender.org/index.php/Doc:2.6/Manual/Physics/Smoke) is designed for Bender Internal. I have everything set up except for the material. I imagine you would set up the material nodes something like this: ![enter image description ...
2013/06/11
[ "https://blender.stackexchange.com/questions/924", "https://blender.stackexchange.com", "https://blender.stackexchange.com/users/131/" ]
From the [Cycles Roadmap](http://wiki.blender.org/index.php/Dev:2.6/Source/Render/Cycles/Roadmap): > > Probably the first release with Volumetrics will be 2.69 or 2.70. > > >
Volumetrics and smoke are not currently supported by Cycles. There are some experimental builds that will support rendering static volumes, but not voxels, yet. Version 2.70 is [reported](http://blenderdiplom.com/en/blog/527-demo-volume-with-blender-cycles.html) to support volumes, and voxels (for smoke) will come lat...
924
I am trying to render smoke in cycles, but the relevant blender [manual page](http://wiki.blender.org/index.php/Doc:2.6/Manual/Physics/Smoke) is designed for Bender Internal. I have everything set up except for the material. I imagine you would set up the material nodes something like this: ![enter image description ...
2013/06/11
[ "https://blender.stackexchange.com/questions/924", "https://blender.stackexchange.com", "https://blender.stackexchange.com/users/131/" ]
From the [Cycles Roadmap](http://wiki.blender.org/index.php/Dev:2.6/Source/Render/Cycles/Roadmap): > > Probably the first release with Volumetrics will be 2.69 or 2.70. > > >
You can do it in Blender 2.71 or newer (which added support for volumetric data in Cycles). Make a group in nodes that looks like on the screenshot below. It's very important that you make the two "Attribute" nodes exactly like shown on the screenshot - "flame" lowercase and "density" lowercase - because it refers to ...
924
I am trying to render smoke in cycles, but the relevant blender [manual page](http://wiki.blender.org/index.php/Doc:2.6/Manual/Physics/Smoke) is designed for Bender Internal. I have everything set up except for the material. I imagine you would set up the material nodes something like this: ![enter image description ...
2013/06/11
[ "https://blender.stackexchange.com/questions/924", "https://blender.stackexchange.com", "https://blender.stackexchange.com/users/131/" ]
As of version 2.73 from 2015: * Make sure render engine is set to cycles (BI wouldn't create the required cycles materials) * Select the object you want to emit smoke * From the menu *Object/Quick Effects* pick *Quick Smoke* After that a material has been created that looks like: ![enter image description here](http...
From the [Cycles Roadmap](http://wiki.blender.org/index.php/Dev:2.6/Source/Render/Cycles/Roadmap): > > Probably the first release with Volumetrics will be 2.69 or 2.70. > > >
924
I am trying to render smoke in cycles, but the relevant blender [manual page](http://wiki.blender.org/index.php/Doc:2.6/Manual/Physics/Smoke) is designed for Bender Internal. I have everything set up except for the material. I imagine you would set up the material nodes something like this: ![enter image description ...
2013/06/11
[ "https://blender.stackexchange.com/questions/924", "https://blender.stackexchange.com", "https://blender.stackexchange.com/users/131/" ]
You can do it in Blender 2.71 or newer (which added support for volumetric data in Cycles). Make a group in nodes that looks like on the screenshot below. It's very important that you make the two "Attribute" nodes exactly like shown on the screenshot - "flame" lowercase and "density" lowercase - because it refers to ...
Volumetrics and smoke are not currently supported by Cycles. There are some experimental builds that will support rendering static volumes, but not voxels, yet. Version 2.70 is [reported](http://blenderdiplom.com/en/blog/527-demo-volume-with-blender-cycles.html) to support volumes, and voxels (for smoke) will come lat...
924
I am trying to render smoke in cycles, but the relevant blender [manual page](http://wiki.blender.org/index.php/Doc:2.6/Manual/Physics/Smoke) is designed for Bender Internal. I have everything set up except for the material. I imagine you would set up the material nodes something like this: ![enter image description ...
2013/06/11
[ "https://blender.stackexchange.com/questions/924", "https://blender.stackexchange.com", "https://blender.stackexchange.com/users/131/" ]
As of version 2.73 from 2015: * Make sure render engine is set to cycles (BI wouldn't create the required cycles materials) * Select the object you want to emit smoke * From the menu *Object/Quick Effects* pick *Quick Smoke* After that a material has been created that looks like: ![enter image description here](http...
Volumetrics and smoke are not currently supported by Cycles. There are some experimental builds that will support rendering static volumes, but not voxels, yet. Version 2.70 is [reported](http://blenderdiplom.com/en/blog/527-demo-volume-with-blender-cycles.html) to support volumes, and voxels (for smoke) will come lat...
924
I am trying to render smoke in cycles, but the relevant blender [manual page](http://wiki.blender.org/index.php/Doc:2.6/Manual/Physics/Smoke) is designed for Bender Internal. I have everything set up except for the material. I imagine you would set up the material nodes something like this: ![enter image description ...
2013/06/11
[ "https://blender.stackexchange.com/questions/924", "https://blender.stackexchange.com", "https://blender.stackexchange.com/users/131/" ]
As of version 2.73 from 2015: * Make sure render engine is set to cycles (BI wouldn't create the required cycles materials) * Select the object you want to emit smoke * From the menu *Object/Quick Effects* pick *Quick Smoke* After that a material has been created that looks like: ![enter image description here](http...
You can do it in Blender 2.71 or newer (which added support for volumetric data in Cycles). Make a group in nodes that looks like on the screenshot below. It's very important that you make the two "Attribute" nodes exactly like shown on the screenshot - "flame" lowercase and "density" lowercase - because it refers to ...
25,684,352
I'm currently working on a project that must take a integer 1-10 switch it to a double then multiple that double with a quantity. However, all of these have to be input by the user like you're ordering something from a restaurant. The problem I'm having is getting a loop of the above that stores the total (price \* qua...
2014/09/05
[ "https://Stackoverflow.com/questions/25684352", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3521214/" ]
`disabledRanges` allows you to define **multiple** date ranges to exclude from being selected.[[1]](http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/controls/DateField.html#disabledRanges) `selectableRange` allows you to define a **single** date range to include for selection.[[2]](http://help.ado...
This properties are opposite. With `disabledRanges` you could disable some date (dates) from choosing (and other dates will be available to user) and with `selectableRange` you could set date (dates) that only available (and other dates will be disabled for user). [disabledRanges](http://help.adobe.com/en_US/FlashPlat...
31,627,992
I have a problem with the json serialization of `ZonedDateTime`. When converted to json it produces an enormous object and I don't want all that data to be transfered every time. So i tried to format it to ISO but it doesn't work. How can i get it to format? Here is my Entity Class: ``` @MappedSuperclass public abstr...
2015/07/25
[ "https://Stackoverflow.com/questions/31627992", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2442740/" ]
I guess that you are using Jackson for json serialization, Jackson now has a module for Java 8 new date time API, <https://github.com/FasterXML/jackson-datatype-jsr310>. Add this dependency into your pom.xml ``` <dependency> <groupId>com.fasterxml.jackson.datatype</groupId> <artifactId>jackson-datatype-jsr310...
Above answer works but if you don't want to touch your existing entity class, following settings will work with `ZonedDateTime` : ``` public static ObjectMapper getMapper() { ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new JavaTimeModule()); return mapper.configure(Deserializatio...
31,627,992
I have a problem with the json serialization of `ZonedDateTime`. When converted to json it produces an enormous object and I don't want all that data to be transfered every time. So i tried to format it to ISO but it doesn't work. How can i get it to format? Here is my Entity Class: ``` @MappedSuperclass public abstr...
2015/07/25
[ "https://Stackoverflow.com/questions/31627992", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2442740/" ]
I guess that you are using Jackson for json serialization, Jackson now has a module for Java 8 new date time API, <https://github.com/FasterXML/jackson-datatype-jsr310>. Add this dependency into your pom.xml ``` <dependency> <groupId>com.fasterxml.jackson.datatype</groupId> <artifactId>jackson-datatype-jsr310...
I resolved the problem setting the following property to `application.yml`. ```yaml spring: jackson: serialization: write_dates_as_timestamps: false ``` I use `spring-boot:2.3.8.RELEASE` and `dependency-management:1.0.10.RELEASE`. For more detailed information [see this link.](https://to...
15,213,007
Is it possible to combine dropdownlist values from an entity. Say I have a person class with Last Name and First Name I have tried doing this: ``` ViewBag.uservalues = new SelectList(db.Persons, "ID", "FirstName" + " " + "LastName"); ``` But this spits out an error.
2013/03/04
[ "https://Stackoverflow.com/questions/15213007", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1238850/" ]
Your call to the `SelectList` constructor ``` new SelectList(db.Persons,"ID", "FirstName"+" " + "LastName"); ``` uses [this overload](http://msdn.microsoft.com/en-us/library/dd505286%28v=vs.108%29.aspx), which requires the name of a public field or property in your `ViewModel` to bind to, and you probably don't have...
Since the entity framework creates partial classes you should make another partial class in the same namespace that has the derived property that you want to use. if the entity fraemwork created a class: ``` public partial class Person { public String FirstName {get;set;} public String LastName{get;set;} ...
15,213,007
Is it possible to combine dropdownlist values from an entity. Say I have a person class with Last Name and First Name I have tried doing this: ``` ViewBag.uservalues = new SelectList(db.Persons, "ID", "FirstName" + " " + "LastName"); ``` But this spits out an error.
2013/03/04
[ "https://Stackoverflow.com/questions/15213007", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1238850/" ]
Your call to the `SelectList` constructor ``` new SelectList(db.Persons,"ID", "FirstName"+" " + "LastName"); ``` uses [this overload](http://msdn.microsoft.com/en-us/library/dd505286%28v=vs.108%29.aspx), which requires the name of a public field or property in your `ViewModel` to bind to, and you probably don't have...
``` var query = from c in db.Persons select new { id = c.ID,Names = c.FirstName + " " + c.LastName }; ViewBag.personid = new SelectList(query, "ID", "Names"); ```
15,213,007
Is it possible to combine dropdownlist values from an entity. Say I have a person class with Last Name and First Name I have tried doing this: ``` ViewBag.uservalues = new SelectList(db.Persons, "ID", "FirstName" + " " + "LastName"); ``` But this spits out an error.
2013/03/04
[ "https://Stackoverflow.com/questions/15213007", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1238850/" ]
``` var query = from c in db.Persons select new { id = c.ID,Names = c.FirstName + " " + c.LastName }; ViewBag.personid = new SelectList(query, "ID", "Names"); ```
Since the entity framework creates partial classes you should make another partial class in the same namespace that has the derived property that you want to use. if the entity fraemwork created a class: ``` public partial class Person { public String FirstName {get;set;} public String LastName{get;set;} ...
9,130,200
I just find out some htc files in my solution with some script inside what does those file do ? Is it possible to remove them. the using inside like behavior link inside of CSS
2012/02/03
[ "https://Stackoverflow.com/questions/9130200", "https://Stackoverflow.com", "https://Stackoverflow.com/users/307072/" ]
It's likely there to support CSS features unavailable in older versions of IE. <http://www.fileinfo.com/extension/htc>
<http://www.filefacts.net/htc-file-extension> Files that use the file extension .htc are HTML Component Files which are HTML pages that are wrapped in descriptors that define properties etc that are used by the component, an apt description can be found on the w3.org website which states "HTC is literally a normal HTM...
9,130,200
I just find out some htc files in my solution with some script inside what does those file do ? Is it possible to remove them. the using inside like behavior link inside of CSS
2012/02/03
[ "https://Stackoverflow.com/questions/9130200", "https://Stackoverflow.com", "https://Stackoverflow.com/users/307072/" ]
It's likely there to support CSS features unavailable in older versions of IE. <http://www.fileinfo.com/extension/htc>
I have only used an htc file to allow IE (< 9) to draw rounded corners, along with the border-radius property. This is not a recommended practice though. It depends on your priorities: if you prefer efficiency over design, I wouldn't use those files.
9,130,200
I just find out some htc files in my solution with some script inside what does those file do ? Is it possible to remove them. the using inside like behavior link inside of CSS
2012/02/03
[ "https://Stackoverflow.com/questions/9130200", "https://Stackoverflow.com", "https://Stackoverflow.com/users/307072/" ]
[HTC reference](http://msdn.microsoft.com/en-us/library/ms531018%28VS.85%29.aspx) from MSDN: > > For Microsoft Internet Explorer 5 and later, HTML Components (HTCs) > provide a mechanism to implement components in script as Dynamic HTML > (DHTML) behaviors. An HTC is an HTML file that contains script and a > set o...
It's likely there to support CSS features unavailable in older versions of IE. <http://www.fileinfo.com/extension/htc>
9,130,200
I just find out some htc files in my solution with some script inside what does those file do ? Is it possible to remove them. the using inside like behavior link inside of CSS
2012/02/03
[ "https://Stackoverflow.com/questions/9130200", "https://Stackoverflow.com", "https://Stackoverflow.com/users/307072/" ]
[HTC reference](http://msdn.microsoft.com/en-us/library/ms531018%28VS.85%29.aspx) from MSDN: > > For Microsoft Internet Explorer 5 and later, HTML Components (HTCs) > provide a mechanism to implement components in script as Dynamic HTML > (DHTML) behaviors. An HTC is an HTML file that contains script and a > set o...
<http://www.filefacts.net/htc-file-extension> Files that use the file extension .htc are HTML Component Files which are HTML pages that are wrapped in descriptors that define properties etc that are used by the component, an apt description can be found on the w3.org website which states "HTC is literally a normal HTM...
9,130,200
I just find out some htc files in my solution with some script inside what does those file do ? Is it possible to remove them. the using inside like behavior link inside of CSS
2012/02/03
[ "https://Stackoverflow.com/questions/9130200", "https://Stackoverflow.com", "https://Stackoverflow.com/users/307072/" ]
[HTC reference](http://msdn.microsoft.com/en-us/library/ms531018%28VS.85%29.aspx) from MSDN: > > For Microsoft Internet Explorer 5 and later, HTML Components (HTCs) > provide a mechanism to implement components in script as Dynamic HTML > (DHTML) behaviors. An HTC is an HTML file that contains script and a > set o...
I have only used an htc file to allow IE (< 9) to draw rounded corners, along with the border-radius property. This is not a recommended practice though. It depends on your priorities: if you prefer efficiency over design, I wouldn't use those files.
44,426,110
![enter image description here](https://i.stack.imgur.com/5JfaS.png) This will give me the list of string having "WIGS\_AUTH\_" in each item. Now I want to remove this part from the list items in the same expression. Or any better way to achieve this?
2017/06/08
[ "https://Stackoverflow.com/questions/44426110", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8128893/" ]
Put this at the top of your code: using System.Web.Configuration; Put this in Web.Config: ``` <connectionStrings > <add name="myConnectionString" connectionString="Server=myServerAddress;Database=myDataBase;User ID=myUsername;Password=myPassword;Trusted_Connection=False;" providerName="System.Data.S...
It looks like something is wrong with the connection string you are using. Make sure you are passing correct ServerName and database name. Also please double check if you want to use Windows Authentication or have any user configured in the database to login with. You can also check the following URL to know more ab...
68,438,128
So I wanted to get a powershell command to list the firewall rules and ports, and I had to basically use 2 commands: `Get-NetFirewallRule` and `Get-NetFirewallPortFilter`. So I basically came up with this: ``` Get-NetFirewallPortFilter | where-object {$_.LocalPort -cmatch '[0-9]+'}|select-object -Property @{n='Name';...
2021/07/19
[ "https://Stackoverflow.com/questions/68438128", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11020882/" ]
So you should be able to just disconnect and then reconnect without the terminal closing. Notice I'm using `.connect()` instead of `.login()` as when you close the connection you're not actually logging out of discord. Edit: I hadn't noticed but Dominik mentioned the thats sleep is not asynchronous and so you can eit...
You can completely restart you bot by using the [`os.execv()` function](https://docs.python.org/3/library/os.html#os.execv). > > "[...] execute[s] a new program, replacing the current process; [it does] not return" > > > --- The implementation would be ```py os.execv("path-to-python-bin", ["python"] + ["absolut...
68,438,128
So I wanted to get a powershell command to list the firewall rules and ports, and I had to basically use 2 commands: `Get-NetFirewallRule` and `Get-NetFirewallPortFilter`. So I basically came up with this: ``` Get-NetFirewallPortFilter | where-object {$_.LocalPort -cmatch '[0-9]+'}|select-object -Property @{n='Name';...
2021/07/19
[ "https://Stackoverflow.com/questions/68438128", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11020882/" ]
So you should be able to just disconnect and then reconnect without the terminal closing. Notice I'm using `.connect()` instead of `.login()` as when you close the connection you're not actually logging out of discord. Edit: I hadn't noticed but Dominik mentioned the thats sleep is not asynchronous and so you can eit...
```py import sys def restart_bot(): os.execv(sys.executable, ['python'] + sys.argv) @bot.command(name= 'restart') async def restart(ctx): await ctx.send("Restarting bot...") restart_bot() ``` This will work perfect . Your code doesnt works because once bot is stops by using bot.close it cant be turned on auto...
22,171,005
i try to get some records from DB Package (ORTAK.MERNIS) using its function (GETMERNISINFO(v\_var number)) into PLL package type (MERNISLIB.MERNIS\_USER). But I ve a trouble with sending parameter to db package function (:TCK). It throws ***ORA-01008 : Not all variables bound*** If I set function parameter statically...
2014/03/04
[ "https://Stackoverflow.com/questions/22171005", "https://Stackoverflow.com", "https://Stackoverflow.com/users/658812/" ]
``` $str = 'stRing'; ucfirst(strtolower($str)); ``` Will output: String
To make all chars of a string lowercase except the first, use: ``` echo $word[0] . strtolower(substr($word, 1)); ```
22,171,005
i try to get some records from DB Package (ORTAK.MERNIS) using its function (GETMERNISINFO(v\_var number)) into PLL package type (MERNISLIB.MERNIS\_USER). But I ve a trouble with sending parameter to db package function (:TCK). It throws ***ORA-01008 : Not all variables bound*** If I set function parameter statically...
2014/03/04
[ "https://Stackoverflow.com/questions/22171005", "https://Stackoverflow.com", "https://Stackoverflow.com/users/658812/" ]
``` $str = 'stRing'; ucfirst(strtolower($str)); ``` Will output: String
Just do ``` ucfirst(strtolower($string)); //Would output "Herman archer lives in new york" ``` Also if you wanted every word to start with a captial you could do ``` ucwords(strtolower($string)); //Would output "Herman Archer Lives In New York" ```
22,171,005
i try to get some records from DB Package (ORTAK.MERNIS) using its function (GETMERNISINFO(v\_var number)) into PLL package type (MERNISLIB.MERNIS\_USER). But I ve a trouble with sending parameter to db package function (:TCK). It throws ***ORA-01008 : Not all variables bound*** If I set function parameter statically...
2014/03/04
[ "https://Stackoverflow.com/questions/22171005", "https://Stackoverflow.com", "https://Stackoverflow.com/users/658812/" ]
``` $str = 'stRing'; ucfirst(strtolower($str)); ``` Will output: String
Use [mb\_convert\_case](http://php.net/manual/function.mb-convert-case.php), but you have to create an equivalent to ucfirst: ``` <?php function mb_ucfirst($string) { $string = mb_strtoupper(mb_substr($string, 0, 1)) . mb_substr($string, 1); return $string; } $string = 'hEllO wOrLD'; ...
22,171,005
i try to get some records from DB Package (ORTAK.MERNIS) using its function (GETMERNISINFO(v\_var number)) into PLL package type (MERNISLIB.MERNIS\_USER). But I ve a trouble with sending parameter to db package function (:TCK). It throws ***ORA-01008 : Not all variables bound*** If I set function parameter statically...
2014/03/04
[ "https://Stackoverflow.com/questions/22171005", "https://Stackoverflow.com", "https://Stackoverflow.com/users/658812/" ]
Just do ``` ucfirst(strtolower($string)); //Would output "Herman archer lives in new york" ``` Also if you wanted every word to start with a captial you could do ``` ucwords(strtolower($string)); //Would output "Herman Archer Lives In New York" ```
To make all chars of a string lowercase except the first, use: ``` echo $word[0] . strtolower(substr($word, 1)); ```
22,171,005
i try to get some records from DB Package (ORTAK.MERNIS) using its function (GETMERNISINFO(v\_var number)) into PLL package type (MERNISLIB.MERNIS\_USER). But I ve a trouble with sending parameter to db package function (:TCK). It throws ***ORA-01008 : Not all variables bound*** If I set function parameter statically...
2014/03/04
[ "https://Stackoverflow.com/questions/22171005", "https://Stackoverflow.com", "https://Stackoverflow.com/users/658812/" ]
To make all chars of a string lowercase except the first, use: ``` echo $word[0] . strtolower(substr($word, 1)); ```
Use [mb\_convert\_case](http://php.net/manual/function.mb-convert-case.php), but you have to create an equivalent to ucfirst: ``` <?php function mb_ucfirst($string) { $string = mb_strtoupper(mb_substr($string, 0, 1)) . mb_substr($string, 1); return $string; } $string = 'hEllO wOrLD'; ...
22,171,005
i try to get some records from DB Package (ORTAK.MERNIS) using its function (GETMERNISINFO(v\_var number)) into PLL package type (MERNISLIB.MERNIS\_USER). But I ve a trouble with sending parameter to db package function (:TCK). It throws ***ORA-01008 : Not all variables bound*** If I set function parameter statically...
2014/03/04
[ "https://Stackoverflow.com/questions/22171005", "https://Stackoverflow.com", "https://Stackoverflow.com/users/658812/" ]
Just do ``` ucfirst(strtolower($string)); //Would output "Herman archer lives in new york" ``` Also if you wanted every word to start with a captial you could do ``` ucwords(strtolower($string)); //Would output "Herman Archer Lives In New York" ```
Use [mb\_convert\_case](http://php.net/manual/function.mb-convert-case.php), but you have to create an equivalent to ucfirst: ``` <?php function mb_ucfirst($string) { $string = mb_strtoupper(mb_substr($string, 0, 1)) . mb_substr($string, 1); return $string; } $string = 'hEllO wOrLD'; ...
34,890,534
Let's say I have a single text output, for example "This is an EditText"(textToUse). I want to display this same text output into not 1, but multiple EditText fields. If I have 3 EditText ids: edit1, edit2 and edit3 Instead of using just: ``` private EditText mEditText; private String textToUse; mEditText = (Edit...
2016/01/20
[ "https://Stackoverflow.com/questions/34890534", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5648032/" ]
Using ELBs remains valuable because redundancy is part of the service. Using Nginx as load-balancer would be a single point of failure unless you also set up a standby server and something like `heartbeat` to automatically fail over to your spare Nginx server. Consider a layered approach of using both ELB and Nginx....
<http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.managing.elb.html> > > You can change the listener protocol from HTTP to TCP if you want the > load balancer to forward requests as-is. **This prevents the load > balancer from rewriting headers (including X-Forwarded-For)** and does > not work ...
34,890,534
Let's say I have a single text output, for example "This is an EditText"(textToUse). I want to display this same text output into not 1, but multiple EditText fields. If I have 3 EditText ids: edit1, edit2 and edit3 Instead of using just: ``` private EditText mEditText; private String textToUse; mEditText = (Edit...
2016/01/20
[ "https://Stackoverflow.com/questions/34890534", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5648032/" ]
Using ELBs remains valuable because redundancy is part of the service. Using Nginx as load-balancer would be a single point of failure unless you also set up a standby server and something like `heartbeat` to automatically fail over to your spare Nginx server. Consider a layered approach of using both ELB and Nginx....
Here's a tool I made for those looking to use Fail2Ban on aws with apache, ELB, and ACL: <https://github.com/anthonymartin/aws-acl-fail2ban> It's useful for detecting and preventing DoS attacks and abuse of ec2 instances.
34,890,534
Let's say I have a single text output, for example "This is an EditText"(textToUse). I want to display this same text output into not 1, but multiple EditText fields. If I have 3 EditText ids: edit1, edit2 and edit3 Instead of using just: ``` private EditText mEditText; private String textToUse; mEditText = (Edit...
2016/01/20
[ "https://Stackoverflow.com/questions/34890534", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5648032/" ]
<http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.managing.elb.html> > > You can change the listener protocol from HTTP to TCP if you want the > load balancer to forward requests as-is. **This prevents the load > balancer from rewriting headers (including X-Forwarded-For)** and does > not work ...
Here's a tool I made for those looking to use Fail2Ban on aws with apache, ELB, and ACL: <https://github.com/anthonymartin/aws-acl-fail2ban> It's useful for detecting and preventing DoS attacks and abuse of ec2 instances.
34,890,534
Let's say I have a single text output, for example "This is an EditText"(textToUse). I want to display this same text output into not 1, but multiple EditText fields. If I have 3 EditText ids: edit1, edit2 and edit3 Instead of using just: ``` private EditText mEditText; private String textToUse; mEditText = (Edit...
2016/01/20
[ "https://Stackoverflow.com/questions/34890534", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5648032/" ]
Its been a while since this question was asked, but I thought it might be worth pointing out that both Classic and next generation Application Load Balancers now support Security Groups for limiting access to your load balancer - <http://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-update-s...
<http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.managing.elb.html> > > You can change the listener protocol from HTTP to TCP if you want the > load balancer to forward requests as-is. **This prevents the load > balancer from rewriting headers (including X-Forwarded-For)** and does > not work ...
34,890,534
Let's say I have a single text output, for example "This is an EditText"(textToUse). I want to display this same text output into not 1, but multiple EditText fields. If I have 3 EditText ids: edit1, edit2 and edit3 Instead of using just: ``` private EditText mEditText; private String textToUse; mEditText = (Edit...
2016/01/20
[ "https://Stackoverflow.com/questions/34890534", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5648032/" ]
Its been a while since this question was asked, but I thought it might be worth pointing out that both Classic and next generation Application Load Balancers now support Security Groups for limiting access to your load balancer - <http://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-update-s...
Here's a tool I made for those looking to use Fail2Ban on aws with apache, ELB, and ACL: <https://github.com/anthonymartin/aws-acl-fail2ban> It's useful for detecting and preventing DoS attacks and abuse of ec2 instances.
928,504
After my .NET program is installed, how do I set the system PATH to include my program absolute directory such that the user can launch my .exe from any directory within the console? Note: I want this to be done automatically without the end-user having to manually add the PATH himself.
2009/05/29
[ "https://Stackoverflow.com/questions/928504", "https://Stackoverflow.com", "https://Stackoverflow.com/users/65313/" ]
I am assuming you're using the VS2008 built-in installer and not InstallShield or Wise or something like that (which both have much better ways). You can create an installer class that adds it (see below). You then add your installer class as a [custom action for install and uninstall](http://msdn.microsoft.com/en-us...
Most installers will allow you to append to the system path environment variable. Check the documentation for this feature. If you're installing manually, you can use setx.exe (from the resource kit IIRC) to modify the path - but be careful, you do not want to replace the existing path with just your app's directory, ...
928,504
After my .NET program is installed, how do I set the system PATH to include my program absolute directory such that the user can launch my .exe from any directory within the console? Note: I want this to be done automatically without the end-user having to manually add the PATH himself.
2009/05/29
[ "https://Stackoverflow.com/questions/928504", "https://Stackoverflow.com", "https://Stackoverflow.com/users/65313/" ]
I am assuming you're using the VS2008 built-in installer and not InstallShield or Wise or something like that (which both have much better ways). You can create an installer class that adds it (see below). You then add your installer class as a [custom action for install and uninstall](http://msdn.microsoft.com/en-us...
You can access and append to the current path at this registry location: ``` HLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\Path ``` This is a change better made in your installer, not in your actual application. Make sure you *append* to the registry value, and don't just *set* it...
14,606,611
I can't figure out how to set the alignment of text and its compound drawable (smaller than text) in a TextView. It seems the default alignment is center, but I need to align them by the edge. PS: The `android:gravity` works great if compound drawable is larger than text, but not if smaller.
2013/01/30
[ "https://Stackoverflow.com/questions/14606611", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1241939/" ]
It sounds like you're using an image with fixed dimensions for `android:drawableLeft`. Try using a [nine-patch](http://developer.android.com/guide/topics/graphics/2d-graphics.html#nine-patch) or defining a drawable through an XML resource file. In this way your drawable's dimensions will stretch to align in the `TextV...
I had a similar problem in that I wanted to use setCompoundDrawables to set a top drawable for a floating hint, however TextView (EditText) sets the top drawable to center, irrespective of what its width is. I am using a custom Drawable, and inside its draw method, I am grabbing the clipBounds, and translating on its ...
57,375,838
How can I avoid excess subscriptions? Is there a function that can be used for making sure any active subscriptions are unsubscribed? ```js clickDown(e) { this.mouseMoveSubscription = fromEvent(this.elementRef.nativeElement, 'mousemove') .subscribe((e: MouseEvent) => { console.log(e); ...
2019/08/06
[ "https://Stackoverflow.com/questions/57375838", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11883991/" ]
Assuming you're not using `async` pipes, then the currently accepted pattern is to use either `takeUntil` or `takeWhile` to manage your subscriptions `onDestroy`. For example: ```js import { Component, OnDestroy, OnInit } from '@angular/core'; import { Router } from '@angular/router'; import { takeWhile } from 'rxjs/...
Unsubscribe from previous and subscribe again if successful: ``` clickDown(e) { if(this.mouseMoveSubscription) this.mouseMoveSubscription.unsubscribe(); this.mouseMoveSubscription = fromEvent(this.elementRef.nativeElement, 'mousemove') .subscribe((e: MouseEvent) => { console.log(e); ...
57,375,838
How can I avoid excess subscriptions? Is there a function that can be used for making sure any active subscriptions are unsubscribed? ```js clickDown(e) { this.mouseMoveSubscription = fromEvent(this.elementRef.nativeElement, 'mousemove') .subscribe((e: MouseEvent) => { console.log(e); ...
2019/08/06
[ "https://Stackoverflow.com/questions/57375838", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11883991/" ]
Unsubscribe from previous and subscribe again if successful: ``` clickDown(e) { if(this.mouseMoveSubscription) this.mouseMoveSubscription.unsubscribe(); this.mouseMoveSubscription = fromEvent(this.elementRef.nativeElement, 'mousemove') .subscribe((e: MouseEvent) => { console.log(e); ...
An even better approach will be to just use async pipes inside your components, Why? 1. They have auto unsubscribe support 2. They run the `markForCheck()` function for the change detection, so you can easily move your components to `onPush` strategy
57,375,838
How can I avoid excess subscriptions? Is there a function that can be used for making sure any active subscriptions are unsubscribed? ```js clickDown(e) { this.mouseMoveSubscription = fromEvent(this.elementRef.nativeElement, 'mousemove') .subscribe((e: MouseEvent) => { console.log(e); ...
2019/08/06
[ "https://Stackoverflow.com/questions/57375838", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11883991/" ]
Another alternative could be to not subscribe observable manually. Add `subscribe()` everywhere can be weary but that's because it's a bad practices You could use `async` pipe provided by Angular. This pipe will subscribe your datas and unsubscribe it when component will be destroyed. **In component do not subs...
Unsubscribe from previous and subscribe again if successful: ``` clickDown(e) { if(this.mouseMoveSubscription) this.mouseMoveSubscription.unsubscribe(); this.mouseMoveSubscription = fromEvent(this.elementRef.nativeElement, 'mousemove') .subscribe((e: MouseEvent) => { console.log(e); ...
57,375,838
How can I avoid excess subscriptions? Is there a function that can be used for making sure any active subscriptions are unsubscribed? ```js clickDown(e) { this.mouseMoveSubscription = fromEvent(this.elementRef.nativeElement, 'mousemove') .subscribe((e: MouseEvent) => { console.log(e); ...
2019/08/06
[ "https://Stackoverflow.com/questions/57375838", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11883991/" ]
Assuming you're not using `async` pipes, then the currently accepted pattern is to use either `takeUntil` or `takeWhile` to manage your subscriptions `onDestroy`. For example: ```js import { Component, OnDestroy, OnInit } from '@angular/core'; import { Router } from '@angular/router'; import { takeWhile } from 'rxjs/...
An even better approach will be to just use async pipes inside your components, Why? 1. They have auto unsubscribe support 2. They run the `markForCheck()` function for the change detection, so you can easily move your components to `onPush` strategy
57,375,838
How can I avoid excess subscriptions? Is there a function that can be used for making sure any active subscriptions are unsubscribed? ```js clickDown(e) { this.mouseMoveSubscription = fromEvent(this.elementRef.nativeElement, 'mousemove') .subscribe((e: MouseEvent) => { console.log(e); ...
2019/08/06
[ "https://Stackoverflow.com/questions/57375838", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11883991/" ]
Another alternative could be to not subscribe observable manually. Add `subscribe()` everywhere can be weary but that's because it's a bad practices You could use `async` pipe provided by Angular. This pipe will subscribe your datas and unsubscribe it when component will be destroyed. **In component do not subs...
An even better approach will be to just use async pipes inside your components, Why? 1. They have auto unsubscribe support 2. They run the `markForCheck()` function for the change detection, so you can easily move your components to `onPush` strategy
43,534,163
I have three classes inside a package `pack1`. The three classes are `classA` `classB` and `classC`. `classA` ``` public class Address { public String town = null; public String street = null; public int postCode = 0; public int houseNumber = 0; } ``` `classB` ``` public class Course { public S...
2017/04/21
[ "https://Stackoverflow.com/questions/43534163", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6027397/" ]
ShallowCopy: The shallow copy of an object will have exact copy of all the fields of original object. If original object has any references to other objects as fields, then only references of those objects are copied into clone object, copy of those objects are not created. Deep Copy: Deep copy of an object will have ...
To do a shallow copy, you just set one variable equal to another. A shallow copy means that the original and the copy are really the same object. If you have: ``` course2 = course1; course2.name = "math"; ``` then `course1`'s name will also change to "math", because course1 and course2 are the same object. To do a ...
43,534,163
I have three classes inside a package `pack1`. The three classes are `classA` `classB` and `classC`. `classA` ``` public class Address { public String town = null; public String street = null; public int postCode = 0; public int houseNumber = 0; } ``` `classB` ``` public class Course { public S...
2017/04/21
[ "https://Stackoverflow.com/questions/43534163", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6027397/" ]
In **ShallowCopy** only reference value is copied, so if you make any changes to it will directly affect the original copy of that object. But in **DeepCopy** you have to create a new instance of that object and initialize it with the values of the original object and return the newly initialized object. You have ...
To do a shallow copy, you just set one variable equal to another. A shallow copy means that the original and the copy are really the same object. If you have: ``` course2 = course1; course2.name = "math"; ``` then `course1`'s name will also change to "math", because course1 and course2 are the same object. To do a ...
43,534,163
I have three classes inside a package `pack1`. The three classes are `classA` `classB` and `classC`. `classA` ``` public class Address { public String town = null; public String street = null; public int postCode = 0; public int houseNumber = 0; } ``` `classB` ``` public class Course { public S...
2017/04/21
[ "https://Stackoverflow.com/questions/43534163", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6027397/" ]
ShallowCopy: The shallow copy of an object will have exact copy of all the fields of original object. If original object has any references to other objects as fields, then only references of those objects are copied into clone object, copy of those objects are not created. Deep Copy: Deep copy of an object will have ...
In **ShallowCopy** only reference value is copied, so if you make any changes to it will directly affect the original copy of that object. But in **DeepCopy** you have to create a new instance of that object and initialize it with the values of the original object and return the newly initialized object. You have ...
14,803,100
I'm pretty sure this is an easy problem but I am completely blacking out on how to fix this. I am trying to work my way through the PGM class on coursera and it starts of with joint probability distribution. So I am trying to generate a list of all possible distributions given n variables, where each variable can take ...
2013/02/10
[ "https://Stackoverflow.com/questions/14803100", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1560517/" ]
It sounds like you want the Cartesian product: ``` from itertools import product for x in product([0,1], [0,1], [0,1]): print x ``` > > [0, 0, 0] > > [0, 0, 1] > > [0, 1, 0] > > [0, 1, 1] > > [1, 0, 0] > > [1, 0, 1] > > [1, 1, 0] > > [1, 1, 1] > > > >
Slight improvement over Nathan's method: ``` >>> import itertools >>> list(itertools.product([0, 1], repeat=3)) [(0, 0, 0), (0, 0, 1), (0, 1, 0), (0, 1, 1), (1, 0, 0), (1, 0, 1), (1, 1, 0), (1, 1, 1)] ```
14,803,100
I'm pretty sure this is an easy problem but I am completely blacking out on how to fix this. I am trying to work my way through the PGM class on coursera and it starts of with joint probability distribution. So I am trying to generate a list of all possible distributions given n variables, where each variable can take ...
2013/02/10
[ "https://Stackoverflow.com/questions/14803100", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1560517/" ]
If you prefer list comprehension: ``` [[a, b, c] for a in range(2) for b in range(2) for c in range(2)] ``` And I forgot to mention that you can use pprint to get the effect you want: ``` >>> import pprint >>> pprint.pprint([[a, b, c] for a in range(2) for b in range(2) for c in range(2)]) [[0, 0, 0], [0, 0,...
Slight improvement over Nathan's method: ``` >>> import itertools >>> list(itertools.product([0, 1], repeat=3)) [(0, 0, 0), (0, 0, 1), (0, 1, 0), (0, 1, 1), (1, 0, 0), (1, 0, 1), (1, 1, 0), (1, 1, 1)] ```
26,107,017
I have a bar here - <http://jsfiddle.net/3pxnjocp/4/> - that gets an image background when rolled over. When the small box is clicked I want to change the bar to become red and stay red when rolled over. Does anyone see why the code I have is not doing that? The box click adds a class to the bar with a hover pseudo ele...
2014/09/29
[ "https://Stackoverflow.com/questions/26107017", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1008834/" ]
`'none'` shouldn't be quoted in `background-image`. ``` #box.alwaysRed:hover { background-image: none; // no !important required } ``` is all that's needed: ```js var flag=false; $('#flag').click( function() { if(!flag) { $('#flag').css('background-color', 'red'); $('#box').addClass('alwaysRed...
Here you are a working solution <http://jsfiddle.net/3pxnjocp/5/> ``` #box.alwaysRed { background:red !important; } ``` Your jQuery code is working as intended, just your css is not as it should be.
5,220,283
I recently started using R language and now i am using R for most of my 2d plots. Now, I want to use R for generating 3d plots. I have x, y, z data coming from a tool, till now i was using splot in gnuplot to generate a surface plot. I want to use R for generating a surface plot similar to the one splot in gnuplot give...
2011/03/07
[ "https://Stackoverflow.com/questions/5220283", "https://Stackoverflow.com", "https://Stackoverflow.com/users/553766/" ]
It's no secret that I'm a `raster` package fan. It comes with a plot method that uses `rgl` package. The images can be quite the eye-full. This is is the example from `?raster::plot3D` ![enter image description here](https://i.stack.imgur.com/KiFob.jpg) **EDIT** Here's an example of how to plot a surface using a mat...
You can use the `outer` function to generate the matrix from a function: ``` fn3d <- function(x,y) x^2-y^2 persp(outer(seq(-10,10,length=30),seq(-10,10,length=30),fn3d)) ``` Look at `?persp`, there are plenty of examples there. If you want interactive 3d plotting, consider installing the package `rgl`.
5,220,283
I recently started using R language and now i am using R for most of my 2d plots. Now, I want to use R for generating 3d plots. I have x, y, z data coming from a tool, till now i was using splot in gnuplot to generate a surface plot. I want to use R for generating a surface plot similar to the one splot in gnuplot give...
2011/03/07
[ "https://Stackoverflow.com/questions/5220283", "https://Stackoverflow.com", "https://Stackoverflow.com/users/553766/" ]
You can use the `outer` function to generate the matrix from a function: ``` fn3d <- function(x,y) x^2-y^2 persp(outer(seq(-10,10,length=30),seq(-10,10,length=30),fn3d)) ``` Look at `?persp`, there are plenty of examples there. If you want interactive 3d plotting, consider installing the package `rgl`.
The wireframe and levelplot functions in the lattice package use a data format like gnuplot does rather than requireing a matrix.
5,220,283
I recently started using R language and now i am using R for most of my 2d plots. Now, I want to use R for generating 3d plots. I have x, y, z data coming from a tool, till now i was using splot in gnuplot to generate a surface plot. I want to use R for generating a surface plot similar to the one splot in gnuplot give...
2011/03/07
[ "https://Stackoverflow.com/questions/5220283", "https://Stackoverflow.com", "https://Stackoverflow.com/users/553766/" ]
It's no secret that I'm a `raster` package fan. It comes with a plot method that uses `rgl` package. The images can be quite the eye-full. This is is the example from `?raster::plot3D` ![enter image description here](https://i.stack.imgur.com/KiFob.jpg) **EDIT** Here's an example of how to plot a surface using a mat...
The wireframe and levelplot functions in the lattice package use a data format like gnuplot does rather than requireing a matrix.
34,518,592
I am new to java. I am writing an android app and there are many import directives at the beginning of my main.java file. Is there a way to put all import directives into a separate file and somehow just include it in the main.java file?
2015/12/29
[ "https://Stackoverflow.com/questions/34518592", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2982512/" ]
No, sorry, that's not possible. Imports must always be in the file in which they are used.
While you cannot put imports in a separate file, it is not generally a problem when using an IDE. Anyway, you can try to reduce the number imports by using a star character to import all classes of a package, like: ``` import java.io.*; ```
2,053,041
[http://i.stack.imgur.com/t1PlV.jpg](https://i.stack.imgur.com/t1PlV.jpg) The equation must be smooth and satisfy the following two conditions: * When $x \leq -10, y=-50$ * When $x \geq 10, y=50$ Is there an equation (or multiple equations) that lets me graph a curve that looks like that?
2016/12/10
[ "https://math.stackexchange.com/questions/2053041", "https://math.stackexchange.com", "https://math.stackexchange.com/users/356944/" ]
The [sigmoid function](https://en.wikipedia.org/wiki/Sigmoid_function), $S(x) = \frac{1}{1+e^{-x}}$, achieves close to what you need (with appropriate scaling and shifting of the function). Do you need the function to be *exactly* $\pm 50$ when evaluated at $\pm 10$? If so, a polynomial option would be to use somethi...
If necessary you could scale a sine function to make the transition: $$ f(x) = \begin{cases} -50 & \quad x<-10\\ 50\sin(\pi x/20) & \quad -10 \le x \le 10 \\ 50 & \quad x >10 \end{cases}$$
2,053,041
[http://i.stack.imgur.com/t1PlV.jpg](https://i.stack.imgur.com/t1PlV.jpg) The equation must be smooth and satisfy the following two conditions: * When $x \leq -10, y=-50$ * When $x \geq 10, y=50$ Is there an equation (or multiple equations) that lets me graph a curve that looks like that?
2016/12/10
[ "https://math.stackexchange.com/questions/2053041", "https://math.stackexchange.com", "https://math.stackexchange.com/users/356944/" ]
The [sigmoid function](https://en.wikipedia.org/wiki/Sigmoid_function), $S(x) = \frac{1}{1+e^{-x}}$, achieves close to what you need (with appropriate scaling and shifting of the function). Do you need the function to be *exactly* $\pm 50$ when evaluated at $\pm 10$? If so, a polynomial option would be to use somethi...
There exist smooth complactly supported functions on $\mathbb{R}$, namely [bump functions](https://en.wikipedia.org/wiki/Bump_function). Pick any such function and integrate it to obtain a monotonic smooth function $F$ that is zero for small enough values and is some non-zero constant for large enough values. Then you ...
19,798,268
Something inside rails is preventing the the files to be served in utf-8. Did they add some new config for utf-8? I'm running rvm ruby 2 and rails 4 ![Wrong encoding](https://i.stack.imgur.com/SLV7i.png)
2013/11/05
[ "https://Stackoverflow.com/questions/19798268", "https://Stackoverflow.com", "https://Stackoverflow.com/users/230202/" ]
You need to start `evince` asynchronously so that the `sleep` gets to run: ``` for file in *.pdf; do echo $file; evince $file & sleep 20s; killall evince; done ``` **UPDATE** As suggested, this is better: ``` for file in *.pdf; do evince "$file" & evince_pid=$! sleep 20s kill $evince_pid done ...
Use `timeout` (part of GNU coreutils) if available: ``` for f in *.pdf; do echo "$f" timeout 20 evince "$file" done ```
25,753,849
I'm working on a long scrolling website that features a number of full background hi res images. It's currently taking too long to load since all the images are loaded in parallel by default. So before I custom write something to load first what comes first and later what comes later (this way the first scroll will l...
2014/09/09
[ "https://Stackoverflow.com/questions/25753849", "https://Stackoverflow.com", "https://Stackoverflow.com/users/678455/" ]
You can use table and create a class with a specific width for those columns that contain the labels. ``` form.myform table tr td.label { width:100px; } ``` [Check this link](http://jsfiddle.net/bhuy1t1x/6/)
I suggest using correct markup with ID, if you don't want to write ID for each element, create a simple jQuery or JS function which assigns `for` attribute for label and equivalent `id` for input field.
25,753,849
I'm working on a long scrolling website that features a number of full background hi res images. It's currently taking too long to load since all the images are loaded in parallel by default. So before I custom write something to load first what comes first and later what comes later (this way the first scroll will l...
2014/09/09
[ "https://Stackoverflow.com/questions/25753849", "https://Stackoverflow.com", "https://Stackoverflow.com/users/678455/" ]
You can use table and create a class with a specific width for those columns that contain the labels. ``` form.myform table tr td.label { width:100px; } ``` [Check this link](http://jsfiddle.net/bhuy1t1x/6/)
I suggest, that you shouldn't put input element inside label element. Label has a attribute called "for" so you should do: ``` <table> <tr> <td><label for="myInput"></label> <input id="myInput"/></td> </tr> </table> ``` If you don't want to use tables for alignment, you could also use sections with `...
32,994,391
I am building a multilingual application using rails-i18n Ruby on Rails. Most of content (and DB entries) I have to translate is pure text, though part of it has some embedded html. I was thinking of using `<%= raw t('translation_key') %>` instead of the straight `<%= t('translation_key') %>` to account for future cha...
2015/10/07
[ "https://Stackoverflow.com/questions/32994391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4809950/" ]
You just just append \_html to your tag keys to handle HTML in translation tags: ``` en: key_one: test text key_one_html: <p>test text</p> ``` Then the standard code will work: ``` <%= t('key_one_html') %> ```
You could also use the globalize gem for bigger text / html sections of content. <https://github.com/globalize/globalize/blob/master/README.md> It also supports eager loading if you're worried about performance.
32,994,391
I am building a multilingual application using rails-i18n Ruby on Rails. Most of content (and DB entries) I have to translate is pure text, though part of it has some embedded html. I was thinking of using `<%= raw t('translation_key') %>` instead of the straight `<%= t('translation_key') %>` to account for future cha...
2015/10/07
[ "https://Stackoverflow.com/questions/32994391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4809950/" ]
You just just append \_html to your tag keys to handle HTML in translation tags: ``` en: key_one: test text key_one_html: <p>test text</p> ``` Then the standard code will work: ``` <%= t('key_one_html') %> ```
**Performance aspect:** The performance impact should be negligible. Calling `raw` copies the parameter into a new string (an `ActiveSupport::SafeBuffer` to be precise) with its `html_safe` flag set to true. On the other hand there is no longer HTML escaping performed on that string. **Security aspect:** There are m...
32,994,391
I am building a multilingual application using rails-i18n Ruby on Rails. Most of content (and DB entries) I have to translate is pure text, though part of it has some embedded html. I was thinking of using `<%= raw t('translation_key') %>` instead of the straight `<%= t('translation_key') %>` to account for future cha...
2015/10/07
[ "https://Stackoverflow.com/questions/32994391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4809950/" ]
**Performance aspect:** The performance impact should be negligible. Calling `raw` copies the parameter into a new string (an `ActiveSupport::SafeBuffer` to be precise) with its `html_safe` flag set to true. On the other hand there is no longer HTML escaping performed on that string. **Security aspect:** There are m...
You could also use the globalize gem for bigger text / html sections of content. <https://github.com/globalize/globalize/blob/master/README.md> It also supports eager loading if you're worried about performance.