qid
int64
1
74.7M
question
stringlengths
15
58.3k
date
stringlengths
10
10
metadata
list
response_j
stringlengths
4
30.2k
response_k
stringlengths
11
36.5k
4,724,007
My maven java project uses the maven-antrun-plugin to execute a deploy.xml ant script that deploys my app. The deploy.xml uses the `<if>` task and this seems to be causing the problem; > > [INFO] Executing tasks > > [taskdef] Could not load definitions from resource net/sf/antcontrib/antlib.xml. It could not be fo...
2011/01/18
[ "https://Stackoverflow.com/questions/4724007", "https://Stackoverflow.com", "https://Stackoverflow.com/users/443515/" ]
I found that you need to include the ant-contrib dependency inside the plugin which will enable the taskdef tag to find antcontrib.properties ``` <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <dependencies> <depen...
another solution would be: keep the ant-contrib-1.0b3.jar to a path and then define it like this ``` <property name="runningLocation" location="" /> <taskdef resource="net/sf/antcontrib/antcontrib.properties"> <classpath> <pathelement location="${runningLocation}/ant-contrib-1.0b3.jar" /> </classpath> ...
25,297,252
I need to find max and min value of a array in different dimensions(will be 1-d, 2-d and up to N dimension array) in my program. Can anyone help me to write a function or function template that can take input of an arbitrary dimension array and find the max/min value? \* I'm using vector of vectors Something like this...
2014/08/13
[ "https://Stackoverflow.com/questions/25297252", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3939274/" ]
The function you wrote the signature of can be implemented with a simple call to `std::max_element`. Then you can overload this function with a template accepting *any nested vector*, which first recursively applies the function to each element of the vector before computing the maximum value of them. The following c...
Be aware that templated functions can derive their argument types. You don't need to specify the types to call the methods; and you can have them drive their call parameters for you (same isn't true for template structures). You can exploit that. Here's another solution: ``` int find_max(int a) { return a; } // Just ...
25,297,252
I need to find max and min value of a array in different dimensions(will be 1-d, 2-d and up to N dimension array) in my program. Can anyone help me to write a function or function template that can take input of an arbitrary dimension array and find the max/min value? \* I'm using vector of vectors Something like this...
2014/08/13
[ "https://Stackoverflow.com/questions/25297252", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3939274/" ]
Here's another minimal example of how it can be done: ``` int find_max(int i) { return i; } template <typename T> int find_max(const std::vector<T>& v) { return std::accumulate(std::begin(v), std::end(v), std::numeric_limits<int>::min(), [] (const int prev, const T& v) { int m = fi...
Be aware that templated functions can derive their argument types. You don't need to specify the types to call the methods; and you can have them drive their call parameters for you (same isn't true for template structures). You can exploit that. Here's another solution: ``` int find_max(int a) { return a; } // Just ...
35,146,110
I'm trying to use macro for c code. However, I stuck in using token concatenation I have below variables. ``` A, aA, bA, cA ... ``` And, all of these variables used for same function (situation is a bit complicate, so just passing variable is not enough). If I have only ``` aA, bA, cA ``` Then, I can do using ...
2016/02/02
[ "https://Stackoverflow.com/questions/35146110", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2268721/" ]
Pass an empty argument and it will effectively concatenate nothing with `A`, producing just `A`: ``` #define CALL_FUNCTION(GROUP) \ FUNCTION(GROUP##A); CALL_FUNCTION() // expands to FUNCTION(A); CALL_FUNCTION(a) // expands to FUNCTION(aA); ``` You can [see this work live](http://coliru.stacked-crooked.com/a/9b...
You just need a second macro that takes no parameters: ``` #define CALL_FUNCTION() \ FUNCTION(A); #define CALL_FUNCTION(GROUP) \ FUNCTION(GROUP##A); ``` Example: ``` #include <stdio.h> #define FUNCTION(x) printf( # x "\n" ) #define CALL_FUNCTION() FUNCTION(A) #define CALL_FUNCTION(GROUP)...
8,239,906
I have written a simple code for Database updatation, but it is sometime updating and sometimes not... i have written LOG for conformation but the log is giving correct output. Here is what i am trying := ``` public void updateDownloadedAssetNumberOfStartingBytesEncrypted(int id, int startingBytesEncrypted) { ...
2011/11/23
[ "https://Stackoverflow.com/questions/8239906", "https://Stackoverflow.com", "https://Stackoverflow.com/users/966540/" ]
Ya i got ur code... Finally i resolved the issue.... actually it is beacuse of threading.... **the thread creating the row was executed later and that updating the row was executed first** i have resolved it.Have fun :)
This happened due to connection of database is not open. Pls keep ex.printstacktrace(); in catch statement.
40,127,784
I need your help in HANA SAP. I'm trying to compare dates in different rows, like: ``` ID~~~~~~|~~~ NAME~~~|~DATE ~~ | STEP --------+-----------+---------+----------- 132~~~~~|~~TEST~~~| 01.01.2001| CREATED 132~~~~~|~~TEST~~~| 05.01.2001| SOLVED 154~~~~~|~~Other~~| 06.01.2001| CREATED 175~~~~~|~~Card~~~| 08.01.2001|...
2016/10/19
[ "https://Stackoverflow.com/questions/40127784", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7041429/" ]
Calling `sess.run(c)` and `c.eval()`, in the same session, provide exactly the same results. You can mix calls to `sess.run` and `<tensor>.eval()` in the code, but it makes your code less consistent. In my opinion, it's better to use always `sess.run`, beacuse within a single call you can evaluate more then one tenso...
The quick answer to your question is **NO**. You just need either `Session.run()` or `Tensor.eval()` to evaluate the value of a tensor object. People usually use `Tensor.eval()` to experiment the programming model, namely print out the value of tensors to track the flow! For example, ``` import tensorflow as tf a = ...
47,640,354
I am running a script which takes a text "rAh%19u^l\&G" i.e which contains special characters as seen. When i pass this text in my script as a argument it runs fine without any error. example - : `./abc.py <username><pwd>` The above text is basically a password. Now, when i place my values in a config file and read...
2017/12/04
[ "https://Stackoverflow.com/questions/47640354", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5304672/" ]
Looks like the `%` character is the problem here. It has special meaning if you are using `ConfigParser`. If you are not using interpolation, then use just `RawConfigParser` instead, otherwise you must escape the `%` by doubling it. When I try the example file with `ConfigParser` it will blow with the following except...
Adding up on Paulo Scardine's comment. if you have special characters that need to be handled, you can set the `ConfigParser`'s `interpolation` argument to `None` and you won't have the error anymore. `ConfigParser` has `interpolation` set to `BasicInterpolation()` by default. You can read more about this here: <htt...
47,640,354
I am running a script which takes a text "rAh%19u^l\&G" i.e which contains special characters as seen. When i pass this text in my script as a argument it runs fine without any error. example - : `./abc.py <username><pwd>` The above text is basically a password. Now, when i place my values in a config file and read...
2017/12/04
[ "https://Stackoverflow.com/questions/47640354", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5304672/" ]
Looks like the `%` character is the problem here. It has special meaning if you are using `ConfigParser`. If you are not using interpolation, then use just `RawConfigParser` instead, otherwise you must escape the `%` by doubling it. When I try the example file with `ConfigParser` it will blow with the following except...
you could escape the special char with same char. for example, to be able to read % you have to write it %%
47,640,354
I am running a script which takes a text "rAh%19u^l\&G" i.e which contains special characters as seen. When i pass this text in my script as a argument it runs fine without any error. example - : `./abc.py <username><pwd>` The above text is basically a password. Now, when i place my values in a config file and read...
2017/12/04
[ "https://Stackoverflow.com/questions/47640354", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5304672/" ]
Looks like the `%` character is the problem here. It has special meaning if you are using `ConfigParser`. If you are not using interpolation, then use just `RawConfigParser` instead, otherwise you must escape the `%` by doubling it. When I try the example file with `ConfigParser` it will blow with the following except...
I had came across this same issue. Understandably the answer has been posted. Using the comments from everyone on this post I had resolved this issue with the following: My password was `Sgf%ts54hhGtrf&yhgf` alembic ini file I was using: `sqlalchemy.url = driver://myuser:Sgf%ts54hhGtrf&yhgf@localhost/my_application` ...
47,640,354
I am running a script which takes a text "rAh%19u^l\&G" i.e which contains special characters as seen. When i pass this text in my script as a argument it runs fine without any error. example - : `./abc.py <username><pwd>` The above text is basically a password. Now, when i place my values in a config file and read...
2017/12/04
[ "https://Stackoverflow.com/questions/47640354", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5304672/" ]
Adding up on Paulo Scardine's comment. if you have special characters that need to be handled, you can set the `ConfigParser`'s `interpolation` argument to `None` and you won't have the error anymore. `ConfigParser` has `interpolation` set to `BasicInterpolation()` by default. You can read more about this here: <htt...
you could escape the special char with same char. for example, to be able to read % you have to write it %%
47,640,354
I am running a script which takes a text "rAh%19u^l\&G" i.e which contains special characters as seen. When i pass this text in my script as a argument it runs fine without any error. example - : `./abc.py <username><pwd>` The above text is basically a password. Now, when i place my values in a config file and read...
2017/12/04
[ "https://Stackoverflow.com/questions/47640354", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5304672/" ]
Adding up on Paulo Scardine's comment. if you have special characters that need to be handled, you can set the `ConfigParser`'s `interpolation` argument to `None` and you won't have the error anymore. `ConfigParser` has `interpolation` set to `BasicInterpolation()` by default. You can read more about this here: <htt...
I had came across this same issue. Understandably the answer has been posted. Using the comments from everyone on this post I had resolved this issue with the following: My password was `Sgf%ts54hhGtrf&yhgf` alembic ini file I was using: `sqlalchemy.url = driver://myuser:Sgf%ts54hhGtrf&yhgf@localhost/my_application` ...
47,640,354
I am running a script which takes a text "rAh%19u^l\&G" i.e which contains special characters as seen. When i pass this text in my script as a argument it runs fine without any error. example - : `./abc.py <username><pwd>` The above text is basically a password. Now, when i place my values in a config file and read...
2017/12/04
[ "https://Stackoverflow.com/questions/47640354", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5304672/" ]
you could escape the special char with same char. for example, to be able to read % you have to write it %%
I had came across this same issue. Understandably the answer has been posted. Using the comments from everyone on this post I had resolved this issue with the following: My password was `Sgf%ts54hhGtrf&yhgf` alembic ini file I was using: `sqlalchemy.url = driver://myuser:Sgf%ts54hhGtrf&yhgf@localhost/my_application` ...
14,840,735
I have an Extension Method as mentioned below.Is there a way were I can make it work in a generic way.For int?,decimal?,long?,double?.Or is there a limitation in the way 0(zero) is compared for different numeric data type? ``` public static bool IsNotNullAndGreaterThanZero(this decimal? value) { return (value ?? 0M) >...
2013/02/12
[ "https://Stackoverflow.com/questions/14840735", "https://Stackoverflow.com", "https://Stackoverflow.com/users/808574/" ]
Well, you could do this: ``` public static bool IsNotNullAndGreaterThanDefault<T>(this T? value) where T : struct, IComparable<T> { return value != null && value.Value.CompareTo(default(T)) > 0; } ``` That uses the fact that for most value types, the default value is the "natural zero".
You could use [IConvertible](http://msdn.microsoft.com/en-us/library/system.iconvertible.aspx) to do this: ``` public static bool IsNotNullAndGreaterThanZero<T>(this T? value) where T : struct, IConvertible { return value != null && value.ToDecimal() > 0M; } ``` The basic value types such as int/long/double...
47,377,032
I am new to OpenCV. I need to detect the eyes using opencv and save them in a folder for further classification. I have written following script for the same: ``` import numpy as np import cv2 face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml') eye_cascade = cv2.CascadeClassifier('haarcascade...
2017/11/19
[ "https://Stackoverflow.com/questions/47377032", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8258705/" ]
Move `count=1` outside of `while-loop`. ``` count = 1 while True: pass #your code ``` And the indent of `cv2.imshow` is not that correct. ``` import numpy as np import cv2 face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml') eye_cascade = cv2.CascadeClassifier('haarcascade_eye.xml') ...
With reference to the previous answer, you can also experiment changing the scaling factor of the haar-cascade sliding window. By this time you might have figured there are false positives in your gallery i.e non-eye images detected as eyes by the haar-cascade. So I'd recommend trying D-lib as it can achieve more accu...
17,095,517
I have an activity like this: ![enter image description here](https://i.stack.imgur.com/syTw5.png) As you can see, the bottom below the checkboxes doesn't fit in the screen. How can I make the checkboxes get closer in the linearlayout? And here is the XML (just the checkboxes + button): ``` <LinearLayout a...
2013/06/13
[ "https://Stackoverflow.com/questions/17095517", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2457591/" ]
``` android:layout_marginTop="-10dp" ``` You can add a top padding with a minus (-) sign on all of your checkboxes, exept for the first one on top, in these case -10, but you can chose whatever works for you ....that should put them closer
set margin of each checkbox to zero
29,394,030
There's the simplified version of my code who keep raise me ORA-06502: ``` declare p_filter varchar2(300) := '2012'; p_value varchar2(300) := '12345.000'; w_new_value number(13,3) := null ; w_count number(4) := null ; BEGIN SELECT count(*) INTO w_count FROM...
2015/04/01
[ "https://Stackoverflow.com/questions/29394030", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4573548/" ]
This used to work for me (I've switched to the lighter and better configurable NLog), log rolled daily, was written in a subfolder named "Logs" under the app's path. ``` <appender name="RollingDebugAppender" type="log4net.Appender.RollingFileAppender"> <file value="Logs\" /> <datePattern value="yyyy-MM-dd'-F...
You should turn on log4net's internal debugging to figure out what's failing... Sample web.config ``` <?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key="log4net.Internal.Debug" value="true"/> </appSettings> <system.diagnostics> <trace autoflush="true"> <listeners> ...
29,394,030
There's the simplified version of my code who keep raise me ORA-06502: ``` declare p_filter varchar2(300) := '2012'; p_value varchar2(300) := '12345.000'; w_new_value number(13,3) := null ; w_count number(4) := null ; BEGIN SELECT count(*) INTO w_count FROM...
2015/04/01
[ "https://Stackoverflow.com/questions/29394030", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4573548/" ]
This is final version of what I ended up doing that worked: ``` <log4net> <root> <level value="ALL"/> <appender-ref ref="RollingFileAppender"/> </root> <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender"> <file value="logs\log4net.log"/> <datePattern va...
You should turn on log4net's internal debugging to figure out what's failing... Sample web.config ``` <?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key="log4net.Internal.Debug" value="true"/> </appSettings> <system.diagnostics> <trace autoflush="true"> <listeners> ...
29,394,030
There's the simplified version of my code who keep raise me ORA-06502: ``` declare p_filter varchar2(300) := '2012'; p_value varchar2(300) := '12345.000'; w_new_value number(13,3) := null ; w_count number(4) := null ; BEGIN SELECT count(*) INTO w_count FROM...
2015/04/01
[ "https://Stackoverflow.com/questions/29394030", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4573548/" ]
You should turn on log4net's internal debugging to figure out what's failing... Sample web.config ``` <?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key="log4net.Internal.Debug" value="true"/> </appSettings> <system.diagnostics> <trace autoflush="true"> <listeners> ...
\*\_%date{yyyyMMdd}.log below is the key, if this is missing u will see logs like above ``` <?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key="log4net.Internal.Debug" value="true"/> </appSettings> <system.diagnostics> <trace autoflush="true"> <listeners> <add n...
29,394,030
There's the simplified version of my code who keep raise me ORA-06502: ``` declare p_filter varchar2(300) := '2012'; p_value varchar2(300) := '12345.000'; w_new_value number(13,3) := null ; w_count number(4) := null ; BEGIN SELECT count(*) INTO w_count FROM...
2015/04/01
[ "https://Stackoverflow.com/questions/29394030", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4573548/" ]
This used to work for me (I've switched to the lighter and better configurable NLog), log rolled daily, was written in a subfolder named "Logs" under the app's path. ``` <appender name="RollingDebugAppender" type="log4net.Appender.RollingFileAppender"> <file value="Logs\" /> <datePattern value="yyyy-MM-dd'-F...
\*\_%date{yyyyMMdd}.log below is the key, if this is missing u will see logs like above ``` <?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key="log4net.Internal.Debug" value="true"/> </appSettings> <system.diagnostics> <trace autoflush="true"> <listeners> <add n...
29,394,030
There's the simplified version of my code who keep raise me ORA-06502: ``` declare p_filter varchar2(300) := '2012'; p_value varchar2(300) := '12345.000'; w_new_value number(13,3) := null ; w_count number(4) := null ; BEGIN SELECT count(*) INTO w_count FROM...
2015/04/01
[ "https://Stackoverflow.com/questions/29394030", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4573548/" ]
This is final version of what I ended up doing that worked: ``` <log4net> <root> <level value="ALL"/> <appender-ref ref="RollingFileAppender"/> </root> <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender"> <file value="logs\log4net.log"/> <datePattern va...
\*\_%date{yyyyMMdd}.log below is the key, if this is missing u will see logs like above ``` <?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key="log4net.Internal.Debug" value="true"/> </appSettings> <system.diagnostics> <trace autoflush="true"> <listeners> <add n...
9,355,952
I've got a Django app that needs to take a list of multiple datetimes and print out a simple string that explains what the pattern is. Example: With 3 datetime instances for Monday, Wednesday, and Friday at 3pm, the simple output would be something like `Monday, Wednesday, Friday at 3:00pm` With 3 datetime instanc...
2012/02/20
[ "https://Stackoverflow.com/questions/9355952", "https://Stackoverflow.com", "https://Stackoverflow.com/users/941729/" ]
It sounds like something that is fundamentally "business logic." For example, if the dates happen to all be Easter on consecutive years, do you expect that to be picked up? What about if they are all the last day of Hanukkah? This isn't likely to be something that's handled by a language or library directly--you'll nee...
As per your need you have to use [`Python Calendar`](http://docs.python.org/library/calendar.html) module to iterate over the weekdays or days or the month. It provide the functions to read on specific day of month or week.
59,837,620
We have a project with a PWA where we want to implement client sided encryption. We wanted to use Webauthn as a second-factor in combination with passwords. In the background we use a randomly generated key to encrypt/decrypt the database, which is stored symmetrically encrypted with the password on the server. However...
2020/01/21
[ "https://Stackoverflow.com/questions/59837620", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10501842/" ]
The protocol as it stands does not provide generic public key crypto services as far as I am aware. The best you can do is prove that a user is in possession of the private key related to the public key you hold.
Years after this question, the [`hmac-secret`](https://fidoalliance.org/specs/fido-v2.0-rd-20180702/fido-client-to-authenticator-protocol-v2.0-rd-20180702.html#sctn-hmac-secret-extension) extension has arrived. This extension binds a secret to a Webauthn credential. This secret can be used to decrypt or encrypt data o...
59,837,620
We have a project with a PWA where we want to implement client sided encryption. We wanted to use Webauthn as a second-factor in combination with passwords. In the background we use a randomly generated key to encrypt/decrypt the database, which is stored symmetrically encrypted with the password on the server. However...
2020/01/21
[ "https://Stackoverflow.com/questions/59837620", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10501842/" ]
The protocol as it stands does not provide generic public key crypto services as far as I am aware. The best you can do is prove that a user is in possession of the private key related to the public key you hold.
You can learn from the following github repo ,it has many Webauthn out of the box examples (see the tech it supports inside) Here are some samples I found at github <https://github.com/OwnID/samples> In addition,I read about FIDO ,Webauthn and passkeys at [passkeys.com](https://passkeys.com) Everything about this co...
59,837,620
We have a project with a PWA where we want to implement client sided encryption. We wanted to use Webauthn as a second-factor in combination with passwords. In the background we use a randomly generated key to encrypt/decrypt the database, which is stored symmetrically encrypted with the password on the server. However...
2020/01/21
[ "https://Stackoverflow.com/questions/59837620", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10501842/" ]
You can learn from the following github repo ,it has many Webauthn out of the box examples (see the tech it supports inside) Here are some samples I found at github <https://github.com/OwnID/samples> In addition,I read about FIDO ,Webauthn and passkeys at [passkeys.com](https://passkeys.com) Everything about this co...
Years after this question, the [`hmac-secret`](https://fidoalliance.org/specs/fido-v2.0-rd-20180702/fido-client-to-authenticator-protocol-v2.0-rd-20180702.html#sctn-hmac-secret-extension) extension has arrived. This extension binds a secret to a Webauthn credential. This secret can be used to decrypt or encrypt data o...
16,218
I'm going to implement a mega menu in my site and am considering the [Menu Minipanels](http://drupal.org/project/menu_minipanels) module... Has anyone tried it? Did you find it easy to use/customize? What about performance? Panels is often quite a heavy module.
2011/11/27
[ "https://drupal.stackexchange.com/questions/16218", "https://drupal.stackexchange.com", "https://drupal.stackexchange.com/users/4206/" ]
[Menu Minipanels](http://drupal.org/project/menu_minipanels) looks like a good choice. An alternative you might want to try for a simple 'mega menu' is the [Mega Menus module](http://drupal.org/project/megamenu). Worked well for me, once I had my settings and CSS sorted out. See also [this answer for lots more mega me...
There's a new mega menu module called [TB Mega Menu](http://drupal.org/project/tb_megamenu) which I found pretty helpful and extremely easy to use. Its got a friendly user interface (WYSIWYG) along with some nice features such as synchronized with Drupal core menu, nice design, built on Twitter Bootstrap, responsive...
14,826,260
Hi i am looking for a guide so that i can build my first phpfox website.Although i have download the phpfox edition and successfully configure on local system.
2013/02/12
[ "https://Stackoverflow.com/questions/14826260", "https://Stackoverflow.com", "https://Stackoverflow.com/users/451302/" ]
Firstly you should slice the html into header, content and footer. The content changes for each page and header and footer will remain same. Add session\_start() and code to establish connection in the header file. Just to give you a rough idea... login.php ``` <?php session_start(); $con = mysql_connect($host,$_...
1.Slice the html and include header and footer file. 2.Change the content in accordance with the url requested e.g. keep one file say index.php and include header then its content and lastly footer. -say the request is index.php?content=register,then you will get the values of $\_REQUEST['content'] and based on it y...
4,119,024
this is a really basic question I know, I am a begginer in Haskell. So, I am wondering how to "take" the lists from a function like: ``` putStr( f [[1,2,3],[4,5,6],[6,7,8]]) ``` I don't know if I am expressing this correctly, but I want to create a function f that takes this type: ``` type Matrix a = [[a]] type Int...
2010/11/07
[ "https://Stackoverflow.com/questions/4119024", "https://Stackoverflow.com", "https://Stackoverflow.com/users/373141/" ]
"find the max of each of the inner lists", "find their length to use later on", both of them can be done with the `map` higher-order function. ``` Prelude> let a = [[1,2,3],[4,5,6],[6,7,8]] :: [[Integer]] Prelude> map maximum a [3,6,8] Prelude> map length a [3,3,3] ``` If you have a list `M = [a, b, c, d, ...]`, and...
If you want to take ith row, then you can use the `(!)` operator. ``` Prelude> [[1, 2], [3]] !! 1 [3] Prelude> [[1, 2], [3]] !! 0 [1,2] Prelude> ``` If you want to apply any function to every row, then you can use `map` ``` Prelude> map length[[1, 2], [3]] [2,1] ```
4,119,024
this is a really basic question I know, I am a begginer in Haskell. So, I am wondering how to "take" the lists from a function like: ``` putStr( f [[1,2,3],[4,5,6],[6,7,8]]) ``` I don't know if I am expressing this correctly, but I want to create a function f that takes this type: ``` type Matrix a = [[a]] type Int...
2010/11/07
[ "https://Stackoverflow.com/questions/4119024", "https://Stackoverflow.com", "https://Stackoverflow.com/users/373141/" ]
Let `f :: [Int] -> a` be the function that does want you want to do to each row of the `IntMat`. Then you can apply it to each row of the matrix by using `map`: `putStr $ map f [[1,2,3],[4,5,6],[6,7,8]]` passes each element of the list to `f` and returns a a new list, where the first element is the result of `f firstE...
If you want to take ith row, then you can use the `(!)` operator. ``` Prelude> [[1, 2], [3]] !! 1 [3] Prelude> [[1, 2], [3]] !! 0 [1,2] Prelude> ``` If you want to apply any function to every row, then you can use `map` ``` Prelude> map length[[1, 2], [3]] [2,1] ```
4,119,024
this is a really basic question I know, I am a begginer in Haskell. So, I am wondering how to "take" the lists from a function like: ``` putStr( f [[1,2,3],[4,5,6],[6,7,8]]) ``` I don't know if I am expressing this correctly, but I want to create a function f that takes this type: ``` type Matrix a = [[a]] type Int...
2010/11/07
[ "https://Stackoverflow.com/questions/4119024", "https://Stackoverflow.com", "https://Stackoverflow.com/users/373141/" ]
I think you want `(map . map)`. If I understand you correctly, you want to perform some operation on each element of the sublists and return a new list. First, lets look at what (map . map) is: ``` Prelude> :t (map . map) (map . map) :: (a -> b) -> [[a]] -> [[b]] ``` I think this is pretty self-explanatory. Lets u...
If you want to take ith row, then you can use the `(!)` operator. ``` Prelude> [[1, 2], [3]] !! 1 [3] Prelude> [[1, 2], [3]] !! 0 [1,2] Prelude> ``` If you want to apply any function to every row, then you can use `map` ``` Prelude> map length[[1, 2], [3]] [2,1] ```
4,119,024
this is a really basic question I know, I am a begginer in Haskell. So, I am wondering how to "take" the lists from a function like: ``` putStr( f [[1,2,3],[4,5,6],[6,7,8]]) ``` I don't know if I am expressing this correctly, but I want to create a function f that takes this type: ``` type Matrix a = [[a]] type Int...
2010/11/07
[ "https://Stackoverflow.com/questions/4119024", "https://Stackoverflow.com", "https://Stackoverflow.com/users/373141/" ]
"find the max of each of the inner lists", "find their length to use later on", both of them can be done with the `map` higher-order function. ``` Prelude> let a = [[1,2,3],[4,5,6],[6,7,8]] :: [[Integer]] Prelude> map maximum a [3,6,8] Prelude> map length a [3,3,3] ``` If you have a list `M = [a, b, c, d, ...]`, and...
The function you are looking for is `map`. Eg.: ``` >>> map maximum [[1,2,3],[4,5,6],[6,7,8]] [3,6,8] ```
4,119,024
this is a really basic question I know, I am a begginer in Haskell. So, I am wondering how to "take" the lists from a function like: ``` putStr( f [[1,2,3],[4,5,6],[6,7,8]]) ``` I don't know if I am expressing this correctly, but I want to create a function f that takes this type: ``` type Matrix a = [[a]] type Int...
2010/11/07
[ "https://Stackoverflow.com/questions/4119024", "https://Stackoverflow.com", "https://Stackoverflow.com/users/373141/" ]
"find the max of each of the inner lists", "find their length to use later on", both of them can be done with the `map` higher-order function. ``` Prelude> let a = [[1,2,3],[4,5,6],[6,7,8]] :: [[Integer]] Prelude> map maximum a [3,6,8] Prelude> map length a [3,3,3] ``` If you have a list `M = [a, b, c, d, ...]`, and...
Let `f :: [Int] -> a` be the function that does want you want to do to each row of the `IntMat`. Then you can apply it to each row of the matrix by using `map`: `putStr $ map f [[1,2,3],[4,5,6],[6,7,8]]` passes each element of the list to `f` and returns a a new list, where the first element is the result of `f firstE...
4,119,024
this is a really basic question I know, I am a begginer in Haskell. So, I am wondering how to "take" the lists from a function like: ``` putStr( f [[1,2,3],[4,5,6],[6,7,8]]) ``` I don't know if I am expressing this correctly, but I want to create a function f that takes this type: ``` type Matrix a = [[a]] type Int...
2010/11/07
[ "https://Stackoverflow.com/questions/4119024", "https://Stackoverflow.com", "https://Stackoverflow.com/users/373141/" ]
"find the max of each of the inner lists", "find their length to use later on", both of them can be done with the `map` higher-order function. ``` Prelude> let a = [[1,2,3],[4,5,6],[6,7,8]] :: [[Integer]] Prelude> map maximum a [3,6,8] Prelude> map length a [3,3,3] ``` If you have a list `M = [a, b, c, d, ...]`, and...
I think you want `(map . map)`. If I understand you correctly, you want to perform some operation on each element of the sublists and return a new list. First, lets look at what (map . map) is: ``` Prelude> :t (map . map) (map . map) :: (a -> b) -> [[a]] -> [[b]] ``` I think this is pretty self-explanatory. Lets u...
4,119,024
this is a really basic question I know, I am a begginer in Haskell. So, I am wondering how to "take" the lists from a function like: ``` putStr( f [[1,2,3],[4,5,6],[6,7,8]]) ``` I don't know if I am expressing this correctly, but I want to create a function f that takes this type: ``` type Matrix a = [[a]] type Int...
2010/11/07
[ "https://Stackoverflow.com/questions/4119024", "https://Stackoverflow.com", "https://Stackoverflow.com/users/373141/" ]
Let `f :: [Int] -> a` be the function that does want you want to do to each row of the `IntMat`. Then you can apply it to each row of the matrix by using `map`: `putStr $ map f [[1,2,3],[4,5,6],[6,7,8]]` passes each element of the list to `f` and returns a a new list, where the first element is the result of `f firstE...
The function you are looking for is `map`. Eg.: ``` >>> map maximum [[1,2,3],[4,5,6],[6,7,8]] [3,6,8] ```
4,119,024
this is a really basic question I know, I am a begginer in Haskell. So, I am wondering how to "take" the lists from a function like: ``` putStr( f [[1,2,3],[4,5,6],[6,7,8]]) ``` I don't know if I am expressing this correctly, but I want to create a function f that takes this type: ``` type Matrix a = [[a]] type Int...
2010/11/07
[ "https://Stackoverflow.com/questions/4119024", "https://Stackoverflow.com", "https://Stackoverflow.com/users/373141/" ]
I think you want `(map . map)`. If I understand you correctly, you want to perform some operation on each element of the sublists and return a new list. First, lets look at what (map . map) is: ``` Prelude> :t (map . map) (map . map) :: (a -> b) -> [[a]] -> [[b]] ``` I think this is pretty self-explanatory. Lets u...
The function you are looking for is `map`. Eg.: ``` >>> map maximum [[1,2,3],[4,5,6],[6,7,8]] [3,6,8] ```
136,662
I've got *strong* suspicions that a particular user is regularly strategically down-voting competing answers that appear on questions he's answered (the answers in question are equal, if not always *better* than the one he's posted). Is this abuse of the system, or should I accept that they're his downvotes, and he ca...
2012/06/19
[ "https://meta.stackexchange.com/questions/136662", "https://meta.stackexchange.com", "https://meta.stackexchange.com/users/163863/" ]
If I've just tendered an answer, of course I think it is better than all the others (well, most of the time I do). Do you see my point? *"Which answer is better?"* can be very subjective. The culprit can cast a single downvote per answer, but he cannot really influence the community, and if the question is attracting...
The only reason why I am answering is so that I can downvote the other answers.
136,662
I've got *strong* suspicions that a particular user is regularly strategically down-voting competing answers that appear on questions he's answered (the answers in question are equal, if not always *better* than the one he's posted). Is this abuse of the system, or should I accept that they're his downvotes, and he ca...
2012/06/19
[ "https://meta.stackexchange.com/questions/136662", "https://meta.stackexchange.com", "https://meta.stackexchange.com/users/163863/" ]
People are free to cast their down votes ( or upvotes) any way they please. The system explicitly allows for voting on questions you have taken part in. If this was a Bad Thing, then the voting system should be changed to not allow people to vote on other answers in a question they've answered. This is easy to do, bu...
The only reason why I am answering is so that I can downvote the other answers.
34,999,656
This is my first ror app. I have main page: `home.html.erb` I have form there. ``` <%= form_for(@lead ,:html => {:class => 'check_form'}) do |f| %> <%= f.text_field :phone, placeholder: 'phone' %> <%= f.submit "Check car status", class: "btn btn-large btn-primary" %> <% end %> ``` Backstory: a custome...
2016/01/25
[ "https://Stackoverflow.com/questions/34999656", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2950593/" ]
> > What I want to do when user inputs his phone number to find lead in > database with the same phone number and show repair status to user. > > > Currently your form serves the wrong purpose. This requires a form with `GET` request. I'll be doing it by declaring a custom `route` like below ``` get :check_lead_...
youre redirecting to `@lead` which means should be the show path in the lead controller. which means you need to put that logic in a method called `show` in your Lead controller then in your view (`views/leads/show.html.erb`) you can access that variable --- edit: if all youre trying to do is query by a different p...
5,141,886
I would like to be able to count how many times a function is called in a library. I have the C++ source of the library available, but I don't have the source of the executable that uses it. **Gprof** seams to be a popular tool but it works only for executables. I have found very limited info on sprof, which is suppose...
2011/02/28
[ "https://Stackoverflow.com/questions/5141886", "https://Stackoverflow.com", "https://Stackoverflow.com/users/324204/" ]
GCC, in recent versions, has a compiler switch `-finstrument-functions` which can be used to have it autogenerate tracepoint hooks within compiled code. See [GCC Code Generation Options](http://gcc.gnu.org/onlinedocs/gcc-4.4.2/gcc/Code-Gen-Options.html) in the manual. With that, you don't even need a full-blown interce...
You can do this pretty easily via an LD\_PRELOAD library. You write a library which catches the calls to the function you're instrumenting, increments a counter, and then calls the original implementation (by dlopening the shared object and calling into it). You then LD\_PRELOAD your interceptor library when launching ...
5,141,886
I would like to be able to count how many times a function is called in a library. I have the C++ source of the library available, but I don't have the source of the executable that uses it. **Gprof** seams to be a popular tool but it works only for executables. I have found very limited info on sprof, which is suppose...
2011/02/28
[ "https://Stackoverflow.com/questions/5141886", "https://Stackoverflow.com", "https://Stackoverflow.com/users/324204/" ]
You can do this pretty easily via an LD\_PRELOAD library. You write a library which catches the calls to the function you're instrumenting, increments a counter, and then calls the original implementation (by dlopening the shared object and calling into it). You then LD\_PRELOAD your interceptor library when launching ...
If its a dynamic library (DLL) you can just recompile it so that it counts and prints out a number that increments whenever the function is called to like a file or over a network
5,141,886
I would like to be able to count how many times a function is called in a library. I have the C++ source of the library available, but I don't have the source of the executable that uses it. **Gprof** seams to be a popular tool but it works only for executables. I have found very limited info on sprof, which is suppose...
2011/02/28
[ "https://Stackoverflow.com/questions/5141886", "https://Stackoverflow.com", "https://Stackoverflow.com/users/324204/" ]
GCC, in recent versions, has a compiler switch `-finstrument-functions` which can be used to have it autogenerate tracepoint hooks within compiled code. See [GCC Code Generation Options](http://gcc.gnu.org/onlinedocs/gcc-4.4.2/gcc/Code-Gen-Options.html) in the manual. With that, you don't even need a full-blown interce...
You should be able to do this using [ltrace](http://www.ltrace.org/), run your program with `ltrace -c -l yourlibrary`, or drop `-l` to get a count of all dynamic library calls.
5,141,886
I would like to be able to count how many times a function is called in a library. I have the C++ source of the library available, but I don't have the source of the executable that uses it. **Gprof** seams to be a popular tool but it works only for executables. I have found very limited info on sprof, which is suppose...
2011/02/28
[ "https://Stackoverflow.com/questions/5141886", "https://Stackoverflow.com", "https://Stackoverflow.com/users/324204/" ]
GCC, in recent versions, has a compiler switch `-finstrument-functions` which can be used to have it autogenerate tracepoint hooks within compiled code. See [GCC Code Generation Options](http://gcc.gnu.org/onlinedocs/gcc-4.4.2/gcc/Code-Gen-Options.html) in the manual. With that, you don't even need a full-blown interce...
If its a dynamic library (DLL) you can just recompile it so that it counts and prints out a number that increments whenever the function is called to like a file or over a network
5,141,886
I would like to be able to count how many times a function is called in a library. I have the C++ source of the library available, but I don't have the source of the executable that uses it. **Gprof** seams to be a popular tool but it works only for executables. I have found very limited info on sprof, which is suppose...
2011/02/28
[ "https://Stackoverflow.com/questions/5141886", "https://Stackoverflow.com", "https://Stackoverflow.com/users/324204/" ]
GCC, in recent versions, has a compiler switch `-finstrument-functions` which can be used to have it autogenerate tracepoint hooks within compiled code. See [GCC Code Generation Options](http://gcc.gnu.org/onlinedocs/gcc-4.4.2/gcc/Code-Gen-Options.html) in the manual. With that, you don't even need a full-blown interce...
You can use [systemtap](http://sourceware.org/systemtap/documentation.html) to get function call count. It is a powerful tool that allows you to instrument at run-time any application without having to recompile it, only debug symbols required. Here is a script that counts the number of calls to a function along with ...
5,141,886
I would like to be able to count how many times a function is called in a library. I have the C++ source of the library available, but I don't have the source of the executable that uses it. **Gprof** seams to be a popular tool but it works only for executables. I have found very limited info on sprof, which is suppose...
2011/02/28
[ "https://Stackoverflow.com/questions/5141886", "https://Stackoverflow.com", "https://Stackoverflow.com/users/324204/" ]
You should be able to do this using [ltrace](http://www.ltrace.org/), run your program with `ltrace -c -l yourlibrary`, or drop `-l` to get a count of all dynamic library calls.
If its a dynamic library (DLL) you can just recompile it so that it counts and prints out a number that increments whenever the function is called to like a file or over a network
5,141,886
I would like to be able to count how many times a function is called in a library. I have the C++ source of the library available, but I don't have the source of the executable that uses it. **Gprof** seams to be a popular tool but it works only for executables. I have found very limited info on sprof, which is suppose...
2011/02/28
[ "https://Stackoverflow.com/questions/5141886", "https://Stackoverflow.com", "https://Stackoverflow.com/users/324204/" ]
You can use [systemtap](http://sourceware.org/systemtap/documentation.html) to get function call count. It is a powerful tool that allows you to instrument at run-time any application without having to recompile it, only debug symbols required. Here is a script that counts the number of calls to a function along with ...
If its a dynamic library (DLL) you can just recompile it so that it counts and prints out a number that increments whenever the function is called to like a file or over a network
35,783,222
Filtering a Hashtable using GetEnumerator always returns a object[] instead of a Hashtable: ``` # Init Hashtable $items = @{ a1 = 1; a2 = 2; b1 = 3; b2 = 4} # apply a filter $filtered = $items.GetEnumerator() | ?{ $_.Key -match "a.*" } # The result looks great $filtered Name Value ---- ...
2016/03/03
[ "https://Stackoverflow.com/questions/35783222", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4795779/" ]
`$filtered` is an array of dictionary entries. There's no single cast or ctor for this as far as I know. You can construct a hash though: ``` $hash = @{} $filtered | ForEach-Object { $hash.Add($_.Key, $_.Value) } ``` Another workflow: ``` # Init Hashtable $items = @{ a1 = 1; a2 = 2; b1 = 3; b2 = 4} # Copy keys to...
As the [accepted answer](https://stackoverflow.com/a/35783327/1128705) was resulting in a `BadEnumeration` exception for me (but still worked), I modified it to not throw an exception and also made sure that the original `HashTable` is not modified by cloning it first: ``` # Init Hashtable $items = @{ a1 = 1; a2 = 2; ...
35,783,222
Filtering a Hashtable using GetEnumerator always returns a object[] instead of a Hashtable: ``` # Init Hashtable $items = @{ a1 = 1; a2 = 2; b1 = 3; b2 = 4} # apply a filter $filtered = $items.GetEnumerator() | ?{ $_.Key -match "a.*" } # The result looks great $filtered Name Value ---- ...
2016/03/03
[ "https://Stackoverflow.com/questions/35783222", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4795779/" ]
`$filtered` is an array of dictionary entries. There's no single cast or ctor for this as far as I know. You can construct a hash though: ``` $hash = @{} $filtered | ForEach-Object { $hash.Add($_.Key, $_.Value) } ``` Another workflow: ``` # Init Hashtable $items = @{ a1 = 1; a2 = 2; b1 = 3; b2 = 4} # Copy keys to...
On a modern `PowerShell` (`5`+ as far as I remember) you can use `reduce` pattern. For that you need to use this form of `ForEach-Object`: ``` $Hashtable.Keys | ForEach-Object {$FilteredHashtable = @{}} { if ($_ -eq 'Example') { $FilteredHashtable[$_] = $Hashtable[$_]; } } {$FilteredHashtable} ``` Ye...
35,783,222
Filtering a Hashtable using GetEnumerator always returns a object[] instead of a Hashtable: ``` # Init Hashtable $items = @{ a1 = 1; a2 = 2; b1 = 3; b2 = 4} # apply a filter $filtered = $items.GetEnumerator() | ?{ $_.Key -match "a.*" } # The result looks great $filtered Name Value ---- ...
2016/03/03
[ "https://Stackoverflow.com/questions/35783222", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4795779/" ]
`$filtered` is an array of dictionary entries. There's no single cast or ctor for this as far as I know. You can construct a hash though: ``` $hash = @{} $filtered | ForEach-Object { $hash.Add($_.Key, $_.Value) } ``` Another workflow: ``` # Init Hashtable $items = @{ a1 = 1; a2 = 2; b1 = 3; b2 = 4} # Copy keys to...
Here's an even simpler function, it even has include and exclude functionality ``` function Select-HashTable { [CmdletBinding()] param ( [Parameter(Mandatory,ValueFromPipeline)][Hashtable]$Hashtable, [String[]]$Include = ($HashTable.Keys), [String[]]$Exclude ) if (-not $Include...
35,783,222
Filtering a Hashtable using GetEnumerator always returns a object[] instead of a Hashtable: ``` # Init Hashtable $items = @{ a1 = 1; a2 = 2; b1 = 3; b2 = 4} # apply a filter $filtered = $items.GetEnumerator() | ?{ $_.Key -match "a.*" } # The result looks great $filtered Name Value ---- ...
2016/03/03
[ "https://Stackoverflow.com/questions/35783222", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4795779/" ]
As the [accepted answer](https://stackoverflow.com/a/35783327/1128705) was resulting in a `BadEnumeration` exception for me (but still worked), I modified it to not throw an exception and also made sure that the original `HashTable` is not modified by cloning it first: ``` # Init Hashtable $items = @{ a1 = 1; a2 = 2; ...
On a modern `PowerShell` (`5`+ as far as I remember) you can use `reduce` pattern. For that you need to use this form of `ForEach-Object`: ``` $Hashtable.Keys | ForEach-Object {$FilteredHashtable = @{}} { if ($_ -eq 'Example') { $FilteredHashtable[$_] = $Hashtable[$_]; } } {$FilteredHashtable} ``` Ye...
35,783,222
Filtering a Hashtable using GetEnumerator always returns a object[] instead of a Hashtable: ``` # Init Hashtable $items = @{ a1 = 1; a2 = 2; b1 = 3; b2 = 4} # apply a filter $filtered = $items.GetEnumerator() | ?{ $_.Key -match "a.*" } # The result looks great $filtered Name Value ---- ...
2016/03/03
[ "https://Stackoverflow.com/questions/35783222", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4795779/" ]
Here's an even simpler function, it even has include and exclude functionality ``` function Select-HashTable { [CmdletBinding()] param ( [Parameter(Mandatory,ValueFromPipeline)][Hashtable]$Hashtable, [String[]]$Include = ($HashTable.Keys), [String[]]$Exclude ) if (-not $Include...
On a modern `PowerShell` (`5`+ as far as I remember) you can use `reduce` pattern. For that you need to use this form of `ForEach-Object`: ``` $Hashtable.Keys | ForEach-Object {$FilteredHashtable = @{}} { if ($_ -eq 'Example') { $FilteredHashtable[$_] = $Hashtable[$_]; } } {$FilteredHashtable} ``` Ye...
27,254,567
I have a PowerPoint 2010 presentation with a table on one slide. I want to create a VBA modeless form that will work like a pallete of formats/colors for formatting cells of that table. Basically, the buttons on the form would just simulate clicking specific Shading color in Table Tools/Design menu. **example:** I...
2014/12/02
[ "https://Stackoverflow.com/questions/27254567", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2523971/" ]
Try this... (Not polished code, but should give you what you need(ed)) ``` Public sub TblCellColorFill() Dim X As Integer Dim Y As Integer Dim oTbl as Table set oTbl = ActiveWindow.Selection.Shaperange(1).Table 'Only works is a single table shape is selected - add some checks in your final code...
For table styling in MSPowerPoint 2013 I use ``` Sub STYLE_TABLE_2() ' Change table style ' Two rows Dark Gray and White Font ' Next odd rows Light Gray/ even Moderate Gray/ and Black Font Dim iCols As Integer Dim iRows As Integer Dim oTbl As Table ' Debug.Print (ActiveWindow.Selection.ShapeRange(1).Type) With...
52,981,401
I made csv file in my python code itself and going to append next data in ti it but the error is comming ``` io.UnsupportedOperation: not readable ``` I tried code is: ``` df.to_csv('timepass.csv', index=False) with open(r'timepass.csv', 'a') as f: writer = csv.reader(f) your_list = list(writer) ...
2018/10/25
[ "https://Stackoverflow.com/questions/52981401", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10533940/" ]
If you have a list of strings of Python expressions that represent lists (how's that for a nested clause), you will have to use `ast.literal_eval()` to get back to reality, as it were. ``` >>> import ast >>> list1 = ["['word']", "['second', 'first']", "['first']"] >>> list2 = [ast.literal_eval(item) for item in list1]...
This is another solution: ``` import re list1 = ["['word']", "['second', 'first']", "['first']"] pattern = re.compile(r'\w+') m = pattern.findall(str(list1)) ``` Result: ``` ['word', 'second', 'first', 'first'] ```
52,981,401
I made csv file in my python code itself and going to append next data in ti it but the error is comming ``` io.UnsupportedOperation: not readable ``` I tried code is: ``` df.to_csv('timepass.csv', index=False) with open(r'timepass.csv', 'a') as f: writer = csv.reader(f) your_list = list(writer) ...
2018/10/25
[ "https://Stackoverflow.com/questions/52981401", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10533940/" ]
If you have a list of strings of Python expressions that represent lists (how's that for a nested clause), you will have to use `ast.literal_eval()` to get back to reality, as it were. ``` >>> import ast >>> list1 = ["['word']", "['second', 'first']", "['first']"] >>> list2 = [ast.literal_eval(item) for item in list1]...
In order to flatten everything use `itertools.chain.from_iterable`: ``` >>> import itertools >>> import ast >>> list1 = ["['word']", "['second', 'first']", "['first']"] >>> list2 = list(itertools.chain.from_iterable(map(ast.literal_eval, list1))) >>> list2 ['word', 'second', 'first', 'first'] ```
52,981,401
I made csv file in my python code itself and going to append next data in ti it but the error is comming ``` io.UnsupportedOperation: not readable ``` I tried code is: ``` df.to_csv('timepass.csv', index=False) with open(r'timepass.csv', 'a') as f: writer = csv.reader(f) your_list = list(writer) ...
2018/10/25
[ "https://Stackoverflow.com/questions/52981401", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10533940/" ]
If you have a list of strings of Python expressions that represent lists (how's that for a nested clause), you will have to use `ast.literal_eval()` to get back to reality, as it were. ``` >>> import ast >>> list1 = ["['word']", "['second', 'first']", "['first']"] >>> list2 = [ast.literal_eval(item) for item in list1]...
``` list1 = ["['word']", "['second', 'first']", "['first']"] new_lst = [sub_val for val in list1 for sub_val in eval(val)] print new_lst Result:['word', 'second', 'first', 'first'] ```
52,981,401
I made csv file in my python code itself and going to append next data in ti it but the error is comming ``` io.UnsupportedOperation: not readable ``` I tried code is: ``` df.to_csv('timepass.csv', index=False) with open(r'timepass.csv', 'a') as f: writer = csv.reader(f) your_list = list(writer) ...
2018/10/25
[ "https://Stackoverflow.com/questions/52981401", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10533940/" ]
If you have a list of strings of Python expressions that represent lists (how's that for a nested clause), you will have to use `ast.literal_eval()` to get back to reality, as it were. ``` >>> import ast >>> list1 = ["['word']", "['second', 'first']", "['first']"] >>> list2 = [ast.literal_eval(item) for item in list1]...
You can also use [more\_itertools.flatten](https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.flatten) ``` from more_itertools import flatten import ast list1 = ["['word']", "['second', 'first']", "['first']"] list(flatten(ast.literal_eval(item) for item in list1)) ``` Output: ``` ['word', 'se...
52,981,401
I made csv file in my python code itself and going to append next data in ti it but the error is comming ``` io.UnsupportedOperation: not readable ``` I tried code is: ``` df.to_csv('timepass.csv', index=False) with open(r'timepass.csv', 'a') as f: writer = csv.reader(f) your_list = list(writer) ...
2018/10/25
[ "https://Stackoverflow.com/questions/52981401", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10533940/" ]
``` list1 = ["['word']", "['second', 'first']", "['first']"] new_lst = [sub_val for val in list1 for sub_val in eval(val)] print new_lst Result:['word', 'second', 'first', 'first'] ```
This is another solution: ``` import re list1 = ["['word']", "['second', 'first']", "['first']"] pattern = re.compile(r'\w+') m = pattern.findall(str(list1)) ``` Result: ``` ['word', 'second', 'first', 'first'] ```
52,981,401
I made csv file in my python code itself and going to append next data in ti it but the error is comming ``` io.UnsupportedOperation: not readable ``` I tried code is: ``` df.to_csv('timepass.csv', index=False) with open(r'timepass.csv', 'a') as f: writer = csv.reader(f) your_list = list(writer) ...
2018/10/25
[ "https://Stackoverflow.com/questions/52981401", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10533940/" ]
You can also use [more\_itertools.flatten](https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.flatten) ``` from more_itertools import flatten import ast list1 = ["['word']", "['second', 'first']", "['first']"] list(flatten(ast.literal_eval(item) for item in list1)) ``` Output: ``` ['word', 'se...
This is another solution: ``` import re list1 = ["['word']", "['second', 'first']", "['first']"] pattern = re.compile(r'\w+') m = pattern.findall(str(list1)) ``` Result: ``` ['word', 'second', 'first', 'first'] ```
52,981,401
I made csv file in my python code itself and going to append next data in ti it but the error is comming ``` io.UnsupportedOperation: not readable ``` I tried code is: ``` df.to_csv('timepass.csv', index=False) with open(r'timepass.csv', 'a') as f: writer = csv.reader(f) your_list = list(writer) ...
2018/10/25
[ "https://Stackoverflow.com/questions/52981401", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10533940/" ]
``` list1 = ["['word']", "['second', 'first']", "['first']"] new_lst = [sub_val for val in list1 for sub_val in eval(val)] print new_lst Result:['word', 'second', 'first', 'first'] ```
In order to flatten everything use `itertools.chain.from_iterable`: ``` >>> import itertools >>> import ast >>> list1 = ["['word']", "['second', 'first']", "['first']"] >>> list2 = list(itertools.chain.from_iterable(map(ast.literal_eval, list1))) >>> list2 ['word', 'second', 'first', 'first'] ```
52,981,401
I made csv file in my python code itself and going to append next data in ti it but the error is comming ``` io.UnsupportedOperation: not readable ``` I tried code is: ``` df.to_csv('timepass.csv', index=False) with open(r'timepass.csv', 'a') as f: writer = csv.reader(f) your_list = list(writer) ...
2018/10/25
[ "https://Stackoverflow.com/questions/52981401", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10533940/" ]
You can also use [more\_itertools.flatten](https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.flatten) ``` from more_itertools import flatten import ast list1 = ["['word']", "['second', 'first']", "['first']"] list(flatten(ast.literal_eval(item) for item in list1)) ``` Output: ``` ['word', 'se...
In order to flatten everything use `itertools.chain.from_iterable`: ``` >>> import itertools >>> import ast >>> list1 = ["['word']", "['second', 'first']", "['first']"] >>> list2 = list(itertools.chain.from_iterable(map(ast.literal_eval, list1))) >>> list2 ['word', 'second', 'first', 'first'] ```
94,476
He was sworn off as chief minister of the state yesterday. (incorrect??) He was sworn in as chief minister of the state yesterday. (correct for sure) whats wrong in 'sworn off' sworn off means stop doing something. so he resigned yesterday..throw some light
2016/06/22
[ "https://ell.stackexchange.com/questions/94476", "https://ell.stackexchange.com", "https://ell.stackexchange.com/users/18918/" ]
If you swear in a person, you administer an oath to him. If you swear off something, you promise to give it up. For example, he swore off smoking. So the first sentence is correct, but the second is not. .
Second sentanve is passive conversation means he was sworn in by someone as a chief person. Now in first sentence He sworn off means he will sworn off by himself so it is active conversation. Thus , the correct statement would be. He sworn off as chief minister of the state yesterday.
94,476
He was sworn off as chief minister of the state yesterday. (incorrect??) He was sworn in as chief minister of the state yesterday. (correct for sure) whats wrong in 'sworn off' sworn off means stop doing something. so he resigned yesterday..throw some light
2016/06/22
[ "https://ell.stackexchange.com/questions/94476", "https://ell.stackexchange.com", "https://ell.stackexchange.com/users/18918/" ]
"swear off" means to promise to abstain from something. It isn't really a correct way to say that someone was removed from a job or position. Some better ways to say that would be "he resigned" if he left the job by his choice, or "he was dismissed" if he left the job and it was not by his choice. If he is giving up t...
Second sentanve is passive conversation means he was sworn in by someone as a chief person. Now in first sentence He sworn off means he will sworn off by himself so it is active conversation. Thus , the correct statement would be. He sworn off as chief minister of the state yesterday.
12,734,619
The Android Tools menu in Eclipse only lets me export an unsigned apk, or one signed with my release cert. I need the debug-certificate-signed apk that Eclipse creates when I debug my Android app. Where is it? Thanks in advance...
2012/10/04
[ "https://Stackoverflow.com/questions/12734619", "https://Stackoverflow.com", "https://Stackoverflow.com/users/706628/" ]
The compiled APK (with debug key) is found at the /bin folder in you eclipse project
I found the complete details (including passwords) in the SDK docs: <http://developer.android.com/tools/publishing/app-signing.html#debugmode>
38,824,631
Let's assume I have a table **table\_data** with *serial* **id** and *text* **name**. ``` select * from table_data where id in (3, 1, 5, 6, 2); ``` Result *id* | *name* 6 | name6 5 | name5 1 | name1 3 | name3 2 | name2 --- But I wanted the result to be sorted as these ids. *id* | *name* 3 | name3 1 | name...
2016/08/08
[ "https://Stackoverflow.com/questions/38824631", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1839360/" ]
why is everybody creating 6 digit ? what really is needed is create 4 and concat. ``` int random = new Random().Next(1000, 9999); string code = "00" + random.ToString(); ``` EDIT: Thanks for marking as correct answer but my code is wrong. If you don't pass minimum value to next method, you can get numbers from 1 to...
I would do something like this: ``` var rnd = new Random(); // the internal seed is good enough var rndNums = string.Join("", Enumerable.Range(0, 4).Select(x => rnd.Next(10))); return "00" + rndNums; ``` Then you can easily change the amount you want, like this: ``` string GetRandomBatch(int numberOfRandomNumbers) ...
38,824,631
Let's assume I have a table **table\_data** with *serial* **id** and *text* **name**. ``` select * from table_data where id in (3, 1, 5, 6, 2); ``` Result *id* | *name* 6 | name6 5 | name5 1 | name1 3 | name3 2 | name2 --- But I wanted the result to be sorted as these ids. *id* | *name* 3 | name3 1 | name...
2016/08/08
[ "https://Stackoverflow.com/questions/38824631", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1839360/" ]
why is everybody creating 6 digit ? what really is needed is create 4 and concat. ``` int random = new Random().Next(1000, 9999); string code = "00" + random.ToString(); ``` EDIT: Thanks for marking as correct answer but my code is wrong. If you don't pass minimum value to next method, you can get numbers from 1 to...
You were close. What you really want is a random *four* digit number, padded with two leading zeroes (to six places) . So use `Random.Next(10000).ToString("D6")` or `. ToString("000000")` Note however for numbers less than 1000, you will end up with more than two leading zeroes. To avoid that, you can do `Random.Nex...
38,824,631
Let's assume I have a table **table\_data** with *serial* **id** and *text* **name**. ``` select * from table_data where id in (3, 1, 5, 6, 2); ``` Result *id* | *name* 6 | name6 5 | name5 1 | name1 3 | name3 2 | name2 --- But I wanted the result to be sorted as these ids. *id* | *name* 3 | name3 1 | name...
2016/08/08
[ "https://Stackoverflow.com/questions/38824631", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1839360/" ]
You were close. What you really want is a random *four* digit number, padded with two leading zeroes (to six places) . So use `Random.Next(10000).ToString("D6")` or `. ToString("000000")` Note however for numbers less than 1000, you will end up with more than two leading zeroes. To avoid that, you can do `Random.Nex...
Your `ToString("D6")` does exactly what it appears that you want, but since you are passing a large upper bound for your `random.Next`, there will in many scenarios not be anything to pad. As others have indicated, you may prefix `"00"`, or you could simply set a lower upper bound, since the `"D6"` will take care of y...
38,824,631
Let's assume I have a table **table\_data** with *serial* **id** and *text* **name**. ``` select * from table_data where id in (3, 1, 5, 6, 2); ``` Result *id* | *name* 6 | name6 5 | name5 1 | name1 3 | name3 2 | name2 --- But I wanted the result to be sorted as these ids. *id* | *name* 3 | name3 1 | name...
2016/08/08
[ "https://Stackoverflow.com/questions/38824631", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1839360/" ]
``` public string getRandomNumber() { Random random = new Random(); string randomNumber = "00"+random.Next(10000).ToString("D4"); return randomNumber; } ``` You should not set a fix seed in the Random, because it will allways generate the same random number sequence. For example if you call your function ...
``` public string RandomNum() { return "00"+ new Random().Next(9999).ToString("D4"); } ``` you can also give minimum and maximum number to Next() function. Like: ``` return "00"+ new Random().Next(1,9999).ToString("D4"); ```
38,824,631
Let's assume I have a table **table\_data** with *serial* **id** and *text* **name**. ``` select * from table_data where id in (3, 1, 5, 6, 2); ``` Result *id* | *name* 6 | name6 5 | name5 1 | name1 3 | name3 2 | name2 --- But I wanted the result to be sorted as these ids. *id* | *name* 3 | name3 1 | name...
2016/08/08
[ "https://Stackoverflow.com/questions/38824631", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1839360/" ]
why is everybody creating 6 digit ? what really is needed is create 4 and concat. ``` int random = new Random().Next(1000, 9999); string code = "00" + random.ToString(); ``` EDIT: Thanks for marking as correct answer but my code is wrong. If you don't pass minimum value to next method, you can get numbers from 1 to...
Another possibility is `"000000"` format string (*six* digits, *leading zeros* are mandatory): * `random.Next(10000)` - last 4 digits are random * `ToString("000000")` - 6 digits are returned (at least 2 leading zeros) Implementation ``` string randomNumber = random.Next(10000).ToString("000000"); ``` Another iss...
38,824,631
Let's assume I have a table **table\_data** with *serial* **id** and *text* **name**. ``` select * from table_data where id in (3, 1, 5, 6, 2); ``` Result *id* | *name* 6 | name6 5 | name5 1 | name1 3 | name3 2 | name2 --- But I wanted the result to be sorted as these ids. *id* | *name* 3 | name3 1 | name...
2016/08/08
[ "https://Stackoverflow.com/questions/38824631", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1839360/" ]
``` public string getRandomNumber() { Random random = new Random(); string randomNumber = "00"+random.Next(10000).ToString("D4"); return randomNumber; } ``` You should not set a fix seed in the Random, because it will allways generate the same random number sequence. For example if you call your function ...
I would do something like this: ``` var rnd = new Random(); // the internal seed is good enough var rndNums = string.Join("", Enumerable.Range(0, 4).Select(x => rnd.Next(10))); return "00" + rndNums; ``` Then you can easily change the amount you want, like this: ``` string GetRandomBatch(int numberOfRandomNumbers) ...
38,824,631
Let's assume I have a table **table\_data** with *serial* **id** and *text* **name**. ``` select * from table_data where id in (3, 1, 5, 6, 2); ``` Result *id* | *name* 6 | name6 5 | name5 1 | name1 3 | name3 2 | name2 --- But I wanted the result to be sorted as these ids. *id* | *name* 3 | name3 1 | name...
2016/08/08
[ "https://Stackoverflow.com/questions/38824631", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1839360/" ]
``` public string getRandomNumber() { Random random = new Random(); string randomNumber = "00"+random.Next(10000).ToString("D4"); return randomNumber; } ``` You should not set a fix seed in the Random, because it will allways generate the same random number sequence. For example if you call your function ...
You were close. What you really want is a random *four* digit number, padded with two leading zeroes (to six places) . So use `Random.Next(10000).ToString("D6")` or `. ToString("000000")` Note however for numbers less than 1000, you will end up with more than two leading zeroes. To avoid that, you can do `Random.Nex...
38,824,631
Let's assume I have a table **table\_data** with *serial* **id** and *text* **name**. ``` select * from table_data where id in (3, 1, 5, 6, 2); ``` Result *id* | *name* 6 | name6 5 | name5 1 | name1 3 | name3 2 | name2 --- But I wanted the result to be sorted as these ids. *id* | *name* 3 | name3 1 | name...
2016/08/08
[ "https://Stackoverflow.com/questions/38824631", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1839360/" ]
why is everybody creating 6 digit ? what really is needed is create 4 and concat. ``` int random = new Random().Next(1000, 9999); string code = "00" + random.ToString(); ``` EDIT: Thanks for marking as correct answer but my code is wrong. If you don't pass minimum value to next method, you can get numbers from 1 to...
``` public string RandomNum() { return "00"+ new Random().Next(9999).ToString("D4"); } ``` you can also give minimum and maximum number to Next() function. Like: ``` return "00"+ new Random().Next(1,9999).ToString("D4"); ```
38,824,631
Let's assume I have a table **table\_data** with *serial* **id** and *text* **name**. ``` select * from table_data where id in (3, 1, 5, 6, 2); ``` Result *id* | *name* 6 | name6 5 | name5 1 | name1 3 | name3 2 | name2 --- But I wanted the result to be sorted as these ids. *id* | *name* 3 | name3 1 | name...
2016/08/08
[ "https://Stackoverflow.com/questions/38824631", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1839360/" ]
why is everybody creating 6 digit ? what really is needed is create 4 and concat. ``` int random = new Random().Next(1000, 9999); string code = "00" + random.ToString(); ``` EDIT: Thanks for marking as correct answer but my code is wrong. If you don't pass minimum value to next method, you can get numbers from 1 to...
With interpolated string (C# 6.0) you can do it like this : ``` Random random = new Random(); string randomNumber = $"00{random.Next(9999)}"; ```
38,824,631
Let's assume I have a table **table\_data** with *serial* **id** and *text* **name**. ``` select * from table_data where id in (3, 1, 5, 6, 2); ``` Result *id* | *name* 6 | name6 5 | name5 1 | name1 3 | name3 2 | name2 --- But I wanted the result to be sorted as these ids. *id* | *name* 3 | name3 1 | name...
2016/08/08
[ "https://Stackoverflow.com/questions/38824631", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1839360/" ]
why is everybody creating 6 digit ? what really is needed is create 4 and concat. ``` int random = new Random().Next(1000, 9999); string code = "00" + random.ToString(); ``` EDIT: Thanks for marking as correct answer but my code is wrong. If you don't pass minimum value to next method, you can get numbers from 1 to...
``` public string getRandomNumber() { Random random = new Random(); string randomNumber = "00"+random.Next(10000).ToString("D4"); return randomNumber; } ``` You should not set a fix seed in the Random, because it will allways generate the same random number sequence. For example if you call your function ...
61,722,374
So I'm pretty new to object-oriented programming (EE with electromagnetics and circuits by trade) and I might be thinking of this completely wrong. My goal is to create around 15-20 objects that have x number of properties each, two of those properties are required and one is optional with a "false" string default. Thi...
2020/05/11
[ "https://Stackoverflow.com/questions/61722374", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9259080/" ]
I figured it out! I used [react-syntax-highlighter](https://github.com/conorhastings/react-syntax-highlighter) in combination with [react-markdown](https://github.com/rexxars/react-markdown). I got some code snippets from [this blog](https://dev.to/jfelx/how-to-make-a-static-blog-with-next-js-2bd6) with how to parse th...
As you've mentioned in your answer that you're using [react-markdown](https://github.com/rexxars/react-markdown), you don't need [react-syntax-highlighter](https://github.com/react-syntax-highlighter/react-syntax-highlighter). It is a package built upon [prismjs](https://prismjs.com/), then why not use [prismjs](https...
61,722,374
So I'm pretty new to object-oriented programming (EE with electromagnetics and circuits by trade) and I might be thinking of this completely wrong. My goal is to create around 15-20 objects that have x number of properties each, two of those properties are required and one is optional with a "false" string default. Thi...
2020/05/11
[ "https://Stackoverflow.com/questions/61722374", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9259080/" ]
I figured it out! I used [react-syntax-highlighter](https://github.com/conorhastings/react-syntax-highlighter) in combination with [react-markdown](https://github.com/rexxars/react-markdown). I got some code snippets from [this blog](https://dev.to/jfelx/how-to-make-a-static-blog-with-next-js-2bd6) with how to parse th...
Here is how I got syntax highlighting working in Next.js <https://thetombomb.com/posts/adding-code-snippets-to-static-markdown-in-Next%20js> I was originally using greymatter since I built the app following the Next.js starter app project. I had to move over to using [react-markdown](https://github.com/remarkjs/react-...
61,722,374
So I'm pretty new to object-oriented programming (EE with electromagnetics and circuits by trade) and I might be thinking of this completely wrong. My goal is to create around 15-20 objects that have x number of properties each, two of those properties are required and one is optional with a "false" string default. Thi...
2020/05/11
[ "https://Stackoverflow.com/questions/61722374", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9259080/" ]
I figured it out! I used [react-syntax-highlighter](https://github.com/conorhastings/react-syntax-highlighter) in combination with [react-markdown](https://github.com/rexxars/react-markdown). I got some code snippets from [this blog](https://dev.to/jfelx/how-to-make-a-static-blog-with-next-js-2bd6) with how to parse th...
```js import ReactMarkdown from "react-markdown"; import { Content } from "mdast"; // import light build import { PrismLight as SyntaxHighlighter } from "react-syntax-highlighter"; // import only whatever languages you are using. Thaw will dramatically reduce the build size of the page import js...
61,722,374
So I'm pretty new to object-oriented programming (EE with electromagnetics and circuits by trade) and I might be thinking of this completely wrong. My goal is to create around 15-20 objects that have x number of properties each, two of those properties are required and one is optional with a "false" string default. Thi...
2020/05/11
[ "https://Stackoverflow.com/questions/61722374", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9259080/" ]
As you've mentioned in your answer that you're using [react-markdown](https://github.com/rexxars/react-markdown), you don't need [react-syntax-highlighter](https://github.com/react-syntax-highlighter/react-syntax-highlighter). It is a package built upon [prismjs](https://prismjs.com/), then why not use [prismjs](https...
```js import ReactMarkdown from "react-markdown"; import { Content } from "mdast"; // import light build import { PrismLight as SyntaxHighlighter } from "react-syntax-highlighter"; // import only whatever languages you are using. Thaw will dramatically reduce the build size of the page import js...
61,722,374
So I'm pretty new to object-oriented programming (EE with electromagnetics and circuits by trade) and I might be thinking of this completely wrong. My goal is to create around 15-20 objects that have x number of properties each, two of those properties are required and one is optional with a "false" string default. Thi...
2020/05/11
[ "https://Stackoverflow.com/questions/61722374", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9259080/" ]
Here is how I got syntax highlighting working in Next.js <https://thetombomb.com/posts/adding-code-snippets-to-static-markdown-in-Next%20js> I was originally using greymatter since I built the app following the Next.js starter app project. I had to move over to using [react-markdown](https://github.com/remarkjs/react-...
```js import ReactMarkdown from "react-markdown"; import { Content } from "mdast"; // import light build import { PrismLight as SyntaxHighlighter } from "react-syntax-highlighter"; // import only whatever languages you are using. Thaw will dramatically reduce the build size of the page import js...
27,882,503
``` String str1 = new String("I love programming"); String str2 = new String("I love programming"); boolean boo = str1 == str2; // evaluates to false String str1 = "I love programming"; String str2 = "I love programming"; boolean boo = str1 == str2; // evaluates to true ``` Why does first one evaluate to false and s...
2015/01/11
[ "https://Stackoverflow.com/questions/27882503", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4354754/" ]
`==` will return true if the objects themselves have the same addresses. For space and efficiency reasons, repeated literals are optimized to use the same address. The second `str1` and `str2` are equal to the same address, thus `==` returns true. In the first example, because you are explicitly declaring memory using...
The equals() method compares the contents of the String and the == compares the reference in Java.
27,882,503
``` String str1 = new String("I love programming"); String str2 = new String("I love programming"); boolean boo = str1 == str2; // evaluates to false String str1 = "I love programming"; String str2 = "I love programming"; boolean boo = str1 == str2; // evaluates to true ``` Why does first one evaluate to false and s...
2015/01/11
[ "https://Stackoverflow.com/questions/27882503", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4354754/" ]
The equals() method compares the contents of the String and the == compares the reference in Java.
Not like C. (==) compares references of java string variables. It compares two address where the strings are stored. Two compare them by values, you need to use string1.equals(string2).
27,882,503
``` String str1 = new String("I love programming"); String str2 = new String("I love programming"); boolean boo = str1 == str2; // evaluates to false String str1 = "I love programming"; String str2 = "I love programming"; boolean boo = str1 == str2; // evaluates to true ``` Why does first one evaluate to false and s...
2015/01/11
[ "https://Stackoverflow.com/questions/27882503", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4354754/" ]
`==` will return true if the objects themselves have the same addresses. For space and efficiency reasons, repeated literals are optimized to use the same address. The second `str1` and `str2` are equal to the same address, thus `==` returns true. In the first example, because you are explicitly declaring memory using...
It's there in the Java Memory Model The first equality statement returns false as your're comparing two different references of two different objects as you used the key word `new` which allocate memory space inside the heap in to two distinct memory addresses, the seconds, the JVM will allocate memory space once "int...
27,882,503
``` String str1 = new String("I love programming"); String str2 = new String("I love programming"); boolean boo = str1 == str2; // evaluates to false String str1 = "I love programming"; String str2 = "I love programming"; boolean boo = str1 == str2; // evaluates to true ``` Why does first one evaluate to false and s...
2015/01/11
[ "https://Stackoverflow.com/questions/27882503", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4354754/" ]
`==` will return true if the objects themselves have the same addresses. For space and efficiency reasons, repeated literals are optimized to use the same address. The second `str1` and `str2` are equal to the same address, thus `==` returns true. In the first example, because you are explicitly declaring memory using...
Not like C. (==) compares references of java string variables. It compares two address where the strings are stored. Two compare them by values, you need to use string1.equals(string2).
27,882,503
``` String str1 = new String("I love programming"); String str2 = new String("I love programming"); boolean boo = str1 == str2; // evaluates to false String str1 = "I love programming"; String str2 = "I love programming"; boolean boo = str1 == str2; // evaluates to true ``` Why does first one evaluate to false and s...
2015/01/11
[ "https://Stackoverflow.com/questions/27882503", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4354754/" ]
It's there in the Java Memory Model The first equality statement returns false as your're comparing two different references of two different objects as you used the key word `new` which allocate memory space inside the heap in to two distinct memory addresses, the seconds, the JVM will allocate memory space once "int...
Not like C. (==) compares references of java string variables. It compares two address where the strings are stored. Two compare them by values, you need to use string1.equals(string2).
24,128,821
I have a question. At the moment I'm using : ``` <div ui-view ng-class="{transparent: loading}" class="{{bodyClass}}"></div> ``` Which is working just fine. But I was wondering if there is a way of doing these actions both in the ng-class atribute. Something like: ``` <div ui-view ng-class="{transparent: loading,...
2014/06/09
[ "https://Stackoverflow.com/questions/24128821", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2452603/" ]
In general, Gmail doesn't allow you to specify an alternate sending server for emails being sent from a domain that they host or gmail.com because part of the service they provide includes actually sending the mail from their servers. There are some options with Google Apps for your domain, but they're fairly limited a...
You can use Mandrill through your gmail interface but it does require you to put in a different send (email) address. This can be done in the "Accounts" section of your gmail settings. Just add a send address then choose "Send emails through your SMTP server" and use the settings in your Mandrill dashboard. Once you h...
20,022,156
I'm using `str_getcsv` to parse tab separated values being returned from a nosql query however I'm running into a problem and the only solution I've found is illogical. Here's some sample code to demonstrate (FYI, it seems the tabs aren't being preserved when showing here)... ``` $data = '0 16 Gruesome Public Execu...
2013/11/16
[ "https://Stackoverflow.com/questions/20022156", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1058733/" ]
Just to give a starting point ... You might wanna consider working with the string itself, instead of using a function like `str_getcsv` in your case. But be aware that there are at least some pitfalls, if you choose this route (might be your only option though): * Handling of escaped characters * Line breaks withi...
Simply use `chr(0)` as enclosure and escape: ``` $data = str_getcsv($data, "\t", chr(0), chr(0)); ```
1,576,850
I was wondering what could be the point in trying to delete committed changelists, because a committed changelist is not supposed to be empty. But then I am playing with the tutorial depot, and using the obliterate command on a whole branch, I can see there are situation where you can end up with empty committed chang...
2009/10/16
[ "https://Stackoverflow.com/questions/1576850", "https://Stackoverflow.com", "https://Stackoverflow.com/users/92401/" ]
Ah ! I should have browse more documentation before asking this... <http://public.perforce.com/wiki/Perforce_Command_Line_Recipes> > > Description: Delete all empty submitted changelists. > > Shell command: p4 changes -s submitted | cut -d " " -f 2 | xargs -n1 p4 change -d -f > > Powershell: p4 changes -s s...
As I am on Windows, I have created a little script doing the exact same thing in PERL, rather than Shell, powershell or px :) : ``` #******************************************************************************* # Module: delete_empty_changelist.pl # Purpose: A script to delete empty changelist # @list = `p4 chang...
1,576,850
I was wondering what could be the point in trying to delete committed changelists, because a committed changelist is not supposed to be empty. But then I am playing with the tutorial depot, and using the obliterate command on a whole branch, I can see there are situation where you can end up with empty committed chang...
2009/10/16
[ "https://Stackoverflow.com/questions/1576850", "https://Stackoverflow.com", "https://Stackoverflow.com/users/92401/" ]
Ah ! I should have browse more documentation before asking this... <http://public.perforce.com/wiki/Perforce_Command_Line_Recipes> > > Description: Delete all empty submitted changelists. > > Shell command: p4 changes -s submitted | cut -d " " -f 2 | xargs -n1 p4 change -d -f > > Powershell: p4 changes -s s...
Here is a DOS CMD only version. Just replace %p4streamsUser%. ``` for /f "tokens=* delims=" %%i in ('p4 changes -u %p4streamsUser% -s pending') do ( for /f "tokens=1-7*" %%a in ("%%i") do ( echo Deleting CL %%b %%h %%f p4 change -d -f %%b ) ) ``` I'm on a Windows 7 mac...
1,576,850
I was wondering what could be the point in trying to delete committed changelists, because a committed changelist is not supposed to be empty. But then I am playing with the tutorial depot, and using the obliterate command on a whole branch, I can see there are situation where you can end up with empty committed chang...
2009/10/16
[ "https://Stackoverflow.com/questions/1576850", "https://Stackoverflow.com", "https://Stackoverflow.com/users/92401/" ]
Ah ! I should have browse more documentation before asking this... <http://public.perforce.com/wiki/Perforce_Command_Line_Recipes> > > Description: Delete all empty submitted changelists. > > Shell command: p4 changes -s submitted | cut -d " " -f 2 | xargs -n1 p4 change -d -f > > Powershell: p4 changes -s s...
To simply *find* all empty submitted changelists without deleting them, you can compare the output of these two commands: * `p4 changes -s submitted` - all changelists * `p4 changes -s submitted //...` - all changelists with associated files In Windows PowerShell, for example, run ``` diff -ReferenceObject (p4 chang...
1,576,850
I was wondering what could be the point in trying to delete committed changelists, because a committed changelist is not supposed to be empty. But then I am playing with the tutorial depot, and using the obliterate command on a whole branch, I can see there are situation where you can end up with empty committed chang...
2009/10/16
[ "https://Stackoverflow.com/questions/1576850", "https://Stackoverflow.com", "https://Stackoverflow.com/users/92401/" ]
As I am on Windows, I have created a little script doing the exact same thing in PERL, rather than Shell, powershell or px :) : ``` #******************************************************************************* # Module: delete_empty_changelist.pl # Purpose: A script to delete empty changelist # @list = `p4 chang...
Here is a DOS CMD only version. Just replace %p4streamsUser%. ``` for /f "tokens=* delims=" %%i in ('p4 changes -u %p4streamsUser% -s pending') do ( for /f "tokens=1-7*" %%a in ("%%i") do ( echo Deleting CL %%b %%h %%f p4 change -d -f %%b ) ) ``` I'm on a Windows 7 mac...
1,576,850
I was wondering what could be the point in trying to delete committed changelists, because a committed changelist is not supposed to be empty. But then I am playing with the tutorial depot, and using the obliterate command on a whole branch, I can see there are situation where you can end up with empty committed chang...
2009/10/16
[ "https://Stackoverflow.com/questions/1576850", "https://Stackoverflow.com", "https://Stackoverflow.com/users/92401/" ]
To simply *find* all empty submitted changelists without deleting them, you can compare the output of these two commands: * `p4 changes -s submitted` - all changelists * `p4 changes -s submitted //...` - all changelists with associated files In Windows PowerShell, for example, run ``` diff -ReferenceObject (p4 chang...
Here is a DOS CMD only version. Just replace %p4streamsUser%. ``` for /f "tokens=* delims=" %%i in ('p4 changes -u %p4streamsUser% -s pending') do ( for /f "tokens=1-7*" %%a in ("%%i") do ( echo Deleting CL %%b %%h %%f p4 change -d -f %%b ) ) ``` I'm on a Windows 7 mac...
962
Windows phone 8 will probably have a larger installed base than windows phone right of the bat, so cool apps like gmail, google maps etc will soon be available on that. How easy is it for app developers to make their windows 8 apps available on windows phone 8 platform?
2012/09/22
[ "https://windowsphone.stackexchange.com/questions/962", "https://windowsphone.stackexchange.com", "https://windowsphone.stackexchange.com/users/634/" ]
To change the wallpaper (back), you simply go to Settings > lock+wallpaper, and choose the `change wallpaper` button. The default wallpapers will show in a folder called "Wallpapers" (which won't show via the Pictures Hub). These will include a mix of any operator customised wallpapers, any manufacturer customised wal...
The default wallpaper on your phone can be set by nokia or your carrier/network so it is probably different for most people. There should be a wallpapers folder in your photos hub so it will be one of those. I also don't think an app can change a user's wallpaper but that's not a different story...
962
Windows phone 8 will probably have a larger installed base than windows phone right of the bat, so cool apps like gmail, google maps etc will soon be available on that. How easy is it for app developers to make their windows 8 apps available on windows phone 8 platform?
2012/09/22
[ "https://windowsphone.stackexchange.com/questions/962", "https://windowsphone.stackexchange.com", "https://windowsphone.stackexchange.com/users/634/" ]
To change the wallpaper (back), you simply go to Settings > lock+wallpaper, and choose the `change wallpaper` button. The default wallpapers will show in a folder called "Wallpapers" (which won't show via the Pictures Hub). These will include a mix of any operator customised wallpapers, any manufacturer customised wal...
Default Lock Screen Wallpaper is one of the Sample Images provided by Microsoft in the pictures hub. Select one and change it. I know this because last week I had reset my phone. I hope it helps :)
962
Windows phone 8 will probably have a larger installed base than windows phone right of the bat, so cool apps like gmail, google maps etc will soon be available on that. How easy is it for app developers to make their windows 8 apps available on windows phone 8 platform?
2012/09/22
[ "https://windowsphone.stackexchange.com/questions/962", "https://windowsphone.stackexchange.com", "https://windowsphone.stackexchange.com/users/634/" ]
To change the wallpaper (back), you simply go to Settings > lock+wallpaper, and choose the `change wallpaper` button. The default wallpapers will show in a folder called "Wallpapers" (which won't show via the Pictures Hub). These will include a mix of any operator customised wallpapers, any manufacturer customised wal...
The default wallpaper on lumia 710 is a man like character made of sticks. You can find the same in *Pictures•Albums•wallpaper*
6,835,684
In C memory allocation/deallocation done by `malloc` and `free`. In C++ memory allocation/deallocation done by `new` and `delete`. There are some solutions in C++ for **automatic memory management** like: * Smart Pointers. * RAII (Resource Acquisition Is Initialization) * Reference counting and cyclic references * ....
2011/07/26
[ "https://Stackoverflow.com/questions/6835684", "https://Stackoverflow.com", "https://Stackoverflow.com/users/309798/" ]
You may use a [Boehm garbage collector library](http://www.hboehm.info/gc/).
As [answered by Juraj Blaho](https://stackoverflow.com/a/6835765/841108), you can use a garbage collection library, such as the [Boehm conservative garbage collector](http://www.hboehm.info/gc/), but there are other ones : [Ravenbrook's memory pool system](http://www.ravenbrook.com/project/mps), my (unmaintained) [Qish...
6,835,684
In C memory allocation/deallocation done by `malloc` and `free`. In C++ memory allocation/deallocation done by `new` and `delete`. There are some solutions in C++ for **automatic memory management** like: * Smart Pointers. * RAII (Resource Acquisition Is Initialization) * Reference counting and cyclic references * ....
2011/07/26
[ "https://Stackoverflow.com/questions/6835684", "https://Stackoverflow.com", "https://Stackoverflow.com/users/309798/" ]
You may use a [Boehm garbage collector library](http://www.hboehm.info/gc/).
For linux, I use valgrind. Sure, the original reason for why valgrind was build was to debug your code, but it does a lot more. It will even tell you where potentially erroneous code could be in a non-invasive way. My own command line of choice is as follows. ``` # Install valgrind. Remove this line of code if you alr...
6,835,684
In C memory allocation/deallocation done by `malloc` and `free`. In C++ memory allocation/deallocation done by `new` and `delete`. There are some solutions in C++ for **automatic memory management** like: * Smart Pointers. * RAII (Resource Acquisition Is Initialization) * Reference counting and cyclic references * ....
2011/07/26
[ "https://Stackoverflow.com/questions/6835684", "https://Stackoverflow.com", "https://Stackoverflow.com/users/309798/" ]
As [answered by Juraj Blaho](https://stackoverflow.com/a/6835765/841108), you can use a garbage collection library, such as the [Boehm conservative garbage collector](http://www.hboehm.info/gc/), but there are other ones : [Ravenbrook's memory pool system](http://www.ravenbrook.com/project/mps), my (unmaintained) [Qish...
For linux, I use valgrind. Sure, the original reason for why valgrind was build was to debug your code, but it does a lot more. It will even tell you where potentially erroneous code could be in a non-invasive way. My own command line of choice is as follows. ``` # Install valgrind. Remove this line of code if you alr...
23,653,510
I have an Android Phonegap app made with HTML5/Javascript/CSS. I'd like to suggest the users to choose between light and dark themes at the very first start of the app. When the user once chooses one of them this chose should be saved and relevant theme should be set as default at evry further start of the app. I have ...
2014/05/14
[ "https://Stackoverflow.com/questions/23653510", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3624504/" ]
`localStorage` wins, simply for persistence and ease-of-use: ``` // set the selected theme localStorage.setItem("appTheme") = "dark"; ... var lsTheme = localStorage.getItem("appTheme"), theme = (typeof lsTheme !== "undefined" ? lsTheme : "bright"); // do something with the selected theme; "bright" is default if no...
`localStorage` is the simplest and most effective solution like Kerri Shotts said however the `setItem` methods syntax is different to that displayed in her answer. As it takes to parameters one being the `keyName` the other being the `keyValue` like so: `storage.setItem(keyName, keyValue);` This then retrieved using t...
191,746
There is a command `l` available on my machine which appears to do nothing. `which l` also produces no output. Is this a real command, and does it actually do anything?
2012/09/22
[ "https://askubuntu.com/questions/191746", "https://askubuntu.com", "https://askubuntu.com/users/12532/" ]
`l` is an [alias](http://en.wikipedia.org/wiki/Alias_%28command%29) for `[ls](http://manpages.ubuntu.com/manpages/precise/en/man1/ls.1.html) -CF`, which **behaves differently from plain `ls`**. `-C` ==== `-C` makes `ls` print output in column form. When [stdout](http://en.wikipedia.org/wiki/Stdout#Standard_output_.28...
Actually both `ls` and `l` are equal ``` raja@badfox:~/Pictures$ l des.png Screenshot from 2012-09-22 19:37:03.png Screenshot from 2012-09-22 19:37:11.png Screenshot from 2012-09-22 19:37:12.png Untitled.png raja@badfox:~/Pictures$ ls des.png Screenshot from 2012-09-22 19:37:03.png Screenshot from 2012-09-22 19:37:11...
191,746
There is a command `l` available on my machine which appears to do nothing. `which l` also produces no output. Is this a real command, and does it actually do anything?
2012/09/22
[ "https://askubuntu.com/questions/191746", "https://askubuntu.com", "https://askubuntu.com/users/12532/" ]
Actually both `ls` and `l` are equal ``` raja@badfox:~/Pictures$ l des.png Screenshot from 2012-09-22 19:37:03.png Screenshot from 2012-09-22 19:37:11.png Screenshot from 2012-09-22 19:37:12.png Untitled.png raja@badfox:~/Pictures$ ls des.png Screenshot from 2012-09-22 19:37:03.png Screenshot from 2012-09-22 19:37:11...
When in doubt, `type l`: ``` l is aliased to `ls -alF' ``` (see also [What does the la command do](https://askubuntu.com/questions/863528/whats-the-difference-between-ls-and-la-why-do-they-give-the-same-output/863626#863626))
191,746
There is a command `l` available on my machine which appears to do nothing. `which l` also produces no output. Is this a real command, and does it actually do anything?
2012/09/22
[ "https://askubuntu.com/questions/191746", "https://askubuntu.com", "https://askubuntu.com/users/12532/" ]
`l` is an [alias](http://en.wikipedia.org/wiki/Alias_%28command%29) for `[ls](http://manpages.ubuntu.com/manpages/precise/en/man1/ls.1.html) -CF`, which **behaves differently from plain `ls`**. `-C` ==== `-C` makes `ls` print output in column form. When [stdout](http://en.wikipedia.org/wiki/Stdout#Standard_output_.28...
When in doubt, `type l`: ``` l is aliased to `ls -alF' ``` (see also [What does the la command do](https://askubuntu.com/questions/863528/whats-the-difference-between-ls-and-la-why-do-they-give-the-same-output/863626#863626))
261,869
I'm trying to use sed to remove the rest of a line after: `HTTP1.1" 200` I can't figure out how to get sed to understand I want that whole thing as a string to match, including the double quote and the space. An example for good measure, I want to turn: ``` "GET /images/loading.gif HTTP/1.1" 200 10819 "https://... ...
2016/02/12
[ "https://unix.stackexchange.com/questions/261869", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/156285/" ]
You have to quote strings with spaces when you use sed (or most other tools) from the commandline. And since you already use the double quote, you have to go for single quotes: ``` echo '"GET /images/loading.gif HTTP/1.1" 200 10819 "https://...' | \ sed 's|HTTP/1.1" 200.*|HTTP/1.1" 200|' ``` gives: ``` "GET /i...
With GNU grep: ``` | grep -o '.*HTTP/1\.1" 200' ``` With GNU sed: ``` | sed -r 's/(.*HTTP\/1\.1" 200).*/\1/' ```
261,869
I'm trying to use sed to remove the rest of a line after: `HTTP1.1" 200` I can't figure out how to get sed to understand I want that whole thing as a string to match, including the double quote and the space. An example for good measure, I want to turn: ``` "GET /images/loading.gif HTTP/1.1" 200 10819 "https://... ...
2016/02/12
[ "https://unix.stackexchange.com/questions/261869", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/156285/" ]
You have to quote strings with spaces when you use sed (or most other tools) from the commandline. And since you already use the double quote, you have to go for single quotes: ``` echo '"GET /images/loading.gif HTTP/1.1" 200 10819 "https://...' | \ sed 's|HTTP/1.1" 200.*|HTTP/1.1" 200|' ``` gives: ``` "GET /i...
If you just append a newline delimiter after your matched string you can `P`rint only so much of pattern space without having to modify it overmuch. This can usually even work when pattern space contains bytes which are not parts of a character. ```sh sed -n 's|HTTP/1.0” 200|&\n|;P' <in >out ``` *note: portably you'...