qid
int64
1
74.7M
question
stringlengths
15
58.3k
date
stringlengths
10
10
metadata
list
response_j
stringlengths
4
30.2k
response_k
stringlengths
11
36.5k
33,551,559
I want to ignore the punctuation.So, I'm trying to make a program that counts all the appearences of every word in my text but without taking in consideration the punctuation marks. So my program is: ``` static void Main(string[] args) { string text = "This my world. World, world,THIS WORLD ! Is this - th...
2015/11/05
[ "https://Stackoverflow.com/questions/33551559", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
``` string[] words = text.Split(new char[]{' ',',','-','!','.'}, StringSplitOPtions.RemoveEmptyItems); ```
... you can go with the making people cry version ... ``` "This my world. World, world,THIS WORLD ! Is this - the world ." .ToLower() .Split(" ,-!.".ToCharArray(), StringSplitOptions.RemoveEmptyEntries) .GroupBy(i => i) .Select(i=>new{Word=i.Key, Count = i.Count()}) .OrderBy(k => k.Count) .ToLi...
33,551,559
I want to ignore the punctuation.So, I'm trying to make a program that counts all the appearences of every word in my text but without taking in consideration the punctuation marks. So my program is: ``` static void Main(string[] args) { string text = "This my world. World, world,THIS WORLD ! Is this - th...
2015/11/05
[ "https://Stackoverflow.com/questions/33551559", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
You should try specifying `StringSplitOptions.RemoveEmptyEntries`: ``` string[] words = text.Split(" ,-!.".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); ``` Note that instead of manually creating a `char[]` with all the punctuation characters, you may create a `string` and call `ToCharArray()` to get the ar...
... you can go with the making people cry version ... ``` "This my world. World, world,THIS WORLD ! Is this - the world ." .ToLower() .Split(" ,-!.".ToCharArray(), StringSplitOptions.RemoveEmptyEntries) .GroupBy(i => i) .Select(i=>new{Word=i.Key, Count = i.Count()}) .OrderBy(k => k.Count) .ToLi...
105,277
Sibling of mine asked me to open an bank account for her in my name. She wants to fill it with her savings and use it on day-to-day basis with a debit card. I have a strong feeling this could backfire against me. What are the risks I could run in to if I did this? --- I am looking for possible risks as if there were...
2019/02/13
[ "https://money.stackexchange.com/questions/105277", "https://money.stackexchange.com", "https://money.stackexchange.com/users/-1/" ]
There are several risks to you. 1. Depending on the details of the arrangement, you might be liable for income tax on the money apparently "given" to you, and your sibling might be liable for income tax on the money you apparently "give" to them. 2. If the bank find out that you have given her "your" debit card to use...
You edited out the part of you assisting your sister in hiding money from the court. Read your original post out loud to yourself three times. Now what do you think? Of course it is a bad idea, and you should say "sorry sis, I am not going to help you break the law". This would hold true even if you are beyond the j...
105,277
Sibling of mine asked me to open an bank account for her in my name. She wants to fill it with her savings and use it on day-to-day basis with a debit card. I have a strong feeling this could backfire against me. What are the risks I could run in to if I did this? --- I am looking for possible risks as if there were...
2019/02/13
[ "https://money.stackexchange.com/questions/105277", "https://money.stackexchange.com", "https://money.stackexchange.com/users/-1/" ]
You edited out the part of you assisting your sister in hiding money from the court. Read your original post out loud to yourself three times. Now what do you think? Of course it is a bad idea, and you should say "sorry sis, I am not going to help you break the law". This would hold true even if you are beyond the j...
Even if this was not fraudulent for external (a priori) reasons, the mere act of opening an account under your name in order to hide the true beneficiary is already money laundering and therefore fraud in its own right. So, even if it were not explicitly against the bank's T&Cs (as Vicky answered), they could still c...
105,277
Sibling of mine asked me to open an bank account for her in my name. She wants to fill it with her savings and use it on day-to-day basis with a debit card. I have a strong feeling this could backfire against me. What are the risks I could run in to if I did this? --- I am looking for possible risks as if there were...
2019/02/13
[ "https://money.stackexchange.com/questions/105277", "https://money.stackexchange.com", "https://money.stackexchange.com/users/-1/" ]
There are several risks to you. 1. Depending on the details of the arrangement, you might be liable for income tax on the money apparently "given" to you, and your sibling might be liable for income tax on the money you apparently "give" to them. 2. If the bank find out that you have given her "your" debit card to use...
Even if this was not fraudulent for external (a priori) reasons, the mere act of opening an account under your name in order to hide the true beneficiary is already money laundering and therefore fraud in its own right. So, even if it were not explicitly against the bank's T&Cs (as Vicky answered), they could still c...
9,203,191
I've recently read the news on <http://allseeing-i.com> that ASIHTTP is being discontinued. I have much respect for the makers of the library. However, I am now looking for a substitute that also supports queued download (multithreaded) on iOS, that also supports a progress bar with appropriate information. Is there a...
2012/02/08
[ "https://Stackoverflow.com/questions/9203191", "https://Stackoverflow.com", "https://Stackoverflow.com/users/624459/" ]
[AFNetworking](https://github.com/AFNetworking/AFNetworking) is being lauded as a successor to ASIHTTPRequest. It is based on operation queues, and in my experience it works reasonably well. You could probably do what you want to do without a third-party library, but if you want to make it a little easier on yourself, ...
I wrote one recently. It's fully ARC compliant and fairly lightweight: <https://github.com/nicklockwood/RequestQueue> As of version 1.2 it supports download and upload progress bars (see the included ProgressLoader example). Rather than make a monolithic framework like ASI, I've tried to keep this as simple as possi...
9,203,191
I've recently read the news on <http://allseeing-i.com> that ASIHTTP is being discontinued. I have much respect for the makers of the library. However, I am now looking for a substitute that also supports queued download (multithreaded) on iOS, that also supports a progress bar with appropriate information. Is there a...
2012/02/08
[ "https://Stackoverflow.com/questions/9203191", "https://Stackoverflow.com", "https://Stackoverflow.com/users/624459/" ]
You may want to look at [MKNetworkKit](https://github.com/MugunthKumar/MKNetworkKit). In its words: > > MKNetworkKit's goal was to make it as feature rich as ASIHTTPRequest yet simple and elegant to use like AFNetworking > > > It has a number of very nice features for queuing and managing offline situations.
I wrote one recently. It's fully ARC compliant and fairly lightweight: <https://github.com/nicklockwood/RequestQueue> As of version 1.2 it supports download and upload progress bars (see the included ProgressLoader example). Rather than make a monolithic framework like ASI, I've tried to keep this as simple as possi...
3,654,960
$$\frac{2bc\cos A + ac\cos B +2ab \cos C}{abc}= \frac{a^2+b^2}{abc}$$ $$b^2+c^2-a^2+a^2+b^2-c^2+ac\cos B =a^2+b^2$$ $$ac\ cos B = a^2-b^2$$ How do I find angle $A$ from here?
2020/05/02
[ "https://math.stackexchange.com/questions/3654960", "https://math.stackexchange.com", "https://math.stackexchange.com/users/690228/" ]
By the Cosine Rule, $2ac \cos B = a^2 + c^2 - b^2$, so from your equation above ($ac \cos B = a^2-b^2$), we obtain \begin{equation\*}a^2 + c^2 - b^2 = 2(a^2-b^2)\end{equation\*} and thus \begin{equation\*}c^2 = a^2-b^2\end{equation\*} This can be rewritten as $b^2 + c^2 - a^2 = 0$, so by the Cosine Rule again, $\cos A ...
Use [Law of sines](https://en.wikipedia.org/wiki/Law_of_sines) then [Prove $ \sin(A+B)\sin(A-B)=\sin^2A-\sin^2B $](https://math.stackexchange.com/questions/175143/prove-sinab-sina-b-sin2a-sin2b) Observe that as $0<A,B,C<\pi, \sin A,\sin B,\sin C>0$ and finally use $\sin(A+B)=\cdots=\sin C$ to find $$\sin B\cos A=0\...
4,537,130
My attempt so far: Base case: $2^{3!}>3^{3}$ $2^6 > 27$ $64> 27$ Then going for $2^{(n+1)!} > (n+1)^{(n+1)}$ I get $(2^{(n!)})^{(n+1)} > (n+1)^{(n+1)}$ Since n+1 is positive, $2^{n!} > n+1$ And I do not go where to go from here. I am unsure if I am following the correct path. Am I approaching this in the cor...
2022/09/23
[ "https://math.stackexchange.com/questions/4537130", "https://math.stackexchange.com", "https://math.stackexchange.com/users/1098962/" ]
We're trying to prove $2^{n!} > n^n$. You've shown that the base case holds - great. In an induction proof you assume that the statement holds for an arbitrary $k$, and then you have to show it holds for $k+1$ *dependent* on it holding for $k$. $2^{(k+1)!} = 2^{(k+1)k!} = (2^{k!})^{k+1}$ Now we have to remember that...
Essentially the solution above is right. I'll give the same but with an extra. **BC (Base case)** You've already proven this. **IH (Induction Hypothesis)** Suppose for some integer $m \ge 3$ that $$ 2^{m!} > m^{m}$$ You can notice now, that $$ 2^{m!} > m^{m} > m+m > m+1 $$ And thus, $2^{m!} > m+1 $. Finally, if...
2,761
I know that as a tourist, some department store will do tax refund for foreigners when you show them your passport. But this time I will be going as with a Working Holiday Visa, not visitor visa. Will I still be eligible to get the tax refund for foreigners?
2014/08/16
[ "https://expatriates.stackexchange.com/questions/2761", "https://expatriates.stackexchange.com", "https://expatriates.stackexchange.com/users/2255/" ]
As per the current tax free shopping regulations, visitors with a temporary stay status are eligible for tax-free shopping. * Japanese citizens are not eligible. * Not eligible if you are working in Japan. * Not eligible if staying in Japan more than six months. If you have a working holiday visa, I imagine you are w...
No, tax-free shopping is only available to foreign citizens whose status of residence is "temporary visitor". Your status will not be "temporary visitor" (it will probably be "designated activities").
54,835,339
I am using Xamarin.Forms to create a data collection application. One particular feature of this app is to export the data via csv. When captured the data is written to a text file using the following method: ``` public void WriteToFile(string CompanyName, string Website, string FirsttName, string LastName, string Jo...
2019/02/22
[ "https://Stackoverflow.com/questions/54835339", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11103719/" ]
To escape comma warp each column in double quotes, to scape double qoutes use 2 double qoutes instead of each: ``` string lineToBeAdded = string.Format("\"{0}\",\"{1}\",\"{2}\",\"{3}\",\"{4}\",\"{5}\",\"{6}\",\"{7}\",\"{8}\",\"{9}\",\"{10}\"", CompanyName.Replace("\"","\"\""), Website.Replace("\"","\"\""), FirsttN...
Also you don't have to use comma's, you can use a | or something else the user doesn't use. To make it even more friendly you can specify the delimiter in the first line, excel supports that I know. ``` sep=| header1|header2|header3 1,2|2,3|3,4 ```
54,835,339
I am using Xamarin.Forms to create a data collection application. One particular feature of this app is to export the data via csv. When captured the data is written to a text file using the following method: ``` public void WriteToFile(string CompanyName, string Website, string FirsttName, string LastName, string Jo...
2019/02/22
[ "https://Stackoverflow.com/questions/54835339", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11103719/" ]
Solution -------- Create this function: ``` string GetCsvLine(params string[] fields) => string.Join(",", fields.Select(x => $"\"{x.Replace("\"", "\"\"")}\"")); ``` And call it like this, replacing the line in your example code that initializes "lineToBeAdded": ``` string lineToBeAdded = GetCsvLine(CompanyName,...
Also you don't have to use comma's, you can use a | or something else the user doesn't use. To make it even more friendly you can specify the delimiter in the first line, excel supports that I know. ``` sep=| header1|header2|header3 1,2|2,3|3,4 ```
41,781,807
I am trying to get the counts of items in a database to confirm that data insertion is successful. 1. Get count before insert 2. Insert 3. Get count after insert 4. Console.log a summary Note: I know this can be implemented using some simple functions: ``` dbName.equal(insertSize, result.insertedCount) ``` However...
2017/01/21
[ "https://Stackoverflow.com/questions/41781807", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5109242/" ]
In general the problem you have is that you expect the value to be already there when your functions return. Well with async functions this is often not the case. There is a huge amount of information about async processing (not to be mistaken with parallel processing like in Java). I have created an example which sho...
The reason why the returns are occurring before the operations have completed is the `asynchronous` design of nodejs, inherited from javascript. The callback from `Mongoose.connect()` is left to do the operation while the program moves forward and encounters the `return`. You have not provided your workaround which la...
13,160
I am filtering a VEP annotated vcf, trying to maintain just those variants classified as deleterious by `SIFT`and as damaging (probably or possibly included) by `PolyPhen`. I am using: ``` filter_vep -i "$input" -o "$output" -filter "SIFT = deleterious and PolyPhen match damaging" ``` and I also tried: ``` filter_...
2020/05/01
[ "https://bioinformatics.stackexchange.com/questions/13160", "https://bioinformatics.stackexchange.com", "https://bioinformatics.stackexchange.com/users/8631/" ]
I think what you're trying to do could be achieved by adding parenthesis to the conditions and by specifying the format of the input file by using the flag `--format vcf`, as specified in the [documentation](https://www.ensembl.org/info/docs/tools/vep/script/vep_filter.html). The final command should look like this: `...
If you are working under a Linux environment, then you may easily use a piped grep search. For example: ``` grep deleterious file.vcf |grep damaging >filtered_file.vcf ```
13,160
I am filtering a VEP annotated vcf, trying to maintain just those variants classified as deleterious by `SIFT`and as damaging (probably or possibly included) by `PolyPhen`. I am using: ``` filter_vep -i "$input" -o "$output" -filter "SIFT = deleterious and PolyPhen match damaging" ``` and I also tried: ``` filter_...
2020/05/01
[ "https://bioinformatics.stackexchange.com/questions/13160", "https://bioinformatics.stackexchange.com", "https://bioinformatics.stackexchange.com/users/8631/" ]
Here is another way to achieve your goal using the `fuc vcf_vep` [command](https://sbslee-fuc.readthedocs.io/en/latest/cli.html#vcf-vep) I wrote: ``` $ fuc vcf_vep in.vcf 'SIFT.str.contains("deleterious") and PolyPhen.str.contains("damaging")' > out.vcf ``` For getting help: ``` $ fuc vcf_vep -h usage: fuc vcf_vep ...
If you are working under a Linux environment, then you may easily use a piped grep search. For example: ``` grep deleterious file.vcf |grep damaging >filtered_file.vcf ```
13,160
I am filtering a VEP annotated vcf, trying to maintain just those variants classified as deleterious by `SIFT`and as damaging (probably or possibly included) by `PolyPhen`. I am using: ``` filter_vep -i "$input" -o "$output" -filter "SIFT = deleterious and PolyPhen match damaging" ``` and I also tried: ``` filter_...
2020/05/01
[ "https://bioinformatics.stackexchange.com/questions/13160", "https://bioinformatics.stackexchange.com", "https://bioinformatics.stackexchange.com/users/8631/" ]
I think what you're trying to do could be achieved by adding parenthesis to the conditions and by specifying the format of the input file by using the flag `--format vcf`, as specified in the [documentation](https://www.ensembl.org/info/docs/tools/vep/script/vep_filter.html). The final command should look like this: `...
Here is another way to achieve your goal using the `fuc vcf_vep` [command](https://sbslee-fuc.readthedocs.io/en/latest/cli.html#vcf-vep) I wrote: ``` $ fuc vcf_vep in.vcf 'SIFT.str.contains("deleterious") and PolyPhen.str.contains("damaging")' > out.vcf ``` For getting help: ``` $ fuc vcf_vep -h usage: fuc vcf_vep ...
136,585
I just read: [What is the best site to ask Facebook questions?](https://meta.stackexchange.com/questions/136560/what-is-the-best-stack-to-ask-facebook-questions) Thanks to gobernador, I just learned that SO has a site for Facebook. This butts up to: [WordPress Answers or Stack Overflow?](https://meta.stackexchange.com/...
2012/06/18
[ "https://meta.stackexchange.com/questions/136585", "https://meta.stackexchange.com", "https://meta.stackexchange.com/users/183974/" ]
For *programming* questions about Facebook, you can ask on <http://facebook.stackoverflow.com/> - this isn't really a *separate site*, merely a custom "view" of Stack Overflow with an emphasis on Facebook questions. Note that "programming" means "developing an app that connects with Facebook's APIs in some way". As wit...
If you want to find questions on a common topic across all of the Stack Exchange sites, check out the "Filtered Questions" tool on <http://stackexchange.com>. ![modify filter screen](https://i.stack.imgur.com/FcbXi.png)
70,483,525
I'm trying to use the Googletranslate function on Google Sheets but would like the cell to detect English or Japanese. I wanted to use Detectlanguage to find out the language first but I'm not sure how to format it. Here's what I did but I get an error: =if(=DETECTLANGUAGE(A2)="en",[=GOOGLETRANSLATE("jp"])) If it's E...
2021/12/26
[ "https://Stackoverflow.com/questions/70483525", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17763584/" ]
based on the GOOGLETRANSLATE and DETECTLANGUAGE functions, try this: ``` =IF(DETECTLANGUAGE(A2)="en",GOOGLETRANSLATE(A2, "en", "ja"),GOOGLETRANSLATE(A2, "ja", "en")) ``` Source: <https://support.google.com/docs/answer/3093331?hl=en> <https://support.google.com/docs/answer/3093278?hl=en>
A few problems with your attempted answer. first to translate from English to Japanese you would use `=googletranslate("en","ja")` or if you want to detect the source language `=googletranslate("auto","ja")` The first language is the source language and the second is the target the list of supported languages and ...
35,489,427
I want to print the two integer variables divided. ``` int a = 1, b = 2; System.out.println(a + b); ``` Obviously println() function processes them as integers and calculates the sum. Instead I would like the output becomes like this "12". Any ideas?
2016/02/18
[ "https://Stackoverflow.com/questions/35489427", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5947430/" ]
Insert some blank Strings to induce this: ``` System.out.println(a +""+ b); ```
Store the integers as strings: ``` String a = "1"; String b = "2"; String c = a + b; System.out.println(c); ```
19,524,881
Need to create a javascript that opens **a single** window. Code: ``` document.body.onclick= function() { window.open( 'www.androidhackz.blogspot.com', 'poppage', 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=1, w...
2013/10/22
[ "https://Stackoverflow.com/questions/19524881", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Add a flag that says you opened it. Check the flag, if set, than do not open it. If it is only one time on the entire site, than means cookie or localstorage.
``` var clickedAlready = false; document.body.onclick = function() { if (!clickedAlready) { window.open('www.androidhackz.blogspot.com', 'poppage', 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=1, width=650, height=650, left = 300, top = 50'); clickedAlrea...
19,524,881
Need to create a javascript that opens **a single** window. Code: ``` document.body.onclick= function() { window.open( 'www.androidhackz.blogspot.com', 'poppage', 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=1, w...
2013/10/22
[ "https://Stackoverflow.com/questions/19524881", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
``` var count = 0; document.body.onclick= function(){ if(count === 0) window.open('www.androidhackz.blogspot.com', 'poppage', 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=1, width=650, height=650, left = 300, top = 50'); count++; } ```
``` var clickedAlready = false; document.body.onclick = function() { if (!clickedAlready) { window.open('www.androidhackz.blogspot.com', 'poppage', 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=1, width=650, height=650, left = 300, top = 50'); clickedAlrea...
51,241,660
please help.. I have 2 tables Current user\_id = 3 Users Table: ``` | user_id | email | name | ------------------------------------------- | 1 | one@gmail.com | ridwan | | 2 | two@gmail.com | budi | | 3 | six@gmail.com | stevan | | 4 | ten@gmail.c...
2018/07/09
[ "https://Stackoverflow.com/questions/51241660", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9584987/" ]
Double check your credentials and also you need to allow less secure apps in gmail. 1) Go to <https://myaccount.google.com/lesssecureapps> 2) Enable Less Secure Apps option
I have another solution for the same. If you want to remove password for security purpose, Then you can use my soltion too. At first you need some sender account credential, you can create that from here: <https://console.developers.google.com/projectselector/apis/credentials?supportedpurview=project> Node.js, Node...
18,832,801
I've been looking to find how to configure a client to connect to a Cassandra cluster. Independent of clients like Pelops, Hector, etc, what is the best way to connect to a multi-node Cassandra cluster? Sending the string IP values works fine, but what about growing number cluster nodes in the future? Is maintaining ...
2013/09/16
[ "https://Stackoverflow.com/questions/18832801", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1119684/" ]
Don't know if this answer all your questions but the growing cluster and your knowledge of clients ip are not related. I have a 5 node cluster but the client(s) only knows 2 ip addresses: the seeds. Since each machine of the cluster knows about the seeds (each cassandra.yaml contains the seeds ip address) if new machi...
You will have an easier time letting the client track the state of each node. Smart clients will track endpoint state via the gossipinfo, which passes on new nodes as they appear in the cluster.
3,829,296
How to show that $$\lim\_{(x,y,z) \to (0,0,0)} \frac{xyz}{x^2+y^2+z^2}=0,$$ where $x,y,z>0$. My attempt: $$||(x,y,z)|| < \delta \implies |x|, |y|, |z| < \delta$$ $$\left | \frac{xyz}{x^2+y^2+z^2} \right | < \left | \frac{xyz}{x^2}\right | < \frac{\delta^3}{x^2}.$$ Now, I do not know how to proceed, and I think my at...
2020/09/17
[ "https://math.stackexchange.com/questions/3829296", "https://math.stackexchange.com", "https://math.stackexchange.com/users/426645/" ]
Let $y= \frac{7x^{2}-4x+4}{x^{2}+1}$ $\Rightarrow (y-7)x^2+4x+(y-4)=0$ As $x$ must be real, the discriminant is $≥0$ $\Rightarrow 16-4(y-7)(y-4)≥0$ $\Rightarrow y^2-11y+24≤0$ Can you finish?
$f(x)=7-\frac{4x+3}{x^2+1}=7-g(x)$ We now have to find the range of $g(x)=\frac{4x+3}{x^2+1}$. We can see that the domain of this is $(-\infty,\infty)$ and that there are no vertical asymptotes and a horizontal asymptote of $y=0$ We can do some more inspection of this function and see that for $x>-\frac{3}{4}$, $g(x)...
2,915,266
A client of mine has a pure HTML website that was built in the dark ages - they want me to find where their users are coming from, how many individual users there are, etc. They want to know if the site is being used enough for them to invest the money into renovating it. I am remote from their site and do not have a...
2010/05/26
[ "https://Stackoverflow.com/questions/2915266", "https://Stackoverflow.com", "https://Stackoverflow.com/users/109035/" ]
it looks like you have stumbled upon a nice [S-Expression](http://en.wikipedia.org/wiki/S-expression) file, also know as [LISP](http://en.wikipedia.org/wiki/Lisp_programming_language) code. It does look complex but its actually pretty easy to parse. In fact if you wan't to learn a lot about Lisp you could follow these ...
You might consider writing a state machine implementation which changes states according to the different tokens you encounter within the file. I have found state-based parsers to be quite easy to write and debug. The most difficult part would likely be defining the tokens you use.
2,915,266
A client of mine has a pure HTML website that was built in the dark ages - they want me to find where their users are coming from, how many individual users there are, etc. They want to know if the site is being used enough for them to invest the money into renovating it. I am remote from their site and do not have a...
2010/05/26
[ "https://Stackoverflow.com/questions/2915266", "https://Stackoverflow.com", "https://Stackoverflow.com/users/109035/" ]
it looks like you have stumbled upon a nice [S-Expression](http://en.wikipedia.org/wiki/S-expression) file, also know as [LISP](http://en.wikipedia.org/wiki/Lisp_programming_language) code. It does look complex but its actually pretty easy to parse. In fact if you wan't to learn a lot about Lisp you could follow these ...
Use a parser generator like ANTLR. It takes a EBNF-like description of the grammar and creates parser code in the language of your choice.
2,915,266
A client of mine has a pure HTML website that was built in the dark ages - they want me to find where their users are coming from, how many individual users there are, etc. They want to know if the site is being used enough for them to invest the money into renovating it. I am remote from their site and do not have a...
2010/05/26
[ "https://Stackoverflow.com/questions/2915266", "https://Stackoverflow.com", "https://Stackoverflow.com/users/109035/" ]
it looks like you have stumbled upon a nice [S-Expression](http://en.wikipedia.org/wiki/S-expression) file, also know as [LISP](http://en.wikipedia.org/wiki/Lisp_programming_language) code. It does look complex but its actually pretty easy to parse. In fact if you wan't to learn a lot about Lisp you could follow these ...
One approach is to just start with a helper parsing like the one described at <http://www.blackbeltcoder.com/Articles/strings/a-text-parsing-helper-class>. And then process the file character by character. This is what I've done for several classes.
2,915,266
A client of mine has a pure HTML website that was built in the dark ages - they want me to find where their users are coming from, how many individual users there are, etc. They want to know if the site is being used enough for them to invest the money into renovating it. I am remote from their site and do not have a...
2010/05/26
[ "https://Stackoverflow.com/questions/2915266", "https://Stackoverflow.com", "https://Stackoverflow.com/users/109035/" ]
it looks like you have stumbled upon a nice [S-Expression](http://en.wikipedia.org/wiki/S-expression) file, also know as [LISP](http://en.wikipedia.org/wiki/Lisp_programming_language) code. It does look complex but its actually pretty easy to parse. In fact if you wan't to learn a lot about Lisp you could follow these ...
I wrote an S-Expression parser for C# using OMeta#. It is available at <https://github.com/databigbang/SExpression.NET> Looking at your S-Expression variant you just need to change my definition of string with opening and ending double quotes to a single quote and add the definition for elements that contains a colon ...
14,694,914
I'm trying to implement a jquery ui dialog. Using [this code](http://jsfiddle.net/N7PRp/) as a base, I've succeeded. But I would rather use elements' classes instead of IDs. I therefore modified the code to this: ``` $(document).ready(function() { $(".add_shipping_address").click(function() { console.log($...
2013/02/04
[ "https://Stackoverflow.com/questions/14694914", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1252748/" ]
The way jQuery dialogs work is that they take the HTML for the dialog out of the current location in the DOM and place a new `div` at the bottom of the DOM. When you open your dialog your new location is defined as seen below. therefore your HTML is not where it was and your selector using `find` is not going to find ...
It may be that the parenting structure for the dialog has changed. Try changing it to ``` //jquery dialog functions $(document).ready(function() { $(".add_shipping_address").click(function() { //console.log($(this).parents('.shipping_sector')); $(".shipping_dialog").dialog(); return false;...
14,694,914
I'm trying to implement a jquery ui dialog. Using [this code](http://jsfiddle.net/N7PRp/) as a base, I've succeeded. But I would rather use elements' classes instead of IDs. I therefore modified the code to this: ``` $(document).ready(function() { $(".add_shipping_address").click(function() { console.log($...
2013/02/04
[ "https://Stackoverflow.com/questions/14694914", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1252748/" ]
You're current code is : ``` $(".OpenDialogOnClick").dialog(); ``` And just change it to: ``` $(".OpenDialogOnClick").clone().dialog(); ``` Voila, you're HTML will never be destroyed / deleted again :)
It may be that the parenting structure for the dialog has changed. Try changing it to ``` //jquery dialog functions $(document).ready(function() { $(".add_shipping_address").click(function() { //console.log($(this).parents('.shipping_sector')); $(".shipping_dialog").dialog(); return false;...
14,694,914
I'm trying to implement a jquery ui dialog. Using [this code](http://jsfiddle.net/N7PRp/) as a base, I've succeeded. But I would rather use elements' classes instead of IDs. I therefore modified the code to this: ``` $(document).ready(function() { $(".add_shipping_address").click(function() { console.log($...
2013/02/04
[ "https://Stackoverflow.com/questions/14694914", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1252748/" ]
The way jQuery dialogs work is that they take the HTML for the dialog out of the current location in the DOM and place a new `div` at the bottom of the DOM. When you open your dialog your new location is defined as seen below. therefore your HTML is not where it was and your selector using `find` is not going to find ...
If you do not mind creating a new dialog every time, you can essentially destroy your dialog and move the contents back to its previous location. That way on the next click, the process will repeat itself. ``` //jquery dialog functions $(document).ready(function() { $(".add_shipping_address").click(function() { ...
14,694,914
I'm trying to implement a jquery ui dialog. Using [this code](http://jsfiddle.net/N7PRp/) as a base, I've succeeded. But I would rather use elements' classes instead of IDs. I therefore modified the code to this: ``` $(document).ready(function() { $(".add_shipping_address").click(function() { console.log($...
2013/02/04
[ "https://Stackoverflow.com/questions/14694914", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1252748/" ]
The way jQuery dialogs work is that they take the HTML for the dialog out of the current location in the DOM and place a new `div` at the bottom of the DOM. When you open your dialog your new location is defined as seen below. therefore your HTML is not where it was and your selector using `find` is not going to find ...
You're current code is : ``` $(".OpenDialogOnClick").dialog(); ``` And just change it to: ``` $(".OpenDialogOnClick").clone().dialog(); ``` Voila, you're HTML will never be destroyed / deleted again :)
14,694,914
I'm trying to implement a jquery ui dialog. Using [this code](http://jsfiddle.net/N7PRp/) as a base, I've succeeded. But I would rather use elements' classes instead of IDs. I therefore modified the code to this: ``` $(document).ready(function() { $(".add_shipping_address").click(function() { console.log($...
2013/02/04
[ "https://Stackoverflow.com/questions/14694914", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1252748/" ]
You're current code is : ``` $(".OpenDialogOnClick").dialog(); ``` And just change it to: ``` $(".OpenDialogOnClick").clone().dialog(); ``` Voila, you're HTML will never be destroyed / deleted again :)
If you do not mind creating a new dialog every time, you can essentially destroy your dialog and move the contents back to its previous location. That way on the next click, the process will repeat itself. ``` //jquery dialog functions $(document).ready(function() { $(".add_shipping_address").click(function() { ...
36,852,475
I have a folder where there are books and I have a file with the real name of each file. I renamed them in a way that I can easily see if they are ordered, say "00.pdf", "01.pdf" and so on. I want to know if there is a way, using the shell, to match each of the lines of the file, say "names", with each file. Actually,...
2016/04/25
[ "https://Stackoverflow.com/questions/36852475", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3591470/" ]
You need a Babel transform. Meteor 1.3.3+ supports additional plugins and presets via .babelrc Install the static transform: ``` npm install babel-plugin-transform-class-properties # .babelrc { "presets": [ "meteor", "es2015", "stage-1" ], "plugins": [ "transform-class-properties" ] } ``` ...
I changed it from extending the class too React.createClass and it now works. ``` import React from 'react'; import AppBar from 'material-ui/AppBar'; import IconButton from 'material-ui/IconButton'; import Navigationclose from 'material-ui/svg-icons/navigation/close'; import IconMenu from 'material-ui/IconMenu'; impor...
41,485,804
How to check if the file uploaded file is **solely** an image and not video file and anything? I tested out a simple code that will check if the uploaded file is an image. **form** ``` <form method="post" enctype="multipart/form-data"> <input type="file" name="photo" accept="image/*"> <input type="submit" na...
2017/01/05
[ "https://Stackoverflow.com/questions/41485804", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7059329/" ]
You do not see code that adds `'\0'` to the end of the sequence because null character is already there. An implementation of `c_str` cannot return a pointer to new array, so the array must be stored on the `std::string` object itself. Hence, you have two valid approaches for implementing this: 1. Always store `'\0'`...
The requirement is the `c_str` must return a null terminated cstring. There is nothing saying that the function has to add the null terminator. Most implementations (and I think all that want to be standard compliant) store the null terminator in the underlying buffer used by the string itself. One reason for this is t...
41,485,804
How to check if the file uploaded file is **solely** an image and not video file and anything? I tested out a simple code that will check if the uploaded file is an image. **form** ``` <form method="post" enctype="multipart/form-data"> <input type="file" name="photo" accept="image/*"> <input type="submit" na...
2017/01/05
[ "https://Stackoverflow.com/questions/41485804", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7059329/" ]
Before C++11, there was no requirement that a `std::string` (or the templated class `std::basic_string` - of which std::string is an instantiation) store a trailing `'\0'`. This was reflected in different specifications of the `data()` and `c_str()` member functions - `data()` returns a pointer to the underlying data (...
The requirement is the `c_str` must return a null terminated cstring. There is nothing saying that the function has to add the null terminator. Most implementations (and I think all that want to be standard compliant) store the null terminator in the underlying buffer used by the string itself. One reason for this is t...
41,485,804
How to check if the file uploaded file is **solely** an image and not video file and anything? I tested out a simple code that will check if the uploaded file is an image. **form** ``` <form method="post" enctype="multipart/form-data"> <input type="file" name="photo" accept="image/*"> <input type="submit" na...
2017/01/05
[ "https://Stackoverflow.com/questions/41485804", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7059329/" ]
Before C++11, there was no requirement that a `std::string` (or the templated class `std::basic_string` - of which std::string is an instantiation) store a trailing `'\0'`. This was reflected in different specifications of the `data()` and `c_str()` member functions - `data()` returns a pointer to the underlying data (...
You do not see code that adds `'\0'` to the end of the sequence because null character is already there. An implementation of `c_str` cannot return a pointer to new array, so the array must be stored on the `std::string` object itself. Hence, you have two valid approaches for implementing this: 1. Always store `'\0'`...
17,711,952
Is there any way that I can remove the successive duplicates from the array below while only keeping the first one? The array is shown below: ``` $a=array("1"=>"go","2"=>"stop","3"=>"stop","4"=>"stop","5"=>"stop","6"=>"go","7"=>"go","8"=>"stop"); ``` What I want is to have an array that contains: ``` $a=array("1"=...
2013/07/17
[ "https://Stackoverflow.com/questions/17711952", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1942410/" ]
Successive duplicates? I don't know about native functions, but this one works. Well almost. Think I understood it wrong. In my function the 7 => "go" is a duplicate of 6 => "go", and 8 => "stop" is the new value...? ``` function filterSuccessiveDuplicates($array) { $result = array(); $lastValue = null; f...
You can just do something like: ``` if(current($a) !== $new_val) $a[] = $new_val; ``` Assuming you're not manipulating that array in between you can use `current()` it's more efficient than counting it each time to check the value at `count($a)-1`
70,677,153
I've always used the term "environment variable", but I have a well-informed colleague who consistently says "environment**al** variable". Which one is correct?
2022/01/12
[ "https://Stackoverflow.com/questions/70677153", "https://Stackoverflow.com", "https://Stackoverflow.com/users/119527/" ]
#### Symmetrical range around focal year & range may differ among 'id' Within each 'id' (`by = id`), use `rleid` to create a grouping variable 'r' based on runs of equal values. Within each 'id' and run (`by = .(id, r)`), check if at least previous and next year from the focal year (e.g. 2018) are present (`if(sum(tim...
As far as I understood, here's a `dplyr` suggestion: ``` library(dplyr) MyF <- function(id2, shock, nb_row) { values <- pdata %>% filter(id == id2) %>% pull(value) if (length(unique(values)) == 1) { pdata %>% filter(id == id2) } else { pdata %>% filter(id == id2) %>% filter(ti...
70,677,153
I've always used the term "environment variable", but I have a well-informed colleague who consistently says "environment**al** variable". Which one is correct?
2022/01/12
[ "https://Stackoverflow.com/questions/70677153", "https://Stackoverflow.com", "https://Stackoverflow.com/users/119527/" ]
A solution with [data.table](/questions/tagged/data.table "show questions tagged 'data.table'"): ``` # load the package & convert data to a data.table library(data.table) setDT(pdata) # define shock-year and number of previous/next rows shock <- 2018 n <- 2 # filter pdata[, .SD[value == value[time == shock] & ...
As far as I understood, here's a `dplyr` suggestion: ``` library(dplyr) MyF <- function(id2, shock, nb_row) { values <- pdata %>% filter(id == id2) %>% pull(value) if (length(unique(values)) == 1) { pdata %>% filter(id == id2) } else { pdata %>% filter(id == id2) %>% filter(ti...
70,677,153
I've always used the term "environment variable", but I have a well-informed colleague who consistently says "environment**al** variable". Which one is correct?
2022/01/12
[ "https://Stackoverflow.com/questions/70677153", "https://Stackoverflow.com", "https://Stackoverflow.com/users/119527/" ]
As far as I understood, here's a `dplyr` suggestion: ``` library(dplyr) MyF <- function(id2, shock, nb_row) { values <- pdata %>% filter(id == id2) %>% pull(value) if (length(unique(values)) == 1) { pdata %>% filter(id == id2) } else { pdata %>% filter(id == id2) %>% filter(ti...
One way to solve your problem using data.table: ``` library(data.table) yrs=2017:2019 setDT(pdata)[, if(uniqueN(value)==1) .(time, value) else if(uniqueN(value <- value[time %in% yrs])==1) .(time=yrs, value), by=id] # id time value # 1: 4 2016 0 # 2: 4 2017 0...
70,677,153
I've always used the term "environment variable", but I have a well-informed colleague who consistently says "environment**al** variable". Which one is correct?
2022/01/12
[ "https://Stackoverflow.com/questions/70677153", "https://Stackoverflow.com", "https://Stackoverflow.com/users/119527/" ]
#### Symmetrical range around focal year & range may differ among 'id' Within each 'id' (`by = id`), use `rleid` to create a grouping variable 'r' based on runs of equal values. Within each 'id' and run (`by = .(id, r)`), check if at least previous and next year from the focal year (e.g. 2018) are present (`if(sum(tim...
Here's another `dplyr` solution. We basically group by sequences of unique values for each `id` and then just filter around the maximum distance to the shock time that is duplicated. ```r pdata %>% group_by(id) %>% mutate(value_group = cumsum(value != lag(value, default = value[1]))) %>% group_by(id, value_group...
70,677,153
I've always used the term "environment variable", but I have a well-informed colleague who consistently says "environment**al** variable". Which one is correct?
2022/01/12
[ "https://Stackoverflow.com/questions/70677153", "https://Stackoverflow.com", "https://Stackoverflow.com/users/119527/" ]
A solution with [data.table](/questions/tagged/data.table "show questions tagged 'data.table'"): ``` # load the package & convert data to a data.table library(data.table) setDT(pdata) # define shock-year and number of previous/next rows shock <- 2018 n <- 2 # filter pdata[, .SD[value == value[time == shock] & ...
Here's another `dplyr` solution. We basically group by sequences of unique values for each `id` and then just filter around the maximum distance to the shock time that is duplicated. ```r pdata %>% group_by(id) %>% mutate(value_group = cumsum(value != lag(value, default = value[1]))) %>% group_by(id, value_group...
70,677,153
I've always used the term "environment variable", but I have a well-informed colleague who consistently says "environment**al** variable". Which one is correct?
2022/01/12
[ "https://Stackoverflow.com/questions/70677153", "https://Stackoverflow.com", "https://Stackoverflow.com/users/119527/" ]
Here's another `dplyr` solution. We basically group by sequences of unique values for each `id` and then just filter around the maximum distance to the shock time that is duplicated. ```r pdata %>% group_by(id) %>% mutate(value_group = cumsum(value != lag(value, default = value[1]))) %>% group_by(id, value_group...
One way to solve your problem using data.table: ``` library(data.table) yrs=2017:2019 setDT(pdata)[, if(uniqueN(value)==1) .(time, value) else if(uniqueN(value <- value[time %in% yrs])==1) .(time=yrs, value), by=id] # id time value # 1: 4 2016 0 # 2: 4 2017 0...
70,677,153
I've always used the term "environment variable", but I have a well-informed colleague who consistently says "environment**al** variable". Which one is correct?
2022/01/12
[ "https://Stackoverflow.com/questions/70677153", "https://Stackoverflow.com", "https://Stackoverflow.com/users/119527/" ]
A solution with [data.table](/questions/tagged/data.table "show questions tagged 'data.table'"): ``` # load the package & convert data to a data.table library(data.table) setDT(pdata) # define shock-year and number of previous/next rows shock <- 2018 n <- 2 # filter pdata[, .SD[value == value[time == shock] & ...
#### Symmetrical range around focal year & range may differ among 'id' Within each 'id' (`by = id`), use `rleid` to create a grouping variable 'r' based on runs of equal values. Within each 'id' and run (`by = .(id, r)`), check if at least previous and next year from the focal year (e.g. 2018) are present (`if(sum(tim...
70,677,153
I've always used the term "environment variable", but I have a well-informed colleague who consistently says "environment**al** variable". Which one is correct?
2022/01/12
[ "https://Stackoverflow.com/questions/70677153", "https://Stackoverflow.com", "https://Stackoverflow.com/users/119527/" ]
#### Symmetrical range around focal year & range may differ among 'id' Within each 'id' (`by = id`), use `rleid` to create a grouping variable 'r' based on runs of equal values. Within each 'id' and run (`by = .(id, r)`), check if at least previous and next year from the focal year (e.g. 2018) are present (`if(sum(tim...
One way to solve your problem using data.table: ``` library(data.table) yrs=2017:2019 setDT(pdata)[, if(uniqueN(value)==1) .(time, value) else if(uniqueN(value <- value[time %in% yrs])==1) .(time=yrs, value), by=id] # id time value # 1: 4 2016 0 # 2: 4 2017 0...
70,677,153
I've always used the term "environment variable", but I have a well-informed colleague who consistently says "environment**al** variable". Which one is correct?
2022/01/12
[ "https://Stackoverflow.com/questions/70677153", "https://Stackoverflow.com", "https://Stackoverflow.com/users/119527/" ]
A solution with [data.table](/questions/tagged/data.table "show questions tagged 'data.table'"): ``` # load the package & convert data to a data.table library(data.table) setDT(pdata) # define shock-year and number of previous/next rows shock <- 2018 n <- 2 # filter pdata[, .SD[value == value[time == shock] & ...
One way to solve your problem using data.table: ``` library(data.table) yrs=2017:2019 setDT(pdata)[, if(uniqueN(value)==1) .(time, value) else if(uniqueN(value <- value[time %in% yrs])==1) .(time=yrs, value), by=id] # id time value # 1: 4 2016 0 # 2: 4 2017 0...
16,542,099
Im working on a MVC app. When I call context.SaveChanges to update a specific records. The update is not registered in the database. I do not get any runtime error either. All in notice is that my Records is not updated. I still see the same values. Insert Functionality work Perfectly. ``` enter code here public Adm...
2013/05/14
[ "https://Stackoverflow.com/questions/16542099", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1203470/" ]
First get the entity you are going to update: ``` var entity = obj.GetEntity(id); entity.col1 = "value"; context.SaveChanges(entity); ``` hope this will help.
Before ``` context.SaveChanges(); ``` You need to call this ``` context.Student_Masters.Add(studentmaster ); ``` **Edit:** introduce `Abstraction` to your `Context class` and Create a method in your context class like below, then you can call it whenever you want to create or update your objects. ``` public void...
16,542,099
Im working on a MVC app. When I call context.SaveChanges to update a specific records. The update is not registered in the database. I do not get any runtime error either. All in notice is that my Records is not updated. I still see the same values. Insert Functionality work Perfectly. ``` enter code here public Adm...
2013/05/14
[ "https://Stackoverflow.com/questions/16542099", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1203470/" ]
It seems like you want to update, so your code should be ``` VDData.Student_Master studentmaster = context.Student_Masters.Single(p=>p.Student_ID == stuid); ``` And you should not change the Student\_ID if it is the primary key. ``` public Admission Update(int stuid){ VDData.VidyaDaanEntities context = ne...
Before ``` context.SaveChanges(); ``` You need to call this ``` context.Student_Masters.Add(studentmaster ); ``` **Edit:** introduce `Abstraction` to your `Context class` and Create a method in your context class like below, then you can call it whenever you want to create or update your objects. ``` public void...
370,385
I was wondering where the Google servers reside and how their DNS lookup work. I'm located in Germany right now. If I'm calling google.de (German Google page) is the server located in Germany for all the searches or are they splitted throughout the world? If I'm calling google.com, does it automatically connect to the ...
2012/03/16
[ "https://serverfault.com/questions/370385", "https://serverfault.com", "https://serverfault.com/users/109245/" ]
How Google search *actually* works is, of course, a closely-guarded secret. However, in the past there has been some info coming out of them with general practices they employ. First off, Google has **hundreds** of datacenters - back in 2008-ish, they were already estimated to run on several hundred thousand servers;...
They probably have multiple datacenters in every continent, and thanks to anycasting they can announce the same networks from multiple providers/datacenters. You will always go the least expensive path (in terms of as paths, hops, metrics, bandwidth between peers etc etc), therefor you will experience low latency fro...
370,385
I was wondering where the Google servers reside and how their DNS lookup work. I'm located in Germany right now. If I'm calling google.de (German Google page) is the server located in Germany for all the searches or are they splitted throughout the world? If I'm calling google.com, does it automatically connect to the ...
2012/03/16
[ "https://serverfault.com/questions/370385", "https://serverfault.com", "https://serverfault.com/users/109245/" ]
They probably have multiple datacenters in every continent, and thanks to anycasting they can announce the same networks from multiple providers/datacenters. You will always go the least expensive path (in terms of as paths, hops, metrics, bandwidth between peers etc etc), therefor you will experience low latency fro...
The closest DNS entry that returns you request, records differ from Google.de, Goggle.fr and .com this works in your favor so you access the service with less network hops, However apart from the large google DC's the severs that you and I connect to are most probally **GGC (Google Global Cache)** servers. They are l...
370,385
I was wondering where the Google servers reside and how their DNS lookup work. I'm located in Germany right now. If I'm calling google.de (German Google page) is the server located in Germany for all the searches or are they splitted throughout the world? If I'm calling google.com, does it automatically connect to the ...
2012/03/16
[ "https://serverfault.com/questions/370385", "https://serverfault.com", "https://serverfault.com/users/109245/" ]
How Google search *actually* works is, of course, a closely-guarded secret. However, in the past there has been some info coming out of them with general practices they employ. First off, Google has **hundreds** of datacenters - back in 2008-ish, they were already estimated to run on several hundred thousand servers;...
The closest DNS entry that returns you request, records differ from Google.de, Goggle.fr and .com this works in your favor so you access the service with less network hops, However apart from the large google DC's the severs that you and I connect to are most probally **GGC (Google Global Cache)** servers. They are l...
42,438,055
I try to execute such a scenery via Jenkins "execute shell" build step: ``` rm -r -f _dpatch; mkdir _dpatch; mkdir _dpatch/deploy; from_revision='HEAD'; to_revision='2766920'; git diff --name-only $from_revision $to_revision > "_dpatch/deploy/files.txt"; for file in $(<"_dpatch/deploy/files.txt"); do cp --parents ...
2017/02/24
[ "https://Stackoverflow.com/questions/42438055", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2248804/" ]
**Solution:** As far as I know, descriptors are the only objects, that can distinguish, if they are invoke for class or instance, because of the `__get__` function signature: `__get__(self, instance, instance_type)`. This property allows us to build a switch on top of it. ``` class boundmethod(object): def __...
I actually just asked this question ([Python descriptors and inheritance](https://stackoverflow.com/questions/44771706/python-descriptors-and-inheritance/44835452#44835452) I hadn't seen this question). [My solution](https://stackoverflow.com/a/44835452/1575353) uses descriptors and a metaclass for inheritance. from ...
4,432,288
I have the CTE as a UDF and am trying to get it to take a default value of nothing in which case the result returned should be everything. I want to call it as a default like this: ``` select * from fnGetEmployeeHierarchyByUsername ``` my UDF/ CTE is: ``` alter FUNCTION [dbo].[fnGetEmployeeHierarchyByUsername] ...
2010/12/13
[ "https://Stackoverflow.com/questions/4432288", "https://Stackoverflow.com", "https://Stackoverflow.com/users/352157/" ]
You cannot get any information about the user unless the user gives permission. Unfortunately. But with "OAuth 2.0 for Canvas" you do receive a the signed\_request POST. And this way is the only way to go about it; <http://developers.facebook.com/docs/authentication/canvas> But user still needs to authorize your appl...
``` $json = file_get_contents("http://graph.facebook.com/$uid"); $fdata = json_decode($json); $fname = $fdata->name; echo 'Merry Christmas x ' . $fname . ' x '; ```
4,432,288
I have the CTE as a UDF and am trying to get it to take a default value of nothing in which case the result returned should be everything. I want to call it as a default like this: ``` select * from fnGetEmployeeHierarchyByUsername ``` my UDF/ CTE is: ``` alter FUNCTION [dbo].[fnGetEmployeeHierarchyByUsername] ...
2010/12/13
[ "https://Stackoverflow.com/questions/4432288", "https://Stackoverflow.com", "https://Stackoverflow.com/users/352157/" ]
I've found the answer. Just use: to show the user's name on a TAB/Canvas app. It also works within the Static FBML app. Writing: ``` Merry Christmas <fb:userlink uid="loggedinuser"/> ``` Will show: ``` Merry Christmas John Smith ``` if John Smith is viewing it :) The name will be formatted as a link, but you ...
``` $json = file_get_contents("http://graph.facebook.com/$uid"); $fdata = json_decode($json); $fname = $fdata->name; echo 'Merry Christmas x ' . $fname . ' x '; ```
12,182,382
**Please someone Fix this Javascript Code.** This script actually reads the URL Parameter and then depending on the parameter it SHOW/HIDE's Table rows. I found out this script on Sack Overflow but when tried it on Dreamweaver, its not working.. Please someone go through the script and fix what is wrong in it.... T...
2012/08/29
[ "https://Stackoverflow.com/questions/12182382", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1633771/" ]
You don't have an apostrophe problem, you have an exclamation point problem. An exclamation point is neither word (`\w`) nor whitespace (`\s`) nor an apostrophe. So you should add `!` to your character class if you want to allow it.
Can't you get away with a simple `.`, e.g., `'<(.+)>'`? Also, it's typically easier if you don't use single quotes for the string if you need to embed a single quote inside, e.g., `"<([\w\s']+)>"`.
25,193,869
i keep getting valgrind errors in my code and i have no idea how to fix it. :/ the idea is that no matter how much tabs / spaces are between 2 or more words/letters in an input, in the output it should be only one space. for example: ``` a b c d -> a b c d ``` code: ``` char* echo(char* in) { char buffer[2...
2014/08/07
[ "https://Stackoverflow.com/questions/25193869", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3910643/" ]
``` char* out=buffer; return out; } ``` Do not return a pointer to an array with automatic storage duration (here `buffer` array). If the pointer value is accessed, it invokes undefined behavior as automatic objects are discarded when the block where they are declared is exited (here when `echo` function returns).
If you want to use the buffer outside of the function then you should pass the allocated buffer to the function. ``` void echo(char *in, char *buffer) { //do stuff } ``` This way you won't be trying to access memory that has gone out of scope. You can then use the function as such ``` char buffer[256]; echo(st...
25,193,869
i keep getting valgrind errors in my code and i have no idea how to fix it. :/ the idea is that no matter how much tabs / spaces are between 2 or more words/letters in an input, in the output it should be only one space. for example: ``` a b c d -> a b c d ``` code: ``` char* echo(char* in) { char buffer[2...
2014/08/07
[ "https://Stackoverflow.com/questions/25193869", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3910643/" ]
``` char* out=buffer; return out; } ``` Do not return a pointer to an array with automatic storage duration (here `buffer` array). If the pointer value is accessed, it invokes undefined behavior as automatic objects are discarded when the block where they are declared is exited (here when `echo` function returns).
This message: ``` ==20521== Conditional jump or move depends on uninitialised value(s) ==20521== at 0x4010B4: echo (hhush.c:53) ==20521== Uninitialised value was created by a stack allocation ==20521== at 0x402017: readCommand (hhush.c:301) ``` is telling you that an `if` or `while` test on line 53 depends on...
53,832,287
I am trying to print out images on the dice, instead of just the number. But when i am using document.write, it just opens a new tab, and shows the picture. What should i use to print it out, with the button i have? ``` <div id="roll-dice"> <button type="button" value="Trow dice" onclick="rolldice()">Roll dice</b...
2018/12/18
[ "https://Stackoverflow.com/questions/53832287", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10260767/" ]
**Use a picturebox and modify its source** ``` <img src="" id="pic-result"/> ``` javascript code : ``` var rollResult = Math.floor(Math.random() * 6) + 1; var pic = document.getElementById("pic-result"); if (rollResult == 1) pic.setAttribute('src', '1.jpg'); else if (rollResult == 2) pic.setAttribute('src', '2.jpg...
You should be able to achieve this with `innerHTML` on `#roll-result`: ```js var diceResult = document.querySelector('#roll-result'); function rolldice() { var rollResult = Math.floor(Math.random() * 6) + 1; diceResult.innerHTML = '<img src="' + rollResult + '.jpg">'; } ``` ```html <div id="roll-dice"> <but...
53,832,287
I am trying to print out images on the dice, instead of just the number. But when i am using document.write, it just opens a new tab, and shows the picture. What should i use to print it out, with the button i have? ``` <div id="roll-dice"> <button type="button" value="Trow dice" onclick="rolldice()">Roll dice</b...
2018/12/18
[ "https://Stackoverflow.com/questions/53832287", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10260767/" ]
You should be able to achieve this with `innerHTML` on `#roll-result`: ```js var diceResult = document.querySelector('#roll-result'); function rolldice() { var rollResult = Math.floor(Math.random() * 6) + 1; diceResult.innerHTML = '<img src="' + rollResult + '.jpg">'; } ``` ```html <div id="roll-dice"> <but...
You should set the innerHTML of a parent element rather than writing the element onto the page: ``` <div id="roll-dice"> <button type="button" value="Trow dice" onclick="rolldice()">Roll dice</button> <span id="roll-result"></span> </div> ``` JS: ``` var rollResult = Math.floor(Math.random() * 6) + 1; var i...
53,832,287
I am trying to print out images on the dice, instead of just the number. But when i am using document.write, it just opens a new tab, and shows the picture. What should i use to print it out, with the button i have? ``` <div id="roll-dice"> <button type="button" value="Trow dice" onclick="rolldice()">Roll dice</b...
2018/12/18
[ "https://Stackoverflow.com/questions/53832287", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10260767/" ]
**Use a picturebox and modify its source** ``` <img src="" id="pic-result"/> ``` javascript code : ``` var rollResult = Math.floor(Math.random() * 6) + 1; var pic = document.getElementById("pic-result"); if (rollResult == 1) pic.setAttribute('src', '1.jpg'); else if (rollResult == 2) pic.setAttribute('src', '2.jpg...
You should set the innerHTML of a parent element rather than writing the element onto the page: ``` <div id="roll-dice"> <button type="button" value="Trow dice" onclick="rolldice()">Roll dice</button> <span id="roll-result"></span> </div> ``` JS: ``` var rollResult = Math.floor(Math.random() * 6) + 1; var i...
52,177
Disclaimer: This is for a homework project. I'm trying to come up with the best model for diamond prices, depending on several variables and I seem to have a pretty good model so far. However I have run into two variables that are obviously collinear: ``` >with(diamonds, cor(data.frame(Table, Depth, Carat.Weight))) ...
2013/03/14
[ "https://stats.stackexchange.com/questions/52177", "https://stats.stackexchange.com", "https://stats.stackexchange.com/users/12031/" ]
Those variables are correlated. The extent of linear association implied by that correlation matrix is not remotely high enough for the variables to be considered collinear. In this case, I'd be quite happy to use all three of those variables for typical regression applications. One way to detect multicollinearity ...
Thought this diamond-cutting schematic might add insight to the Question. Can't add an image to a Comment so made it an answer.... ![enter image description here](https://i.stack.imgur.com/zGX2f.gif) PS. @PeterEllis's comment: The fact that "diamonds which are longer across the top are shorter from top to bottom" mig...
52,177
Disclaimer: This is for a homework project. I'm trying to come up with the best model for diamond prices, depending on several variables and I seem to have a pretty good model so far. However I have run into two variables that are obviously collinear: ``` >with(diamonds, cor(data.frame(Table, Depth, Carat.Weight))) ...
2013/03/14
[ "https://stats.stackexchange.com/questions/52177", "https://stats.stackexchange.com", "https://stats.stackexchange.com/users/12031/" ]
Thought this diamond-cutting schematic might add insight to the Question. Can't add an image to a Comment so made it an answer.... ![enter image description here](https://i.stack.imgur.com/zGX2f.gif) PS. @PeterEllis's comment: The fact that "diamonds which are longer across the top are shorter from top to bottom" mig...
From the correlation its difficult to conclude if the Table and Width are indeed correlated. A coefficient close to +1/-1 would say they are collinear. It also depends on the sample size..if you have more data use it to confirm. The standard procedure in dealing with collinear variables is to eliminate one of them...c...
52,177
Disclaimer: This is for a homework project. I'm trying to come up with the best model for diamond prices, depending on several variables and I seem to have a pretty good model so far. However I have run into two variables that are obviously collinear: ``` >with(diamonds, cor(data.frame(Table, Depth, Carat.Weight))) ...
2013/03/14
[ "https://stats.stackexchange.com/questions/52177", "https://stats.stackexchange.com", "https://stats.stackexchange.com/users/12031/" ]
Thought this diamond-cutting schematic might add insight to the Question. Can't add an image to a Comment so made it an answer.... ![enter image description here](https://i.stack.imgur.com/zGX2f.gif) PS. @PeterEllis's comment: The fact that "diamonds which are longer across the top are shorter from top to bottom" mig...
What makes you think that table and depth cause collinearity in your model? From the correlation matrix alone it's hard to tell that these two variables will cause collinearity issues. What does a joint F test tell you about both variables' contribution to your model? As curious\_cat mentioned the Pearson may not be th...
52,177
Disclaimer: This is for a homework project. I'm trying to come up with the best model for diamond prices, depending on several variables and I seem to have a pretty good model so far. However I have run into two variables that are obviously collinear: ``` >with(diamonds, cor(data.frame(Table, Depth, Carat.Weight))) ...
2013/03/14
[ "https://stats.stackexchange.com/questions/52177", "https://stats.stackexchange.com", "https://stats.stackexchange.com/users/12031/" ]
Thought this diamond-cutting schematic might add insight to the Question. Can't add an image to a Comment so made it an answer.... ![enter image description here](https://i.stack.imgur.com/zGX2f.gif) PS. @PeterEllis's comment: The fact that "diamonds which are longer across the top are shorter from top to bottom" mig...
Using ratios in linear regression should be avoided. Essentially, what you are saying is that, if a linear regression was done on those two variables, they would be linearly correlated with no intercept; this is obviously not the case. See: <http://cscu.cornell.edu/news/statnews/stnews03.pdf> Also,they are measuring ...
52,177
Disclaimer: This is for a homework project. I'm trying to come up with the best model for diamond prices, depending on several variables and I seem to have a pretty good model so far. However I have run into two variables that are obviously collinear: ``` >with(diamonds, cor(data.frame(Table, Depth, Carat.Weight))) ...
2013/03/14
[ "https://stats.stackexchange.com/questions/52177", "https://stats.stackexchange.com", "https://stats.stackexchange.com/users/12031/" ]
Those variables are correlated. The extent of linear association implied by that correlation matrix is not remotely high enough for the variables to be considered collinear. In this case, I'd be quite happy to use all three of those variables for typical regression applications. One way to detect multicollinearity ...
From the correlation its difficult to conclude if the Table and Width are indeed correlated. A coefficient close to +1/-1 would say they are collinear. It also depends on the sample size..if you have more data use it to confirm. The standard procedure in dealing with collinear variables is to eliminate one of them...c...
52,177
Disclaimer: This is for a homework project. I'm trying to come up with the best model for diamond prices, depending on several variables and I seem to have a pretty good model so far. However I have run into two variables that are obviously collinear: ``` >with(diamonds, cor(data.frame(Table, Depth, Carat.Weight))) ...
2013/03/14
[ "https://stats.stackexchange.com/questions/52177", "https://stats.stackexchange.com", "https://stats.stackexchange.com/users/12031/" ]
Those variables are correlated. The extent of linear association implied by that correlation matrix is not remotely high enough for the variables to be considered collinear. In this case, I'd be quite happy to use all three of those variables for typical regression applications. One way to detect multicollinearity ...
What makes you think that table and depth cause collinearity in your model? From the correlation matrix alone it's hard to tell that these two variables will cause collinearity issues. What does a joint F test tell you about both variables' contribution to your model? As curious\_cat mentioned the Pearson may not be th...
52,177
Disclaimer: This is for a homework project. I'm trying to come up with the best model for diamond prices, depending on several variables and I seem to have a pretty good model so far. However I have run into two variables that are obviously collinear: ``` >with(diamonds, cor(data.frame(Table, Depth, Carat.Weight))) ...
2013/03/14
[ "https://stats.stackexchange.com/questions/52177", "https://stats.stackexchange.com", "https://stats.stackexchange.com/users/12031/" ]
Those variables are correlated. The extent of linear association implied by that correlation matrix is not remotely high enough for the variables to be considered collinear. In this case, I'd be quite happy to use all three of those variables for typical regression applications. One way to detect multicollinearity ...
Using ratios in linear regression should be avoided. Essentially, what you are saying is that, if a linear regression was done on those two variables, they would be linearly correlated with no intercept; this is obviously not the case. See: <http://cscu.cornell.edu/news/statnews/stnews03.pdf> Also,they are measuring ...
52,177
Disclaimer: This is for a homework project. I'm trying to come up with the best model for diamond prices, depending on several variables and I seem to have a pretty good model so far. However I have run into two variables that are obviously collinear: ``` >with(diamonds, cor(data.frame(Table, Depth, Carat.Weight))) ...
2013/03/14
[ "https://stats.stackexchange.com/questions/52177", "https://stats.stackexchange.com", "https://stats.stackexchange.com/users/12031/" ]
Using ratios in linear regression should be avoided. Essentially, what you are saying is that, if a linear regression was done on those two variables, they would be linearly correlated with no intercept; this is obviously not the case. See: <http://cscu.cornell.edu/news/statnews/stnews03.pdf> Also,they are measuring ...
From the correlation its difficult to conclude if the Table and Width are indeed correlated. A coefficient close to +1/-1 would say they are collinear. It also depends on the sample size..if you have more data use it to confirm. The standard procedure in dealing with collinear variables is to eliminate one of them...c...
52,177
Disclaimer: This is for a homework project. I'm trying to come up with the best model for diamond prices, depending on several variables and I seem to have a pretty good model so far. However I have run into two variables that are obviously collinear: ``` >with(diamonds, cor(data.frame(Table, Depth, Carat.Weight))) ...
2013/03/14
[ "https://stats.stackexchange.com/questions/52177", "https://stats.stackexchange.com", "https://stats.stackexchange.com/users/12031/" ]
Using ratios in linear regression should be avoided. Essentially, what you are saying is that, if a linear regression was done on those two variables, they would be linearly correlated with no intercept; this is obviously not the case. See: <http://cscu.cornell.edu/news/statnews/stnews03.pdf> Also,they are measuring ...
What makes you think that table and depth cause collinearity in your model? From the correlation matrix alone it's hard to tell that these two variables will cause collinearity issues. What does a joint F test tell you about both variables' contribution to your model? As curious\_cat mentioned the Pearson may not be th...
40,746
I am working on a small custom Markup script in Java that converts a Markdown/Wiki style markup into HTML. The below works, but as I add more Markup I can see it becoming unwieldy and hard to maintain. Is there is a better, more elegant, way to do something similar? ``` private String processString(String t) { t...
2014/02/03
[ "https://codereview.stackexchange.com/questions/40746", "https://codereview.stackexchange.com", "https://codereview.stackexchange.com/users/14889/" ]
You could create a `StringProcessor` interface: ``` public interface StringProcessor { String process(String input); } public class BoldProcessor implements StringProcessor { public String process(final String input) { ... } } ``` and create a `List` from the available implementations: ``` fi...
This sounds like a case where you should encapsulate the data with a ['Decorator Pattern'](http://en.wikipedia.org/wiki/Decorator_pattern). You should declare a simple interface such as: ``` public interface StyledString { public String toFormatted(); public StyledString getSource(); } ``` Then create a con...
40,746
I am working on a small custom Markup script in Java that converts a Markdown/Wiki style markup into HTML. The below works, but as I add more Markup I can see it becoming unwieldy and hard to maintain. Is there is a better, more elegant, way to do something similar? ``` private String processString(String t) { t...
2014/02/03
[ "https://codereview.stackexchange.com/questions/40746", "https://codereview.stackexchange.com", "https://codereview.stackexchange.com/users/14889/" ]
If you want to process a language, even a simple one like a Wiki Markup, you should eventually write a proper parser, not do step-by-step replacement, nor chain a number of individual processors, no matter how fancy their implementation. You can go with the fully generic approach, generate an AST from the markup (this...
This sounds like a case where you should encapsulate the data with a ['Decorator Pattern'](http://en.wikipedia.org/wiki/Decorator_pattern). You should declare a simple interface such as: ``` public interface StyledString { public String toFormatted(); public StyledString getSource(); } ``` Then create a con...
40,746
I am working on a small custom Markup script in Java that converts a Markdown/Wiki style markup into HTML. The below works, but as I add more Markup I can see it becoming unwieldy and hard to maintain. Is there is a better, more elegant, way to do something similar? ``` private String processString(String t) { t...
2014/02/03
[ "https://codereview.stackexchange.com/questions/40746", "https://codereview.stackexchange.com", "https://codereview.stackexchange.com/users/14889/" ]
You could create a `StringProcessor` interface: ``` public interface StringProcessor { String process(String input); } public class BoldProcessor implements StringProcessor { public String process(final String input) { ... } } ``` and create a `List` from the available implementations: ``` fi...
If you want to process a language, even a simple one like a Wiki Markup, you should eventually write a proper parser, not do step-by-step replacement, nor chain a number of individual processors, no matter how fancy their implementation. You can go with the fully generic approach, generate an AST from the markup (this...
40,746
I am working on a small custom Markup script in Java that converts a Markdown/Wiki style markup into HTML. The below works, but as I add more Markup I can see it becoming unwieldy and hard to maintain. Is there is a better, more elegant, way to do something similar? ``` private String processString(String t) { t...
2014/02/03
[ "https://codereview.stackexchange.com/questions/40746", "https://codereview.stackexchange.com", "https://codereview.stackexchange.com/users/14889/" ]
You could create a `StringProcessor` interface: ``` public interface StringProcessor { String process(String input); } public class BoldProcessor implements StringProcessor { public String process(final String input) { ... } } ``` and create a `List` from the available implementations: ``` fi...
I like @palacsint's approach but I just have one thing to add, you can probably do most of the processing with the same class. ``` public class TagProcessor implements StringProcessor { private final String wrapWith; public TagProcessor(String wrapWith) { this.wrapWith = wrapWith; } @Override ...
40,746
I am working on a small custom Markup script in Java that converts a Markdown/Wiki style markup into HTML. The below works, but as I add more Markup I can see it becoming unwieldy and hard to maintain. Is there is a better, more elegant, way to do something similar? ``` private String processString(String t) { t...
2014/02/03
[ "https://codereview.stackexchange.com/questions/40746", "https://codereview.stackexchange.com", "https://codereview.stackexchange.com/users/14889/" ]
If you want to process a language, even a simple one like a Wiki Markup, you should eventually write a proper parser, not do step-by-step replacement, nor chain a number of individual processors, no matter how fancy their implementation. You can go with the fully generic approach, generate an AST from the markup (this...
I like @palacsint's approach but I just have one thing to add, you can probably do most of the processing with the same class. ``` public class TagProcessor implements StringProcessor { private final String wrapWith; public TagProcessor(String wrapWith) { this.wrapWith = wrapWith; } @Override ...
1,173,383
My Run button is grayed out. This includes starting a new project of any type. I completely un-installed VS 2008 and Re-Installed it. The Run is Still grayed out. VB is now worthless.
2009/07/23
[ "https://Stackoverflow.com/questions/1173383", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18225/" ]
It sounds like you do not have a clear spec. If you don't have a clear spec then how can you possibly know whether the code works according to spec? Take a step back. Start by writing a **one sentence spec**: **The FrobFilter component takes a sequence of Frobs and places each one in the correct FrobBin until one bi...
It sounds like you should be testing each of these filters separately, with a mock filter "underneath" each one to be chained to. Hopefully each of the filters is simple, and can be tested simply. I'd then have a few integration tests for the whole thing when it's all wired up.
6,304,375
I'm looking for a `RegEx` for multiple line email addresses. For example: 1) Single email: ``` johnsmith@email.com - ok ``` 2) Two line email: ``` johnsmith@email.com karensmith@emailcom - ok ``` 3) Two line email: ``` john smith@email.com - not ok karensmith@emailcom ``` I've tried the following: ``` ((\...
2011/06/10
[ "https://Stackoverflow.com/questions/6304375", "https://Stackoverflow.com", "https://Stackoverflow.com/users/306098/" ]
How about: ``` ^(((\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*(\r\n)?\s?)+)*)$ ``` Check the beginning of the string using '^' and the end using '$'. Allow an optional whitespace character with '\s?'. Try out <http://myregexp.com/signedJar.html> for testing regex expressions.
My guess would be that you probably need a multiline option at the end of your regexp (in most cases `/m` after the regexp). **Edit** You might also want to add anchors `\A` and `\z` to mark the beginning and end of the input data. Here is a [good article](http://www.regular-expressions.info/anchors.html) on anchors. ...
6,304,375
I'm looking for a `RegEx` for multiple line email addresses. For example: 1) Single email: ``` johnsmith@email.com - ok ``` 2) Two line email: ``` johnsmith@email.com karensmith@emailcom - ok ``` 3) Two line email: ``` john smith@email.com - not ok karensmith@emailcom ``` I've tried the following: ``` ((\...
2011/06/10
[ "https://Stackoverflow.com/questions/6304375", "https://Stackoverflow.com", "https://Stackoverflow.com/users/306098/" ]
I'd split the string on `[\r\n]+` and then test each address individualy.
My guess would be that you probably need a multiline option at the end of your regexp (in most cases `/m` after the regexp). **Edit** You might also want to add anchors `\A` and `\z` to mark the beginning and end of the input data. Here is a [good article](http://www.regular-expressions.info/anchors.html) on anchors. ...
6,304,375
I'm looking for a `RegEx` for multiple line email addresses. For example: 1) Single email: ``` johnsmith@email.com - ok ``` 2) Two line email: ``` johnsmith@email.com karensmith@emailcom - ok ``` 3) Two line email: ``` john smith@email.com - not ok karensmith@emailcom ``` I've tried the following: ``` ((\...
2011/06/10
[ "https://Stackoverflow.com/questions/6304375", "https://Stackoverflow.com", "https://Stackoverflow.com/users/306098/" ]
How about: ``` ^(((\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*(\r\n)?\s?)+)*)$ ``` Check the beginning of the string using '^' and the end using '$'. Allow an optional whitespace character with '\s?'. Try out <http://myregexp.com/signedJar.html> for testing regex expressions.
I'd split the string on `[\r\n]+` and then test each address individualy.
49,029,592
I have data ``` dat1 <- data.table(id=1:9, group=c(1,1,2,2,2,3,3,3,3), t=c(14,17,20,21,26,89,90,95,99), index=c(1,2,1,2,3,1,2,3,4) ) ``` and I would like to compute the difference on `t` to the previous value, according to `index`. For the fi...
2018/02/28
[ "https://Stackoverflow.com/questions/49029592", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5089467/" ]
A possible solution: ``` dat1[, dif := ifelse(index == min(index), t - dat2$start[match(.BY, dat2$group)], t - shift(t)) , by = group][] ``` which gives: > > > ``` > id group t index dif > 1: 1 1 14 1 4 > 2: 2 1 17 2 3 > 3: 3 2 20 1...
I would try to avoid `ifelse` and use data.tables efficient join-capabilities: ``` dat1[dat2, on = "group", # join on group start := i.start][, # add start value diff := diff(c(start[1L], t)), by = group][, # compute difference sta...
49,029,592
I have data ``` dat1 <- data.table(id=1:9, group=c(1,1,2,2,2,3,3,3,3), t=c(14,17,20,21,26,89,90,95,99), index=c(1,2,1,2,3,1,2,3,4) ) ``` and I would like to compute the difference on `t` to the previous value, according to `index`. For the fi...
2018/02/28
[ "https://Stackoverflow.com/questions/49029592", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5089467/" ]
A possible solution: ``` dat1[, dif := ifelse(index == min(index), t - dat2$start[match(.BY, dat2$group)], t - shift(t)) , by = group][] ``` which gives: > > > ``` > id group t index dif > 1: 1 1 14 1 4 > 2: 2 1 17 2 3 > 3: 3 2 20 1...
You may use `shift` with a dynamic `fill` argument: Index 'dat2' with `.BY` to get 'start' values for each 'group': ``` dat1[ , dif := t - shift(t, fill = dat2[group == .BY, start]), by = group] # id group t index dif # 1: 1 1 14 1 4 # 2: 2 1 17 2 3 # 3: 3 2 20 1 5 # 4: 4 2 ...
345,483
What's the word for when a person chooses to believe something based on preconceptions rather than judging it objectively? Here's an example (a little contrived but hopefully illustrates the point): A person ,P, is usually very healthy and prides themself on eating good, healthy food. This person has two friends, A a...
2016/08/29
[ "https://english.stackexchange.com/questions/345483", "https://english.stackexchange.com", "https://english.stackexchange.com/users/193661/" ]
It's almost in your title. **[preconceived](https://www.oxforddictionaries.com/definition/english/preconceived)** > > ADJECTIVE > (Of an idea or opinion) formed before having the evidence for its truth or usefulness: > the same set of facts can be tailored to fit any preconceived belief > > >
**Biased** is the word that comes to my mind when a person is not objective. From your example, person P is unfair in treating person B's food even though B's food is super healthy. So P is biased towards person A's choices. [Cambridge](http://dictionary.cambridge.org/dictionary/english/biased) dictionary defines *...
345,483
What's the word for when a person chooses to believe something based on preconceptions rather than judging it objectively? Here's an example (a little contrived but hopefully illustrates the point): A person ,P, is usually very healthy and prides themself on eating good, healthy food. This person has two friends, A a...
2016/08/29
[ "https://english.stackexchange.com/questions/345483", "https://english.stackexchange.com", "https://english.stackexchange.com/users/193661/" ]
I think you are looking for ***[prejudice](http://www.dictionary.com/browse/prejudice):*** > > * any preconceived opinion or feeling, either favorable or unfavorable. > > > (Dictionary.com)
**Biased** is the word that comes to my mind when a person is not objective. From your example, person P is unfair in treating person B's food even though B's food is super healthy. So P is biased towards person A's choices. [Cambridge](http://dictionary.cambridge.org/dictionary/english/biased) dictionary defines *...
60,369,740
I've reduced my code down to the following minimum code: ``` #include<iostream> #include<vector> class tt { public: bool player; std::vector<tt> actions; }; template<typename state_t> int func(state_t &state, const bool is_max) { state.player = true; const auto &actions = state.actions; if(st...
2020/02/24
[ "https://Stackoverflow.com/questions/60369740", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8869570/" ]
**Answer is mainly extracted from Scott Mayers *Effective C++* book.** ``` template<typename T> void f(ParamType param); f(expr); // deduce T and ParamType from expr ``` **ParamType is a Reference or Pointer, but not a Universal Reference** The simplest situation is when ParamType is a reference type...
In addition to @aep's answer, If it had been deduced as `tt` instead of `const tt`, the compiler would generated an error too, because it is not possible to bind `const reference` to `non-const reference` without `const_cast`. ``` #include<iostream> #include<vector> class tt { public: bool player; std::...
28,016,571
Although undocumented, conventional wisdom using the Android BLE apis is that certain operations like reading / writing Characteristics & Descriptors should be done one at a time (although some devices are more lenient than others). However, I am not clear on whether this policy should apply only to a single connection...
2015/01/19
[ "https://Stackoverflow.com/questions/28016571", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4468153/" ]
While I cannot speak for the upper layer, I can relate to what will happen on lower hardware level and that might provide some insights for your design. Which ever is the stack on upper layer doing, at the end the operation has to be handled by the transceiver chip. BLE is operating over 40 channel band in which 3 ar...
BLE is designed to be asynchronous and event driven. You can send the commands however you like and you will get the responses back in no particular order. If you send a command and expect the next packet to be the response, you're going to get into trouble. This being said, I'm not sure how the Android library is str...
28,016,571
Although undocumented, conventional wisdom using the Android BLE apis is that certain operations like reading / writing Characteristics & Descriptors should be done one at a time (although some devices are more lenient than others). However, I am not clear on whether this policy should apply only to a single connection...
2015/01/19
[ "https://Stackoverflow.com/questions/28016571", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4468153/" ]
On Android, *per BluetoothGatt object* you should only execute one operation at a time (request mtu, discover services, read/write characteristic/descriptor) otherwise things will go wrong. You have to wait until the corresponding callback gets called until you can execute the next operation. Regarding having pending ...
BLE is designed to be asynchronous and event driven. You can send the commands however you like and you will get the responses back in no particular order. If you send a command and expect the next packet to be the response, you're going to get into trouble. This being said, I'm not sure how the Android library is str...
28,016,571
Although undocumented, conventional wisdom using the Android BLE apis is that certain operations like reading / writing Characteristics & Descriptors should be done one at a time (although some devices are more lenient than others). However, I am not clear on whether this policy should apply only to a single connection...
2015/01/19
[ "https://Stackoverflow.com/questions/28016571", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4468153/" ]
On Android, *per BluetoothGatt object* you should only execute one operation at a time (request mtu, discover services, read/write characteristic/descriptor) otherwise things will go wrong. You have to wait until the corresponding callback gets called until you can execute the next operation. Regarding having pending ...
While I cannot speak for the upper layer, I can relate to what will happen on lower hardware level and that might provide some insights for your design. Which ever is the stack on upper layer doing, at the end the operation has to be handled by the transceiver chip. BLE is operating over 40 channel band in which 3 ar...
14,319,795
I have create a jsFiddle to demonstrate my problem: > > <http://jsfiddle.net/MXt8d/1/> > > > ``` .outer { display: inline-block; vertical-align: top; overflow: visible; position: relative; width: 100%; height: 100%; background: red; } .inner { overflow: hidden; height: 50%; width: 100%; mar...
2013/01/14
[ "https://Stackoverflow.com/questions/14319795", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1115457/" ]
To `#inner` element: 1) Add `position:absolute` 2) Remove `margin-top` and `margin-bottom` properties 3) Add `top:25%` That's it!
It is a solution to your problem.I hope I helped you ``` .inner { overflow: hidden; height: 50%; width: 100%; top:0; bottom:0; left:0; right:0; position: absolute; margin: auto; background: blue; opacity: 0.7; color: white; } ```
14,319,795
I have create a jsFiddle to demonstrate my problem: > > <http://jsfiddle.net/MXt8d/1/> > > > ``` .outer { display: inline-block; vertical-align: top; overflow: visible; position: relative; width: 100%; height: 100%; background: red; } .inner { overflow: hidden; height: 50%; width: 100%; mar...
2013/01/14
[ "https://Stackoverflow.com/questions/14319795", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1115457/" ]
To `#inner` element: 1) Add `position:absolute` 2) Remove `margin-top` and `margin-bottom` properties 3) Add `top:25%` That's it!
There are various solutions to your problem: 1) add `position:absolute` and `top:25%` on the inner element - **[Example](http://jsfiddle.net/MXt8d/3/)** 2) use `display:table` on the outer and `display:table-cell` on the inner element, this also allows vertical centering. - **[Example](http://jsfiddle.net/MXt8d/2/)**...
13,553,531
Is there any attribute to tell a (standard) NumberPicker to stop after its last value? E.g. if my MinValue was 0 and my MaxValue was 5 the NumberPicker just repeats itself after the 5, so that the user could scroll endlessly.
2012/11/25
[ "https://Stackoverflow.com/questions/13553531", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1786159/" ]
If You had set min/max value, try this: ``` yourNumberPicker.setWrapSelectorWheel(false); ``` does this work for you? EDIT ---- For TimePicker: ``` timePicker.setOnTimeChangedListener(new TimePicker.OnTimeChangedListener() { public void onTimeChanged(TimePicker view, int hourOfDay, int minute) { if(hourOf...
This [Answer](https://stackoverflow.com/a/24963508/2630035) helped me: ``` public void updatePickerValues(String[] newValues){ picker.setDisplayedValues(null); picker.setMinValue(0); picker.setMaxValue(newValues.length -1); picker.setWrapSelectorWheel(false); picker.setDisplayedValues(newValues); } ``` App...
9,088,608
I have 2 list: List1: ```none ID 1 2 3 ``` List2: ```none ID Name 1 Jason 1 Jim 2 Mike 3 Phil ``` I like to join both of these but get only the first record from list2 for a given ID: The end result would be ```none ID Name 1 Jason 2 Mike 3 Phil ``` I tried the following but was not successful: ``` ...
2012/01/31
[ "https://Stackoverflow.com/questions/9088608", "https://Stackoverflow.com", "https://Stackoverflow.com/users/996431/" ]
You can get this result with what the [101 LINQ Samples](http://code.msdn.microsoft.com/101-LINQ-Samples-3fb9811b) calls ["Cross Join with Group Join"](http://code.msdn.microsoft.com/LINQ-Join-Operators-dabef4e9). Combine that with `First()` to get just one item from the group. ``` var lst = ( from lst1 in list1 ...
Here's one way to do it: ```cs var lst = list1 // Select distinct IDs that are in both lists: .Where(lst1 => list2 .Select(lst2 => lst2.ID) .Contains(lst1.ID)) .Distinct() // Select items in list 2 matching the IDs above: .Select(lst1 => list2 .Where(lst2 => lst2.ID == lst1....
9,088,608
I have 2 list: List1: ```none ID 1 2 3 ``` List2: ```none ID Name 1 Jason 1 Jim 2 Mike 3 Phil ``` I like to join both of these but get only the first record from list2 for a given ID: The end result would be ```none ID Name 1 Jason 2 Mike 3 Phil ``` I tried the following but was not successful: ``` ...
2012/01/31
[ "https://Stackoverflow.com/questions/9088608", "https://Stackoverflow.com", "https://Stackoverflow.com/users/996431/" ]
Here's one way to do it: ```cs var lst = list1 // Select distinct IDs that are in both lists: .Where(lst1 => list2 .Select(lst2 => lst2.ID) .Contains(lst1.ID)) .Distinct() // Select items in list 2 matching the IDs above: .Select(lst1 => list2 .Where(lst2 => lst2.ID == lst1....
Another way: ``` var query = from lst1 in list1 let first = list2.FirstOrDefault(f => f.Id == lst1.Id) where first != null select first; ``` Or if you wanted to know about items that could not be located in list2: ``` var query = from lst1 in list1 let first = list2.F...
9,088,608
I have 2 list: List1: ```none ID 1 2 3 ``` List2: ```none ID Name 1 Jason 1 Jim 2 Mike 3 Phil ``` I like to join both of these but get only the first record from list2 for a given ID: The end result would be ```none ID Name 1 Jason 2 Mike 3 Phil ``` I tried the following but was not successful: ``` ...
2012/01/31
[ "https://Stackoverflow.com/questions/9088608", "https://Stackoverflow.com", "https://Stackoverflow.com/users/996431/" ]
You can get this result with what the [101 LINQ Samples](http://code.msdn.microsoft.com/101-LINQ-Samples-3fb9811b) calls ["Cross Join with Group Join"](http://code.msdn.microsoft.com/LINQ-Join-Operators-dabef4e9). Combine that with `First()` to get just one item from the group. ``` var lst = ( from lst1 in list1 ...
Try grouping list2 by ID first and then selecting the first item from each group. After that, do the join and select what you want. ``` var uniqueIDList2 = list2.GroupBy(p => p.ID) .Select(p => p.First()); var result = from lst1 in list1 join lst2 in uniqueIDList2 on lst1.ID equa...
9,088,608
I have 2 list: List1: ```none ID 1 2 3 ``` List2: ```none ID Name 1 Jason 1 Jim 2 Mike 3 Phil ``` I like to join both of these but get only the first record from list2 for a given ID: The end result would be ```none ID Name 1 Jason 2 Mike 3 Phil ``` I tried the following but was not successful: ``` ...
2012/01/31
[ "https://Stackoverflow.com/questions/9088608", "https://Stackoverflow.com", "https://Stackoverflow.com/users/996431/" ]
Try grouping list2 by ID first and then selecting the first item from each group. After that, do the join and select what you want. ``` var uniqueIDList2 = list2.GroupBy(p => p.ID) .Select(p => p.First()); var result = from lst1 in list1 join lst2 in uniqueIDList2 on lst1.ID equa...
Another way: ``` var query = from lst1 in list1 let first = list2.FirstOrDefault(f => f.Id == lst1.Id) where first != null select first; ``` Or if you wanted to know about items that could not be located in list2: ``` var query = from lst1 in list1 let first = list2.F...
9,088,608
I have 2 list: List1: ```none ID 1 2 3 ``` List2: ```none ID Name 1 Jason 1 Jim 2 Mike 3 Phil ``` I like to join both of these but get only the first record from list2 for a given ID: The end result would be ```none ID Name 1 Jason 2 Mike 3 Phil ``` I tried the following but was not successful: ``` ...
2012/01/31
[ "https://Stackoverflow.com/questions/9088608", "https://Stackoverflow.com", "https://Stackoverflow.com/users/996431/" ]
You can get this result with what the [101 LINQ Samples](http://code.msdn.microsoft.com/101-LINQ-Samples-3fb9811b) calls ["Cross Join with Group Join"](http://code.msdn.microsoft.com/LINQ-Join-Operators-dabef4e9). Combine that with `First()` to get just one item from the group. ``` var lst = ( from lst1 in list1 ...
Another way: ``` var query = from lst1 in list1 let first = list2.FirstOrDefault(f => f.Id == lst1.Id) where first != null select first; ``` Or if you wanted to know about items that could not be located in list2: ``` var query = from lst1 in list1 let first = list2.F...
58,203,700
I have a string: ``` a = '"{""key1"": ""val1"", ""key2"":""val2""}"' ``` What is the most propriate way to convert this to a dictionary in Python? plain `json.loads(a)` cannot decipher this format. **EDIT:** This weird JSON string is created when I read a CSV with one "json-like" column.
2019/10/02
[ "https://Stackoverflow.com/questions/58203700", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4174013/" ]
I don't know this kind of format for json. So you can use the next function : ``` import json def load_weird_json(json_string): a = json_string.replace('""','"') a = a[1:len(a)-1] return json.loads(a) ```
Try ``` import json a = '"{""key1"": ""val1"", ""key2"":"val2""}"' a = a.replace('""','"').replace('}"',"}").replace('"{','{') data = json.loads(a) print(data) ``` output ``` {'key1': 'val1', 'key2': 'val2'} ```
58,203,700
I have a string: ``` a = '"{""key1"": ""val1"", ""key2"":""val2""}"' ``` What is the most propriate way to convert this to a dictionary in Python? plain `json.loads(a)` cannot decipher this format. **EDIT:** This weird JSON string is created when I read a CSV with one "json-like" column.
2019/10/02
[ "https://Stackoverflow.com/questions/58203700", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4174013/" ]
Assuming the string came from a CSV file, use `csv` to decode it before passing the result to `json` for decoding. ``` >>> import io, csv, json >>> a = '"{""key1"": ""val1"", ""key2"":""val2""}"' >>> csv_file_like = io.StringIO(a) >>> reader = csv.reader(csv_file_like) >>> result = list(reader) >>> json.loads(result[0...
I don't know this kind of format for json. So you can use the next function : ``` import json def load_weird_json(json_string): a = json_string.replace('""','"') a = a[1:len(a)-1] return json.loads(a) ```
58,203,700
I have a string: ``` a = '"{""key1"": ""val1"", ""key2"":""val2""}"' ``` What is the most propriate way to convert this to a dictionary in Python? plain `json.loads(a)` cannot decipher this format. **EDIT:** This weird JSON string is created when I read a CSV with one "json-like" column.
2019/10/02
[ "https://Stackoverflow.com/questions/58203700", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4174013/" ]
I don't know this kind of format for json. So you can use the next function : ``` import json def load_weird_json(json_string): a = json_string.replace('""','"') a = a[1:len(a)-1] return json.loads(a) ```
The @chepner's answer actually sent me in the right direction. The string was loaded from CSV and I could effectively prevent this weird JSON forming by using answer from here: [spark 2.0 read csv with json](https://stackoverflow.com/questions/47176021/spark-2-0-read-csv-with-json), i.e. add the escape char `'\"'` opti...
58,203,700
I have a string: ``` a = '"{""key1"": ""val1"", ""key2"":""val2""}"' ``` What is the most propriate way to convert this to a dictionary in Python? plain `json.loads(a)` cannot decipher this format. **EDIT:** This weird JSON string is created when I read a CSV with one "json-like" column.
2019/10/02
[ "https://Stackoverflow.com/questions/58203700", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4174013/" ]
Assuming the string came from a CSV file, use `csv` to decode it before passing the result to `json` for decoding. ``` >>> import io, csv, json >>> a = '"{""key1"": ""val1"", ""key2"":""val2""}"' >>> csv_file_like = io.StringIO(a) >>> reader = csv.reader(csv_file_like) >>> result = list(reader) >>> json.loads(result[0...
Try ``` import json a = '"{""key1"": ""val1"", ""key2"":"val2""}"' a = a.replace('""','"').replace('}"',"}").replace('"{','{') data = json.loads(a) print(data) ``` output ``` {'key1': 'val1', 'key2': 'val2'} ```
58,203,700
I have a string: ``` a = '"{""key1"": ""val1"", ""key2"":""val2""}"' ``` What is the most propriate way to convert this to a dictionary in Python? plain `json.loads(a)` cannot decipher this format. **EDIT:** This weird JSON string is created when I read a CSV with one "json-like" column.
2019/10/02
[ "https://Stackoverflow.com/questions/58203700", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4174013/" ]
Assuming the string came from a CSV file, use `csv` to decode it before passing the result to `json` for decoding. ``` >>> import io, csv, json >>> a = '"{""key1"": ""val1"", ""key2"":""val2""}"' >>> csv_file_like = io.StringIO(a) >>> reader = csv.reader(csv_file_like) >>> result = list(reader) >>> json.loads(result[0...
The @chepner's answer actually sent me in the right direction. The string was loaded from CSV and I could effectively prevent this weird JSON forming by using answer from here: [spark 2.0 read csv with json](https://stackoverflow.com/questions/47176021/spark-2-0-read-csv-with-json), i.e. add the escape char `'\"'` opti...