qid
int64
1
74.7M
question
stringlengths
0
58.3k
date
stringlengths
10
10
metadata
list
response_j
stringlengths
2
48.3k
response_k
stringlengths
2
40.5k
148,963
Keeping the GUI responsive while the application does some CPU-heavy processing is one of the challenges of effective GUI programming. [Here's a good discussion](http://wiki.wxpython.org/LongRunningTasks) of how to do this in wxPython. To summarize, there are 3 ways: 1. Use threads 2. Use wxYield 3. Chunk the work an...
2008/09/29
[ "https://Stackoverflow.com/questions/148963", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8206/" ]
Definitely threads. Why? The future is multi-core. Almost any new CPU has more than one core or if it has just one, it might support hyperthreading and thus pretending it has more than one. To effectively make use of multi-core CPUs (and Intel is planing to go up to 32 cores in the not so far future), you need multiple...
This answer doesn't apply to the OP's question regarding Python, but is more of a meta-response. The easy way is threads. However, not every platform has pre-emptive threading (e.g. BREW, some other embedded systems) If possibly, simply chunk the work and do it in the IDLE event handler. Another problem with using th...
148,963
Keeping the GUI responsive while the application does some CPU-heavy processing is one of the challenges of effective GUI programming. [Here's a good discussion](http://wiki.wxpython.org/LongRunningTasks) of how to do this in wxPython. To summarize, there are 3 ways: 1. Use threads 2. Use wxYield 3. Chunk the work an...
2008/09/29
[ "https://Stackoverflow.com/questions/148963", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8206/" ]
Definitely threads. Why? The future is multi-core. Almost any new CPU has more than one core or if it has just one, it might support hyperthreading and thus pretending it has more than one. To effectively make use of multi-core CPUs (and Intel is planing to go up to 32 cores in the not so far future), you need multiple...
Threads - Let's use a simple 2-layer view (GUI, application logic). The application logic work should be done in a separate Python thread. For Asynchronous events that need to propagate up to the GUI layer, use wx's event system to post custom events. Posting wx events is thread safe so you could conceivably do it fro...
148,963
Keeping the GUI responsive while the application does some CPU-heavy processing is one of the challenges of effective GUI programming. [Here's a good discussion](http://wiki.wxpython.org/LongRunningTasks) of how to do this in wxPython. To summarize, there are 3 ways: 1. Use threads 2. Use wxYield 3. Chunk the work an...
2008/09/29
[ "https://Stackoverflow.com/questions/148963", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8206/" ]
Threads. They're what I always go for because you can do it in every framework you need. And once you're used to multi-threading and parallel processing in one language/framework, you're good on all frameworks.
Definitely threads. Why? The future is multi-core. Almost any new CPU has more than one core or if it has just one, it might support hyperthreading and thus pretending it has more than one. To effectively make use of multi-core CPUs (and Intel is planing to go up to 32 cores in the not so far future), you need multiple...
148,963
Keeping the GUI responsive while the application does some CPU-heavy processing is one of the challenges of effective GUI programming. [Here's a good discussion](http://wiki.wxpython.org/LongRunningTasks) of how to do this in wxPython. To summarize, there are 3 ways: 1. Use threads 2. Use wxYield 3. Chunk the work an...
2008/09/29
[ "https://Stackoverflow.com/questions/148963", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8206/" ]
Definitely threads. Why? The future is multi-core. Almost any new CPU has more than one core or if it has just one, it might support hyperthreading and thus pretending it has more than one. To effectively make use of multi-core CPUs (and Intel is planing to go up to 32 cores in the not so far future), you need multiple...
Working with Qt/C++ for Win32. We divide the major work units into different processes. The GUI runs as a separate process and is able to command/receive data from the "worker" processes as needed. Works nicely in todays multi-core world.
148,963
Keeping the GUI responsive while the application does some CPU-heavy processing is one of the challenges of effective GUI programming. [Here's a good discussion](http://wiki.wxpython.org/LongRunningTasks) of how to do this in wxPython. To summarize, there are 3 ways: 1. Use threads 2. Use wxYield 3. Chunk the work an...
2008/09/29
[ "https://Stackoverflow.com/questions/148963", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8206/" ]
Threads - Let's use a simple 2-layer view (GUI, application logic). The application logic work should be done in a separate Python thread. For Asynchronous events that need to propagate up to the GUI layer, use wx's event system to post custom events. Posting wx events is thread safe so you could conceivably do it fro...
Working with Qt/C++ for Win32. We divide the major work units into different processes. The GUI runs as a separate process and is able to command/receive data from the "worker" processes as needed. Works nicely in todays multi-core world.
56,631,624
I try to return a specific .xls file with FindFirstFile(). Howerver it also returns .xlsx, due to naming convention. It is possible to use "\*.xls" in the file explorer to return only .xls files. Does this work for the functi
2019/06/17
[ "https://Stackoverflow.com/questions/56631624", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10191057/" ]
As @Hans Passant said you got bitten by the legacy support for [8.3 MSDOS names](https://en.wikipedia.org/wiki/8.3_filename). Your `LovelyTable.xlsx` also has a secondary name, something like `LOVELY~1.XLS` and this second name is what `FindFirstFile()/FindNextFile()` gives you. The only robust way to avoid such resul...
This is a consequence of support for short 8.3 filenames. Your .xlsx file is given a short name with .xls extension. And it is the short file name that is matching. Whilst you can turn off support for short filenames of drives that you control, that option is not practical for machines that you don't control. So reali...
25,691,677
I do not know much about iframes (never really used them) and I am using it to display a form on one of our pages. Currently we are using wufoo forms and use their embed code, but our seo team discovered that the embed form is adding h1 tags to things that we do not want. So we are taking the form and putting it to our...
2014/09/05
[ "https://Stackoverflow.com/questions/25691677", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1649697/" ]
Sorry, but it seems you cannot do this in Smarty2. I tried a few ways but it doesn't work. There is no `scope` property in Smarty3. You looked at documentation of Smarty3 and you should look at [documentation for Smarty2](http://www.smarty.net/docsv2/en/)
I was making the assumption that using {include file='mytemplate.tpl'} would find the "file" however it did not work until I used the full absolute path such as: {include file='/home/username/public\_html/mysite/custom\_template.tpl} and getting the variable using the format: {$smarty.capture.myvariable\_name} so I ans...
19,690,653
I am using the decorator pattern for a `List<WebElement>`.Part of this decoration entails using a proxy. When I call `get(index)` with an index that is out of bounds, it throws an `IndexOutOfBounds` exception, which is then caught by the proxy, and wrapped with an `UndeclaredThrowableException`. My understanding is ...
2013/10/30
[ "https://Stackoverflow.com/questions/19690653", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1769273/" ]
Vic Jang is right. You need to wrap the invocation in try-catch and rethrow the inner exception. ``` try { return method.invoke(webElements, args); } catch (InvocationTargetException ite) { throw ite.getCause(); } ``` The reason is that "Method.invoke" wraps in InvocationTargetException those exceptions which ar...
I don't have enough reputation to comment. Your problem seems very similar to [this one](http://amitstechblog.wordpress.com/2011/07/24/java-proxies-and-undeclaredthrowableexception/) You can look at the solution there and see if that works. In short, you need to wrap your `method.invoke` into `try{}`, `catch` the exc...
56,372,208
I have two variables and want to assign same value to both the variables at the same time something like below: ``` var allGood: Boolean = false val deviceId: String = "3550200583" var isValidId: Boolean = false allGood = isValidId = deviceId.length > 0 && deviceId.length <= 16 ``` is there any way to achieve this?
2019/05/30
[ "https://Stackoverflow.com/questions/56372208", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3629588/" ]
Because assignment is not an expression in Kotlin, you can't do multiple assignments that way.  But there are other ways.  The most obvious is simply: ``` isValidId = deviceId.length > 0 && deviceId.length <= 16 allGood = isValidId ``` A more idiomatic (if longer) way is: ``` (deviceId.length > 0 && deviceId.length...
Another way is to do it like this: ``` val deviceId: String = "3550200583"; val condition = deviceId.length > 0 && deviceId.length <= 16 var (allGood, isValidId) = arrayOf(condition, condition); ```
56,372,208
I have two variables and want to assign same value to both the variables at the same time something like below: ``` var allGood: Boolean = false val deviceId: String = "3550200583" var isValidId: Boolean = false allGood = isValidId = deviceId.length > 0 && deviceId.length <= 16 ``` is there any way to achieve this?
2019/05/30
[ "https://Stackoverflow.com/questions/56372208", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3629588/" ]
Because assignment is not an expression in Kotlin, you can't do multiple assignments that way.  But there are other ways.  The most obvious is simply: ``` isValidId = deviceId.length > 0 && deviceId.length <= 16 allGood = isValidId ``` A more idiomatic (if longer) way is: ``` (deviceId.length > 0 && deviceId.length...
What about: ``` var allGood: Boolean = false val deviceId: String = ... val isValidId: Boolean = (deviceId.length in 1..16).also { allGood = it } ``` `.also` allows you to perform additional operations with the value that it receives and then returns the original value.
56,372,208
I have two variables and want to assign same value to both the variables at the same time something like below: ``` var allGood: Boolean = false val deviceId: String = "3550200583" var isValidId: Boolean = false allGood = isValidId = deviceId.length > 0 && deviceId.length <= 16 ``` is there any way to achieve this?
2019/05/30
[ "https://Stackoverflow.com/questions/56372208", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3629588/" ]
What about: ``` var allGood: Boolean = false val deviceId: String = ... val isValidId: Boolean = (deviceId.length in 1..16).also { allGood = it } ``` `.also` allows you to perform additional operations with the value that it receives and then returns the original value.
Another way is to do it like this: ``` val deviceId: String = "3550200583"; val condition = deviceId.length > 0 && deviceId.length <= 16 var (allGood, isValidId) = arrayOf(condition, condition); ```
28,044,180
I have looked on the web and I cannot find anything that helps me, all I can find is changing the characters into ASCII or Hexadecimal. However I would like to do it a different way. For example, say the string that got passed in was `abcdef`, I would like to have a key which changes these characters into another strin...
2015/01/20
[ "https://Stackoverflow.com/questions/28044180", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4366103/" ]
Because `%` is a format specifier escape sequence (as in `%d` would print an `int`). To get the program to print the actual symbol, you write `%%`. The same goes for `\` (although fundamentally different, you still need to to print one).
``` "%%" ``` in printf is an escaped '%' sign. See this Stack Overflow answer: *[How to escape the % (percent) sign in C's printf](https://stackoverflow.com/questions/1860159/how-to-escape-the-sign-in-cs-printf)*
28,044,180
I have looked on the web and I cannot find anything that helps me, all I can find is changing the characters into ASCII or Hexadecimal. However I would like to do it a different way. For example, say the string that got passed in was `abcdef`, I would like to have a key which changes these characters into another strin...
2015/01/20
[ "https://Stackoverflow.com/questions/28044180", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4366103/" ]
Because `%` is a format specifier escape sequence (as in `%d` would print an `int`). To get the program to print the actual symbol, you write `%%`. The same goes for `\` (although fundamentally different, you still need to to print one).
The `"%"` is a special character, and it's used to specify format specifiers. To print a literal `"%"`, you need a sequence of two `"%%"`. The `"%"` is used in the format string to specify a placeholder that will be replaced by a corresponding argument passed to the functions that format their output, like `printf()`/...
28,044,180
I have looked on the web and I cannot find anything that helps me, all I can find is changing the characters into ASCII or Hexadecimal. However I would like to do it a different way. For example, say the string that got passed in was `abcdef`, I would like to have a key which changes these characters into another strin...
2015/01/20
[ "https://Stackoverflow.com/questions/28044180", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4366103/" ]
The `"%"` is a special character, and it's used to specify format specifiers. To print a literal `"%"`, you need a sequence of two `"%%"`. The `"%"` is used in the format string to specify a placeholder that will be replaced by a corresponding argument passed to the functions that format their output, like `printf()`/...
``` "%%" ``` in printf is an escaped '%' sign. See this Stack Overflow answer: *[How to escape the % (percent) sign in C's printf](https://stackoverflow.com/questions/1860159/how-to-escape-the-sign-in-cs-printf)*
55,922,994
I'm currently working on a game in monogame. The game is heavily based on clicking buttons and this is where the problem occurs. Whenever I hold down the left mouse button and then move it over a button in the game, that button gets clicked instantly. I've tried to fix the issue in many ways, by rearrange the if state...
2019/04/30
[ "https://Stackoverflow.com/questions/55922994", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10792784/" ]
If `oldState` is declared as instance field, different instances of this class will have different versions of it. I.e., the old state may get lost. Declare `oldState` as `static`! ``` private static MouseState oldState = Mouse.GetState(); ```
I usually use a class like this to read the input ``` public class InputManager { KeyboardState currentKeyboard, previousKeyboard; MouseState currentMouse, previousMouse; public bool LeftKeyIsHeldDown { get; private set; } public bool RightKeyIsHeldDown { get; private set; } public bool JumpWasJus...
16,436,094
I have a code some thing like this ``` dxMemOrdered : TdxMemData; while not qrySandbox2.EOF do begin dxMemOrdered.append; dxMemOrderedTotal.asCurrency := qrySandbox2.FieldByName('TOTAL').asCurrency; dxMemOrdered.post; qrySandbox2.Next; end; ``` this code executes in a thread. When th...
2013/05/08
[ "https://Stackoverflow.com/questions/16436094", "https://Stackoverflow.com", "https://Stackoverflow.com/users/462467/" ]
Some ideas in order of performance gain vs work to do by you: 1) Check if the SQL dialect that you are using lets you use queries that directly SELECT from/INSERT to. This depends on the database you're using. 2) Make sure that if your datasets are not coupled to visual controls, that you call DisableControls/EnableC...
Without seeing more code, the only suggestion I can make is make sure that any visual control that is using the memory table is disabled. Suppose you have a cxgrid called `Grid` that is linked to your dxMemOrdered memory table: ``` var dxMemOrdered: TdxMemData; ... Grid.BeginUpdate; try while not qrySandbox2....
16,436,094
I have a code some thing like this ``` dxMemOrdered : TdxMemData; while not qrySandbox2.EOF do begin dxMemOrdered.append; dxMemOrderedTotal.asCurrency := qrySandbox2.FieldByName('TOTAL').asCurrency; dxMemOrdered.post; qrySandbox2.Next; end; ``` this code executes in a thread. When th...
2013/05/08
[ "https://Stackoverflow.com/questions/16436094", "https://Stackoverflow.com", "https://Stackoverflow.com/users/462467/" ]
Some ideas in order of performance gain vs work to do by you: 1) Check if the SQL dialect that you are using lets you use queries that directly SELECT from/INSERT to. This depends on the database you're using. 2) Make sure that if your datasets are not coupled to visual controls, that you call DisableControls/EnableC...
It's much better to let SQL do the work instead of iterating though a loop in Delphi. Try a query such as ``` insert into dxMemOrdered (total) select total from qrySandbox2 ``` Is 'total' the only field in dxMemOrdered? I hope that it's not the primary key otherwise you are likely to have collisions, meaning that ro...
16,436,094
I have a code some thing like this ``` dxMemOrdered : TdxMemData; while not qrySandbox2.EOF do begin dxMemOrdered.append; dxMemOrderedTotal.asCurrency := qrySandbox2.FieldByName('TOTAL').asCurrency; dxMemOrdered.post; qrySandbox2.Next; end; ``` this code executes in a thread. When th...
2013/05/08
[ "https://Stackoverflow.com/questions/16436094", "https://Stackoverflow.com", "https://Stackoverflow.com/users/462467/" ]
Some ideas in order of performance gain vs work to do by you: 1) Check if the SQL dialect that you are using lets you use queries that directly SELECT from/INSERT to. This depends on the database you're using. 2) Make sure that if your datasets are not coupled to visual controls, that you call DisableControls/EnableC...
There's actually a lot you could do to speed up your thread. The first would be to look at the problem in a broader perspective: * Am I fetching data from a cached / fast disk, possibly moved in memory? * Am I doing the right thing, when aggregating totals by hand? SQL engines are expecially optimized to do those thi...
16,436,094
I have a code some thing like this ``` dxMemOrdered : TdxMemData; while not qrySandbox2.EOF do begin dxMemOrdered.append; dxMemOrderedTotal.asCurrency := qrySandbox2.FieldByName('TOTAL').asCurrency; dxMemOrdered.post; qrySandbox2.Next; end; ``` this code executes in a thread. When th...
2013/05/08
[ "https://Stackoverflow.com/questions/16436094", "https://Stackoverflow.com", "https://Stackoverflow.com/users/462467/" ]
Without seeing more code, the only suggestion I can make is make sure that any visual control that is using the memory table is disabled. Suppose you have a cxgrid called `Grid` that is linked to your dxMemOrdered memory table: ``` var dxMemOrdered: TdxMemData; ... Grid.BeginUpdate; try while not qrySandbox2....
It's much better to let SQL do the work instead of iterating though a loop in Delphi. Try a query such as ``` insert into dxMemOrdered (total) select total from qrySandbox2 ``` Is 'total' the only field in dxMemOrdered? I hope that it's not the primary key otherwise you are likely to have collisions, meaning that ro...
16,436,094
I have a code some thing like this ``` dxMemOrdered : TdxMemData; while not qrySandbox2.EOF do begin dxMemOrdered.append; dxMemOrderedTotal.asCurrency := qrySandbox2.FieldByName('TOTAL').asCurrency; dxMemOrdered.post; qrySandbox2.Next; end; ``` this code executes in a thread. When th...
2013/05/08
[ "https://Stackoverflow.com/questions/16436094", "https://Stackoverflow.com", "https://Stackoverflow.com/users/462467/" ]
Without seeing more code, the only suggestion I can make is make sure that any visual control that is using the memory table is disabled. Suppose you have a cxgrid called `Grid` that is linked to your dxMemOrdered memory table: ``` var dxMemOrdered: TdxMemData; ... Grid.BeginUpdate; try while not qrySandbox2....
There's actually a lot you could do to speed up your thread. The first would be to look at the problem in a broader perspective: * Am I fetching data from a cached / fast disk, possibly moved in memory? * Am I doing the right thing, when aggregating totals by hand? SQL engines are expecially optimized to do those thi...
57,582,901
I am trying to make a new version of AuthenticationStateProvider so that I can use the data already in my db. I called it ServerAuthenticationStateProvider: ``` using Microsoft.AspNetCore.Components; using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Security.Cla...
2019/08/21
[ "https://Stackoverflow.com/questions/57582901", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
You should replace ``` @inject ServerAuthenticationStateProvider AuthenticationStateProvider ``` with ``` @inject AuthenticationStateProvider AuthenticationStateProvider ``` because that is how you registered it.
Note: When you add a service to the DI container, the left-side parameter should be an interface ( or an abstract class), whereas the right-side parameter should be the concrete class, like the following: ``` services.AddScoped<IJSRuntime, RemoteJSRuntime>(); ``` And you can inject the type IJSRuntime into your comp...
57,582,901
I am trying to make a new version of AuthenticationStateProvider so that I can use the data already in my db. I called it ServerAuthenticationStateProvider: ``` using Microsoft.AspNetCore.Components; using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Security.Cla...
2019/08/21
[ "https://Stackoverflow.com/questions/57582901", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
You should replace ``` @inject ServerAuthenticationStateProvider AuthenticationStateProvider ``` with ``` @inject AuthenticationStateProvider AuthenticationStateProvider ``` because that is how you registered it.
In my case it didn't work because i had a **mutated vowel** in my **Database Name**: My db name was "Bücher.dbo" and the "**ü**" wasn't accepted. I changed the name to "Books.dbo" and it worked perfectly fine.
57,582,901
I am trying to make a new version of AuthenticationStateProvider so that I can use the data already in my db. I called it ServerAuthenticationStateProvider: ``` using Microsoft.AspNetCore.Components; using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Security.Cla...
2019/08/21
[ "https://Stackoverflow.com/questions/57582901", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Note: When you add a service to the DI container, the left-side parameter should be an interface ( or an abstract class), whereas the right-side parameter should be the concrete class, like the following: ``` services.AddScoped<IJSRuntime, RemoteJSRuntime>(); ``` And you can inject the type IJSRuntime into your comp...
In my case it didn't work because i had a **mutated vowel** in my **Database Name**: My db name was "Bücher.dbo" and the "**ü**" wasn't accepted. I changed the name to "Books.dbo" and it worked perfectly fine.
36,343,214
I am trying to select specific columns from a large tab-delimited CSV file and output only certain columns to a new CSV file. Furthermore, I want to recode the data as this happens. If the cell has a value of 0 then just output 0. However, if the cell has a value of greater than 0, then just output 1 (i.e., all values ...
2016/03/31
[ "https://Stackoverflow.com/questions/36343214", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5323539/" ]
The first operation in most `Throwable` constructors is to [fill in the stack trace,](https://docs.oracle.com/javase/8/docs/api/java/lang/Throwable.html#fillInStackTrace--) which is where most of the expense is. There is, however, a protected constructor with a flag to disable the stack trace. [This constructor](https...
Using @AustinD's answer as a starting point, I made some tweaks. Code at the bottom. In addition to adding the case where one Exception instance is thrown repeatedly, I also turned off compiler optimization so that we can get accurate performance results. I added `-Djava.compiler=NONE` to the VM arguments, as per [thi...
36,343,214
I am trying to select specific columns from a large tab-delimited CSV file and output only certain columns to a new CSV file. Furthermore, I want to recode the data as this happens. If the cell has a value of 0 then just output 0. However, if the cell has a value of greater than 0, then just output 1 (i.e., all values ...
2016/03/31
[ "https://Stackoverflow.com/questions/36343214", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5323539/" ]
**Creating** an exception object is not *necessarily* more expensive than creating other regular objects. The main cost is hidden in native [`fillInStackTrace`](http://docs.oracle.com/javase/8/docs/api/java/lang/Throwable.html#fillInStackTrace--) method which walks through the call stack and collects all required infor...
The creation of the `Exception` with a `null` stack trace takes about as much time as the `throw` and `try-catch` block together. However, **filling the stack trace takes on average 5x longer**. I created the following benchmark to demonstrate the impact on performance. I added the `-Djava.compiler=NONE` to the Run C...
36,343,214
I am trying to select specific columns from a large tab-delimited CSV file and output only certain columns to a new CSV file. Furthermore, I want to recode the data as this happens. If the cell has a value of 0 then just output 0. However, if the cell has a value of greater than 0, then just output 1 (i.e., all values ...
2016/03/31
[ "https://Stackoverflow.com/questions/36343214", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5323539/" ]
The creation of the `Exception` with a `null` stack trace takes about as much time as the `throw` and `try-catch` block together. However, **filling the stack trace takes on average 5x longer**. I created the following benchmark to demonstrate the impact on performance. I added the `-Djava.compiler=NONE` to the Run C...
Using @AustinD's answer as a starting point, I made some tweaks. Code at the bottom. In addition to adding the case where one Exception instance is thrown repeatedly, I also turned off compiler optimization so that we can get accurate performance results. I added `-Djava.compiler=NONE` to the VM arguments, as per [thi...
36,343,214
I am trying to select specific columns from a large tab-delimited CSV file and output only certain columns to a new CSV file. Furthermore, I want to recode the data as this happens. If the cell has a value of 0 then just output 0. However, if the cell has a value of greater than 0, then just output 1 (i.e., all values ...
2016/03/31
[ "https://Stackoverflow.com/questions/36343214", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5323539/" ]
**Creating** an exception object is not *necessarily* more expensive than creating other regular objects. The main cost is hidden in native [`fillInStackTrace`](http://docs.oracle.com/javase/8/docs/api/java/lang/Throwable.html#fillInStackTrace--) method which walks through the call stack and collects all required infor...
Using @AustinD's answer as a starting point, I made some tweaks. Code at the bottom. In addition to adding the case where one Exception instance is thrown repeatedly, I also turned off compiler optimization so that we can get accurate performance results. I added `-Djava.compiler=NONE` to the VM arguments, as per [thi...
36,343,214
I am trying to select specific columns from a large tab-delimited CSV file and output only certain columns to a new CSV file. Furthermore, I want to recode the data as this happens. If the cell has a value of 0 then just output 0. However, if the cell has a value of greater than 0, then just output 1 (i.e., all values ...
2016/03/31
[ "https://Stackoverflow.com/questions/36343214", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5323539/" ]
The first operation in most `Throwable` constructors is to [fill in the stack trace,](https://docs.oracle.com/javase/8/docs/api/java/lang/Throwable.html#fillInStackTrace--) which is where most of the expense is. There is, however, a protected constructor with a flag to disable the stack trace. [This constructor](https...
This part of the question... > > Another way of asking this is, if I made one instance of Exception and > threw and caught it over and over, would that be significantly faster > than creating a new Exception every time I throw? > > > Seems to be asking if creating an exception and caching it somewhere improves ...
36,343,214
I am trying to select specific columns from a large tab-delimited CSV file and output only certain columns to a new CSV file. Furthermore, I want to recode the data as this happens. If the cell has a value of 0 then just output 0. However, if the cell has a value of greater than 0, then just output 1 (i.e., all values ...
2016/03/31
[ "https://Stackoverflow.com/questions/36343214", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5323539/" ]
**Creating** an exception object is not *necessarily* more expensive than creating other regular objects. The main cost is hidden in native [`fillInStackTrace`](http://docs.oracle.com/javase/8/docs/api/java/lang/Throwable.html#fillInStackTrace--) method which walks through the call stack and collects all required infor...
The first operation in most `Throwable` constructors is to [fill in the stack trace,](https://docs.oracle.com/javase/8/docs/api/java/lang/Throwable.html#fillInStackTrace--) which is where most of the expense is. There is, however, a protected constructor with a flag to disable the stack trace. [This constructor](https...
36,343,214
I am trying to select specific columns from a large tab-delimited CSV file and output only certain columns to a new CSV file. Furthermore, I want to recode the data as this happens. If the cell has a value of 0 then just output 0. However, if the cell has a value of greater than 0, then just output 1 (i.e., all values ...
2016/03/31
[ "https://Stackoverflow.com/questions/36343214", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5323539/" ]
Theres a good write up on Exceptions here. <http://shipilev.net/blog/2014/exceptional-performance/> The conclusion being that stack trace construction and stack unwinding are the expensive parts. The code below takes advantage of a feature in `1.7` where we can turn stack traces on and off. We can then use this to se...
This part of the question... > > Another way of asking this is, if I made one instance of Exception and > threw and caught it over and over, would that be significantly faster > than creating a new Exception every time I throw? > > > Seems to be asking if creating an exception and caching it somewhere improves ...
36,343,214
I am trying to select specific columns from a large tab-delimited CSV file and output only certain columns to a new CSV file. Furthermore, I want to recode the data as this happens. If the cell has a value of 0 then just output 0. However, if the cell has a value of greater than 0, then just output 1 (i.e., all values ...
2016/03/31
[ "https://Stackoverflow.com/questions/36343214", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5323539/" ]
Theres a good write up on Exceptions here. <http://shipilev.net/blog/2014/exceptional-performance/> The conclusion being that stack trace construction and stack unwinding are the expensive parts. The code below takes advantage of a feature in `1.7` where we can turn stack traces on and off. We can then use this to se...
The creation of the `Exception` with a `null` stack trace takes about as much time as the `throw` and `try-catch` block together. However, **filling the stack trace takes on average 5x longer**. I created the following benchmark to demonstrate the impact on performance. I added the `-Djava.compiler=NONE` to the Run C...
36,343,214
I am trying to select specific columns from a large tab-delimited CSV file and output only certain columns to a new CSV file. Furthermore, I want to recode the data as this happens. If the cell has a value of 0 then just output 0. However, if the cell has a value of greater than 0, then just output 1 (i.e., all values ...
2016/03/31
[ "https://Stackoverflow.com/questions/36343214", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5323539/" ]
**Creating** an exception object is not *necessarily* more expensive than creating other regular objects. The main cost is hidden in native [`fillInStackTrace`](http://docs.oracle.com/javase/8/docs/api/java/lang/Throwable.html#fillInStackTrace--) method which walks through the call stack and collects all required infor...
This part of the question... > > Another way of asking this is, if I made one instance of Exception and > threw and caught it over and over, would that be significantly faster > than creating a new Exception every time I throw? > > > Seems to be asking if creating an exception and caching it somewhere improves ...
36,343,214
I am trying to select specific columns from a large tab-delimited CSV file and output only certain columns to a new CSV file. Furthermore, I want to recode the data as this happens. If the cell has a value of 0 then just output 0. However, if the cell has a value of greater than 0, then just output 1 (i.e., all values ...
2016/03/31
[ "https://Stackoverflow.com/questions/36343214", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5323539/" ]
**Creating** an exception object is not *necessarily* more expensive than creating other regular objects. The main cost is hidden in native [`fillInStackTrace`](http://docs.oracle.com/javase/8/docs/api/java/lang/Throwable.html#fillInStackTrace--) method which walks through the call stack and collects all required infor...
Theres a good write up on Exceptions here. <http://shipilev.net/blog/2014/exceptional-performance/> The conclusion being that stack trace construction and stack unwinding are the expensive parts. The code below takes advantage of a feature in `1.7` where we can turn stack traces on and off. We can then use this to se...
66,959
GF and I have a flight from Montreal (YUL) to Rome (FCO) via Heathrow (LHR) Terminal 5. Both flights are on British Airways and were booked on the BA sites at the same time. Arriving at LHR at Terminal 5 at 9:35am, leaving LHR from Terminal 5 at 10:40am. I don't think I've had such a small delay between flights. The...
2016/04/20
[ "https://travel.stackexchange.com/questions/66959", "https://travel.stackexchange.com", "https://travel.stackexchange.com/users/8279/" ]
I'm only a little nervous about your connection. It is *technically* doable, and you can certainly [get from arrival gate to departure gate](http://www.heathrow.com/flight-connections/personal-connection-planner/BA094/BA546/22-APR-2016/22-APR-2016/5/6B) with plenty of time, if queues at security aren't too long. But,...
Just to answer a few of your other questions: > > Should We tell the flight attendants when checking in the luggage > about the connection ? > > > No need as they will have all the information required once they enter your reservation number. You can ask them to put a priority handling tag on your checked in lu...
23,052,035
I am getting an error attempting to start mongo with authorization enabled via the security.authorization configuration parameter (see <http://docs.mongodb.org/manual/reference/configuration-options/#security.authorization>) On running mongod I get ``` Error parsing INI config file: unknown option security.authorizat...
2014/04/14
[ "https://Stackoverflow.com/questions/23052035", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3530446/" ]
**Note:** I would have written this as a comment, however I do not have the points yet. Just wondering whether what you are trying to achieve is *authentication* instead? If this is the case, all you need to set in `mongodb.conf` is: ``` # auth auth = true # true or false. Whether or not authentication is required...
MongoDB server config file format changed from version 2.6 and still old format works. <http://docs.mongodb.org/manual/reference/configuration-options/> > > Changed in version 2.6: MongoDB introduces a YAML-based configuration file format. The 2.4 configuration file format remains for backward compatibility. > > ...
12,916,379
I've been playing with this and so far I haven't been able to find any way to hide or trick `instanceof` into returning `false` by hiding its type through layers of obfuscation, but that doesn't mean it's not possible since I'm far from the most knowledgeable person about Java. So I've come to ask the experts. I've tr...
2012/10/16
[ "https://Stackoverflow.com/questions/12916379", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1435657/" ]
It is possible to confuse yourself with `instanceof` but not the JVM. * classes with the same name but in different packages are not the same. This means you can do ``` // in one class ClassA classA = new ClassA(); // package1.ClassA another.test(classA); // calls in another class public void test(Object o) { if ...
> > So basically, is there any way to hide this information or to somehow lose the type information? > > > No it is not possible. Each object has a real type, and Java's strong + static type system makes it impossible to alter the type of an object, or pretend that its actual type is different to what it is. ---...
12,916,379
I've been playing with this and so far I haven't been able to find any way to hide or trick `instanceof` into returning `false` by hiding its type through layers of obfuscation, but that doesn't mean it's not possible since I'm far from the most knowledgeable person about Java. So I've come to ask the experts. I've tr...
2012/10/16
[ "https://Stackoverflow.com/questions/12916379", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1435657/" ]
> > So basically, is there any way to hide this information or to somehow lose the type information? > > > No it is not possible. Each object has a real type, and Java's strong + static type system makes it impossible to alter the type of an object, or pretend that its actual type is different to what it is. ---...
You could run the code through an obfuscator. But this is basically a rename. `TestObject` may be renamed to e.g. `A`, but `instanceof A` still returns the correct result. BTW: naming your classes \*Object is a bad idea (in object oriented languages).
12,916,379
I've been playing with this and so far I haven't been able to find any way to hide or trick `instanceof` into returning `false` by hiding its type through layers of obfuscation, but that doesn't mean it's not possible since I'm far from the most knowledgeable person about Java. So I've come to ask the experts. I've tr...
2012/10/16
[ "https://Stackoverflow.com/questions/12916379", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1435657/" ]
> > So basically, is there any way to hide this information or to somehow lose the type information? > > > No it is not possible. Each object has a real type, and Java's strong + static type system makes it impossible to alter the type of an object, or pretend that its actual type is different to what it is. ---...
It depends on what the OP really wants, but [this](http://ideone.com/5KtHs) may do it. Basically I make the class private. This means any `object instanceof Class` code will not compile (outside the scope of the private class).
12,916,379
I've been playing with this and so far I haven't been able to find any way to hide or trick `instanceof` into returning `false` by hiding its type through layers of obfuscation, but that doesn't mean it's not possible since I'm far from the most knowledgeable person about Java. So I've come to ask the experts. I've tr...
2012/10/16
[ "https://Stackoverflow.com/questions/12916379", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1435657/" ]
It is possible to confuse yourself with `instanceof` but not the JVM. * classes with the same name but in different packages are not the same. This means you can do ``` // in one class ClassA classA = new ClassA(); // package1.ClassA another.test(classA); // calls in another class public void test(Object o) { if ...
You could run the code through an obfuscator. But this is basically a rename. `TestObject` may be renamed to e.g. `A`, but `instanceof A` still returns the correct result. BTW: naming your classes \*Object is a bad idea (in object oriented languages).
12,916,379
I've been playing with this and so far I haven't been able to find any way to hide or trick `instanceof` into returning `false` by hiding its type through layers of obfuscation, but that doesn't mean it's not possible since I'm far from the most knowledgeable person about Java. So I've come to ask the experts. I've tr...
2012/10/16
[ "https://Stackoverflow.com/questions/12916379", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1435657/" ]
It is possible to confuse yourself with `instanceof` but not the JVM. * classes with the same name but in different packages are not the same. This means you can do ``` // in one class ClassA classA = new ClassA(); // package1.ClassA another.test(classA); // calls in another class public void test(Object o) { if ...
It depends on what the OP really wants, but [this](http://ideone.com/5KtHs) may do it. Basically I make the class private. This means any `object instanceof Class` code will not compile (outside the scope of the private class).
73,407,561
I am trying to create a simple powershell script which will allow it to display the PID and the starttime of a process. For the moment this is my code --> ``` $proc=$args[0] if (get-process -name $proc -ErrorAction SilentlyContinue) { $time= get-process $proc | Select-Object starttime |format-table -HideTabl...
2022/08/18
[ "https://Stackoverflow.com/questions/73407561", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17263768/" ]
There are two common problems with your code: * `Format-*` cmdlets emit output objects whose sole purpose is to provide *formatting instructions* to PowerShell's for-display output-formatting system. In short: **only ever use `Format-*` cmdlets to format data *for display*, never for subsequent *programmatic processin...
Found an answer for my own question. If anyone else is wondering why this happens , it is all explained in this post. [How can I store output from Format-Table for later use](https://stackoverflow.com/questions/36358047/how-can-i-store-output-from-format-table-for-later-use)
269,171
For a particular problem, I need to have a list that: 1. supports `O(1)` prepend, and 2. that I can call [`bisect.bisect_left`](https://docs.python.org/3.9/library/bisect.html?highlight=bisect#bisect.bisect_left) on, which means the list must be sorted. Prepending to a list via `list.insert(0, item)` is `O(N)`; howev...
2021/10/20
[ "https://codereview.stackexchange.com/questions/269171", "https://codereview.stackexchange.com", "https://codereview.stackexchange.com/users/239973/" ]
> > Should just use a `deque`? > > > No. Unless you're ok with `bisect_left` taking O(n log n) instead of O(log n). Your class doesn't support negative indexes, like lists normally do. Not saying you should add that (up to you, doesn't sound like you need it), but you can take advantage of lists supporting it to ...
> > Should I just use a `deque`? > > > Maybe, it depends on what exactly you're trying to do, but probably not - as dont talk just code pointed out, `deque` does not offer efficient access to elements near the middle, which is very much not great for binary search. Which is unfortunate, since this approach does co...
74,344,367
I have a data frame: ``` pl.DataFrame({'no_of_docs':[[9,4,2], [3,9,1,10], [10,3,2,1], [10,30], [1,2,3,6,4,5]]}) ``` Here the column: no\_of\_docs is a list[int] type one: i would like to add a new column w...
2022/11/07
[ "https://Stackoverflow.com/questions/74344367", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9479925/" ]
I have found a way to do it for list[int] type as below: ``` df.with_column(pl.col('no_of_docs').arr.arg_max().alias('idx') ``` The same thing to be done to list[str] type.
Can you try this code please : ```py df['idx']=[sub_list.index(max(sub_list)) for sub_list in df['no_of_docs']] ```
74,344,367
I have a data frame: ``` pl.DataFrame({'no_of_docs':[[9,4,2], [3,9,1,10], [10,3,2,1], [10,30], [1,2,3,6,4,5]]}) ``` Here the column: no\_of\_docs is a list[int] type one: i would like to add a new column w...
2022/11/07
[ "https://Stackoverflow.com/questions/74344367", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9479925/" ]
I mean you answered the question mostly yourself, but in case you still need the casting to List[i64]. Here would be the solution ``` df.with_column( pl.col("no_of_docs").cast(pl.List(pl.Int64)).arr.arg_max().alias('idx') ) shape: (5, 2) ┌──────────────────────┬─────┐ │ no_of_docs ┆ idx │ │ --- ...
Can you try this code please : ```py df['idx']=[sub_list.index(max(sub_list)) for sub_list in df['no_of_docs']] ```
1,646,326
I'm soon to launch a [beta app](http://www.bestsellerapp.com/) and this have the option to create custom integration scripts on [Python](http://en.wikipedia.org/wiki/Python_(programming_language)). The app will target [Mac OS X](http://en.wikipedia.org/wiki/Mac_OS_X) and Windows, and my problem is with Windows where P...
2009/10/29
[ "https://Stackoverflow.com/questions/1646326", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53185/" ]
Copy a [Portable Python](http://www.portablepython.com/) folder out of your installer, into the same folder as your Delphi/Lazarus app. Set all paths appropriately for that.
You might try using [py2exe](http://www.py2exe.org/). It creates a .exe file with Python already included!
1,646,326
I'm soon to launch a [beta app](http://www.bestsellerapp.com/) and this have the option to create custom integration scripts on [Python](http://en.wikipedia.org/wiki/Python_(programming_language)). The app will target [Mac OS X](http://en.wikipedia.org/wiki/Mac_OS_X) and Windows, and my problem is with Windows where P...
2009/10/29
[ "https://Stackoverflow.com/questions/1646326", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53185/" ]
You might try using [py2exe](http://www.py2exe.org/). It creates a .exe file with Python already included!
Integrate the python interpreter into your Delphi app with [P4D](http://python4delphi.googlecode.com/svn/trunk/). These components actually work, and in both directions too (Delphi classes exposed to Python as binary extensions, and Python interpreter inside Delphi). I also saw a patch for Lazarus compatibility on the ...
1,646,326
I'm soon to launch a [beta app](http://www.bestsellerapp.com/) and this have the option to create custom integration scripts on [Python](http://en.wikipedia.org/wiki/Python_(programming_language)). The app will target [Mac OS X](http://en.wikipedia.org/wiki/Mac_OS_X) and Windows, and my problem is with Windows where P...
2009/10/29
[ "https://Stackoverflow.com/questions/1646326", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53185/" ]
You might try using [py2exe](http://www.py2exe.org/). It creates a .exe file with Python already included!
I think there's no problem combining .EXE packaging with a tool like PyInstaller or py2exe and Python-written plugins. The created .EXE can easily detect where it's installed and the code inside can then simply `import` files from some pre-determined plugin directory. Don't forget that once you package a Python script ...
1,646,326
I'm soon to launch a [beta app](http://www.bestsellerapp.com/) and this have the option to create custom integration scripts on [Python](http://en.wikipedia.org/wiki/Python_(programming_language)). The app will target [Mac OS X](http://en.wikipedia.org/wiki/Mac_OS_X) and Windows, and my problem is with Windows where P...
2009/10/29
[ "https://Stackoverflow.com/questions/1646326", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53185/" ]
Copy a [Portable Python](http://www.portablepython.com/) folder out of your installer, into the same folder as your Delphi/Lazarus app. Set all paths appropriately for that.
Integrate the python interpreter into your Delphi app with [P4D](http://python4delphi.googlecode.com/svn/trunk/). These components actually work, and in both directions too (Delphi classes exposed to Python as binary extensions, and Python interpreter inside Delphi). I also saw a patch for Lazarus compatibility on the ...
1,646,326
I'm soon to launch a [beta app](http://www.bestsellerapp.com/) and this have the option to create custom integration scripts on [Python](http://en.wikipedia.org/wiki/Python_(programming_language)). The app will target [Mac OS X](http://en.wikipedia.org/wiki/Mac_OS_X) and Windows, and my problem is with Windows where P...
2009/10/29
[ "https://Stackoverflow.com/questions/1646326", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53185/" ]
Copy a [Portable Python](http://www.portablepython.com/) folder out of your installer, into the same folder as your Delphi/Lazarus app. Set all paths appropriately for that.
I think there's no problem combining .EXE packaging with a tool like PyInstaller or py2exe and Python-written plugins. The created .EXE can easily detect where it's installed and the code inside can then simply `import` files from some pre-determined plugin directory. Don't forget that once you package a Python script ...
1,646,326
I'm soon to launch a [beta app](http://www.bestsellerapp.com/) and this have the option to create custom integration scripts on [Python](http://en.wikipedia.org/wiki/Python_(programming_language)). The app will target [Mac OS X](http://en.wikipedia.org/wiki/Mac_OS_X) and Windows, and my problem is with Windows where P...
2009/10/29
[ "https://Stackoverflow.com/questions/1646326", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53185/" ]
Integrate the python interpreter into your Delphi app with [P4D](http://python4delphi.googlecode.com/svn/trunk/). These components actually work, and in both directions too (Delphi classes exposed to Python as binary extensions, and Python interpreter inside Delphi). I also saw a patch for Lazarus compatibility on the ...
I think there's no problem combining .EXE packaging with a tool like PyInstaller or py2exe and Python-written plugins. The created .EXE can easily detect where it's installed and the code inside can then simply `import` files from some pre-determined plugin directory. Don't forget that once you package a Python script ...
156,539
I always visit one website which I don't want others to see the title of. I want that whenever I open that site my title of that site changes to something else or hide. There is a addonon in Firefox which can hide the title of window, but I have to manually click on hide title. Is there something which can do it aut...
2010/06/25
[ "https://superuser.com/questions/156539", "https://superuser.com", "https://superuser.com/users/24524/" ]
Use Greasemonkey. Write a script that changes the page title.
Use `F11` to toggle Firefox's **full screen mode** - that will hide the title and URL.
156,539
I always visit one website which I don't want others to see the title of. I want that whenever I open that site my title of that site changes to something else or hide. There is a addonon in Firefox which can hide the title of window, but I have to manually click on hide title. Is there something which can do it aut...
2010/06/25
[ "https://superuser.com/questions/156539", "https://superuser.com", "https://superuser.com/users/24524/" ]
Use Greasemonkey. Write a script that changes the page title.
As Graphain said, use [Greasemonkey](https://addons.mozilla.org/en-US/firefox/addon/748/). And, because it's easy fun, I have written the GM script for you. :) ``` // ==UserScript== // @name Title Changer for web page XXX // @namespace Google // @include YourWebsiteHere.tld/* // ==/UserScript== ...
156,539
I always visit one website which I don't want others to see the title of. I want that whenever I open that site my title of that site changes to something else or hide. There is a addonon in Firefox which can hide the title of window, but I have to manually click on hide title. Is there something which can do it aut...
2010/06/25
[ "https://superuser.com/questions/156539", "https://superuser.com", "https://superuser.com/users/24524/" ]
As Graphain said, use [Greasemonkey](https://addons.mozilla.org/en-US/firefox/addon/748/). And, because it's easy fun, I have written the GM script for you. :) ``` // ==UserScript== // @name Title Changer for web page XXX // @namespace Google // @include YourWebsiteHere.tld/* // ==/UserScript== ...
Use `F11` to toggle Firefox's **full screen mode** - that will hide the title and URL.
52,547
I need to look for some requests in a huge pile of apache logs. My only requirement is this: I need to only view the requests coming from any IP address that is NOT included in a list of 50 IP ranges I have. How can I make that happen using any combination of regexes awk grep or anything? Can't think of an easy way. ...
2012/10/22
[ "https://unix.stackexchange.com/questions/52547", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/26150/" ]
A simple and crude way could be to use grep. Create a file ( *ranges.txt* ) with you're ranges something like this: ``` 192\.168\.0\.[0-9]* 10\.0\.0\.[0-9]* ``` To create that file from the range-file you already had you could use `sed` like so: ``` sed -n -e 's/^\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\) .*$/...
Log is your log file, and iprange is your file containing the ipranges. Perl part of the solution gets the first 3 components of your ip address, and the for loop prints it if it does not exist in the file ipranges: ``` for i in `perl -lne 'print $1 if (m/(\d{1,3}\.\d{1,3}\.\d{1,3})\.\d{1,3}/);' log` > do > grep -q $...
53,843,378
In a React project, I want to dynamically access an object property name using a string variable I pass through props. I am able to pass a value as string; however, when I try to use it to access the object property it doesn't work. Here's an example: ``` const passedField = 'title'; // this comes from props const bo...
2018/12/19
[ "https://Stackoverflow.com/questions/53843378", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1661286/" ]
What you're using is called a [`dot notation`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_accessors#Dot_notation) property accessor. What you need to use is a [`bracket notation`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_accessors#Bra...
You can access object properties using `book[passedField]`
53,843,378
In a React project, I want to dynamically access an object property name using a string variable I pass through props. I am able to pass a value as string; however, when I try to use it to access the object property it doesn't work. Here's an example: ``` const passedField = 'title'; // this comes from props const bo...
2018/12/19
[ "https://Stackoverflow.com/questions/53843378", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1661286/" ]
`book.passedField` will be returning undefined because there is no `passedField` in `book`. Instead use bracket notation as below ```js const book = { title: 'abc', pages: 350 }; const passedField = 'pages'; console.log(book[passedField]) ```
You can access object properties using `book[passedField]`
69,177,214
I want to consume messages with AvroConfluent format from kafka topic and store them in a clickhouse table so i created a table with kafka engine and I entered my schema registry url in table settings, but the schema registry server needs basic authentication which I am not sure where and how should I put my user infor...
2021/09/14
[ "https://Stackoverflow.com/questions/69177214", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16908481/" ]
This is a bug introduced in KDiff3 version 1.8.6. To fix it, uninstall your version of KDiff3 and install KDiff3 version 1.8.5. It should work. Here is a link to download: <https://download.kde.org/stable/kdiff3/> References: * <https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=256606> * <https://invent.kde.org/sdk...
FYI, I had this bug with 1.9.4. Upgrading to 1.9.5 fixes that.
39,468,640
I am currently trying to export a trained TensorFlow model as a ProtoBuf file to use it with the TensorFlow C++ API on Android. Therefore, I'm using the [`freeze_graph.py`](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/tools/freeze_graph.py) script. I exported my model using `tf.train.write_gr...
2016/09/13
[ "https://Stackoverflow.com/questions/39468640", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2206976/" ]
The `--filename_tensor_name` flag is used to specify the name of a placeholder tensor created when you construct a [`tf.train.Saver`](https://www.tensorflow.org/versions/r0.10/api_docs/python/state_ops.html#Saver) for your model.\* In your original program, you can print out the value of `saver.saver_def.filename_tens...
I noticed that error happened to me when I had code arranged like this: ``` sess = tf.Session() tf.train.write_graph(sess.graph_def, '', '/tmp/train.pbtxt') init = tf.initialize_all_variables() saver = tf.train.Saver() sess.run(init) ``` It worked after I changed code layout like this: ``` # Add ops to save and res...
39,468,640
I am currently trying to export a trained TensorFlow model as a ProtoBuf file to use it with the TensorFlow C++ API on Android. Therefore, I'm using the [`freeze_graph.py`](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/tools/freeze_graph.py) script. I exported my model using `tf.train.write_gr...
2016/09/13
[ "https://Stackoverflow.com/questions/39468640", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2206976/" ]
The `--filename_tensor_name` flag is used to specify the name of a placeholder tensor created when you construct a [`tf.train.Saver`](https://www.tensorflow.org/versions/r0.10/api_docs/python/state_ops.html#Saver) for your model.\* In your original program, you can print out the value of `saver.saver_def.filename_tens...
It should not be problematic in latest freeze\_graph.py as I could see these removed: `del restore_op_name, filename_tensor_name # Unused by updated loading code.` [source:freeze\_graph.py](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/tools/freeze_graph.py) In earlier version, it was using ...
39,468,640
I am currently trying to export a trained TensorFlow model as a ProtoBuf file to use it with the TensorFlow C++ API on Android. Therefore, I'm using the [`freeze_graph.py`](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/tools/freeze_graph.py) script. I exported my model using `tf.train.write_gr...
2016/09/13
[ "https://Stackoverflow.com/questions/39468640", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2206976/" ]
The `--filename_tensor_name` flag is used to specify the name of a placeholder tensor created when you construct a [`tf.train.Saver`](https://www.tensorflow.org/versions/r0.10/api_docs/python/state_ops.html#Saver) for your model.\* In your original program, you can print out the value of `saver.saver_def.filename_tens...
Some follow-up on @Drag0's answer and why the new code layout fixed the error. When calling `saver = tf.train.Saver()`, you add the different variables related to the `tf.train.Saver()` such as `'save/Const:0'` to the default graph. In the first code arrangement the graph is saved before so without the `tf.train.Save...
39,468,640
I am currently trying to export a trained TensorFlow model as a ProtoBuf file to use it with the TensorFlow C++ API on Android. Therefore, I'm using the [`freeze_graph.py`](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/tools/freeze_graph.py) script. I exported my model using `tf.train.write_gr...
2016/09/13
[ "https://Stackoverflow.com/questions/39468640", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2206976/" ]
I noticed that error happened to me when I had code arranged like this: ``` sess = tf.Session() tf.train.write_graph(sess.graph_def, '', '/tmp/train.pbtxt') init = tf.initialize_all_variables() saver = tf.train.Saver() sess.run(init) ``` It worked after I changed code layout like this: ``` # Add ops to save and res...
It should not be problematic in latest freeze\_graph.py as I could see these removed: `del restore_op_name, filename_tensor_name # Unused by updated loading code.` [source:freeze\_graph.py](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/tools/freeze_graph.py) In earlier version, it was using ...
39,468,640
I am currently trying to export a trained TensorFlow model as a ProtoBuf file to use it with the TensorFlow C++ API on Android. Therefore, I'm using the [`freeze_graph.py`](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/tools/freeze_graph.py) script. I exported my model using `tf.train.write_gr...
2016/09/13
[ "https://Stackoverflow.com/questions/39468640", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2206976/" ]
I noticed that error happened to me when I had code arranged like this: ``` sess = tf.Session() tf.train.write_graph(sess.graph_def, '', '/tmp/train.pbtxt') init = tf.initialize_all_variables() saver = tf.train.Saver() sess.run(init) ``` It worked after I changed code layout like this: ``` # Add ops to save and res...
Some follow-up on @Drag0's answer and why the new code layout fixed the error. When calling `saver = tf.train.Saver()`, you add the different variables related to the `tf.train.Saver()` such as `'save/Const:0'` to the default graph. In the first code arrangement the graph is saved before so without the `tf.train.Save...
39,468,640
I am currently trying to export a trained TensorFlow model as a ProtoBuf file to use it with the TensorFlow C++ API on Android. Therefore, I'm using the [`freeze_graph.py`](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/tools/freeze_graph.py) script. I exported my model using `tf.train.write_gr...
2016/09/13
[ "https://Stackoverflow.com/questions/39468640", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2206976/" ]
Some follow-up on @Drag0's answer and why the new code layout fixed the error. When calling `saver = tf.train.Saver()`, you add the different variables related to the `tf.train.Saver()` such as `'save/Const:0'` to the default graph. In the first code arrangement the graph is saved before so without the `tf.train.Save...
It should not be problematic in latest freeze\_graph.py as I could see these removed: `del restore_op_name, filename_tensor_name # Unused by updated loading code.` [source:freeze\_graph.py](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/tools/freeze_graph.py) In earlier version, it was using ...
29,436,756
I wrote the following class in salesforce: ``` global class ChangeImmo implements Schedulable{ // Execute method global void execute(SchedulableContext SC) { List<Realty_User__c> rs = [SELECT Buttons__c FROM Realty_User__c WHERE not (Buttons__c INCLUDES ('Terminplaner'))]; for(Realty_User__c r : rs...
2015/04/03
[ "https://Stackoverflow.com/questions/29436756", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2885690/" ]
003 - it's a prefix of Contact object. Looks like you have some trigger in your production that work with contacts after you update Realty\_User\_\_c object.
``` global class ChangeImmo implements Schedulable{ ``` // Execute method ``` global void execute(SchedulableContext SC) { List<Realty_User__c> rs = [SELECT Buttons__c FROM Realty_User__c WHERE not (Buttons__c INCLUDES ('Terminplaner'))]; for(Realty_User__c r : rs){ **r.Buttons__c += ';Terminplaner...
64,682
I came across these words: > > Kleingruppe, Reinform > > > Why are they like that? Why not "kleine Gruppe" and "reine Form"? This looks really interesting. Please explain to me how and when can I use this type of adjective. I would like to add it to my German language arsenal.
2021/04/13
[ "https://german.stackexchange.com/questions/64682", "https://german.stackexchange.com", "https://german.stackexchange.com/users/42148/" ]
These words are a special type of compound nouns, but they're more than just a different way to affix an adjective to a noun. They are new words with their own life, and they can have acquired meanings that go beyond just the noun plus the adjective, or a different meaning altogether. E.g., a *Blaulicht* isn't just an...
These are no adjectives, but nouns. As a rule of thumb, you can normally combine an adjective ("kleine", "reine") with a general noun ("Gruppe", "Form") to get a compound noun in German. This is used because it is more concise, even though it regularly adds a sense of bureaucracy to the language.
65,129,265
I am making a web page. There is a navigation section on the left that is all nested in `<p>` something like this. ``` <nav> <p>Home</p> <p>About</p> <p>Shop</p> <p>Contact Us</p> </nav> ``` I have used `flexbox` to make this appear on the `left-hand` side of the page and be r...
2020/12/03
[ "https://Stackoverflow.com/questions/65129265", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9191469/" ]
You should define padding for your p element ``` @media only screen and (max-width: 700px) { nav { width: 100%; display: flex; flex-direction: row; } p { padding: 0 1rem; } } ```
Set a breakpoint and set your `flex-direction` to `column`. ``` nav { width: 40%; display: flex; justify-content: space-between; } @media only screen and (max-width: 700px) { nav { width: 100%; flex-direction: column; } } ```
10,365,510
When I run the following query on browser: ``` http://127.0.0.1:8096/solr/select/?q=june 17&amp;start=0&amp;rows=8&amp;indent=on&amp;hl=on&amp;hl.fl=Data&amp;wt=json ``` I get results. No problems. Notice that there is a space between june and 17 However when I receive that query in my PHP i.e. $q=June 17 I use ``...
2012/04/28
[ "https://Stackoverflow.com/questions/10365510", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1315930/" ]
There is a space in the `q` parameter's value. Could be that. Try `urlencode()`ing the parameter. ``` $url="http://127.0.0.1:8096/solr/select/?q=".urlencode($q)."&start=0&rows=8&indent=on&hl=on&hl.fl=Data&wt=json"; $json_O=json_decode(file_get_contents($url),true); ```
This is, because the `file_get_contents` function sends a request to a web server in HTTP, which looks like this ``` GET /solr/select/?q=bla HTTP/1.0 Host: 127.0.0.1 ...[more headers here]... ``` Note, that there is a the in HTTP version specified in the request (`HTTP/1.0`) Now, if there is a space in your request...
69,587,409
A quick question. I use to see the inferred type by option click the property or object on the left of a statement. After upgrade to Xcode 13, for instance, when I option click on below `text` property, there is no quick help popping up. Do u guys meet this same issue? Just Google it, no clue found. ``` let text = "Ha...
2021/10/15
[ "https://Stackoverflow.com/questions/69587409", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10158398/" ]
Well, restart your Mac will solve this problem. It seems I had not restarted my Mac since the day I upgrade to Xcode 13. The issue link in Apple forum: [link](https://developer.apple.com/forums/thread/691234)
For me restarting the Mac, cleaning build folder and derived data + quitting Xcode didn't help. Seems like it works only on small projects, but not on the one for the company I work for. It's pretty random and extremely annoying, no idea what could fix it honestly
6,530,980
I want to create a **Sub Menu** in existing **Menu Item** in **Android**. How I can achieve it ? Thanks.
2011/06/30
[ "https://Stackoverflow.com/questions/6530980", "https://Stackoverflow.com", "https://Stackoverflow.com/users/645753/" ]
It's as simple as placing a `menu` inside an `item`. For example: ``` <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/file" android:icon="@drawable/file" android:title="@string/file" > <!-- "file" submenu -...
Try reading [this](http://developer.android.com/guide/topics/ui/menus.html#submenu) first.
29,632,729
I have a model which has a `ForeignKey` field, with `null=True`. The field-semantics are that a NULL entry is permissive, while a non-NULL entry binds it to a single row in the foreign table. I want to build an ORM filter which corresponds to: ``` SELECT * FROM foo WHERE foo.fk_field = ? OR foo.fk_field IS NULL ```...
2015/04/14
[ "https://Stackoverflow.com/questions/29632729", "https://Stackoverflow.com", "https://Stackoverflow.com/users/129805/" ]
Use the [Q objects](https://docs.djangoproject.com/en/1.8/topics/db/queries/#complex-lookups-with-q-objects): ``` from django.db.models import Q Foo.objects.filter(Q(fk_field=fk_value) | Q(fk_field=None)) ```
You can achieve this using [Q](https://docs.djangoproject.com/en/1.8/topics/db/queries/#complex-lookups-with-q-objects) objects: ``` from django.db.models import Q Foo.objects.filter(Q(fk=fk) | Q(fk__isnull=True)) ```
29,632,729
I have a model which has a `ForeignKey` field, with `null=True`. The field-semantics are that a NULL entry is permissive, while a non-NULL entry binds it to a single row in the foreign table. I want to build an ORM filter which corresponds to: ``` SELECT * FROM foo WHERE foo.fk_field = ? OR foo.fk_field IS NULL ```...
2015/04/14
[ "https://Stackoverflow.com/questions/29632729", "https://Stackoverflow.com", "https://Stackoverflow.com/users/129805/" ]
Use the [Q objects](https://docs.djangoproject.com/en/1.8/topics/db/queries/#complex-lookups-with-q-objects): ``` from django.db.models import Q Foo.objects.filter(Q(fk_field=fk_value) | Q(fk_field=None)) ```
I think this is a little more readable than the other answers. Mind you, I'm not sure when this started being supported. ``` Foo.objects.filter(a=b) | Bar.objects.filter(c=d) ```
29,632,729
I have a model which has a `ForeignKey` field, with `null=True`. The field-semantics are that a NULL entry is permissive, while a non-NULL entry binds it to a single row in the foreign table. I want to build an ORM filter which corresponds to: ``` SELECT * FROM foo WHERE foo.fk_field = ? OR foo.fk_field IS NULL ```...
2015/04/14
[ "https://Stackoverflow.com/questions/29632729", "https://Stackoverflow.com", "https://Stackoverflow.com/users/129805/" ]
You can achieve this using [Q](https://docs.djangoproject.com/en/1.8/topics/db/queries/#complex-lookups-with-q-objects) objects: ``` from django.db.models import Q Foo.objects.filter(Q(fk=fk) | Q(fk__isnull=True)) ```
I think this is a little more readable than the other answers. Mind you, I'm not sure when this started being supported. ``` Foo.objects.filter(a=b) | Bar.objects.filter(c=d) ```
25,173,084
Note: This is the first time asking a question about a general curiosity regarding syntax. Because of this I might not be using the correct terminology to describe my question, which may mean its already been answered, and I can't find it because I'm unaware of what terms to use in the search. If that is the case, plea...
2014/08/07
[ "https://Stackoverflow.com/questions/25173084", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2435221/" ]
Put simply -- it's for readability. You can look solely at the property definition and know that it's static, without having to look at the class definition. Your two-line example may make it look unnecessary, but if you have a class with 500, 1000 or more lines of code, you will appreciate the extra clarity when digg...
From what I understand, static on the class is a way to enforce all members are static (remove static from one, and it should give you an error). But yes, there is the requirement of defining the methods static. Technically, you wouldn't need to define static on the class. You could, as an alternative, define a class,...
25,173,084
Note: This is the first time asking a question about a general curiosity regarding syntax. Because of this I might not be using the correct terminology to describe my question, which may mean its already been answered, and I can't find it because I'm unaware of what terms to use in the search. If that is the case, plea...
2014/08/07
[ "https://Stackoverflow.com/questions/25173084", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2435221/" ]
From what I understand, static on the class is a way to enforce all members are static (remove static from one, and it should give you an error). But yes, there is the requirement of defining the methods static. Technically, you wouldn't need to define static on the class. You could, as an alternative, define a class,...
For consistency - uniformity of meaning. Making a class static doesn't change anything about the class; all it does is forbid the declaration of instance members. The class itself is neither instance nor static. It would be more concise if static on a class implied all members static, but one could argue that doing so ...
25,173,084
Note: This is the first time asking a question about a general curiosity regarding syntax. Because of this I might not be using the correct terminology to describe my question, which may mean its already been answered, and I can't find it because I'm unaware of what terms to use in the search. If that is the case, plea...
2014/08/07
[ "https://Stackoverflow.com/questions/25173084", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2435221/" ]
Put simply -- it's for readability. You can look solely at the property definition and know that it's static, without having to look at the class definition. Your two-line example may make it look unnecessary, but if you have a class with 500, 1000 or more lines of code, you will appreciate the extra clarity when digg...
For consistency - uniformity of meaning. Making a class static doesn't change anything about the class; all it does is forbid the declaration of instance members. The class itself is neither instance nor static. It would be more concise if static on a class implied all members static, but one could argue that doing so ...
1,624,159
I have a Axis 1.4 (with Spring) web service client consuming a PHP web service (running on Apache). This works perfectly in the development environment, but in the production environment the code execution hangs somewhere in the Axis library directly after the client has received the SOAP response. I have identified wi...
2009/10/26
[ "https://Stackoverflow.com/questions/1624159", "https://Stackoverflow.com", "https://Stackoverflow.com/users/76777/" ]
Try setting the -Dhttp.keepAlive=false system property in your application, if can afford disabling keep alives in other parts of the application. This will prevent certain hangs with the java-internal HttpClient class trying to eagerly fill a BufferedInputStream from the open connection. For details see also <http://...
You might try sending Http Header "Connection: close" with your request.
46,468,392
I have a text file. I would like to use python v3.6 to read the text file line by line, append each line with a sub-string and replace the existing line with the appended string line by line. To be clearer, here is the original text file; ``` 1,2,3 4,5,6 ``` The desired output text file should look like this; ``` ...
2017/09/28
[ "https://Stackoverflow.com/questions/46468392", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3848207/" ]
There's no such thing as "replacing an existing line" in a file. For what you want to do, you have to write a new file with the modified content and then replace the old file with the new one. Example code: ``` with open("old.file") as old, open("new.file", "w") as new: for line in old: line = modi...
I believe to get what you want you need to put `myfile.readlines()` before your `for` loop.
46,468,392
I have a text file. I would like to use python v3.6 to read the text file line by line, append each line with a sub-string and replace the existing line with the appended string line by line. To be clearer, here is the original text file; ``` 1,2,3 4,5,6 ``` The desired output text file should look like this; ``` ...
2017/09/28
[ "https://Stackoverflow.com/questions/46468392", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3848207/" ]
You cannot, in general, modify a file in place like this. Instead, write a copy to a new file, then replace the original with the new one. ``` with open(filename, 'r') as myfile: with open("copy", 'w') as newfile: for line in myfile: newline = "appended_text" + "," + line ...
I believe to get what you want you need to put `myfile.readlines()` before your `for` loop.
46,468,392
I have a text file. I would like to use python v3.6 to read the text file line by line, append each line with a sub-string and replace the existing line with the appended string line by line. To be clearer, here is the original text file; ``` 1,2,3 4,5,6 ``` The desired output text file should look like this; ``` ...
2017/09/28
[ "https://Stackoverflow.com/questions/46468392", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3848207/" ]
Here is what I would do: ``` with open(filename, 'r+') as f: lines = [] for line in f: lines.append("appended_text" + "," + line) f.seek(0) for line in lines: f.write(line) ``` For example: **sample.txt before**: ``` hello there world ``` **code:** ``` fp = r"C:\Users\Me\Desktop\...
I believe to get what you want you need to put `myfile.readlines()` before your `for` loop.
46,468,392
I have a text file. I would like to use python v3.6 to read the text file line by line, append each line with a sub-string and replace the existing line with the appended string line by line. To be clearer, here is the original text file; ``` 1,2,3 4,5,6 ``` The desired output text file should look like this; ``` ...
2017/09/28
[ "https://Stackoverflow.com/questions/46468392", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3848207/" ]
If you want to write it to the same file: ``` f = open(filename, 'r') lines = f.readlines() f.close() lines = ['appended_text, ' + l for l in lines] f = open(filename, 'w') f.writelines(lines) f.close() ```
I believe to get what you want you need to put `myfile.readlines()` before your `for` loop.
46,468,392
I have a text file. I would like to use python v3.6 to read the text file line by line, append each line with a sub-string and replace the existing line with the appended string line by line. To be clearer, here is the original text file; ``` 1,2,3 4,5,6 ``` The desired output text file should look like this; ``` ...
2017/09/28
[ "https://Stackoverflow.com/questions/46468392", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3848207/" ]
There's no such thing as "replacing an existing line" in a file. For what you want to do, you have to write a new file with the modified content and then replace the old file with the new one. Example code: ``` with open("old.file") as old, open("new.file", "w") as new: for line in old: line = modi...
You cannot, in general, modify a file in place like this. Instead, write a copy to a new file, then replace the original with the new one. ``` with open(filename, 'r') as myfile: with open("copy", 'w') as newfile: for line in myfile: newline = "appended_text" + "," + line ...
46,468,392
I have a text file. I would like to use python v3.6 to read the text file line by line, append each line with a sub-string and replace the existing line with the appended string line by line. To be clearer, here is the original text file; ``` 1,2,3 4,5,6 ``` The desired output text file should look like this; ``` ...
2017/09/28
[ "https://Stackoverflow.com/questions/46468392", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3848207/" ]
There's no such thing as "replacing an existing line" in a file. For what you want to do, you have to write a new file with the modified content and then replace the old file with the new one. Example code: ``` with open("old.file") as old, open("new.file", "w") as new: for line in old: line = modi...
Here is what I would do: ``` with open(filename, 'r+') as f: lines = [] for line in f: lines.append("appended_text" + "," + line) f.seek(0) for line in lines: f.write(line) ``` For example: **sample.txt before**: ``` hello there world ``` **code:** ``` fp = r"C:\Users\Me\Desktop\...
46,468,392
I have a text file. I would like to use python v3.6 to read the text file line by line, append each line with a sub-string and replace the existing line with the appended string line by line. To be clearer, here is the original text file; ``` 1,2,3 4,5,6 ``` The desired output text file should look like this; ``` ...
2017/09/28
[ "https://Stackoverflow.com/questions/46468392", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3848207/" ]
There's no such thing as "replacing an existing line" in a file. For what you want to do, you have to write a new file with the modified content and then replace the old file with the new one. Example code: ``` with open("old.file") as old, open("new.file", "w") as new: for line in old: line = modi...
If you want to write it to the same file: ``` f = open(filename, 'r') lines = f.readlines() f.close() lines = ['appended_text, ' + l for l in lines] f = open(filename, 'w') f.writelines(lines) f.close() ```
46,468,392
I have a text file. I would like to use python v3.6 to read the text file line by line, append each line with a sub-string and replace the existing line with the appended string line by line. To be clearer, here is the original text file; ``` 1,2,3 4,5,6 ``` The desired output text file should look like this; ``` ...
2017/09/28
[ "https://Stackoverflow.com/questions/46468392", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3848207/" ]
You cannot, in general, modify a file in place like this. Instead, write a copy to a new file, then replace the original with the new one. ``` with open(filename, 'r') as myfile: with open("copy", 'w') as newfile: for line in myfile: newline = "appended_text" + "," + line ...
Here is what I would do: ``` with open(filename, 'r+') as f: lines = [] for line in f: lines.append("appended_text" + "," + line) f.seek(0) for line in lines: f.write(line) ``` For example: **sample.txt before**: ``` hello there world ``` **code:** ``` fp = r"C:\Users\Me\Desktop\...
46,468,392
I have a text file. I would like to use python v3.6 to read the text file line by line, append each line with a sub-string and replace the existing line with the appended string line by line. To be clearer, here is the original text file; ``` 1,2,3 4,5,6 ``` The desired output text file should look like this; ``` ...
2017/09/28
[ "https://Stackoverflow.com/questions/46468392", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3848207/" ]
You cannot, in general, modify a file in place like this. Instead, write a copy to a new file, then replace the original with the new one. ``` with open(filename, 'r') as myfile: with open("copy", 'w') as newfile: for line in myfile: newline = "appended_text" + "," + line ...
If you want to write it to the same file: ``` f = open(filename, 'r') lines = f.readlines() f.close() lines = ['appended_text, ' + l for l in lines] f = open(filename, 'w') f.writelines(lines) f.close() ```
740
R U RLY NT A LWYR? PRVE IT! PPL MAY NT UNDRSTND SHRT ACRNYMS LIK DIS! IANAL, TINLA, I<3OS! AAMOF, N BTW, WHT M I DOIN? OMG WHT M I SYIN? WL, THX THX TQ FOR LSTNING! --- Translated as... > > Are you really not a lawyer? Prove it! People may not understand short acronyms, like this! *I am not a lawyer*, *This is not...
2016/08/18
[ "https://opensource.meta.stackexchange.com/questions/740", "https://opensource.meta.stackexchange.com", "https://opensource.meta.stackexchange.com/users/69/" ]
I think we could even go further: could the opening page of the board simply say that none of the questions, answers or comments should be considered as legal advice even if they may look like it. And that we are not a lawyers, and even if some are, they are not your lawyer, and this is not legal advice. And explain in...
Personally I like it the way it is. I'd like to keep the acronyms, because although they may require some research the first time a reader encounters them, once I'm used to it I can read IANAL or TINLA more quickly than the spelled-out form. Just like [TANSTAAFL](https://en.wikipedia.org/wiki/There_ain%27t_no_such_thi...
24,063,445
I need to use Java on the command line so I can use a tool called sencha command. I have java 1.6 and 1.7 installed, but for whatever reason 1.4 is showing up in my command line. Has anyone any idea why this is happeneing and how to fix it. I've searched everywhere for this version on my machine and can't find it. Has...
2014/06/05
[ "https://Stackoverflow.com/questions/24063445", "https://Stackoverflow.com", "https://Stackoverflow.com/users/967797/" ]
It seems as if your PATH environment variable is pointing to the old installation of Java. Go to Control Panel->System->Advanced System Settings->Advanced(Tab)->Environment Variables... Under the "System Variables" header, you should see a "JAVA\_HOME" environment variable, ensure that points to the JRE7 install dire...
That is pretty weird. What I would do first is go to your environment path in windows and make sure that the correct path for the latest java is there. That will make it so the java is executed. Open your environment paths: **Windows 8** ``` Drag the Mouse pointer to the Right bottom corner of the screen Click on th...
24,063,445
I need to use Java on the command line so I can use a tool called sencha command. I have java 1.6 and 1.7 installed, but for whatever reason 1.4 is showing up in my command line. Has anyone any idea why this is happeneing and how to fix it. I've searched everywhere for this version on my machine and can't find it. Has...
2014/06/05
[ "https://Stackoverflow.com/questions/24063445", "https://Stackoverflow.com", "https://Stackoverflow.com/users/967797/" ]
It seems as if your PATH environment variable is pointing to the old installation of Java. Go to Control Panel->System->Advanced System Settings->Advanced(Tab)->Environment Variables... Under the "System Variables" header, you should see a "JAVA\_HOME" environment variable, ensure that points to the JRE7 install dire...
Assuming your machine is setup the "usual" way, go to your System environment variables and change your "JAVA\_HOME" path. Also, on a 64-bit machine you should probably install a 64-bit version of Java, but given what you have here (on the command line) - ``` set "JAVA_HOME=c:\Program Files (x86)\Java\jdk1.7.0_07" ``...
18,319,436
The code works fine but problem is that i want 3 columns and three rows.. But output shows 6 columns instead of three rows and three columns Here is a code in which problem appears.. Here is a main class: ``` import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import games.board.Board; import ga...
2013/08/19
[ "https://Stackoverflow.com/questions/18319436", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2694776/" ]
> > i want 3 columns and three rows.. But output shows 6 columns > > > You need to specify proper parameters to the GridLayout: ``` this.setLayout(new GridLayout(0, 3)); ``` This will tell the grid to contain 3 columns. The number of rows will depend on the number of components you add.
Change in your Board class: ``` for( int r = 0; r < cells[0].length; r++ ) { for (int c = 0; c < cells[1].length; c++) { cells[r][c] = new Cell(r,c); } } ``` To ``` for( int r = 0; r < cells[0].length; r++ ) { for (int c = 0; c < cells[r].length; c++) { cells[r][c] = new Cell(r,c); } } ...
18,319,436
The code works fine but problem is that i want 3 columns and three rows.. But output shows 6 columns instead of three rows and three columns Here is a code in which problem appears.. Here is a main class: ``` import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import games.board.Board; import ga...
2013/08/19
[ "https://Stackoverflow.com/questions/18319436", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2694776/" ]
> > i want 3 columns and three rows.. But output shows 6 columns > > > You need to specify proper parameters to the GridLayout: ``` this.setLayout(new GridLayout(0, 3)); ``` This will tell the grid to contain 3 columns. The number of rows will depend on the number of components you add.
> > I want 3 columns and three rows... But output shows 6 columns > > > Use, `this.setLayout(new GridLayout(nRows, nColumns));` Change `nRows` and `nColumns` accordingly to how many columns and rows you want, ie, if you wanted a `20x20` game you would use, `this.setLayout(new GridLayout(20, 20));`
10,879,761
> > **Possible Duplicate:** > > [What is the Java equivalent for LINQ?](https://stackoverflow.com/questions/1217228/what-is-the-java-equivalent-for-linq) > > > There are numerous questions asking whether there is a Java equivalent for LINQ. But most of them are incorrectly specifying that there is nothing.
2012/06/04
[ "https://Stackoverflow.com/questions/10879761", "https://Stackoverflow.com", "https://Stackoverflow.com/users/195524/" ]
This library provides a full LINQ API: <https://github.com/nicholas22/jpropel-light> It does so with functional-style constructs and it also uses deferred execution. ``` // select names starting with j, using LINQ-style statements new String[] { "james", "john", "john", "eddie" }.where(startsWith("j")).distinct().all...
Another one that I've tried myself is jaque: <http://code.google.com/p/jaque/>
38,918,332
I need to change the 8080 port on my spring boot application, getting it from an external config file. I have my application.properties in /config directory and I added server.port = 8090 When the app starts, the logger says something like: ``` 2016-08-12 14:41:04 INFO Http11NioProtocol:180 - Initializing Protocol...
2016/08/12
[ "https://Stackoverflow.com/questions/38918332", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5550833/" ]
In fact, there's, as far as I know, 2 ways to change default server port for spring boot : **application.properties** In your application.properties file, you just have to add : ``` server.port=9080 ``` If it's not working, it's most likely because your `application.properties` configuration file is not taken into...
By default spring uses port 8080 and depending on your system it may be in use, thus causing problems for Spring, so: Modify the application.properties file and only add server.port = XXXX
38,918,332
I need to change the 8080 port on my spring boot application, getting it from an external config file. I have my application.properties in /config directory and I added server.port = 8090 When the app starts, the logger says something like: ``` 2016-08-12 14:41:04 INFO Http11NioProtocol:180 - Initializing Protocol...
2016/08/12
[ "https://Stackoverflow.com/questions/38918332", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5550833/" ]
In fact, there's, as far as I know, 2 ways to change default server port for spring boot : **application.properties** In your application.properties file, you just have to add : ``` server.port=9080 ``` If it's not working, it's most likely because your `application.properties` configuration file is not taken into...
If your project is maven modular, make sure in your pom file packaging type is `jar, becuase if your root project packageing type is pom, then configuring application.properties for changing server port not affected.
38,918,332
I need to change the 8080 port on my spring boot application, getting it from an external config file. I have my application.properties in /config directory and I added server.port = 8090 When the app starts, the logger says something like: ``` 2016-08-12 14:41:04 INFO Http11NioProtocol:180 - Initializing Protocol...
2016/08/12
[ "https://Stackoverflow.com/questions/38918332", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5550833/" ]
If your project is maven modular, make sure in your pom file packaging type is `jar, becuase if your root project packageing type is pom, then configuring application.properties for changing server port not affected.
By default spring uses port 8080 and depending on your system it may be in use, thus causing problems for Spring, so: Modify the application.properties file and only add server.port = XXXX
74,166,243
I have a .csv file that is about 5mb (~45,000 rows). What I need to do is run through each row of the file and check if the ID in each line is already in a table in my database. If it is, I can delete that row from the file. I did a good amount of research on the most memory efficient way to do this, so I've been usin...
2022/10/22
[ "https://Stackoverflow.com/questions/74166243", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13872573/" ]
You fire a database query per line, aka 45.000 queries... that takes too much time. Better you do a query before the loop and read the existing id into a lookup array, then only check this array in the loop. Pseudo code: ``` $st = query('SELECT id FROM table'); while ($row = $st->fetch()) { $lookup[ $row['id'] ]...
1. I would use `LOAD DATA INFILE`: <https://dev.mysql.com/doc/refman/8.0/en/load-data.html> Your database user needs to have `FILE` priveleges on the database to use. to read the csv file into a separate table. 2. Then you can run one query to delete id's already exist (delete from join ...) 3. And export the rows ...
66,612,578
I have this folder structure: ``` sass/main.sass css/main.css js/... img/... ``` I want the sass output to go to the css folder, but each time I run sass watcher it creates a new css file within the sass directory among sass files.
2021/03/13
[ "https://Stackoverflow.com/questions/66612578", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15328189/" ]
Thx for information about using 'Live SASS Compiler' in VS Code. To set special otuput pathes to your project you need to add the settings for output pathes to the `settigns.json` of your project: File: `projectDIR/.vscode/settings.json' Example for setting the save pathes to output directory: ``` "settings": { ...
Go to path: C:\Users\your user\AppData\Roaming\Code\User\settings.json and change there the "liveSassCompile.settings.formats" section for example: the parameter : "savePath": "/Python/CSS", [![enter image description here](https://i.stack.imgur.com/WT9rO.png)](https://i.stack.imgur.com/WT9rO.png)
249,956
Does this table comply with 1NF, even if **CourseNo** and **StudentNo**? ``` Student(StudentNo, StudentName, Major, CourseNo, CourseName, InstructorNo, InstructorName, InstructorLocation, Grade) ```
2019/09/30
[ "https://dba.stackexchange.com/questions/249956", "https://dba.stackexchange.com", "https://dba.stackexchange.com/users/191413/" ]
If all the attributes/columns of that relation/table always contain *atomic* values (i.e., they accept *exactly one* value —neither no value, nor two or more, nor NULL marks— of the corresponding *simple domain*1, 2 per tuple/row), then yes, that relation/table meets first normal form (1NF); otherwise, no, it is not in...
The table comply with 1NF. The page you link to (<https://opentextbc.ca/dbdesign01/chapter/chapter-12-normalization/>) is incorrect. The page states that the example has a "repeating group" because there can be multiple courses per student and therefore is not in 1NF. But this is a misunderstanding of 1NF. 1NF is abou...
15,481,759
I am trying to convert a nested JSON object on an ASP.NET server. The incoming JSON string looks something like this - ```js data: { user_id: 1, taskid: "1234", list: { "item-1": { one: 1, two: 2 }, "item-2": { one: 1, two: 2 } //.. where number of items is unknown } } ``` I have ...
2013/03/18
[ "https://Stackoverflow.com/questions/15481759", "https://Stackoverflow.com", "https://Stackoverflow.com/users/95055/" ]
``` List<Data> decodedData = JSON.Decode<DataList>(Request["data"]) ``` Should Be ``` var decodedData = JSON.Decode<List<Data>>(Request["data"]) var myDataList = new DataList() { data = decodedData; } ```
Try iterating over `decodedData.data` instead. `decodedData` is a `DataList`, and the `DataList` class has a member `data` which is a `List<Data>`. `List<Data>` has a `GetEnumerator` method, as required by `foreach`. Alternatively, you could add a `GetEnumerator` method to `DataList`: ``` public IEnumerator GetEnume...
15,481,759
I am trying to convert a nested JSON object on an ASP.NET server. The incoming JSON string looks something like this - ```js data: { user_id: 1, taskid: "1234", list: { "item-1": { one: 1, two: 2 }, "item-2": { one: 1, two: 2 } //.. where number of items is unknown } } ``` I have ...
2013/03/18
[ "https://Stackoverflow.com/questions/15481759", "https://Stackoverflow.com", "https://Stackoverflow.com/users/95055/" ]
Try iterating over `decodedData.data` instead. `decodedData` is a `DataList`, and the `DataList` class has a member `data` which is a `List<Data>`. `List<Data>` has a `GetEnumerator` method, as required by `foreach`. Alternatively, you could add a `GetEnumerator` method to `DataList`: ``` public IEnumerator GetEnume...
You can try decoding the JSON into an array of Data objects, and then calling the ToList() extension method on that array. ``` var dataArray = JSON.Decode<Data[]>(Request["data"]); var list = dataArray.ToList(); ```
15,481,759
I am trying to convert a nested JSON object on an ASP.NET server. The incoming JSON string looks something like this - ```js data: { user_id: 1, taskid: "1234", list: { "item-1": { one: 1, two: 2 }, "item-2": { one: 1, two: 2 } //.. where number of items is unknown } } ``` I have ...
2013/03/18
[ "https://Stackoverflow.com/questions/15481759", "https://Stackoverflow.com", "https://Stackoverflow.com/users/95055/" ]
``` List<Data> decodedData = JSON.Decode<DataList>(Request["data"]) ``` Should Be ``` var decodedData = JSON.Decode<List<Data>>(Request["data"]) var myDataList = new DataList() { data = decodedData; } ```
Your example is not [valid json](http://jsonlint.com/). You should have a collection `[]` for list: ``` data: { "user_id": 1, "taskid": "1234", "list": [ { "one": 1, "two": 2 }, { "one": 1, "two": 2 } ] } ```