qid
int64
1
74.7M
question
stringlengths
0
58.3k
date
stringlengths
10
10
metadata
list
response_j
stringlengths
2
48.3k
response_k
stringlengths
2
40.5k
12,044
I have an APEX script that generates emails after some event occurs. I would like to see a record of all the emails that have been sent. Is this possible in the Setup portion of SalesForce?
2013/05/23
[ "https://salesforce.stackexchange.com/questions/12044", "https://salesforce.stackexchange.com", "https://salesforce.stackexchange.com/users/2772/" ]
To access email logs, click Your Name | Setup | Monitoring | Email Log Files. <http://login.salesforce.com/help/doc/en/email_logs.htm> For that to work, the employee will need to have the "Modify All Data" as described [here](https://help.salesforce.com/apex/HTViewHelpDoc?id=email_logs.htm&language=en_US)
You can also add a Compliance BCC email address, which will be added to the BCC of every email that is sent out of your org. Of course, you'll get a lot more than just the emails generated by the apex script. I have a separate inbox for this purpose. <http://login.salesforce.com/help/doc/en/admin_compliancebcc.htm>
3,342,800
If we used the **jquery popup** in my site, and if the user block pop in the browser. Is it works?
2010/07/27
[ "https://Stackoverflow.com/questions/3342800", "https://Stackoverflow.com", "https://Stackoverflow.com/users/152510/" ]
I'm not quite sure how "jQuery popup" works, but technically: * if it opens a window (`window.open()`) it will get blocked by every popup blocker that is around * if it uses `DIVs` to popup information (or any other `HTML markup`) it should work with standard popup blockers
@DhrubaJyoti Your answer is "Yes" your jquery popup will work even if the user has popup blockers enabled. Popup blockers look for new "windows" (popups) to be created and then block them. However, what jquery does is not create new windows but it just creates Modal Dialog's which as standard HTML elements on the webp...
28,069,204
I currently have this code which saves all the information to the database but I want to be able to allow users to search using their postcode so only results within the radius they select is shown eg. 1mile, 2mile etc I am not sure how to go about doing this. ``` <form action="addhobby.php" method="POST"> Type:<inp...
2015/01/21
[ "https://Stackoverflow.com/questions/28069204", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4258493/" ]
Why using postcode if you can get latitude and longitude with HTML5 Geolocation API? You can use the following SQL statement: ``` SELECT id, ( 3959 * acos( cos( radians(37) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians(-122) ) + sin( radians(37) ) * sin( radians( lat ) ) ) ) AS distance FROM markers HAVIN...
To do this you will need a zip code database which provides latitude and longtitude coordinates for each zip code. If you have this data, then you can query all the ZIP codes which are located between a specified distance. You can use an open source zip code database like [this](http://zips.sourceforge.net/) (for US o...
53,995
I just met a terminology called "embedding" in a paper regarding deep learning. The context is "multi-modal embedding" My guess: embedding of something is extract some feature of sth,to form a vector. I couldn't get the explicit meaning for this terminology and that stops me from fully understanding the author's idea...
2019/06/18
[ "https://datascience.stackexchange.com/questions/53995", "https://datascience.stackexchange.com", "https://datascience.stackexchange.com/users/43765/" ]
In the context of machine learning, an embedding is a low-dimensional, learned continuous vector representation of discrete variables into which you can translate high-dimensional vectors. Generally, embeddings make ML models more efficient and easier to work with, and can be used with other models as well. Typically,...
According to all answers(Thank you) and my google search I got a better understanding, So my newly updated understanding is: The embedding in machine learning or NLP is actually a technique mapping from words to vectors which you can do better analysis or relating, for example, "toyota" or "honda" can be hardly relate...
53,995
I just met a terminology called "embedding" in a paper regarding deep learning. The context is "multi-modal embedding" My guess: embedding of something is extract some feature of sth,to form a vector. I couldn't get the explicit meaning for this terminology and that stops me from fully understanding the author's idea...
2019/06/18
[ "https://datascience.stackexchange.com/questions/53995", "https://datascience.stackexchange.com", "https://datascience.stackexchange.com/users/43765/" ]
In the context of machine learning, an embedding is a low-dimensional, learned continuous vector representation of discrete variables into which you can translate high-dimensional vectors. Generally, embeddings make ML models more efficient and easier to work with, and can be used with other models as well. Typically,...
> > The LSA community seems to have first used the word “embedding” in Landauer > et al. (1997), in a variant of its mathematical meaning as a mapping from one space or mathematical structure to another. In LSA, the word embedding seems to have described the mapping from the space of sparse count vectors to the latent...
53,995
I just met a terminology called "embedding" in a paper regarding deep learning. The context is "multi-modal embedding" My guess: embedding of something is extract some feature of sth,to form a vector. I couldn't get the explicit meaning for this terminology and that stops me from fully understanding the author's idea...
2019/06/18
[ "https://datascience.stackexchange.com/questions/53995", "https://datascience.stackexchange.com", "https://datascience.stackexchange.com/users/43765/" ]
According to all answers(Thank you) and my google search I got a better understanding, So my newly updated understanding is: The embedding in machine learning or NLP is actually a technique mapping from words to vectors which you can do better analysis or relating, for example, "toyota" or "honda" can be hardly relate...
**For me embedding is used to represent big sparse matrix into smaller dimensions, where each dimension(feature) represent a meaningful association with other elements in the embedding matrix.** Consider an example of NLP. Where each sentence broken down into words(also called token). Such set of different words make ...
53,995
I just met a terminology called "embedding" in a paper regarding deep learning. The context is "multi-modal embedding" My guess: embedding of something is extract some feature of sth,to form a vector. I couldn't get the explicit meaning for this terminology and that stops me from fully understanding the author's idea...
2019/06/18
[ "https://datascience.stackexchange.com/questions/53995", "https://datascience.stackexchange.com", "https://datascience.stackexchange.com/users/43765/" ]
According to all answers(Thank you) and my google search I got a better understanding, So my newly updated understanding is: The embedding in machine learning or NLP is actually a technique mapping from words to vectors which you can do better analysis or relating, for example, "toyota" or "honda" can be hardly relate...
> > The LSA community seems to have first used the word “embedding” in Landauer > et al. (1997), in a variant of its mathematical meaning as a mapping from one space or mathematical structure to another. In LSA, the word embedding seems to have described the mapping from the space of sparse count vectors to the latent...
53,995
I just met a terminology called "embedding" in a paper regarding deep learning. The context is "multi-modal embedding" My guess: embedding of something is extract some feature of sth,to form a vector. I couldn't get the explicit meaning for this terminology and that stops me from fully understanding the author's idea...
2019/06/18
[ "https://datascience.stackexchange.com/questions/53995", "https://datascience.stackexchange.com", "https://datascience.stackexchange.com/users/43765/" ]
> > The LSA community seems to have first used the word “embedding” in Landauer > et al. (1997), in a variant of its mathematical meaning as a mapping from one space or mathematical structure to another. In LSA, the word embedding seems to have described the mapping from the space of sparse count vectors to the latent...
As well known, machine only identify 0 and 1. Therefore, we, for an instance, "encode" characters and symbols with ASCII codes. 0 & 1 can only code two characters. To make sure the code is unique for all characters, we have to use a series number to code them. The hard ware experienced 8, 16, 32, and 64 bits (now 64 bi...
53,995
I just met a terminology called "embedding" in a paper regarding deep learning. The context is "multi-modal embedding" My guess: embedding of something is extract some feature of sth,to form a vector. I couldn't get the explicit meaning for this terminology and that stops me from fully understanding the author's idea...
2019/06/18
[ "https://datascience.stackexchange.com/questions/53995", "https://datascience.stackexchange.com", "https://datascience.stackexchange.com/users/43765/" ]
In the context of machine learning, an embedding is a low-dimensional, learned continuous vector representation of discrete variables into which you can translate high-dimensional vectors. Generally, embeddings make ML models more efficient and easier to work with, and can be used with other models as well. Typically,...
**For me embedding is used to represent big sparse matrix into smaller dimensions, where each dimension(feature) represent a meaningful association with other elements in the embedding matrix.** Consider an example of NLP. Where each sentence broken down into words(also called token). Such set of different words make ...
53,995
I just met a terminology called "embedding" in a paper regarding deep learning. The context is "multi-modal embedding" My guess: embedding of something is extract some feature of sth,to form a vector. I couldn't get the explicit meaning for this terminology and that stops me from fully understanding the author's idea...
2019/06/18
[ "https://datascience.stackexchange.com/questions/53995", "https://datascience.stackexchange.com", "https://datascience.stackexchange.com/users/43765/" ]
**For me embedding is used to represent big sparse matrix into smaller dimensions, where each dimension(feature) represent a meaningful association with other elements in the embedding matrix.** Consider an example of NLP. Where each sentence broken down into words(also called token). Such set of different words make ...
As well known, machine only identify 0 and 1. Therefore, we, for an instance, "encode" characters and symbols with ASCII codes. 0 & 1 can only code two characters. To make sure the code is unique for all characters, we have to use a series number to code them. The hard ware experienced 8, 16, 32, and 64 bits (now 64 bi...
53,995
I just met a terminology called "embedding" in a paper regarding deep learning. The context is "multi-modal embedding" My guess: embedding of something is extract some feature of sth,to form a vector. I couldn't get the explicit meaning for this terminology and that stops me from fully understanding the author's idea...
2019/06/18
[ "https://datascience.stackexchange.com/questions/53995", "https://datascience.stackexchange.com", "https://datascience.stackexchange.com/users/43765/" ]
According to all answers(Thank you) and my google search I got a better understanding, So my newly updated understanding is: The embedding in machine learning or NLP is actually a technique mapping from words to vectors which you can do better analysis or relating, for example, "toyota" or "honda" can be hardly relate...
Embeddings are vector representations of a particular word. In Machine learning, textual content has to be converted to numerical data to feed it into Algorithm. One method is one hot encoding but it breaks down when we have large no of vocabulary. The size of word representation grows as the vocabulary grows. Also,...
53,995
I just met a terminology called "embedding" in a paper regarding deep learning. The context is "multi-modal embedding" My guess: embedding of something is extract some feature of sth,to form a vector. I couldn't get the explicit meaning for this terminology and that stops me from fully understanding the author's idea...
2019/06/18
[ "https://datascience.stackexchange.com/questions/53995", "https://datascience.stackexchange.com", "https://datascience.stackexchange.com/users/43765/" ]
> > The LSA community seems to have first used the word “embedding” in Landauer > et al. (1997), in a variant of its mathematical meaning as a mapping from one space or mathematical structure to another. In LSA, the word embedding seems to have described the mapping from the space of sparse count vectors to the latent...
Embeddings are vector representations of a particular word. In Machine learning, textual content has to be converted to numerical data to feed it into Algorithm. One method is one hot encoding but it breaks down when we have large no of vocabulary. The size of word representation grows as the vocabulary grows. Also,...
53,995
I just met a terminology called "embedding" in a paper regarding deep learning. The context is "multi-modal embedding" My guess: embedding of something is extract some feature of sth,to form a vector. I couldn't get the explicit meaning for this terminology and that stops me from fully understanding the author's idea...
2019/06/18
[ "https://datascience.stackexchange.com/questions/53995", "https://datascience.stackexchange.com", "https://datascience.stackexchange.com/users/43765/" ]
In the context of machine learning, an embedding is a low-dimensional, learned continuous vector representation of discrete variables into which you can translate high-dimensional vectors. Generally, embeddings make ML models more efficient and easier to work with, and can be used with other models as well. Typically,...
Embeddings are vector representations of a particular word. In Machine learning, textual content has to be converted to numerical data to feed it into Algorithm. One method is one hot encoding but it breaks down when we have large no of vocabulary. The size of word representation grows as the vocabulary grows. Also,...
44,729,747
I am trying to find a method to return a record set with a dynamic number of columns. I can write one query that will produce the list of column names I need as such: ``` SELECT DISTINCT name FROM tests WHERE group = 'basic'; ``` This will return a short list like 'poke', 'prod', 'hit', 'drop', etc. Then I want a ta...
2017/06/23
[ "https://Stackoverflow.com/questions/44729747", "https://Stackoverflow.com", "https://Stackoverflow.com/users/681359/" ]
Enable the 'tablefunc' extension, and then use the 'crosstab' function; see the PG docs: <https://www.postgresql.org/docs/current/static/tablefunc.html>. The argument to the crosstab function should be the text of a query that produces three columns: the date, the test name, and the test success, in that order.
I would picture a query like this: ``` SELECT tr.name, tr.date, tr.success FROM tests t JOIN test_results tr ON t.testid = tr.testid WHERE t.group = 'basic' AND tr.date > now() - '1 week'::interval; ``` You are probably better off pivoting the data at the application level.
44,729,747
I am trying to find a method to return a record set with a dynamic number of columns. I can write one query that will produce the list of column names I need as such: ``` SELECT DISTINCT name FROM tests WHERE group = 'basic'; ``` This will return a short list like 'poke', 'prod', 'hit', 'drop', etc. Then I want a ta...
2017/06/23
[ "https://Stackoverflow.com/questions/44729747", "https://Stackoverflow.com", "https://Stackoverflow.com/users/681359/" ]
There are different methods used, some already mentioned here like crosstab. Also, you can build an own function that builds the query dynamically and returns as [TABLE](https://www.postgresql.org/docs/current/static/xfunc-sql.html#XFUNC-SQL-FUNCTIONS-RETURNING-TABLE) and few more methods. But all require you to prede...
I would picture a query like this: ``` SELECT tr.name, tr.date, tr.success FROM tests t JOIN test_results tr ON t.testid = tr.testid WHERE t.group = 'basic' AND tr.date > now() - '1 week'::interval; ``` You are probably better off pivoting the data at the application level.
44,729,747
I am trying to find a method to return a record set with a dynamic number of columns. I can write one query that will produce the list of column names I need as such: ``` SELECT DISTINCT name FROM tests WHERE group = 'basic'; ``` This will return a short list like 'poke', 'prod', 'hit', 'drop', etc. Then I want a ta...
2017/06/23
[ "https://Stackoverflow.com/questions/44729747", "https://Stackoverflow.com", "https://Stackoverflow.com/users/681359/" ]
There are different methods used, some already mentioned here like crosstab. Also, you can build an own function that builds the query dynamically and returns as [TABLE](https://www.postgresql.org/docs/current/static/xfunc-sql.html#XFUNC-SQL-FUNCTIONS-RETURNING-TABLE) and few more methods. But all require you to prede...
Enable the 'tablefunc' extension, and then use the 'crosstab' function; see the PG docs: <https://www.postgresql.org/docs/current/static/tablefunc.html>. The argument to the crosstab function should be the text of a query that produces three columns: the date, the test name, and the test success, in that order.
15,161,557
If I want to move a rectangle in a Canvas, would I have to modify the Top and Left properties? Thats the only way I see it would be possible. I am making a tile-based game, and the rectangles I want to move are filled with images of enemies and my hero.
2013/03/01
[ "https://Stackoverflow.com/questions/15161557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2037244/" ]
Using Apache commons IOUtils function ``` import org.apache.commons.io.IOUtils; InputStream inStream = new FileInputStream("filename.txt"); String body = IOUtils.toString(inStream, StandardCharsets.UTF_8.name()); ```
From an answer I edited [here](https://stackoverflow.com/a/5445161/1599699): ``` static String convertStreamToString(java.io.InputStream is) { if (is == null) { return ""; } java.util.Scanner s = new java.util.Scanner(is); s.useDelimiter("\\A"); String streamString = s.hasNext() ? s.next(...
15,161,557
If I want to move a rectangle in a Canvas, would I have to modify the Top and Left properties? Thats the only way I see it would be possible. I am making a tile-based game, and the rectangles I want to move are filled with images of enemies and my hero.
2013/03/01
[ "https://Stackoverflow.com/questions/15161557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2037244/" ]
You can't directly convert it to string. You should implement something like this Add this code to your method ``` //Commented this out because this is not the efficient way to achieve that //StringBuilder builder = new StringBuilder(); //int ch; //while((ch = fis.read()) != -1){ // builder.append...
Using Apache commons IOUtils function ``` import org.apache.commons.io.IOUtils; InputStream inStream = new FileInputStream("filename.txt"); String body = IOUtils.toString(inStream, StandardCharsets.UTF_8.name()); ```
15,161,557
If I want to move a rectangle in a Canvas, would I have to modify the Top and Left properties? Thats the only way I see it would be possible. I am making a tile-based game, and the rectangles I want to move are filled with images of enemies and my hero.
2013/03/01
[ "https://Stackoverflow.com/questions/15161557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2037244/" ]
You can't directly convert it to string. You should implement something like this Add this code to your method ``` //Commented this out because this is not the efficient way to achieve that //StringBuilder builder = new StringBuilder(); //int ch; //while((ch = fis.read()) != -1){ // builder.append...
From an answer I edited [here](https://stackoverflow.com/a/5445161/1599699): ``` static String convertStreamToString(java.io.InputStream is) { if (is == null) { return ""; } java.util.Scanner s = new java.util.Scanner(is); s.useDelimiter("\\A"); String streamString = s.hasNext() ? s.next(...
15,161,557
If I want to move a rectangle in a Canvas, would I have to modify the Top and Left properties? Thats the only way I see it would be possible. I am making a tile-based game, and the rectangles I want to move are filled with images of enemies and my hero.
2013/03/01
[ "https://Stackoverflow.com/questions/15161557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2037244/" ]
``` public static String getFileContent( FileInputStream fis, String encoding ) throws IOException { try( BufferedReader br = new BufferedReader( new InputStreamReader(fis, encoding ))) { StringBuilder sb = new StringBuilder(); String line; while(( line = br.readLine()...
From an answer I edited [here](https://stackoverflow.com/a/5445161/1599699): ``` static String convertStreamToString(java.io.InputStream is) { if (is == null) { return ""; } java.util.Scanner s = new java.util.Scanner(is); s.useDelimiter("\\A"); String streamString = s.hasNext() ? s.next(...
15,161,557
If I want to move a rectangle in a Canvas, would I have to modify the Top and Left properties? Thats the only way I see it would be possible. I am making a tile-based game, and the rectangles I want to move are filled with images of enemies and my hero.
2013/03/01
[ "https://Stackoverflow.com/questions/15161557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2037244/" ]
Using Apache commons IOUtils function ``` import org.apache.commons.io.IOUtils; InputStream inStream = new FileInputStream("filename.txt"); String body = IOUtils.toString(inStream, StandardCharsets.UTF_8.name()); ```
Use following code ----> ``` try { FileInputStream fis=new FileInputStream("filename.txt"); int i=0; while((i = fis.read()) !=-1 ) { // to reach until the laste bytecode -1 System.out.print((char)i); /* For converting each bytecode into character */ } fis.close(); } catch(Exception ...
15,161,557
If I want to move a rectangle in a Canvas, would I have to modify the Top and Left properties? Thats the only way I see it would be possible. I am making a tile-based game, and the rectangles I want to move are filled with images of enemies and my hero.
2013/03/01
[ "https://Stackoverflow.com/questions/15161557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2037244/" ]
You can't directly convert it to string. You should implement something like this Add this code to your method ``` //Commented this out because this is not the efficient way to achieve that //StringBuilder builder = new StringBuilder(); //int ch; //while((ch = fis.read()) != -1){ // builder.append...
Don't make the mistake of relying upon or needlessly converting/losing endline characters. Do it character by character. Don't forget to use the proper character encoding to interpres the stream. ``` public String getFileContent( FileInputStream fis ) { StringBuilder sb = new StringBuilder(); Reader r = new In...
15,161,557
If I want to move a rectangle in a Canvas, would I have to modify the Top and Left properties? Thats the only way I see it would be possible. I am making a tile-based game, and the rectangles I want to move are filled with images of enemies and my hero.
2013/03/01
[ "https://Stackoverflow.com/questions/15161557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2037244/" ]
Don't make the mistake of relying upon or needlessly converting/losing endline characters. Do it character by character. Don't forget to use the proper character encoding to interpres the stream. ``` public String getFileContent( FileInputStream fis ) { StringBuilder sb = new StringBuilder(); Reader r = new In...
From an answer I edited [here](https://stackoverflow.com/a/5445161/1599699): ``` static String convertStreamToString(java.io.InputStream is) { if (is == null) { return ""; } java.util.Scanner s = new java.util.Scanner(is); s.useDelimiter("\\A"); String streamString = s.hasNext() ? s.next(...
15,161,557
If I want to move a rectangle in a Canvas, would I have to modify the Top and Left properties? Thats the only way I see it would be possible. I am making a tile-based game, and the rectangles I want to move are filled with images of enemies and my hero.
2013/03/01
[ "https://Stackoverflow.com/questions/15161557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2037244/" ]
``` public static String getFileContent( FileInputStream fis, String encoding ) throws IOException { try( BufferedReader br = new BufferedReader( new InputStreamReader(fis, encoding ))) { StringBuilder sb = new StringBuilder(); String line; while(( line = br.readLine()...
Use following code ----> ``` try { FileInputStream fis=new FileInputStream("filename.txt"); int i=0; while((i = fis.read()) !=-1 ) { // to reach until the laste bytecode -1 System.out.print((char)i); /* For converting each bytecode into character */ } fis.close(); } catch(Exception ...
15,161,557
If I want to move a rectangle in a Canvas, would I have to modify the Top and Left properties? Thats the only way I see it would be possible. I am making a tile-based game, and the rectangles I want to move are filled with images of enemies and my hero.
2013/03/01
[ "https://Stackoverflow.com/questions/15161557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2037244/" ]
``` public static String getFileContent( FileInputStream fis, String encoding ) throws IOException { try( BufferedReader br = new BufferedReader( new InputStreamReader(fis, encoding ))) { StringBuilder sb = new StringBuilder(); String line; while(( line = br.readLine()...
Using Apache commons IOUtils function ``` import org.apache.commons.io.IOUtils; InputStream inStream = new FileInputStream("filename.txt"); String body = IOUtils.toString(inStream, StandardCharsets.UTF_8.name()); ```
15,161,557
If I want to move a rectangle in a Canvas, would I have to modify the Top and Left properties? Thats the only way I see it would be possible. I am making a tile-based game, and the rectangles I want to move are filled with images of enemies and my hero.
2013/03/01
[ "https://Stackoverflow.com/questions/15161557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2037244/" ]
You can't directly convert it to string. You should implement something like this Add this code to your method ``` //Commented this out because this is not the efficient way to achieve that //StringBuilder builder = new StringBuilder(); //int ch; //while((ch = fis.read()) != -1){ // builder.append...
Use following code ----> ``` try { FileInputStream fis=new FileInputStream("filename.txt"); int i=0; while((i = fis.read()) !=-1 ) { // to reach until the laste bytecode -1 System.out.print((char)i); /* For converting each bytecode into character */ } fis.close(); } catch(Exception ...
46,863,176
i am using retrofit 2 to make my API calls, but my issue is that API response takes time to show the response, is there any chance I can store the data and load that cache and show it and then meanwhile calling the network API. Like for example : the first hit -> Make Network Call - render the output to the screen s...
2017/10/21
[ "https://Stackoverflow.com/questions/46863176", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7074112/" ]
Yes, there are many solutions for doing that. This is the solution if you use **RxJava** (which works well with [retrofit](https://github.com/square/retrofit/tree/master/retrofit-adapters/rxjava2)) First is using concat like: ``` Observable<Data> source = Observable .concat(memory, disk, network).first(); ``` ...
You could first cache all the responses: ``` public static Retrofit getAdapter(Context context, String baseUrl) { OkHttpClient.Builder okHttpClient = new OkHttpClient().newBuilder(); Cache cache = new Cache(getCacheDir(), cacheSize); okHttpClient.cache(cache).build(); Retrofit.Builder retrofitBuilder...
7,315,711
Is it possible to declare variable in @protocol? Just to force programmers to add those variable in implementing class's(classes which implements this protocol) header and implementation? Thanks
2011/09/06
[ "https://Stackoverflow.com/questions/7315711", "https://Stackoverflow.com", "https://Stackoverflow.com/users/753603/" ]
Short answer: **No, it isn't possible to do that**. You can enforce the availability of methods and properties at most.
You can't declare ivars in `@protocol`s but you can force the conforming class to implement an accessor and a mutator, which sounds like what you're getting at. For example: ``` @protocol Priced @property(assign, nonatomic) double price; @end @interface Carrot : NSObject <Priced> { double price; } @end @implement...
7,315,711
Is it possible to declare variable in @protocol? Just to force programmers to add those variable in implementing class's(classes which implements this protocol) header and implementation? Thanks
2011/09/06
[ "https://Stackoverflow.com/questions/7315711", "https://Stackoverflow.com", "https://Stackoverflow.com/users/753603/" ]
Short answer: **No, it isn't possible to do that**. You can enforce the availability of methods and properties at most.
You could make the objects a concrete subclass. That would be the only way to ensure that they contained the internals that you needed. Of course if you are interested in how the classes are storing their data internally... That is violating some oop paradigms.
7,315,711
Is it possible to declare variable in @protocol? Just to force programmers to add those variable in implementing class's(classes which implements this protocol) header and implementation? Thanks
2011/09/06
[ "https://Stackoverflow.com/questions/7315711", "https://Stackoverflow.com", "https://Stackoverflow.com/users/753603/" ]
You can't declare ivars in `@protocol`s but you can force the conforming class to implement an accessor and a mutator, which sounds like what you're getting at. For example: ``` @protocol Priced @property(assign, nonatomic) double price; @end @interface Carrot : NSObject <Priced> { double price; } @end @implement...
You could make the objects a concrete subclass. That would be the only way to ensure that they contained the internals that you needed. Of course if you are interested in how the classes are storing their data internally... That is violating some oop paradigms.
13,432,471
I am still a beginner in Android and java. I am trying to load an image from a server by using AsyncTask. The size of the image is around 50kb. Yet it takes several seconds to show up. The following code is used to download the image from the server. ``` public static Bitmap getBitmapFromURL(String src) { tr...
2012/11/17
[ "https://Stackoverflow.com/questions/13432471", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1791613/" ]
The `tagName` for that element is `INPUT`; there are no elements with tag name `submit`. Try this: ``` document.getElementsByName('REG_BTN')[0].click(); ```
If page is complete loading first, and use querySelector (CSS) and click. ' ``` if (document.readyState=='complete'){ document.querySelector('input[type*="submit"]').click(); } ``` '
219,629
This is a general question that I couldn't find a satisfactory answer to. Apart from the obvious, making a node visible on the user side versus keeping it in a 'draft' mode, what does publishing a node accomplish? Especially if the node isn't front-end content.
2016/11/04
[ "https://drupal.stackexchange.com/questions/219629", "https://drupal.stackexchange.com", "https://drupal.stackexchange.com/users/26246/" ]
Node status is baked into the [node access system](https://api.drupal.org/api/drupal/core%21modules%21node%21node.module/group/node_access/8.2.x) fairly deeply in implementations. What I mean is, it is not directly used by used `hook_node_access()` and `hook_node_grants()`, but implementations of these hooks do. The no...
In the database, the 'node' table has a 'status' column. On 1, the node is published, and on 0 it is unpublished. Basically, publishing an unpublished node is setting this 0 to 1.
1,399,896
It's weird to me that the import fails even when it's in the `sys.path`. today, I set up a google app engine django environment on ubuntu in my lab's pc. And it works fine when I checked out the code and ran it in windows(same pc in the lab). But when I went to the dorm, and checked out the code and start to run, it ...
2009/09/09
[ "https://Stackoverflow.com/questions/1399896", "https://Stackoverflow.com", "https://Stackoverflow.com/users/125633/" ]
Can you import `google` and `google.appengine`? Are you sure interpreter has read and traverse access rights to the module tree?
Sometimes you can get an import error for a module when the error is something different, like a syntax error. Try putting ``` import pdb;pdb.set_trace() ``` just before the import and then s(tep) into the import, and n(ext) thruogh the module in question to see of you get an error.
1,399,896
It's weird to me that the import fails even when it's in the `sys.path`. today, I set up a google app engine django environment on ubuntu in my lab's pc. And it works fine when I checked out the code and ran it in windows(same pc in the lab). But when I went to the dorm, and checked out the code and start to run, it ...
2009/09/09
[ "https://Stackoverflow.com/questions/1399896", "https://Stackoverflow.com", "https://Stackoverflow.com/users/125633/" ]
Looks like you're getting a module (or package) called 'google' from elsewhere -- perhaps `/home/tower/googlecode/mygae` -- and THAT google module has no `appengine` in it. To check, print `google.__file__` and if possible `google.__path__`; that should be informative.
Sometimes you can get an import error for a module when the error is something different, like a syntax error. Try putting ``` import pdb;pdb.set_trace() ``` just before the import and then s(tep) into the import, and n(ext) thruogh the module in question to see of you get an error.
1,399,896
It's weird to me that the import fails even when it's in the `sys.path`. today, I set up a google app engine django environment on ubuntu in my lab's pc. And it works fine when I checked out the code and ran it in windows(same pc in the lab). But when I went to the dorm, and checked out the code and start to run, it ...
2009/09/09
[ "https://Stackoverflow.com/questions/1399896", "https://Stackoverflow.com", "https://Stackoverflow.com/users/125633/" ]
I had the same problem on **Ubuntu** when I wanted to play with **google.appengine** in console. First I tried to fix it by removing the `/usr/lib/python2.7/dist-packages/google` package altogether but **Ubuntu One** complained. Finally I resolved it by merging the **GAE SDK google package** into the **package that cau...
Sometimes you can get an import error for a module when the error is something different, like a syntax error. Try putting ``` import pdb;pdb.set_trace() ``` just before the import and then s(tep) into the import, and n(ext) thruogh the module in question to see of you get an error.
1,399,896
It's weird to me that the import fails even when it's in the `sys.path`. today, I set up a google app engine django environment on ubuntu in my lab's pc. And it works fine when I checked out the code and ran it in windows(same pc in the lab). But when I went to the dorm, and checked out the code and start to run, it ...
2009/09/09
[ "https://Stackoverflow.com/questions/1399896", "https://Stackoverflow.com", "https://Stackoverflow.com/users/125633/" ]
Can you import `google` and `google.appengine`? Are you sure interpreter has read and traverse access rights to the module tree?
Looks like you're getting a module (or package) called 'google' from elsewhere -- perhaps `/home/tower/googlecode/mygae` -- and THAT google module has no `appengine` in it. To check, print `google.__file__` and if possible `google.__path__`; that should be informative.
1,399,896
It's weird to me that the import fails even when it's in the `sys.path`. today, I set up a google app engine django environment on ubuntu in my lab's pc. And it works fine when I checked out the code and ran it in windows(same pc in the lab). But when I went to the dorm, and checked out the code and start to run, it ...
2009/09/09
[ "https://Stackoverflow.com/questions/1399896", "https://Stackoverflow.com", "https://Stackoverflow.com/users/125633/" ]
Can you import `google` and `google.appengine`? Are you sure interpreter has read and traverse access rights to the module tree?
I had the same problem on **Ubuntu** when I wanted to play with **google.appengine** in console. First I tried to fix it by removing the `/usr/lib/python2.7/dist-packages/google` package altogether but **Ubuntu One** complained. Finally I resolved it by merging the **GAE SDK google package** into the **package that cau...
1,399,896
It's weird to me that the import fails even when it's in the `sys.path`. today, I set up a google app engine django environment on ubuntu in my lab's pc. And it works fine when I checked out the code and ran it in windows(same pc in the lab). But when I went to the dorm, and checked out the code and start to run, it ...
2009/09/09
[ "https://Stackoverflow.com/questions/1399896", "https://Stackoverflow.com", "https://Stackoverflow.com/users/125633/" ]
I had the same problem on **Ubuntu** when I wanted to play with **google.appengine** in console. First I tried to fix it by removing the `/usr/lib/python2.7/dist-packages/google` package altogether but **Ubuntu One** complained. Finally I resolved it by merging the **GAE SDK google package** into the **package that cau...
Looks like you're getting a module (or package) called 'google' from elsewhere -- perhaps `/home/tower/googlecode/mygae` -- and THAT google module has no `appengine` in it. To check, print `google.__file__` and if possible `google.__path__`; that should be informative.
121,052
It looks to me like ChromaticityPlot3D has some default lighting, but unlike most Graphics3D functions the Lighting option doesn't seem to have any effect. However, the documentation states "ChromaticityPlot3D accepts all Graphics3D options with the following additions and changes: ...". Any ideas how to affect the l...
2016/07/19
[ "https://mathematica.stackexchange.com/questions/121052", "https://mathematica.stackexchange.com", "https://mathematica.stackexchange.com/users/38979/" ]
If you look at the `InputForm` of `ChromaticityPlot3D[{"WideGamutRGB", "sRGB"}]` you'll find several spots where it says `Lighting -> "Neutral"` So if you want to change that, you'll have to modify the output of `ChromaticityPlot3D` using a replacement rule. Here is an extreme example, one that totally ruins the plot ...
One could override the setting for each polygon group (or `GraphicsGroup[]`): ``` cp /. p_Polygon :> {Lighting -> {{"Ambient", White}}, p} cp /. gg_GraphicsGroup :> {Lighting -> {{"Ambient", White}}, gg} ``` ![Mathematica graphics](https://i.stack.imgur.com/hK4f0.png) --- *Update: Addendum.* While `Lighting` show...
31,837,724
Here's the original image I'm trying to remove background from: [![enter image description here](https://i.stack.imgur.com/rTVSl.jpg)](https://i.stack.imgur.com/rTVSl.jpg) I am trying to use imagemagick to remove the background from an image. When the image has a white product, my script doesn't work well. It removes...
2015/08/05
[ "https://Stackoverflow.com/questions/31837724", "https://Stackoverflow.com", "https://Stackoverflow.com/users/439574/" ]
I would take advantage of [HSL](https://en.wikipedia.org/wiki/HSL_and_HSV) colorspace, and create an alpha mask from the lightness channel. ``` convert tshirt.jpg \( \ +clone -colorspace HSL -separate \ -delete 0,1 -fx 'u>0.975?0:1' \) \ -compose CopyOpacity -composite \ out.png ``` ...
I would go for a simple threshold to pick out the white and then some sort of filtration to remove the noise/ragged edges. So, for example ``` convert shirt.jpg -threshold 99.99% -negate result.jpg ``` which gives this: [![enter image description here](https://i.stack.imgur.com/pKjoT.jpg)](https://i.stack.imgur.co...
56,395,430
I would like to use or-tools and the [GLOP](https://developers.google.com/optimization/lp/glop) solver to solve linear programming problems. I already have another program that creates [LP files](http://lpsolve.sourceforge.net/5.0/CPLEX-format.htm) which are, as far as I know, fairly standard for defining linear progr...
2019/05/31
[ "https://Stackoverflow.com/questions/56395430", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1557306/" ]
There is not API to read LP files, we did not write a good enough LP reader. We do support reading MPS files.
After scouring through the `or-tools` GitHub repo, I found that it *was* possible to read `.lp` files (**of the [`lp_solve` `.lp` file format](https://web.mit.edu/lpsolve/doc/lp-format.htm)**, **not** the [CPLEX `.lp` file format](https://web.mit.edu/lpsolve/doc/CPLEX-format.htm)) until March 2022 (`ortools==9.3.10497`...
5,254,367
I moved some files from 1 directory to the other inside visual studio. Now when I try to commit those files, it tells me the other directory is not found (i deleted it). Why does svn still need those directories? `/svn//trunk/Source/SampleRepoProject.Data/Domains/Interfaces' path not found` <-- this is my previous and...
2011/03/10
[ "https://Stackoverflow.com/questions/5254367", "https://Stackoverflow.com", "https://Stackoverflow.com/users/400861/" ]
As @GregS indicated in his comment, an int divided by an int is an int. Casting one of the numbers to a double will produce the output your desire. ``` double chiSquare = ((double)hashtable.get(key).intValue())/noWords; ``` Or, use the convenience method on Integer to convert it to a double: ``` double chiSquare = ...
Because the parentheses are incorrect. ``` double chiSquare = ( (double) hashtable.get(key).intValue() )/noWords; ```
40,529,897
Is it possible to use Jest with Web pack? I mean using it in parallel with Web pack hot-load.And Run our tests every time when Web pack will build the project .
2016/11/10
[ "https://Stackoverflow.com/questions/40529897", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6485113/" ]
If you want check if your `UPDATE` query has actually updated one or more rows, you can use [PDOStatement::rowCount](http://php.net/manual/en/pdostatement.rowcount.php) after the execution of the query.
> > A few Observations: > > 1.) You bound `expires` and `token` but not `selector`. > > 2.) You may want to remove the colon ( **:** ) in front of the array containing the named-parameters. > > > ``` if(isset($_COOKIE['authUser'])) { $cookie_contents = $_COOKIE['authUser']; $selector = "gh...
13,697
I live in a 3 bedroom shared house and want to reduce the noise that the bathroom door makes when it closes. I tried to find a photo of the door. It's basically a old mansion block of apartments in London. The door has a brass knob and stained glass is about an inch thick wooden. I don't know if you can picture the ol...
2012/04/19
[ "https://diy.stackexchange.com/questions/13697", "https://diy.stackexchange.com", "https://diy.stackexchange.com/users/5943/" ]
I guess you could try putting some thin foam or felt stick on pads on the inside of the door frame where the door contacts it. This should lower the sound of the wood to wood contact. If the knob hardware is also loud, try using some dry silicon spray lubricant on the moving parts and on the door hinges. Sleep well.......
Get narrow weather seal and put it on the door jamb so the door never touches the wood.
23,878,954
i make a view in sql server and throw an error: ``` USE BaseDeDatos; CREATE VIEW TEMAS_USUARIO AS SELECT TOP 5 t.id_userTopic, t.nameTopic, u.id_user, u.name FROM Topic t, Users u WHERE t.id_userTopic = u.id_group ORDER BY t.id_topic DESC; ``` what is wrong whit the syntax? error ---> CREATE VIEW TEMAS\_USUARIO ca...
2014/05/26
[ "https://Stackoverflow.com/questions/23878954", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3602478/" ]
This unfortunately was a mistake in our tutorial. Indeed you need to add two properties to `Grid.h`: ``` @property (nonatomic, assign) int totalAlive; @property (nonatomic, assign) int generation; ``` Instead of adding instance variables to `Grid.m`. The tutorial has now been updated: <https://www.makegameswith.u...
The error message is telling you that there is no property named `generation` for the class `Grid`. Perhaps you are getting confused with accessing properties directly with a leading "\_" vs "self.". Insure that such a property exists. Update the question to show th declarations of the missing properties. Just use t...
61,196,489
I created a chat messenger between my website users based on wix repeater when a new msg launch a new row insert into chat collection (my chat collection including the following fields User A, User B, MSG ) and the messenger repeater should refresh for both users. So if user A send a message to User B I should do t...
2020/04/13
[ "https://Stackoverflow.com/questions/61196489", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1921025/" ]
You can use the [Realtime API](https://www.wix.com/corvid/reference/wix-realtime.html) to create a subscriber for the collection on the client. In your backend code in the afterInsert function, publish a message to the specific client which execute the refresh function for the list in the repeater in the callback funct...
The best thing you can do is here is to set a setInterval() function under the page's onReady() function to refresh user B's dataset/repeater every 3-5 seconds which would check for fresh messages.
239,440
In Octave ``` octave.exe:4> asin(1/2) ans = 0.52360 ``` is it possible to get the result in form of: ``` ans = pi/6 ``` It seems not possible with [format function](http://octave.sourceforge.net/octave/function/format.html), but may be there are any tricks.
2012/11/17
[ "https://math.stackexchange.com/questions/239440", "https://math.stackexchange.com", "https://math.stackexchange.com/users/20343/" ]
I assume it's the same as with Matlab, where you would do sym(asin(1/2)).
Try using "format rat". "rat" stands for rational, which puts answers in fractional terms. Using "format rat" puts ALL terms in fractional terms (unless you switch back to a different format such as "format g"), as opposed to rats([expression]), which (I assume - I've never used that) only puts [expression] in rational...
239,440
In Octave ``` octave.exe:4> asin(1/2) ans = 0.52360 ``` is it possible to get the result in form of: ``` ans = pi/6 ``` It seems not possible with [format function](http://octave.sourceforge.net/octave/function/format.html), but may be there are any tricks.
2012/11/17
[ "https://math.stackexchange.com/questions/239440", "https://math.stackexchange.com", "https://math.stackexchange.com/users/20343/" ]
An alternative might be to convert into units of $\pi$ explicitly, and then seek a rational approximation: ``` > rats(asin(1/2) / pi) ans = 1/6 ```
Try using "format rat". "rat" stands for rational, which puts answers in fractional terms. Using "format rat" puts ALL terms in fractional terms (unless you switch back to a different format such as "format g"), as opposed to rats([expression]), which (I assume - I've never used that) only puts [expression] in rational...
59,069,129
``` def prepare_data(df, config, data_dir): X = np.empty(shape=(df.shape[0], config.dim[0], config.dim[1], 1)) input_length = config.audio_length for i, fname in enumerate(df.index): file_path = data_dir + fname data, _ = librosa.core.load(file_path, sr=config.sampling_rate, res_type="kaiser...
2019/11/27
[ "https://Stackoverflow.com/questions/59069129", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9114781/" ]
Yes because you're trying to concat strings and integers as `file_path = data_dir + fname + '.wav'` but fname will be an integer value so typecast it with string. ``` for i, fname in enumerate(df.index): #print(fname) file_path = data_dir + str(fname) + '.wav' data, _ = librosa.core.load(file_path, sr=con...
``` file_path = str(data_dir) + str(fname) + '.wav' ```
834,530
I am interested in using Ubuntu for the fist time, so I went to the Ubuntu download page (<https://www.ubuntu.com/download/desktop>), to get the download file. When the file downloaded he file, it appeared in WinRAR, so I cannot burn the file to a DVD. Can anybody point me in the right direction as to how to burn this ...
2016/10/08
[ "https://askubuntu.com/questions/834530", "https://askubuntu.com", "https://askubuntu.com/users/604338/" ]
It's not actually a RAR file, it's just that WinRAR wants to open ISOs. **This happens when both of these two conditions are true:** 1. Windows is configured to *Hide extensions for known file types*, which is the default. ![](https://i.stack.imgur.com/Q9zBx.png) 2. WinRAR is installed, and configured to open ISO im...
Try: do right click on downloaded iso, open with appropriate cd burner app or You can do that from pendrive too , download rufus portable app from [rufus.akeo.ie](http://rufus.akeo.ie) , attach pendrive a, open this app and select your downloaded iso file.
5,111,866
Can't seem to get chrome to play videos with html5 video tag when I host them on a Rackspace cloudfiles server. Works perfectly on the regular hosting, but as soon as I link the video with the rackspace cdn url, Chrome freezes (total freeze, website UI completely blocked - after a while Chrome pops a message saying "T...
2011/02/24
[ "https://Stackoverflow.com/questions/5111866", "https://Stackoverflow.com", "https://Stackoverflow.com/users/192705/" ]
I work quite a bit with the Rackspace API. Their API actually allows you to set a container as streaming enabled. My first instinct tells me that you haven't done this. I stream various file types and they all work an absolute treat. There is more information about CDN Streaming Enabled containers here: <http://docs...
I don't have a concrete answer, just some thoughts: 1. what about in other browsers? 2. it works on the web server with the content type above is text/plain so why force to video/webm? 3. can Rackspace provide you (or can you find on their site or someone else's) some sample content that does play so you can inspect ...
129,334
I have a compound, dimethylaminoethanol (DMAE) bitartrate, which I originally purchased as a supplement and possible smart drug. I bought an absurd amount of it. It didn’t do anything for me as a supplement. I understand that DMAE, not the bitartrate salt, is commonly used in cosmetics, & I’d like to play with it for t...
2020/03/21
[ "https://chemistry.stackexchange.com/questions/129334", "https://chemistry.stackexchange.com", "https://chemistry.stackexchange.com/users/90071/" ]
I see on Wikipedia: "Dimethylethanolamine (DMAE or DMEA) is an organic compound with the formula (CH3)2NCH2CH2OH. It is bifunctional, containing both a tertiary amine and primary alcohol functional groups. It is a colorless viscous liquid. It is used in skin care products." Now the fact that it is used in skin care pr...
This might work: Make a solution of NaOH in absolute ethanol, e.g. at a 1 mol/L concentration. Suspend the DMAE bitartrate in ethanol, and add 2 equivalents of the NaOH solution slowly to the suspension, making sure it doesn't heat up too much. After everything is added, stir or agitate it for a while. Then filter off ...
1,268,656
I am sure, I've uninstalled iTunes but don't know how logo is displaying in applications. [![itunes in my Applications ](https://i.stack.imgur.com/tFk01.png)](https://i.stack.imgur.com/tFk01.png) I tried to view all the list file using `sudo apt list` but nothing regarding iTunes and also searched in packages to find...
2020/08/20
[ "https://askubuntu.com/questions/1268656", "https://askubuntu.com", "https://askubuntu.com/users/1118557/" ]
You don't really need to use `expect` and can give commands to `bluetoothctl` directly as arguments. ```bsh # ... bluetoothctl -- power on bluetoothctl -- connect $mac # ... ``` For a more complete example, here is the full Bash script that I use in Ubuntu 20.04 for my BT radio : ```bsh #!/bin/bash mac="90:03:B7:1...
Capture the output and strip the prompts... ``` typeset -a OUTPUT clean_line () { local LINE while read LINE;do echo ${LINE} | perl -pe 's/\x1b\[[0-9;]*[mG]//g; s/\[.*\]#?//g; s/\x0d\x1b\x20\x0d\x1b\x5b\x4b//g; s/^ //g' done } coproc bluetoothctl echo -e 'agent on\nconnect 00:0C:8A:FE:ED:18\nexit' >&...
97,355
**Task** Given an input `n`, calculate the n-th decimal digit of pi **Rules** * Answer can be a full program or a function. * Input must be taken from stdin or from function arguments. * Output must be either sent to stdout, the return value of a function, or written to a file. * all `n` values between 0 and 20000 m...
2016/10/25
[ "https://codegolf.stackexchange.com/questions/97355", "https://codegolf.stackexchange.com", "https://codegolf.stackexchange.com/users/53251/" ]
Python 2, ~~182~~ 65 bytes ========================== ```python a=p=2*10**20004 i=3 while a:a=i/2*a/i;p+=a;i+=2 print`p`[input()] ``` **[repl.it](https://repl.it/EF0E/3)** Uses the [Leibniz formula](https://en.wikipedia.org/wiki/Leibniz_formula_for_%CF%80) to calculate 20000 correct digits (plus a handful to allow ...
Java 7, ~~260~~ 258 bytes ========================= ``` import java.math.*;int c(int n){BigInteger p,a=p=BigInteger.TEN.pow(20010).multiply(new BigInteger("2"));for(int i=1;a.compareTo(BigInteger.ZERO)>0;p=p.add(a))a=a.multiply(new BigInteger(i+"")).divide(new BigInteger((2*i+++1)+""));return(p+"").charAt(n)-48;} ```...
9,238,323
When it comes to programming, I don't hold strong opinions about feature x vs feature y. I think all have their appropriate uses. And I'm always reading everything I can about as many programming languages I can get my hands on so that I can pull the best ideas out and compare them all (from Haskell to Lisp to C to Er...
2012/02/11
[ "https://Stackoverflow.com/questions/9238323", "https://Stackoverflow.com", "https://Stackoverflow.com/users/369618/" ]
An example would be when you change a variable from one type to another: ``` setType(String type) ``` Then later you decide to change the type to a more efficient enum: ``` setType(SomeEnum type) ``` When you do that in a strongly typed language, you will get errors wherever `setType` is called. That allows you t...
@Laurent has answered your question very nicely. I would just like to add that, for example, there's a testing/dynamic-bug-finding tool for JavaScript (a dynamically typed language) called [TypedJS](http://typedjs.com/). It is just designed to prevent bugs that occur due to dynamic programming. An example bug that Typ...
9,238,323
When it comes to programming, I don't hold strong opinions about feature x vs feature y. I think all have their appropriate uses. And I'm always reading everything I can about as many programming languages I can get my hands on so that I can pull the best ideas out and compare them all (from Haskell to Lisp to C to Er...
2012/02/11
[ "https://Stackoverflow.com/questions/9238323", "https://Stackoverflow.com", "https://Stackoverflow.com/users/369618/" ]
An example would be when you change a variable from one type to another: ``` setType(String type) ``` Then later you decide to change the type to a more efficient enum: ``` setType(SomeEnum type) ``` When you do that in a strongly typed language, you will get errors wherever `setType` is called. That allows you t...
There is a lot that can be said about types and their value for programming. For example, here is a recent article in CACM discussing (among other things) the anecdotical advantages of the advanced type system found in the functional language OCaml: <http://cacm.acm.org/magazines/2011/11/138203-ocaml-for-the-masses/> ...
129,053
Question: > > Prove a simple graph $G$ is Hamiltonian if and only if its closure is Hamiltonian. > > > $|V(G)|=n$, $\deg(u)+\deg(v)\ge n$ ($u$ and $v$ is a pair of non-adjacent vertices on $G$) I know if $G$ is Hamiltonian, its closure must be Hamiltonian. However, I don't know how to prove $G$ is Hamiltonian w...
2012/04/07
[ "https://math.stackexchange.com/questions/129053", "https://math.stackexchange.com", "https://math.stackexchange.com/users/28408/" ]
Consider the construction of $\operatorname{cl}(G)$ from $G$. At each stage you add an edge $uv$ such that $\deg(u)+\deg(v)\ge n$. Say the stages are $G\_0=G,G\_1,\dots,G\_m=\operatorname{cl}(G)$. Show that if $G\_{k+1}$ is Hamiltonian, then so is $G\_k$. Then from the hypothesis that $\operatorname{cl}(G)$ is Hamilton...
Case 1: If G is non Hamiltonian graph.by adding any extra edge without loss of any generality we get a maximal non Hamiltonian graph(by definition of maximal non Hamiltonian graph) then graph G is Hamiltonian. Case 2:If possible suppose graph is non-Hamiltonian. If there is path passing through every vertex of G $ V\_...
881,133
How can I dynamically create an array in C#?
2009/05/19
[ "https://Stackoverflow.com/questions/881133", "https://Stackoverflow.com", "https://Stackoverflow.com/users/99268/" ]
First make an arraylist. Add/remove items. And then `ArrayList.ToArray()` And there is your array!
``` int[] array = { 1, 2, 3, 4, 5}; for (int i=0;i<=array.Length-1 ;i++ ) { Console.WriteLine(array[i]); } ```
881,133
How can I dynamically create an array in C#?
2009/05/19
[ "https://Stackoverflow.com/questions/881133", "https://Stackoverflow.com", "https://Stackoverflow.com/users/99268/" ]
``` object foo = Array.CreateInstance(typeof(byte), length); ```
You can also use the `new` operator just like with other object types: ``` int[] array = new int[5]; ``` or, with a variable: ``` int[] array = new int[someLength]; ```
881,133
How can I dynamically create an array in C#?
2009/05/19
[ "https://Stackoverflow.com/questions/881133", "https://Stackoverflow.com", "https://Stackoverflow.com/users/99268/" ]
I'd like to add to Natrium's answer that generic collections also support this .ToArray() method. ``` List<string> stringList = new List<string>(); stringList.Add("1"); stringList.Add("2"); stringList.Add("3"); string[] stringArray = stringList.ToArray(); ```
``` object foo = Array.CreateInstance(typeof(byte), length); ```
881,133
How can I dynamically create an array in C#?
2009/05/19
[ "https://Stackoverflow.com/questions/881133", "https://Stackoverflow.com", "https://Stackoverflow.com/users/99268/" ]
``` object foo = Array.CreateInstance(typeof(byte), length); ```
Use generic List or ArrayList.
881,133
How can I dynamically create an array in C#?
2009/05/19
[ "https://Stackoverflow.com/questions/881133", "https://Stackoverflow.com", "https://Stackoverflow.com/users/99268/" ]
I'd like to add to Natrium's answer that generic collections also support this .ToArray() method. ``` List<string> stringList = new List<string>(); stringList.Add("1"); stringList.Add("2"); stringList.Add("3"); string[] stringArray = stringList.ToArray(); ```
Use generic List or ArrayList.
881,133
How can I dynamically create an array in C#?
2009/05/19
[ "https://Stackoverflow.com/questions/881133", "https://Stackoverflow.com", "https://Stackoverflow.com/users/99268/" ]
Ok so array initialisation gets me *every single time*. so I took 10 minutes to do this right. ``` static void Main(string[] args) { String[] as1 = new String[] { "Static", "with", "initializer" }; ShowArray("as1", as1); String[] as2 = new String[5]; as2[0] = "Static"; ...
Use generic List or ArrayList.
881,133
How can I dynamically create an array in C#?
2009/05/19
[ "https://Stackoverflow.com/questions/881133", "https://Stackoverflow.com", "https://Stackoverflow.com/users/99268/" ]
I'd like to add to Natrium's answer that generic collections also support this .ToArray() method. ``` List<string> stringList = new List<string>(); stringList.Add("1"); stringList.Add("2"); stringList.Add("3"); string[] stringArray = stringList.ToArray(); ```
``` int[] array = { 1, 2, 3, 4, 5}; for (int i=0;i<=array.Length-1 ;i++ ) { Console.WriteLine(array[i]); } ```
881,133
How can I dynamically create an array in C#?
2009/05/19
[ "https://Stackoverflow.com/questions/881133", "https://Stackoverflow.com", "https://Stackoverflow.com/users/99268/" ]
I'd like to add to Natrium's answer that generic collections also support this .ToArray() method. ``` List<string> stringList = new List<string>(); stringList.Add("1"); stringList.Add("2"); stringList.Add("3"); string[] stringArray = stringList.ToArray(); ```
You can also use the `new` operator just like with other object types: ``` int[] array = new int[5]; ``` or, with a variable: ``` int[] array = new int[someLength]; ```
881,133
How can I dynamically create an array in C#?
2009/05/19
[ "https://Stackoverflow.com/questions/881133", "https://Stackoverflow.com", "https://Stackoverflow.com/users/99268/" ]
I'd like to add to Natrium's answer that generic collections also support this .ToArray() method. ``` List<string> stringList = new List<string>(); stringList.Add("1"); stringList.Add("2"); stringList.Add("3"); string[] stringArray = stringList.ToArray(); ```
First make an arraylist. Add/remove items. And then `ArrayList.ToArray()` And there is your array!
881,133
How can I dynamically create an array in C#?
2009/05/19
[ "https://Stackoverflow.com/questions/881133", "https://Stackoverflow.com", "https://Stackoverflow.com/users/99268/" ]
First make an arraylist. Add/remove items. And then `ArrayList.ToArray()` And there is your array!
Use generic List or ArrayList.
40,675,681
From an input string I would like to get rid of the non-alphanumeric characters (`:`, `-`, etc.) but maintain latin characters. Also replace the blank spaces `" "` with `"-"`. This is my try, but I dont know how to maintain the latin characters. ``` String title ="NEYÑO: HOW ARE YÓU MATE"; title = title.replaceAll("[...
2016/11/18
[ "https://Stackoverflow.com/questions/40675681", "https://Stackoverflow.com", "https://Stackoverflow.com/users/742269/" ]
Add `vertical-align: middle;` for `li` this will make the `div` to middle ```css .container { width: 800px; margin: 20px auto; } ul { list-style: none; margin: 0; padding: 0; text-align: center; } li { display: inline-block; margin-left: 15px; margin-right: 15px; vertical-align: middl...
Just use `vertical-align: middle;` for the `li` element too. ``` li { display: inline-block; margin-left: 15px; margin-right: 15px; vertical-align: middle; } ``` **[DEMO](https://jsfiddle.net/0bbboj29/1/)**
40,675,681
From an input string I would like to get rid of the non-alphanumeric characters (`:`, `-`, etc.) but maintain latin characters. Also replace the blank spaces `" "` with `"-"`. This is my try, but I dont know how to maintain the latin characters. ``` String title ="NEYÑO: HOW ARE YÓU MATE"; title = title.replaceAll("[...
2016/11/18
[ "https://Stackoverflow.com/questions/40675681", "https://Stackoverflow.com", "https://Stackoverflow.com/users/742269/" ]
You just need add these three css properties to ul...{align-items: center; justify-content: center; flex-wrap: wrap;} ```css .container { width: 800px; margin: 20px auto; } ul { list-style: none; margin: 0; padding: 0; text-align: center; display: flex; align-items: center; justify-conten...
Replace ``` li { display: inline-block; << margin-left: 15px; margin-right: 15px; } ``` with ``` li { display: block; << margin-left: 15px; margin-right: 15px; } ```
40,675,681
From an input string I would like to get rid of the non-alphanumeric characters (`:`, `-`, etc.) but maintain latin characters. Also replace the blank spaces `" "` with `"-"`. This is my try, but I dont know how to maintain the latin characters. ``` String title ="NEYÑO: HOW ARE YÓU MATE"; title = title.replaceAll("[...
2016/11/18
[ "https://Stackoverflow.com/questions/40675681", "https://Stackoverflow.com", "https://Stackoverflow.com/users/742269/" ]
Just use `vertical-align: middle;` for the `li` element too. ``` li { display: inline-block; margin-left: 15px; margin-right: 15px; vertical-align: middle; } ``` **[DEMO](https://jsfiddle.net/0bbboj29/1/)**
Replace ``` li { display: inline-block; << margin-left: 15px; margin-right: 15px; } ``` with ``` li { display: block; << margin-left: 15px; margin-right: 15px; } ```
40,675,681
From an input string I would like to get rid of the non-alphanumeric characters (`:`, `-`, etc.) but maintain latin characters. Also replace the blank spaces `" "` with `"-"`. This is my try, but I dont know how to maintain the latin characters. ``` String title ="NEYÑO: HOW ARE YÓU MATE"; title = title.replaceAll("[...
2016/11/18
[ "https://Stackoverflow.com/questions/40675681", "https://Stackoverflow.com", "https://Stackoverflow.com/users/742269/" ]
Add `vertical-align: middle;` for `li` this will make the `div` to middle ```css .container { width: 800px; margin: 20px auto; } ul { list-style: none; margin: 0; padding: 0; text-align: center; } li { display: inline-block; margin-left: 15px; margin-right: 15px; vertical-align: middl...
You just need add these three css properties to ul...{align-items: center; justify-content: center; flex-wrap: wrap;} ```css .container { width: 800px; margin: 20px auto; } ul { list-style: none; margin: 0; padding: 0; text-align: center; display: flex; align-items: center; justify-conten...
40,675,681
From an input string I would like to get rid of the non-alphanumeric characters (`:`, `-`, etc.) but maintain latin characters. Also replace the blank spaces `" "` with `"-"`. This is my try, but I dont know how to maintain the latin characters. ``` String title ="NEYÑO: HOW ARE YÓU MATE"; title = title.replaceAll("[...
2016/11/18
[ "https://Stackoverflow.com/questions/40675681", "https://Stackoverflow.com", "https://Stackoverflow.com/users/742269/" ]
You just need add these three css properties to ul...{align-items: center; justify-content: center; flex-wrap: wrap;} ```css .container { width: 800px; margin: 20px auto; } ul { list-style: none; margin: 0; padding: 0; text-align: center; display: flex; align-items: center; justify-conten...
You can achieve it with a simpler html structure as compared to above. Consider the following markup: ``` <ul class="container"> <li><img src="http://placehold.it/161x35"></li> <li><img src="http://placehold.it/162x75"></li> .... .... <li><img src="http://placehold.it/162x75"></li> </ul> ``` And use follow...
40,675,681
From an input string I would like to get rid of the non-alphanumeric characters (`:`, `-`, etc.) but maintain latin characters. Also replace the blank spaces `" "` with `"-"`. This is my try, but I dont know how to maintain the latin characters. ``` String title ="NEYÑO: HOW ARE YÓU MATE"; title = title.replaceAll("[...
2016/11/18
[ "https://Stackoverflow.com/questions/40675681", "https://Stackoverflow.com", "https://Stackoverflow.com/users/742269/" ]
Add `vertical-align: middle;` for `li` this will make the `div` to middle ```css .container { width: 800px; margin: 20px auto; } ul { list-style: none; margin: 0; padding: 0; text-align: center; } li { display: inline-block; margin-left: 15px; margin-right: 15px; vertical-align: middl...
only thing you will need is in code Snippest ```css li{ width : 200px; display : inline-block; vertical-align : middle; text-align : center; } ``` ```html <ul style="" align="center"> <li class="class-div"><img src="http://placehold.it/142x39"></img></div> <li class="class-div"><img src="http://p...
40,675,681
From an input string I would like to get rid of the non-alphanumeric characters (`:`, `-`, etc.) but maintain latin characters. Also replace the blank spaces `" "` with `"-"`. This is my try, but I dont know how to maintain the latin characters. ``` String title ="NEYÑO: HOW ARE YÓU MATE"; title = title.replaceAll("[...
2016/11/18
[ "https://Stackoverflow.com/questions/40675681", "https://Stackoverflow.com", "https://Stackoverflow.com/users/742269/" ]
Add `vertical-align: middle;` for `li` this will make the `div` to middle ```css .container { width: 800px; margin: 20px auto; } ul { list-style: none; margin: 0; padding: 0; text-align: center; } li { display: inline-block; margin-left: 15px; margin-right: 15px; vertical-align: middl...
You can achieve it with a simpler html structure as compared to above. Consider the following markup: ``` <ul class="container"> <li><img src="http://placehold.it/161x35"></li> <li><img src="http://placehold.it/162x75"></li> .... .... <li><img src="http://placehold.it/162x75"></li> </ul> ``` And use follow...
40,675,681
From an input string I would like to get rid of the non-alphanumeric characters (`:`, `-`, etc.) but maintain latin characters. Also replace the blank spaces `" "` with `"-"`. This is my try, but I dont know how to maintain the latin characters. ``` String title ="NEYÑO: HOW ARE YÓU MATE"; title = title.replaceAll("[...
2016/11/18
[ "https://Stackoverflow.com/questions/40675681", "https://Stackoverflow.com", "https://Stackoverflow.com/users/742269/" ]
You just need add these three css properties to ul...{align-items: center; justify-content: center; flex-wrap: wrap;} ```css .container { width: 800px; margin: 20px auto; } ul { list-style: none; margin: 0; padding: 0; text-align: center; display: flex; align-items: center; justify-conten...
only thing you will need is in code Snippest ```css li{ width : 200px; display : inline-block; vertical-align : middle; text-align : center; } ``` ```html <ul style="" align="center"> <li class="class-div"><img src="http://placehold.it/142x39"></img></div> <li class="class-div"><img src="http://p...
40,675,681
From an input string I would like to get rid of the non-alphanumeric characters (`:`, `-`, etc.) but maintain latin characters. Also replace the blank spaces `" "` with `"-"`. This is my try, but I dont know how to maintain the latin characters. ``` String title ="NEYÑO: HOW ARE YÓU MATE"; title = title.replaceAll("[...
2016/11/18
[ "https://Stackoverflow.com/questions/40675681", "https://Stackoverflow.com", "https://Stackoverflow.com/users/742269/" ]
Add `vertical-align: middle;` for `li` this will make the `div` to middle ```css .container { width: 800px; margin: 20px auto; } ul { list-style: none; margin: 0; padding: 0; text-align: center; } li { display: inline-block; margin-left: 15px; margin-right: 15px; vertical-align: middl...
Replace ``` li { display: inline-block; << margin-left: 15px; margin-right: 15px; } ``` with ``` li { display: block; << margin-left: 15px; margin-right: 15px; } ```
40,675,681
From an input string I would like to get rid of the non-alphanumeric characters (`:`, `-`, etc.) but maintain latin characters. Also replace the blank spaces `" "` with `"-"`. This is my try, but I dont know how to maintain the latin characters. ``` String title ="NEYÑO: HOW ARE YÓU MATE"; title = title.replaceAll("[...
2016/11/18
[ "https://Stackoverflow.com/questions/40675681", "https://Stackoverflow.com", "https://Stackoverflow.com/users/742269/" ]
Just use `vertical-align: middle;` for the `li` element too. ``` li { display: inline-block; margin-left: 15px; margin-right: 15px; vertical-align: middle; } ``` **[DEMO](https://jsfiddle.net/0bbboj29/1/)**
You can achieve it with a simpler html structure as compared to above. Consider the following markup: ``` <ul class="container"> <li><img src="http://placehold.it/161x35"></li> <li><img src="http://placehold.it/162x75"></li> .... .... <li><img src="http://placehold.it/162x75"></li> </ul> ``` And use follow...
34,030,873
I would like to know how to do an equivalent of the range function in python, but with the ability to specify the base number. For example: ``` countUp(start=0, end=1010, base=2) countUp(start=0, end=101, base=3) countUp(start=0, end=22, base=4) ``` Example output for base 2 counting: ``` [0, 1, 10, 11, 100, ...] ...
2015/12/01
[ "https://Stackoverflow.com/questions/34030873", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4468084/" ]
You can do it with a custom iterator: I took the iterater code from [here](https://stackoverflow.com/a/24377/4194964) and the base conversion from [here](https://stackoverflow.com/a/2267446/4194964) ``` import string class BaseRange: def __init__(self, low, high, base): digs = string.digits + string.lette...
You can not crate integers with special based, but you can create your expected numbers in a specified base in string : ``` def my_range(start,end,base,step=1): def Convert(n,base): string = "0123456789ABCDEF" if n < base: return string[n] else: return Convert(n//base,base...
34,030,873
I would like to know how to do an equivalent of the range function in python, but with the ability to specify the base number. For example: ``` countUp(start=0, end=1010, base=2) countUp(start=0, end=101, base=3) countUp(start=0, end=22, base=4) ``` Example output for base 2 counting: ``` [0, 1, 10, 11, 100, ...] ...
2015/12/01
[ "https://Stackoverflow.com/questions/34030873", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4468084/" ]
You are apparently confusing numbers with the representation of numbers. A number does not have a base... it's the number **representation** that has a base... for example the number represented as "101" in base 2 is the same as the number represented with "5" in base 10. The `range` function will count successive nu...
You can not crate integers with special based, but you can create your expected numbers in a specified base in string : ``` def my_range(start,end,base,step=1): def Convert(n,base): string = "0123456789ABCDEF" if n < base: return string[n] else: return Convert(n//base,base...
34,030,873
I would like to know how to do an equivalent of the range function in python, but with the ability to specify the base number. For example: ``` countUp(start=0, end=1010, base=2) countUp(start=0, end=101, base=3) countUp(start=0, end=22, base=4) ``` Example output for base 2 counting: ``` [0, 1, 10, 11, 100, ...] ...
2015/12/01
[ "https://Stackoverflow.com/questions/34030873", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4468084/" ]
You can not crate integers with special based, but you can create your expected numbers in a specified base in string : ``` def my_range(start,end,base,step=1): def Convert(n,base): string = "0123456789ABCDEF" if n < base: return string[n] else: return Convert(n//base,base...
You could do this with the itertools [product](https://docs.python.org/3/library/itertools.html#itertools.product) function. ```py from itertools import product def countUp(start, end, base): n_digits = len(end) combs = product(*[range(base)] * n_digits) while (n := next(combs)) <= end: yield n l...
34,030,873
I would like to know how to do an equivalent of the range function in python, but with the ability to specify the base number. For example: ``` countUp(start=0, end=1010, base=2) countUp(start=0, end=101, base=3) countUp(start=0, end=22, base=4) ``` Example output for base 2 counting: ``` [0, 1, 10, 11, 100, ...] ...
2015/12/01
[ "https://Stackoverflow.com/questions/34030873", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4468084/" ]
You can do it with a custom iterator: I took the iterater code from [here](https://stackoverflow.com/a/24377/4194964) and the base conversion from [here](https://stackoverflow.com/a/2267446/4194964) ``` import string class BaseRange: def __init__(self, low, high, base): digs = string.digits + string.lette...
You could do this with the itertools [product](https://docs.python.org/3/library/itertools.html#itertools.product) function. ```py from itertools import product def countUp(start, end, base): n_digits = len(end) combs = product(*[range(base)] * n_digits) while (n := next(combs)) <= end: yield n l...
34,030,873
I would like to know how to do an equivalent of the range function in python, but with the ability to specify the base number. For example: ``` countUp(start=0, end=1010, base=2) countUp(start=0, end=101, base=3) countUp(start=0, end=22, base=4) ``` Example output for base 2 counting: ``` [0, 1, 10, 11, 100, ...] ...
2015/12/01
[ "https://Stackoverflow.com/questions/34030873", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4468084/" ]
You are apparently confusing numbers with the representation of numbers. A number does not have a base... it's the number **representation** that has a base... for example the number represented as "101" in base 2 is the same as the number represented with "5" in base 10. The `range` function will count successive nu...
You could do this with the itertools [product](https://docs.python.org/3/library/itertools.html#itertools.product) function. ```py from itertools import product def countUp(start, end, base): n_digits = len(end) combs = product(*[range(base)] * n_digits) while (n := next(combs)) <= end: yield n l...
4,850
I've read various pieces arguing that the USA is not a democracy, but a (fill in the blank, ex., a Republic). Perhaps there is no perfect fit, but **which form of government does the USA most closely match?**
2014/09/13
[ "https://politics.stackexchange.com/questions/4850", "https://politics.stackexchange.com", "https://politics.stackexchange.com/users/4459/" ]
The definition of democracy varies, but for most definitions used, **yes, the USA is a democracy.** Wikipedia's article on [Liberal Democracy](http://en.wikipedia.org/wiki/Liberal_democracy) defines a liberal democracy as follows: > > It is characterised by fair, free, and competitive elections between multiple dis...
The United States is a **[Representational Democracy](http://en.wikipedia.org/wiki/Representative_democracy)**. The people have no direct say in government, but have the ability to freely vote for those who *do* have direct say (the people's representatives). This is contrast to a Direct Democracy (which is also somet...
4,850
I've read various pieces arguing that the USA is not a democracy, but a (fill in the blank, ex., a Republic). Perhaps there is no perfect fit, but **which form of government does the USA most closely match?**
2014/09/13
[ "https://politics.stackexchange.com/questions/4850", "https://politics.stackexchange.com", "https://politics.stackexchange.com/users/4459/" ]
The definition of democracy varies, but for most definitions used, **yes, the USA is a democracy.** Wikipedia's article on [Liberal Democracy](http://en.wikipedia.org/wiki/Liberal_democracy) defines a liberal democracy as follows: > > It is characterised by fair, free, and competitive elections between multiple dis...
You cannot counter-posite democracy to a republic. Republic is a well-defined form of state. As such, the US is republic. Democracy is a form of government. There can be various degree of democracy and various opinions on what practice is more democratic.
4,850
I've read various pieces arguing that the USA is not a democracy, but a (fill in the blank, ex., a Republic). Perhaps there is no perfect fit, but **which form of government does the USA most closely match?**
2014/09/13
[ "https://politics.stackexchange.com/questions/4850", "https://politics.stackexchange.com", "https://politics.stackexchange.com/users/4459/" ]
The United States is a **[Representational Democracy](http://en.wikipedia.org/wiki/Representative_democracy)**. The people have no direct say in government, but have the ability to freely vote for those who *do* have direct say (the people's representatives). This is contrast to a Direct Democracy (which is also somet...
You cannot counter-posite democracy to a republic. Republic is a well-defined form of state. As such, the US is republic. Democracy is a form of government. There can be various degree of democracy and various opinions on what practice is more democratic.
38,793,472
I have a hidden field where the question\_id is unique. I am trying to get that hidden field within jquery from the next page so that I can post a message of the form status. Then I will put that status in the HTML at the bottom of the form that was submitted. form.php ``` <!doctype html> <html lang="en"> <head> ...
2016/08/05
[ "https://Stackoverflow.com/questions/38793472", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
`[` is actually a binary, not just some punctuation: ``` $ ls -l /usr/bin/[ -rwxr-xr-x 1 root root 51920 Feb 18 07:37 /usr/bin/[ $ /usr/bin/[ --version [ (GNU coreutils) 8.25 Copyright (C) 2016 Free Software Foundation, Inc. ``` and on some systems may be a symlink to `test`. So here ``` if [ $? -gt 0 ] ``` `$?`...
You should rarely need to examine `$?` explicitly anyway, since doing that is the purpose of `if` (and other conditional builtins like `while`). The proper way to write that is ``` if ls /sdfg; then echo "Command succeeded: $?" else echo "Command failed: $?" fi ``` Notice how the failure case is now the `els...
38,793,472
I have a hidden field where the question\_id is unique. I am trying to get that hidden field within jquery from the next page so that I can post a message of the form status. Then I will put that status in the HTML at the bottom of the form that was submitted. form.php ``` <!doctype html> <html lang="en"> <head> ...
2016/08/05
[ "https://Stackoverflow.com/questions/38793472", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
`[` is actually a binary, not just some punctuation: ``` $ ls -l /usr/bin/[ -rwxr-xr-x 1 root root 51920 Feb 18 07:37 /usr/bin/[ $ /usr/bin/[ --version [ (GNU coreutils) 8.25 Copyright (C) 2016 Free Software Foundation, Inc. ``` and on some systems may be a symlink to `test`. So here ``` if [ $? -gt 0 ] ``` `$?`...
Collect the return value **immediately** after the command being tested if you're going to reuse it: ``` #!/bin/bash # best-practice: collect *on the same line*, so any logging added in the future doesn't # ...change your exit status. ls /sdfg; retval=$? if [ $retval -gt 0 ]; then echo "Command failed: $retv...
38,793,472
I have a hidden field where the question\_id is unique. I am trying to get that hidden field within jquery from the next page so that I can post a message of the form status. Then I will put that status in the HTML at the bottom of the form that was submitted. form.php ``` <!doctype html> <html lang="en"> <head> ...
2016/08/05
[ "https://Stackoverflow.com/questions/38793472", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
You should rarely need to examine `$?` explicitly anyway, since doing that is the purpose of `if` (and other conditional builtins like `while`). The proper way to write that is ``` if ls /sdfg; then echo "Command succeeded: $?" else echo "Command failed: $?" fi ``` Notice how the failure case is now the `els...
Collect the return value **immediately** after the command being tested if you're going to reuse it: ``` #!/bin/bash # best-practice: collect *on the same line*, so any logging added in the future doesn't # ...change your exit status. ls /sdfg; retval=$? if [ $retval -gt 0 ]; then echo "Command failed: $retv...
25,113,495
So I have a web application developed in Ruby on Rails 4.0 and accessible on my local PC via localhost:3000 (after I start the rails server by running `rails s` in cmd at the root of the app). It is of moderate complexity, has DB interaction (I use PostgreSQL) etc. Now, the application has zero utility unless I can ma...
2014/08/04
[ "https://Stackoverflow.com/questions/25113495", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3436063/" ]
If the app is available at `localhost:3000` than it should also be available via `1.1.34.45:3000`. Assuming Port `3000` is open on your local PC and `1.1.34.45` is your current IP address within your local network. Note that a Webbrick server is not really something you want to use in production. But for tests it migh...
Maybe you will find usefull proxylocal gem. "ProxyLocal could proxy your local web-server and make it publicly available over the internet." [Official site](http://proxylocal.com)
25,113,495
So I have a web application developed in Ruby on Rails 4.0 and accessible on my local PC via localhost:3000 (after I start the rails server by running `rails s` in cmd at the root of the app). It is of moderate complexity, has DB interaction (I use PostgreSQL) etc. Now, the application has zero utility unless I can ma...
2014/08/04
[ "https://Stackoverflow.com/questions/25113495", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3436063/" ]
If the app is available at `localhost:3000` than it should also be available via `1.1.34.45:3000`. Assuming Port `3000` is open on your local PC and `1.1.34.45` is your current IP address within your local network. Note that a Webbrick server is not really something you want to use in production. But for tests it migh...
To make a development app available for use within a firewalled business environment, consider using the heroku tools, especially "foreman". You can configure foreman to use a faster web server (unicorn is a good choice, IMO), to run on port 3000 or 500 or whatever... But foreman will then need to stay running, until y...
17,545,933
*There is a corresponding VS dev ticket <https://connect.microsoft.com/VisualStudio/feedback/details/817276/error-cs0012-the-type-is-defined-in-an-assembly-that-is-not-referenced-issued-for-an-extension-method-that-is-not-used>* I have 2 extension methods: ``` public static class ExtensionMethods { public static ...
2013/07/09
[ "https://Stackoverflow.com/questions/17545933", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2528649/" ]
From C# 5.0 spec, section 7.5.3: > > Given the set of applicable candidate function members, the best function member in that set is located. If the set contains only one function member, then that function member is the best function member. Otherwise, the best function member is the one function member that is bett...
I also made a simple test without extension methods and got the same effect. As Damien\_The\_Unbeliever said, the issue is related to method overloading only.
23,265,855
Are there any benefits in using the new Stream API for simple iterations? Without Stream API: ``` for (Map.Entry<String, String> entry : map.entrySet()) { doSomething(entry); } ``` Using Stream API: ``` map.entrySet().stream().forEach((entry) -> { doSomething(entry); }); ``` Length and r...
2014/04/24
[ "https://Stackoverflow.com/questions/23265855", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1143117/" ]
The Streams API makes parallelism much easier to accomplish (although you'll only see the benefit with a large sized collection). If you had to implement parallelism on your first example then there would be a sizeable difference in the amount of code (as opposed to adding .parallelStream() to the second example) As p...
You had asked about Streams, but as skiwi's comment noted, passing a lambda to the `forEach` default method on Map possibly fills the bill if the iteration is simple and doesn't require parallelism or any additional logic. Assuming that `doSomething` can be refactored to take separate key and value args instead of a `M...
55,780,173
I was looking into BFS search code provide in [here](https://www.geeksforgeeks.org/breadth-first-search-or-bfs-for-a-graph/): ``` // Program to print BFS traversal from a given // source vertex. BFS(int s) traverses vertices // reachable from s. #include<iostream> #include <list> using namespace std; // This ...
2019/04/21
[ "https://Stackoverflow.com/questions/55780173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9875090/" ]
This is a perfect use case for callbacks and the observer pattern. Your master process should produce beat events, and trigger functions that are waiting for them. You can use a framework for message busses that helps you with this, or you could even use a function that gets a promise for the next beat to occur from ...
You could have a Boolean to decide if nar() should be called each time that foo() is executed and have bar() set the Boolean to true when the function needs to run. ```js let runNar = false; (function foo() { setTimeout(function() { if (runNar === true) { nar(); runNar = false; } console.log('foo c...
55,780,173
I was looking into BFS search code provide in [here](https://www.geeksforgeeks.org/breadth-first-search-or-bfs-for-a-graph/): ``` // Program to print BFS traversal from a given // source vertex. BFS(int s) traverses vertices // reachable from s. #include<iostream> #include <list> using namespace std; // This ...
2019/04/21
[ "https://Stackoverflow.com/questions/55780173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9875090/" ]
This is a perfect use case for callbacks and the observer pattern. Your master process should produce beat events, and trigger functions that are waiting for them. You can use a framework for message busses that helps you with this, or you could even use a function that gets a promise for the next beat to occur from ...
It can be solved using Promises too, but I think there are better solutions: Using [`setter`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/set)s or the [`Proxy`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy)! ### How does it work? * **Setter:...
26,719,598
I'm writing a program in Visual Basic about Databases. Now I have a Sub/Function who searches the database for correct inputs. I have five text boxes where the user can put in something for each data field. ``` If txtBox1.Text <> "" Or txtBox2.Text <> "" Or txtBox3.Text <> "" Or txtBox4.Text <> "" Or txtBox5.Text <> "...
2014/11/03
[ "https://Stackoverflow.com/questions/26719598", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2102106/" ]
Your problem is that your query always uses all the conditions also when there is no input in the relevant textboxes. In this way your LIKEs become `LIKE '%%'` and, of course, this matches every record. You need to add the conditions only if the textboxes are not empty or null. So you need to build your query in p...
I hope I understand your problem correctly. I am sure there are better ways to do this and my VB is rusty but something like this may work ``` Dim query As String = "SELECT * FROM lager" Function addField (ByVal query As String, ByVal value as String, ByVal field as String) As String addField = query If value <> ...
8,279,605
I've been reading [Code Complete 2](https://rads.stackoverflow.com/amzn/click/com/0735619670). As I am not native english speaker some statements take some time for me to understand. I would like you to describe the difference between these two statements the author made in his book: > > 1. You should program into Yo...
2011/11/26
[ "https://Stackoverflow.com/questions/8279605", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44852/" ]
Program **into** your language means that you *use* the language to construct the "missing" pieces - leverage it to do more than it currently does. Things like creating missing data structure, algorithms and ways of accomplishing tasks that are not native to the language. Program **in** your language means just that -...
The author provides an example of his own in that part of the book (which unfortunately I don't remember). You can try reading a bit further. It means that even if the language doesn't support a particularly convenient feature, as you should always think of writing readable, easy to maintain, modular code, you should ...
8,279,605
I've been reading [Code Complete 2](https://rads.stackoverflow.com/amzn/click/com/0735619670). As I am not native english speaker some statements take some time for me to understand. I would like you to describe the difference between these two statements the author made in his book: > > 1. You should program into Yo...
2011/11/26
[ "https://Stackoverflow.com/questions/8279605", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44852/" ]
As I understand it, it means to think outside of the bounds of your programming language. So **in** means you are thinking in terms of the language, so your thinking is limited by the language itself, and the program you write may not be easily translated into some other language if needed. But **into** means you thi...
The author provides an example of his own in that part of the book (which unfortunately I don't remember). You can try reading a bit further. It means that even if the language doesn't support a particularly convenient feature, as you should always think of writing readable, easy to maintain, modular code, you should ...
19,989,127
I am trying to convert string like this: ``` {"Shops":[ {"city":"Riga","shops":[{"a":"some info here","b":"...","c":"..."},{"a":"some info here","b":"...","c":"..."}]},{"city":"Liepaja","shops":[{"a":"info here","b":"info....","c":"..."}] ]} ``` to 2d array, like ``` shops[0][0]=>{"a":"some info here","b":"...","c"...
2013/11/14
[ "https://Stackoverflow.com/questions/19989127", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2938190/" ]
That is a [JSON](http://www.json.org/) string. There are a number of libraries that will do this for you. * [JSON in Java](http://json.org/java/) * [GSON](https://code.google.com/p/google-gson/)
That looks like JSON data, and you should treat it as such. Try a JSON parsing library for Java. I like [GSON](http://code.google.com/p/google-gson/) for its simplicity. Take a look at the Gson.fromJson() set of methods.
19,989,127
I am trying to convert string like this: ``` {"Shops":[ {"city":"Riga","shops":[{"a":"some info here","b":"...","c":"..."},{"a":"some info here","b":"...","c":"..."}]},{"city":"Liepaja","shops":[{"a":"info here","b":"info....","c":"..."}] ]} ``` to 2d array, like ``` shops[0][0]=>{"a":"some info here","b":"...","c"...
2013/11/14
[ "https://Stackoverflow.com/questions/19989127", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2938190/" ]
That is a [JSON](http://www.json.org/) string. There are a number of libraries that will do this for you. * [JSON in Java](http://json.org/java/) * [GSON](https://code.google.com/p/google-gson/)
The type of data you have posted is JSON encoded. you could use a [json encoder and decoder](http://code.google.com/p/json-simple/) to do this job easily.
18,957,232
I have two element-level directives, a search box and a search results. My markup is something like this (simplified): ``` <catalogue-search-box query="{{query}}"> <catalogue-search-results></catalogue-search-results> ``` I'm trying to access the search box controller from the search results directive, but the docum...
2013/09/23
[ "https://Stackoverflow.com/questions/18957232", "https://Stackoverflow.com", "https://Stackoverflow.com/users/703951/" ]
After you comments here is how I would do it: use an object to hold all your state and pass it to both directives. [Demo plunker](http://plnkr.co/edit/KSsavZ7Hi9yOWezLuAIC?p=preview) **HTML** ``` <body ng-controller="MySearchController"> <search-box search="mySearch"></search-box> <search-results search="mySearch...
One way I've been experimenting with since the question is having some kind of controller directive i.e. ``` <catalogue-search> <catalogue-search-box query="{{query}}"> <catalogue-search-results></catalogue-search-results> </catalogue-search> ``` I can then access the "controller directive" this using the pa...