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
25,758,729
I have a python script that grabs a bunch of recent tweets from the twitter API and dumps them to screen. It works well, but when I try to direct the output to a file something strange happens and a print statement causes an exception: ``` > ./tweets.py > tweets.txt UnicodeEncodeError: 'ascii' codec can't encode chara...
2014/09/10
[ "https://Stackoverflow.com/questions/25758729", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1475548/" ]
Without modifying the script, you can just set the environment variable `PYTHONIOENCODING=utf8` and Python will assume that encoding when redirecting to a file. References: <https://docs.python.org/2.7/using/cmdline.html#envvar-PYTHONIOENCODING> <https://docs.python.org/3.3/using/cmdline.html#envvar-PYTHONIOENCODING>
You may need encode the unicode object with `.encode('utf-8')` ~~In your python file append this to first line~~ ``` # -*- coding: utf-8 -*- ``` If your script file is working standalone, append it to second line ``` #!/usr/local/bin/python # -*- coding: utf-8 -*- ``` Here is the document: [PEP 0263](http://lega...
103,317
I have 2 web parts. One is a web parts with link buttons that represent the title of videos. The second is a html5 video player. I need to send the id of a video from web part 1 to web part 2
2014/06/11
[ "https://sharepoint.stackexchange.com/questions/103317", "https://sharepoint.stackexchange.com", "https://sharepoint.stackexchange.com/users/29547/" ]
You can make this via connections. Here's an overview: <http://office.microsoft.com/en-us/windows-sharepoint-services-help/connect-data-in-web-parts-HA010024105.aspx> Just open the menu in the right top of your webpart (in edit mode) and you'll see "Connection"-> "Get Parameters From" for example.
I strongly suggest you to not use server-side connections. As far as I see, you only need to pass an ID. As far as you do not need and do not need to do something heavy on a server side (such as working with server-side controls), you should take a look on javascript custom events. [Custom events with jQuery](http://w...
38,365,645
I now where my errors are, I just don't know enough about javascript know where it needs to go, can anyone help me. I finally got this all working to auto embed media and images on my site (phpbb forum), and it works good, but the image embed isn't correct (even though it does work). Here's my errors from W3: require...
2016/07/14
[ "https://Stackoverflow.com/questions/38365645", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3570857/" ]
My guess is that this feature is not needed to be somehow specially supported by Datalab, because the only what you need to do is to supply table name with time partition as suffix (like you have it in your question - Feature.test$20141228). Of course you need to make sure first that your table (Feature.test) is proper...
There is great feature for tables in Google Big Query. If you have several tables with the same name + (Date), e.g test20141228, test20141229... You will have a set of tables with a scroll down button, as shown in the pic, which is really nice. Then you can use wild card function TABLE\_DATE\_RANGE([Feature.test], dat...
62,564,094
This MCVE won't compile in g++10 (with `-std=c++21 -fcoroutines` options). ``` #include <iostream> int f() { for (int i = 0; i < 10; ++i) co_yield i; } int main () { for (int i : f()) std::cout << i << ' '; return 0; } ``` What should that top line of `f` look like, so I get a working coroutine? O...
2020/06/24
[ "https://Stackoverflow.com/questions/62564094", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2216129/" ]
Here's a minimal working example with gcc 10.1 of a coroutine `myCoroutineFunction` that uses just `co_yield` and does not have a `co_return` It uses a counted for loop. A range for loop requires a little more work to write an iterator. The return type of a coroutine is a generator object that needs a promise object ...
From your question: > > What should that top line of f look like, so I get a working coroutine? > > > --- I have modified your code as below. Please pay special attention to return type of f. ``` Couroutine_Example_Generator<int> f() { for (int i = 0; i < 10; ++i) co_yield i; } int main () { for (auto i = ...
63,439,071
When I using this command in kubernetes v1.18 jenkins's master pod to mount a nfs file system: ``` root@jenkins-67fff76bb6-q77xf:/# mount -t nfs -o v4 192.168.31.2:/infrastructure/jenkins-share-workspaces /opt/jenkins mount: permission denied root@jenkins-67fff76bb6-q77xf:/# ``` why it shows permission denied althr...
2020/08/16
[ "https://Stackoverflow.com/questions/63439071", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2628868/" ]
There are two ways to mount nfs volume to a pod First (directly in pod spec): ``` kind: Pod apiVersion: v1 metadata: name: pod-using-nfs spec: volumes: - name: nfs-volume nfs: server: 192.168.31.2 path: /infrastructure/jenkins-share-workspaces containers: - name: app image: ...
Try using ``` securityContext: privileged: true ``` This needs if you are using dind for jenkins
4,575,098
When compiling a C/C++ program under Windows using Visual Studio (or a compiler that tries to be compatible) there is a predefined macro \_WIN32 (Source: <http://msdn.microsoft.com/en-us/library/b0084kay.aspx>) that you can use for platform-specific #ifdef-s. What I am looking for is an analogon under Linux: a macro w...
2011/01/01
[ "https://Stackoverflow.com/questions/4575098", "https://Stackoverflow.com", "https://Stackoverflow.com/users/497193/" ]
I once collected the identifying macros for use by pkgsrc, a cross-platform package system: <http://www.netbsd.org/docs/pkgsrc/fixes.html#fixes.build.cpp> I didn't find any authoritative source back then.
Nowadays, there are two games in town: Windows, and POSIX. You're very likely to be able to get what you want with `#ifndef _WIN32`, therefore. Distinctions among the surviving Unix variants are best done with autoconf-style feature tests, e.g. `#ifdef HAVE_SYS_WHATEVER_H`; but don't bother with any of those till you k...
4,575,098
When compiling a C/C++ program under Windows using Visual Studio (or a compiler that tries to be compatible) there is a predefined macro \_WIN32 (Source: <http://msdn.microsoft.com/en-us/library/b0084kay.aspx>) that you can use for platform-specific #ifdef-s. What I am looking for is an analogon under Linux: a macro w...
2011/01/01
[ "https://Stackoverflow.com/questions/4575098", "https://Stackoverflow.com", "https://Stackoverflow.com/users/497193/" ]
The [glibc manual](http://www.gnu.org/s/libc/manual/html_node/Feature-Test-Macros.html) lists several of these macros, including `_POSIX_SOURCE`. However, they work differently from what you might expect: the programmer defines these macros (in a build script, probably) and the C library headers check it to enable or d...
Nowadays, there are two games in town: Windows, and POSIX. You're very likely to be able to get what you want with `#ifndef _WIN32`, therefore. Distinctions among the surviving Unix variants are best done with autoconf-style feature tests, e.g. `#ifdef HAVE_SYS_WHATEVER_H`; but don't bother with any of those till you k...
26,547
J'ai trouvé cette phrase dans une émission de **News in Slow French**. > > nous parlerons de la nouvelle mesure de l’UE pour combattre le passage de clandestins **depuis** l’Afrique. > > > Si j'avais écrit cette phrase, ce serait plutôt : > > nous parlerons de la nouvelle mesure de l’UE pour combattre le passag...
2017/07/21
[ "https://french.stackexchange.com/questions/26547", "https://french.stackexchange.com", "https://french.stackexchange.com/users/12225/" ]
La présence de *depuis* est dûe à l'emploi de **passage** (On peut passer *depuis* un endroit A *vers* un endroit B). Hors de ce contexte, sans un autre verbe d'action similaire, on dirait plutôt *les clandestins d'Afrique* dans la plupart des cas. Ceci pour les mêmes raisons qu'on ne pourrait pas dire par exemple « Je...
Il peut exister d'autres façons que la suivante de supprimer le manque de netteté de l'effet produit par « depuis » ou « de » dans cette phrase, mais celle-ci est effective en même temps qu'elle ne demande pas tellement plus de mots; * nous parlerons de la nouvelle mesure de l’UE pour combattre le passage de clandesti...
53,725,464
I'm trying to print out the names that comes after the search engine clears them so for example I wrote in the searchValue "Mohamed" expecting it to print all Mohameds in the usersSeenStory but it's giving me an error saying **Missing argument for parameter 'in' in call** ``` var usersSeenStory = ("ameerahmed_", "_mo...
2018/12/11
[ "https://Stackoverflow.com/questions/53725464", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10775862/" ]
You can first extract all `uniq` sectors in an `array`. After that `map` into each sector and `filter` in your data which place correspond to. ```js var data = [{ city: 'a', value: 1, sector: 'Hospital' }, { city: 'b', value: 1, sector: 'Hardware' }, { city: 'c', value: 1, sector: 'Hardware' }, { city: 'd'...
You can create a function which will iterate using `reduce` over the array and store the unique sectors in an array and then return an array using `map` and `filter` with the required values. ``` function normalize (input){ const sectors = input.reduce(function(result, value){ if(result.indexOf(value.sector) ===...
53,725,464
I'm trying to print out the names that comes after the search engine clears them so for example I wrote in the searchValue "Mohamed" expecting it to print all Mohameds in the usersSeenStory but it's giving me an error saying **Missing argument for parameter 'in' in call** ``` var usersSeenStory = ("ameerahmed_", "_mo...
2018/12/11
[ "https://Stackoverflow.com/questions/53725464", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10775862/" ]
You can first extract all `uniq` sectors in an `array`. After that `map` into each sector and `filter` in your data which place correspond to. ```js var data = [{ city: 'a', value: 1, sector: 'Hospital' }, { city: 'b', value: 1, sector: 'Hardware' }, { city: 'c', value: 1, sector: 'Hardware' }, { city: 'd'...
Using [`reduce`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce) slightly differently with [`findIndex`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex). No need to create a separate array of keys this way. ```js const dat...
53,725,464
I'm trying to print out the names that comes after the search engine clears them so for example I wrote in the searchValue "Mohamed" expecting it to print all Mohameds in the usersSeenStory but it's giving me an error saying **Missing argument for parameter 'in' in call** ``` var usersSeenStory = ("ameerahmed_", "_mo...
2018/12/11
[ "https://Stackoverflow.com/questions/53725464", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10775862/" ]
Using [`reduce`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce) slightly differently with [`findIndex`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex). No need to create a separate array of keys this way. ```js const dat...
You can create a function which will iterate using `reduce` over the array and store the unique sectors in an array and then return an array using `map` and `filter` with the required values. ``` function normalize (input){ const sectors = input.reduce(function(result, value){ if(result.indexOf(value.sector) ===...
13,273,490
I'm trying to convert the following for loop into an enhanced for loop ``` for(int i=0; i< vowels.length; i++){ if(vowels[i] == Character.toLowerCase(c)){ return true; } } return false; ``` This is what I got, but I got `i == Character.isLetter(c)` unde...
2012/11/07
[ "https://Stackoverflow.com/questions/13273490", "https://Stackoverflow.com", "https://Stackoverflow.com/users/133466/" ]
`Character.isLetter(c)` returns `boolean` not `char`. You can't compare `boolean` with `char`. You may need to do something like below: ``` for(char i: vowels){ boolean isChar = Character.isLetter(c); if(isChar){ if(i ==c){ return true; } } ...
You must have meant ``` for (char v: vowels){ if (Character.isLetter(v)) { return true; } } return false; ``` Right now, you're comparing a `char` to the `boolean` resulting from the `isLetter` check. (I changed the variable name to `v` to emphasize that it's a vowel, not an index.)
63,803,607
I'm farly new to coding and I need some help. I'm trying to make a system with a Y/N input. I want to make is so that even if you enter in the input in lower or upper case it still registers the input. I can't really find anything that works as .lower() doesn't work and raw\_input is registered as a error, so please he...
2020/09/09
[ "https://Stackoverflow.com/questions/63803607", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14244860/" ]
just lowercase the logic you could also edit the code to find if the string starts with a 'y' or 'n'... ``` confirm_user = input("Is this your account? - Admin087 >> ") if confirm_user.lower() == "y": print("yes") elif confirm_user.lower() == "n": print('''Shutting down Windows 95 Beta System...''') else: ...
the easiest it would be to use `"string".upper()` method to force input to always be in uppercase. Then just check if the answer in uppercase is right. Best Regards
275,718
Wordpress post favorite image not showing on wp-admin and on page although it is set on DB. I have inserted posts with unnecessary data and post meta in DB from other db, all is ok. When I call thumbnail url like this , it is working ``` $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); echo $url; ```...
2017/08/03
[ "https://wordpress.stackexchange.com/questions/275718", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/57668/" ]
You have to echo it out: ``` echo get_the_post_thumbnail(); ``` Perhaps you meant to use `the_post_thumbnail();` <https://developer.wordpress.org/reference/functions/the_post_thumbnail/>
As you said the images are from another domain, it won't load. Check the database for 'siteurl' and 'home' columns in YOUR\_TABLE\_PREFIX\_options table have the correct url that you're working on. Probably this may be the problem > > website.tv/sub and website.tv(the main WP project). > > > Your main WP projec...
40,129,608
I have a problem with my contact form Filling in the form is OK etc, but when I send the message, I only receive the telephone nr. This is PHP code from sendmail. ``` <?php if (isset($_POST["submit"])) { // Checking For Blank Fields.. if ($_POST["name"] == "" || $_POST["email"] == "" || $_POST["tel"] == "") ...
2016/10/19
[ "https://Stackoverflow.com/questions/40129608", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
You overwrite the `$message` with each field so you will get only the last one (`tel`). You need to concatenate all the fields using `.` like this: ``` $message = $_POST['name'] . ", "; $message .= $_POST['email'] . ", " ; $message .= $_POST['tel']; ``` Or you can do in one line like this: ``` $message = $_POST['na...
You are replacing value of $message everytime with new value , and at end it is assigned to telephone so u only recieve telephone no Replace ``` $message = $_POST['name']; $message = $_POST['email']; $message = $_POST['tel']; ``` With ``` $message =$_POST['name']; $message =$message.$_POST['email']; $message =...
35,972,815
Any thought what am I doing wrong here? Here is my HTML code where I'm trying to do same thing but I'm getting element not found: ``` <div class="cell option"> <div class="form chk left"> <input id="check_returndate" type="radio" checked="" value="1" name="return"/> <label for="check_returndate">Round trip</label> </...
2016/03/13
[ "https://Stackoverflow.com/questions/35972815", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6016315/" ]
Why don't you use `driver.findElement(By.id("check_oneway"))` For CSS selector use `By.cssSelector("input[id='check_oneway'][value='0'][type='radio']")` You have space between the value and type filter that is why your selector not working.
You need to set context of the driver to the frame where the element is. Try this: ``` WebDriver driver = new FirefoxDriver(); driver.get("http://flight.ca"); driver.switchTo().frame(0); driver.findElement(By.cssSelector("#check_oneway")).click(); ```
35,972,815
Any thought what am I doing wrong here? Here is my HTML code where I'm trying to do same thing but I'm getting element not found: ``` <div class="cell option"> <div class="form chk left"> <input id="check_returndate" type="radio" checked="" value="1" name="return"/> <label for="check_returndate">Round trip</label> </...
2016/03/13
[ "https://Stackoverflow.com/questions/35972815", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6016315/" ]
Why don't you use `driver.findElement(By.id("check_oneway"))` For CSS selector use `By.cssSelector("input[id='check_oneway'][value='0'][type='radio']")` You have space between the value and type filter that is why your selector not working.
``` driver.findElement(By.cssSelector("input[id=check_oneway][value=0][type=radio]")).click(); driver.findElement(By.id("check_returndate")).click(); ```
35,972,815
Any thought what am I doing wrong here? Here is my HTML code where I'm trying to do same thing but I'm getting element not found: ``` <div class="cell option"> <div class="form chk left"> <input id="check_returndate" type="radio" checked="" value="1" name="return"/> <label for="check_returndate">Round trip</label> </...
2016/03/13
[ "https://Stackoverflow.com/questions/35972815", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6016315/" ]
You need to set context of the driver to the frame where the element is. Try this: ``` WebDriver driver = new FirefoxDriver(); driver.get("http://flight.ca"); driver.switchTo().frame(0); driver.findElement(By.cssSelector("#check_oneway")).click(); ```
``` driver.findElement(By.cssSelector("input[id=check_oneway][value=0][type=radio]")).click(); driver.findElement(By.id("check_returndate")).click(); ```
59,493,318
I'm trying to return and output the contents of a vector as a cohesive String. I tried `vector.toString()` but that would also include brackets and commas. I can't have that. Is there a way to convert just the elements of that vector into a String?
2019/12/26
[ "https://Stackoverflow.com/questions/59493318", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12603256/" ]
* You can do this by using apache StringUtils: ``` import java.util.Vector; import org.apache.commons.lang3.StringUtils; public class VectorExample { public static void main(String[] args) { Vector<String> vector= new Vector<String>(); vector.add("test1"); vector.add("test2"); vector.add("test3"); Sys...
You can do it as follows: ``` import java.util.Vector; public class Main { public static void main(String args[]) { Vector<Integer> vector = new Vector<Integer>(); vector.add(1); vector.add(2); vector.add(3); StringBuilder sb = new StringBuilder(); vector.forEach(n...
687,136
Basically I am not satisfied with the answers to [this question](https://physics.stackexchange.com/q/468142/). The question is asking for records (images, videos) of the double slit experiment with a which-way detector. And although the answers give some interesting information, they don't point to any such records. ...
2022/01/05
[ "https://physics.stackexchange.com/questions/687136", "https://physics.stackexchange.com", "https://physics.stackexchange.com/users/324325/" ]
Most real-world versions of the experiment that I've seen don't actually use two slits, but rather an optical circuit with separate paths using beam-splitters. In ["Induced coherence and indistinguishability in optical interference"](https://doi.org/10.1103/PhysRevLett.67.318) by Zou et. al., they discuss an experiment...
<https://phys.org/news/2011-01-which-way-detector-mystery-double-slit.html> In this link they describe a which way experiment with electrons done by the Italians. After this there were many thought experiments to emphasize the point.
42,589,987
after searching and trying for about 2 hours I decided to ask you. If I call my website with Google Chrome or Safari I do not have this issue. But if I call my website with Mozilla Firefox, I see a little white space between my 3 social media links and the next row. Test it by yourself. Does it works with Chrome/Safa...
2017/03/03
[ "https://Stackoverflow.com/questions/42589987", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7547694/" ]
You need to remove the `display: inline-block;` from the following selector: `a.ubtn-link`
Every browser has its own default stylesheet. Try using CSS reset (resets default CSS) and your problem should be solved. To use CSS Reset, include the following source file in your web page:
42,589,987
after searching and trying for about 2 hours I decided to ask you. If I call my website with Google Chrome or Safari I do not have this issue. But if I call my website with Mozilla Firefox, I see a little white space between my 3 social media links and the next row. Test it by yourself. Does it works with Chrome/Safa...
2017/03/03
[ "https://Stackoverflow.com/questions/42589987", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7547694/" ]
You need to remove the `display: inline-block;` from the following selector: `a.ubtn-link`
at BODY tag set the line-height to zero. like this: ``` <body class="home page-template-default page page-id-14 gecko osx wpb-js-composer js-comp-ver-5.0.1 vc_responsive" style="line-height:0;"> ``` Or do it in your custom .CSS file.
57,302,227
This seems like a basic question. I want to use the datetime index in a pandas dataframe as the x values of a machine leanring algorithm for a univarte time series comparisons. I tried to isolate the index and then convert it to a number but i get an error. ``` df=data["Close"] idx=df.index df.index.get_loc(idx) Dat...
2019/08/01
[ "https://Stackoverflow.com/questions/57302227", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4821921/" ]
One approach would be to use an `EXISTS` condition in the `WHERE` clause which asserts that a given IQ value matches at least one other married record: ``` SELECT age, iq, married FROM People p1 WHERE EXISTS (SELECT 1 FROM People p2 WHERE p1.iq = p2.iq AND p2.married = 1); ``` [![enter image description here](https:...
Try this query: ``` select * from People where iq in ( select iq from People group by iq having sum(married) > 0 ) ```
1,469,986
``` One\n Two\n Three\n Four\n ``` remove\_lines(2) would remove the first two lines, leaving the string: ``` Three\n Four\n ```
2009/09/24
[ "https://Stackoverflow.com/questions/1469986", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25068/" ]
### s.to\_a[2..-1].join ``` >> s = "One\nTwo\nThree\nFour\n" => "One\nTwo\nThree\nFour\n" >> s.to_a[2..-1].join => "Three\nFour\n" ```
``` class String def remove_lines(i) split("\n")[i..-1].join("\n") end end ``` Calling `"One\nTwo\nThree\nFour\n".remove_lines(2)` would result in `"Three\nFour"`. If you need the trailing `"\n"` you need to extend this method accordingly.
1,469,986
``` One\n Two\n Three\n Four\n ``` remove\_lines(2) would remove the first two lines, leaving the string: ``` Three\n Four\n ```
2009/09/24
[ "https://Stackoverflow.com/questions/1469986", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25068/" ]
I had a situation where I needed to support multiple platform EOLN (both \r and \n), and had success with the following: ``` split(/\r\n|\r|\n/, 2).last ``` Or the equivalent `remove_lines`: ``` def remove_lines(number_of_lines=1) split(/\r\n|\r|\n/, number_of_lines+1).last end ```
This problem will remove the first two lines using regular expression. ``` Text = "One\nTwo\nThree\nFour" Text = Text.gsub /^(?:[^\n]*\n){2}/, '' # -----------------------------------^^ (2) Replace with nothing # ----------------^^^^^^^^^^^^^^^^ (1) Detect first 2 lines puts Text ``` **EDIT:** I've just saw t...
1,469,986
``` One\n Two\n Three\n Four\n ``` remove\_lines(2) would remove the first two lines, leaving the string: ``` Three\n Four\n ```
2009/09/24
[ "https://Stackoverflow.com/questions/1469986", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25068/" ]
``` class String def remove_lines(i) split("\n")[i..-1].join("\n") end end ``` Calling `"One\nTwo\nThree\nFour\n".remove_lines(2)` would result in `"Three\nFour"`. If you need the trailing `"\n"` you need to extend this method accordingly.
I had a situation where I needed to support multiple platform EOLN (both \r and \n), and had success with the following: ``` split(/\r\n|\r|\n/, 2).last ``` Or the equivalent `remove_lines`: ``` def remove_lines(number_of_lines=1) split(/\r\n|\r|\n/, number_of_lines+1).last end ```
1,469,986
``` One\n Two\n Three\n Four\n ``` remove\_lines(2) would remove the first two lines, leaving the string: ``` Three\n Four\n ```
2009/09/24
[ "https://Stackoverflow.com/questions/1469986", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25068/" ]
``` class String def remove_lines(i) split("\n")[i..-1].join("\n") end end ``` Calling `"One\nTwo\nThree\nFour\n".remove_lines(2)` would result in `"Three\nFour"`. If you need the trailing `"\n"` you need to extend this method accordingly.
This problem will remove the first two lines using regular expression. ``` Text = "One\nTwo\nThree\nFour" Text = Text.gsub /^(?:[^\n]*\n){2}/, '' # -----------------------------------^^ (2) Replace with nothing # ----------------^^^^^^^^^^^^^^^^ (1) Detect first 2 lines puts Text ``` **EDIT:** I've just saw t...
1,469,986
``` One\n Two\n Three\n Four\n ``` remove\_lines(2) would remove the first two lines, leaving the string: ``` Three\n Four\n ```
2009/09/24
[ "https://Stackoverflow.com/questions/1469986", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25068/" ]
Here is a pure regexp one-liner. Hypothetically it should be even faster than the elegant solution provided by @DigitalRoss: ``` n = 4 # number of lines str.gsub(/\A(.*\n){#{n}}/,'') ``` If you know in advance how many line you want to cut (4 here): ``` str.gsub(/\A(.*\n){4}/,'') ``` And if you want to cut only o...
This problem will remove the first two lines using regular expression. ``` Text = "One\nTwo\nThree\nFour" Text = Text.gsub /^(?:[^\n]*\n){2}/, '' # -----------------------------------^^ (2) Replace with nothing # ----------------^^^^^^^^^^^^^^^^ (1) Detect first 2 lines puts Text ``` **EDIT:** I've just saw t...
1,469,986
``` One\n Two\n Three\n Four\n ``` remove\_lines(2) would remove the first two lines, leaving the string: ``` Three\n Four\n ```
2009/09/24
[ "https://Stackoverflow.com/questions/1469986", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25068/" ]
### s.to\_a[2..-1].join ``` >> s = "One\nTwo\nThree\nFour\n" => "One\nTwo\nThree\nFour\n" >> s.to_a[2..-1].join => "Three\nFour\n" ```
I had a situation where I needed to support multiple platform EOLN (both \r and \n), and had success with the following: ``` split(/\r\n|\r|\n/, 2).last ``` Or the equivalent `remove_lines`: ``` def remove_lines(number_of_lines=1) split(/\r\n|\r|\n/, number_of_lines+1).last end ```
1,469,986
``` One\n Two\n Three\n Four\n ``` remove\_lines(2) would remove the first two lines, leaving the string: ``` Three\n Four\n ```
2009/09/24
[ "https://Stackoverflow.com/questions/1469986", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25068/" ]
### s.to\_a[2..-1].join ``` >> s = "One\nTwo\nThree\nFour\n" => "One\nTwo\nThree\nFour\n" >> s.to_a[2..-1].join => "Three\nFour\n" ```
``` s = "One\nTwo\nThree\nFour" lines = s.lines > ["One\n", "Two\n", "Three\n", "Four"] remaining_lines = lines[2..-1] > ["Three\n", "Four"] remaining_lines.join > "Three\nFour" ``` * `String#lines` converts the string into an array of lines (retaining the new line character at the end of each string) * `[2..-1]` ...
1,469,986
``` One\n Two\n Three\n Four\n ``` remove\_lines(2) would remove the first two lines, leaving the string: ``` Three\n Four\n ```
2009/09/24
[ "https://Stackoverflow.com/questions/1469986", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25068/" ]
### s.to\_a[2..-1].join ``` >> s = "One\nTwo\nThree\nFour\n" => "One\nTwo\nThree\nFour\n" >> s.to_a[2..-1].join => "Three\nFour\n" ```
This problem will remove the first two lines using regular expression. ``` Text = "One\nTwo\nThree\nFour" Text = Text.gsub /^(?:[^\n]*\n){2}/, '' # -----------------------------------^^ (2) Replace with nothing # ----------------^^^^^^^^^^^^^^^^ (1) Detect first 2 lines puts Text ``` **EDIT:** I've just saw t...
1,469,986
``` One\n Two\n Three\n Four\n ``` remove\_lines(2) would remove the first two lines, leaving the string: ``` Three\n Four\n ```
2009/09/24
[ "https://Stackoverflow.com/questions/1469986", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25068/" ]
I had a situation where I needed to support multiple platform EOLN (both \r and \n), and had success with the following: ``` split(/\r\n|\r|\n/, 2).last ``` Or the equivalent `remove_lines`: ``` def remove_lines(number_of_lines=1) split(/\r\n|\r|\n/, number_of_lines+1).last end ```
``` def remove_lines(str, n) res = "" arr = str.split("\n")[n..(str.size-n)] arr.each { |i| res.concat(i + "\n") } return res end a = "1\n2\n3\n4\n" b = remove_lines(a, 2) print b ```
1,469,986
``` One\n Two\n Three\n Four\n ``` remove\_lines(2) would remove the first two lines, leaving the string: ``` Three\n Four\n ```
2009/09/24
[ "https://Stackoverflow.com/questions/1469986", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25068/" ]
``` s = "One\nTwo\nThree\nFour" lines = s.lines > ["One\n", "Two\n", "Three\n", "Four"] remaining_lines = lines[2..-1] > ["Three\n", "Four"] remaining_lines.join > "Three\nFour" ``` * `String#lines` converts the string into an array of lines (retaining the new line character at the end of each string) * `[2..-1]` ...
Here is a pure regexp one-liner. Hypothetically it should be even faster than the elegant solution provided by @DigitalRoss: ``` n = 4 # number of lines str.gsub(/\A(.*\n){#{n}}/,'') ``` If you know in advance how many line you want to cut (4 here): ``` str.gsub(/\A(.*\n){4}/,'') ``` And if you want to cut only o...
44,037,280
``` <div class="divColorContainer"> <div class="Blue"></div> <div class="Green"></div> <div class="Blue"></div> </div> ``` I have a button, when clicked I want to push that attribute into a array to compare for a score function later. I attempted `element.push($(.divColorContainer).attr(.Blue)` and many other ...
2017/05/18
[ "https://Stackoverflow.com/questions/44037280", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7907945/" ]
Hopefully, this article could help <http://www.htmlgoodies.com/beyond/javascript/making-promises-with-jquery-deferred.html> You will need to gather your ajax calls as promises, and get their responses together as in the code below (adapted from the link above) ``` var xhr1 = $.ajax("/some1"); var xhr2 = $.ajax("/some...
Can you modify your .done function to trigger the Face detect element? ``` .done(function(msg) { console.log("saved"); $("#uploading").hide(); $("#uploaded").show(); // Trigger the click event $('#testDetect').click(); }); ```
1,538,523
I am using the Ajax.BeginForm to create a form the will do an ajax postback to a certain controller action and then if the action is successful, the user should get redirected to another page (if the action fails then a status message gets displayed using the AjaxOptions UpdateTargetId). ``` using (Ajax.BeginForm("Del...
2009/10/08
[ "https://Stackoverflow.com/questions/1538523", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21579/" ]
You can return a JSON with the URL and change the window.location using JavaScript at client side. I prefer this way than calling a JavaScript function from the server, which I think that it's breaking the separation of concerns. Server side: ``` return Json(new {result = "Redirect", url = Url.Action("ActionName", "C...
How about this : ``` public ActionResult GetGrid() { string url = "login.html"; return new HttpStatusCodeResult(System.Net.HttpStatusCode.Redirect,url) } ``` **And then** ``` $(document).ajaxError(function (event, jqxhr, settings, thrownError) { if (jqxhr.status == 302) { location.href = jqxhr.stat...
1,538,523
I am using the Ajax.BeginForm to create a form the will do an ajax postback to a certain controller action and then if the action is successful, the user should get redirected to another page (if the action fails then a status message gets displayed using the AjaxOptions UpdateTargetId). ``` using (Ajax.BeginForm("Del...
2009/10/08
[ "https://Stackoverflow.com/questions/1538523", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21579/" ]
I needed to do this because I have an ajax login form. When users login successfully I redirect to a new page and end the previous request because the other page handles redirecting back to the relying party (because it's a STS SSO System). However, I also wanted it to work with javascript disabled, being the central ...
You can get a non-js-based redirection from an ajax call by putting in one of those meta refresh tags. This here seems to be working: `return Content("<meta http-equiv=\"refresh\" content=\"0;URL='" + @Url.Action("Index", "Home") + "'\" />");` Note: I discovered that meta refreshes are auto-disabled by Firefox, render...
1,538,523
I am using the Ajax.BeginForm to create a form the will do an ajax postback to a certain controller action and then if the action is successful, the user should get redirected to another page (if the action fails then a status message gets displayed using the AjaxOptions UpdateTargetId). ``` using (Ajax.BeginForm("Del...
2009/10/08
[ "https://Stackoverflow.com/questions/1538523", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21579/" ]
You can return a JSON with the URL and change the window.location using JavaScript at client side. I prefer this way than calling a JavaScript function from the server, which I think that it's breaking the separation of concerns. Server side: ``` return Json(new {result = "Redirect", url = Url.Action("ActionName", "C...
While not elegant, works for me in certain situations. **Controller** ``` if (RedirectToPage) return PartialView("JavascriptRedirect", new JavascriptRedirectModel("http://www.google.com")); else ... return regular ajax partialview ``` **Model** ``` public JavascriptRedirectModel(string location) { ...
1,538,523
I am using the Ajax.BeginForm to create a form the will do an ajax postback to a certain controller action and then if the action is successful, the user should get redirected to another page (if the action fails then a status message gets displayed using the AjaxOptions UpdateTargetId). ``` using (Ajax.BeginForm("Del...
2009/10/08
[ "https://Stackoverflow.com/questions/1538523", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21579/" ]
How about this : ``` public ActionResult GetGrid() { string url = "login.html"; return new HttpStatusCodeResult(System.Net.HttpStatusCode.Redirect,url) } ``` **And then** ``` $(document).ajaxError(function (event, jqxhr, settings, thrownError) { if (jqxhr.status == 302) { location.href = jqxhr.stat...
As ben foster says you can return the Javascripts and it will redirect you to the desired page. To load page in the current page: ``` return JavaScript("window.location = 'http://www.google.co.uk'");' ``` To load page in the new tab: ``` return JavaScript("window.open('http://www.google.co.uk')"); ```
1,538,523
I am using the Ajax.BeginForm to create a form the will do an ajax postback to a certain controller action and then if the action is successful, the user should get redirected to another page (if the action fails then a status message gets displayed using the AjaxOptions UpdateTargetId). ``` using (Ajax.BeginForm("Del...
2009/10/08
[ "https://Stackoverflow.com/questions/1538523", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21579/" ]
Using `JavaScript` will definitely do the job. You can also use `Content` if this is more your style. Example: **MVC Controller** ``` [HttpPost] public ActionResult AjaxMethod() { return Content(@"http://www.google.co.uk"); } ``` **Javascript** ``` $.ajax({ type: 'POST', url: '/AjaxMethod', succe...
I m not satisfied by the best answer by the Joseph, instead of fixing the correct problem, he told that this is wrong use case. In fact there are many places for example if you are converting an old codebase to ajaxified code and there you NEED it, then you NEED it. In programming there is no excuse because its not onl...
1,538,523
I am using the Ajax.BeginForm to create a form the will do an ajax postback to a certain controller action and then if the action is successful, the user should get redirected to another page (if the action fails then a status message gets displayed using the AjaxOptions UpdateTargetId). ``` using (Ajax.BeginForm("Del...
2009/10/08
[ "https://Stackoverflow.com/questions/1538523", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21579/" ]
You can return a JSON with the URL and change the window.location using JavaScript at client side. I prefer this way than calling a JavaScript function from the server, which I think that it's breaking the separation of concerns. Server side: ``` return Json(new {result = "Redirect", url = Url.Action("ActionName", "C...
You can get a non-js-based redirection from an ajax call by putting in one of those meta refresh tags. This here seems to be working: `return Content("<meta http-equiv=\"refresh\" content=\"0;URL='" + @Url.Action("Index", "Home") + "'\" />");` Note: I discovered that meta refreshes are auto-disabled by Firefox, render...
1,538,523
I am using the Ajax.BeginForm to create a form the will do an ajax postback to a certain controller action and then if the action is successful, the user should get redirected to another page (if the action fails then a status message gets displayed using the AjaxOptions UpdateTargetId). ``` using (Ajax.BeginForm("Del...
2009/10/08
[ "https://Stackoverflow.com/questions/1538523", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21579/" ]
You can use `JavascriptResult` to achieve this. To redirect: ``` return JavaScript("window.location = 'http://www.google.co.uk'"); ``` To reload the current page: ``` return JavaScript("location.reload(true)"); ``` Seems the simplest option.
As ben foster says you can return the Javascripts and it will redirect you to the desired page. To load page in the current page: ``` return JavaScript("window.location = 'http://www.google.co.uk'");' ``` To load page in the new tab: ``` return JavaScript("window.open('http://www.google.co.uk')"); ```
1,538,523
I am using the Ajax.BeginForm to create a form the will do an ajax postback to a certain controller action and then if the action is successful, the user should get redirected to another page (if the action fails then a status message gets displayed using the AjaxOptions UpdateTargetId). ``` using (Ajax.BeginForm("Del...
2009/10/08
[ "https://Stackoverflow.com/questions/1538523", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21579/" ]
Using `JavaScript` will definitely do the job. You can also use `Content` if this is more your style. Example: **MVC Controller** ``` [HttpPost] public ActionResult AjaxMethod() { return Content(@"http://www.google.co.uk"); } ``` **Javascript** ``` $.ajax({ type: 'POST', url: '/AjaxMethod', succe...
The accepted answer works well except for the fact that the javascript is briefly displayed in whatever the ajax target element is. To get around this, create a partial view called \_Redirect with the following code: ``` @model string <script> window.location = '@Model'; </script> ``` Then, in the controller repl...
1,538,523
I am using the Ajax.BeginForm to create a form the will do an ajax postback to a certain controller action and then if the action is successful, the user should get redirected to another page (if the action fails then a status message gets displayed using the AjaxOptions UpdateTargetId). ``` using (Ajax.BeginForm("Del...
2009/10/08
[ "https://Stackoverflow.com/questions/1538523", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21579/" ]
You can return a JSON with the URL and change the window.location using JavaScript at client side. I prefer this way than calling a JavaScript function from the server, which I think that it's breaking the separation of concerns. Server side: ``` return Json(new {result = "Redirect", url = Url.Action("ActionName", "C...
I needed to do this because I have an ajax login form. When users login successfully I redirect to a new page and end the previous request because the other page handles redirecting back to the relying party (because it's a STS SSO System). However, I also wanted it to work with javascript disabled, being the central ...
1,538,523
I am using the Ajax.BeginForm to create a form the will do an ajax postback to a certain controller action and then if the action is successful, the user should get redirected to another page (if the action fails then a status message gets displayed using the AjaxOptions UpdateTargetId). ``` using (Ajax.BeginForm("Del...
2009/10/08
[ "https://Stackoverflow.com/questions/1538523", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21579/" ]
You can simply do some kind of ajax response filter for incomming responses with **$.ajaxSetup**. If the response contains MVC redirection you can evaluate this expression on JS side. Example code for JS below: ``` $.ajaxSetup({ dataFilter: function (data, type) { if (data && typeof data == "string") { ...
You can get a non-js-based redirection from an ajax call by putting in one of those meta refresh tags. This here seems to be working: `return Content("<meta http-equiv=\"refresh\" content=\"0;URL='" + @Url.Action("Index", "Home") + "'\" />");` Note: I discovered that meta refreshes are auto-disabled by Firefox, render...
74,237,208
I am currently making a mobile app in flutter, which has a boomMenu, I would like to add a 'FutureBuilder' within this menu, this is possible, when I try to do it I get the following error: > > The body might complete normally, causing 'null' to be returned, but the return type is a potentially non-nullable type > >...
2022/10/28
[ "https://Stackoverflow.com/questions/74237208", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11156021/" ]
Never ever use floating point arithmetics for integer values, specialy in Python! In other languages, you may have to use multiprecision library for large values, but Python integer **are** multiprecision integers... Now 24 \*\* 36 = (3 \* 2\*\*3) \*\* 36 = (3 \*\* 36) \* (2 \*\* 108) So you can divide it 108 times b...
``` n = 24**36 i = 0 while True: a,b = divmod(n,2) if a == 1: break if b > 0: break i += 1 n = a print(i) ``` I used the built-in `divmod` that gives back the result of the division and the remainder. Then I simply looped until the remainder was `1` while counting the number of div...
74,237,208
I am currently making a mobile app in flutter, which has a boomMenu, I would like to add a 'FutureBuilder' within this menu, this is possible, when I try to do it I get the following error: > > The body might complete normally, causing 'null' to be returned, but the return type is a potentially non-nullable type > >...
2022/10/28
[ "https://Stackoverflow.com/questions/74237208", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11156021/" ]
Python has two division operators: `/` and `//`, so "divide by 2" is ambiguous. 2436 is 336×2108, and 336 is a little bigger than 257, which means that it requires 58 bits for a precise representation. Since the expression 24\*\*36 is an integer and Python stores integer in an arbitrary precision format, the result ca...
``` n = 24**36 i = 0 while True: a,b = divmod(n,2) if a == 1: break if b > 0: break i += 1 n = a print(i) ``` I used the built-in `divmod` that gives back the result of the division and the remainder. Then I simply looped until the remainder was `1` while counting the number of div...
74,237,208
I am currently making a mobile app in flutter, which has a boomMenu, I would like to add a 'FutureBuilder' within this menu, this is possible, when I try to do it I get the following error: > > The body might complete normally, causing 'null' to be returned, but the return type is a potentially non-nullable type > >...
2022/10/28
[ "https://Stackoverflow.com/questions/74237208", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11156021/" ]
Never ever use floating point arithmetics for integer values, specialy in Python! In other languages, you may have to use multiprecision library for large values, but Python integer **are** multiprecision integers... Now 24 \*\* 36 = (3 \* 2\*\*3) \*\* 36 = (3 \*\* 36) \* (2 \*\* 108) So you can divide it 108 times b...
Python has two division operators: `/` and `//`, so "divide by 2" is ambiguous. 2436 is 336×2108, and 336 is a little bigger than 257, which means that it requires 58 bits for a precise representation. Since the expression 24\*\*36 is an integer and Python stores integer in an arbitrary precision format, the result ca...
71,594,306
I have a grouped dataset with patients and a condition column (Caffeinefactor) with yes and no. I now want to create a new column that basically divides Patient in before and after the condition was yes for the first time. So if the Patient has the condition no,no,no,no,yes,yes,no,no,yes and I would like to ne column t...
2022/03/23
[ "https://Stackoverflow.com/questions/71594306", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18091918/" ]
The simplest solution would be to add a `Spacer` with `Modifier.weight(1f)` between your text and the radio button. `Row` and `Column` distribute remaining available space between components with a `weight` Modifier according to their weight. Since there is only one, it will receive all of the remaining space, pushing ...
You could create a Box that fills the rest of the Row and put the Button inside it. You can then align the Button to the right. ``` Box(modifier = Modifier.fillMaxWidth()) { RadioButton(modifier = Modifier.align(Alignment.End)){} } ``` The same can be achieved with columns instead of the Box, but then every sepa...
57,178
I read somewhere that the bass line is usually the tonics of the chords in the progression. But I doubt this is right. So if we're playing a bass line, is the current bass note just one of the notes of the underlying chord? So if we're playing a C major chord, then the bass note can be C or E or G? Or can the bass l...
2017/05/06
[ "https://music.stackexchange.com/questions/57178", "https://music.stackexchange.com", "https://music.stackexchange.com/users/-1/" ]
If you are a complete beginner, GNU solfege may be a bit much at first. As one review on their site reads, > > However, after testing the program, you can easily tell that you need to have already some basic – if not intermediate - music knowledge if you want to make the most of GNU Solfege. > > > Nonetheless the...
I find that it has great worth for musicians to first discuss their ambitions with their new teachers and to also share their musical likes with their teachers. If you are a singer just take your MP3 player with you and play some of your favourite music for your new teacher. Do you want to be a opera singer or do you ...
57,178
I read somewhere that the bass line is usually the tonics of the chords in the progression. But I doubt this is right. So if we're playing a bass line, is the current bass note just one of the notes of the underlying chord? So if we're playing a C major chord, then the bass note can be C or E or G? Or can the bass l...
2017/05/06
[ "https://music.stackexchange.com/questions/57178", "https://music.stackexchange.com", "https://music.stackexchange.com/users/-1/" ]
If you are a complete beginner, GNU solfege may be a bit much at first. As one review on their site reads, > > However, after testing the program, you can easily tell that you need to have already some basic – if not intermediate - music knowledge if you want to make the most of GNU Solfege. > > > Nonetheless the...
The best plan (apart from the very good advice about listening!) would be *ask to your teacher*. If he/she starts complete beginners on *practical* work with their instrument, and lets the theory follow on from that, the answer might be "no, there isn't really anything much that you can do before the first proper less...
57,178
I read somewhere that the bass line is usually the tonics of the chords in the progression. But I doubt this is right. So if we're playing a bass line, is the current bass note just one of the notes of the underlying chord? So if we're playing a C major chord, then the bass note can be C or E or G? Or can the bass l...
2017/05/06
[ "https://music.stackexchange.com/questions/57178", "https://music.stackexchange.com", "https://music.stackexchange.com/users/-1/" ]
The best plan (apart from the very good advice about listening!) would be *ask to your teacher*. If he/she starts complete beginners on *practical* work with their instrument, and lets the theory follow on from that, the answer might be "no, there isn't really anything much that you can do before the first proper less...
I find that it has great worth for musicians to first discuss their ambitions with their new teachers and to also share their musical likes with their teachers. If you are a singer just take your MP3 player with you and play some of your favourite music for your new teacher. Do you want to be a opera singer or do you ...
73,957
According to [Bing Translator](http://www.bing.com/translator/) 'kitten' (in English) translates as 'kitten' (In Klingon). Not that Klingons would enjoy the company of a fluffy kitten; but this is the internet. **Surely there must be a word for it?** ![enter image description here](https://i.stack.imgur.com/RKWek.pn...
2014/12/03
[ "https://scifi.stackexchange.com/questions/73957", "https://scifi.stackexchange.com", "https://scifi.stackexchange.com/users/36791/" ]
Per the [Klingon Wikia](http://klingon.wikia.com/wiki/vIghro%27) page for cat, the literal translation for kitten would be; > > **vIghro' Qup.** > > > Young cat. --- You might also consider > > **vIghro' ghu** > > > Baby cat --- Note that there's no ***direct*** translation of the word "cat" in the off...
I kinda think there is no Klingon word for "kitten." Perhaps one way to approach this is to consider what the Universal Translator would do. We know that English speakers hear a Klington talk about his "targ." While Klingons treat targs very much like humans treat dogs--including eating them--the UT says "targ" not "do...
54,205,025
I am creating a Alexa Skill that will get data from BPM tool. My BPM Tool provide a secure rest api that we can invoke with basic auth like username and password. How can i call this type of web api in node.js code created in lambda?
2019/01/15
[ "https://Stackoverflow.com/questions/54205025", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10918543/" ]
You could try also: ``` private String foo(Deque<String> words) { return String.join(" ", (Iterable<String>) words::descendingIterator); } ``` But for general case it would be better to create an utility method: ``` public static <T> Iterable<T> iterable(Iterable<T> iterable) { return iterable; } ``` Then...
OK I found what I was looking for and it was actually pretty simple: ``` private String foo(Deque<String> words) { Iterator<String> iterator = words.descendingIterator(); return String.join(" ", (Iterable<String>) () -> iterator); } ``` No need to use the wildcard at all.
25,527
im developing a game which has different levels and i need to store all levels and its elements (position, image, sounds,..) into a file/database. The levels will be updated so i need a function that checks online for a update and downloads a database dump and additional files. I was planing to store all the persisten...
2012/03/14
[ "https://gamedev.stackexchange.com/questions/25527", "https://gamedev.stackexchange.com", "https://gamedev.stackexchange.com/users/7916/" ]
I would recommend using your own binary format if you want efficient storage. Creating and packaging deltas for levels should be done on the server side. The clients should be able to only read the deltas and apply them. If you are comfortable with SQL and sqlite storage is good and efficient enough for you, there is...
Seems that your game doesn't need to store much data. I recommend that your save data can be easily converted to an NSDictionary (you can easily convert it to XML/plist). This way you won't have to worry about exporting the data elsewhere (in your case in a server). In my projects, I have a protocol where you can do t...
25,527
im developing a game which has different levels and i need to store all levels and its elements (position, image, sounds,..) into a file/database. The levels will be updated so i need a function that checks online for a update and downloads a database dump and additional files. I was planing to store all the persisten...
2012/03/14
[ "https://gamedev.stackexchange.com/questions/25527", "https://gamedev.stackexchange.com", "https://gamedev.stackexchange.com/users/7916/" ]
Seems that your game doesn't need to store much data. I recommend that your save data can be easily converted to an NSDictionary (you can easily convert it to XML/plist). This way you won't have to worry about exporting the data elsewhere (in your case in a server). In my projects, I have a protocol where you can do t...
Parse library [1] addresses exactly the problem of data persistence in mobile apps. It frees you from the "burden" of mantaining and query a database efficiently, and it should be quite easy to use since it is JSON friendly. Pricing allows you not to pay anything for trying it, or as long as your app becomes is not pop...
25,527
im developing a game which has different levels and i need to store all levels and its elements (position, image, sounds,..) into a file/database. The levels will be updated so i need a function that checks online for a update and downloads a database dump and additional files. I was planing to store all the persisten...
2012/03/14
[ "https://gamedev.stackexchange.com/questions/25527", "https://gamedev.stackexchange.com", "https://gamedev.stackexchange.com/users/7916/" ]
I would recommend using your own binary format if you want efficient storage. Creating and packaging deltas for levels should be done on the server side. The clients should be able to only read the deltas and apply them. If you are comfortable with SQL and sqlite storage is good and efficient enough for you, there is...
Parse library [1] addresses exactly the problem of data persistence in mobile apps. It frees you from the "burden" of mantaining and query a database efficiently, and it should be quite easy to use since it is JSON friendly. Pricing allows you not to pay anything for trying it, or as long as your app becomes is not pop...
5,130,616
The timestamp in my database is in the following format: ``` 2011-02-26T13:00:00-05:00 ``` But getting the current timestamp via MySQL with: ``` SELECT current_timestamp(); ``` Gives me something formatted like... ``` 2011-02-26 13:05:00 ``` My end goal is to go through all entries (each 2 days) and delete tho...
2011/02/27
[ "https://Stackoverflow.com/questions/5130616", "https://Stackoverflow.com", "https://Stackoverflow.com/users/228948/" ]
Try: ``` SELECT DATE(`yourtimestamp`) FROM thetablename WHERE DATE(`yourtimestam`) < CURDATE() - INTERVAL 2 DAY; ```
Sounds like you store your date (in your preferred format) in a character-based column (`VARCHAR` et al). Don't. It's a) bad style, b) you run into issues such as this. Instead, use the standard timestamp type, and if you need that specific ISO format when querying from the database, then format it accordingly. If yo...
42,699,637
In Angular 2, I need to absolute position an element relative to another element. In jQuery this can be done using jQueryUI .position() <https://api.jqueryui.com/1.8/position/> I've attempted to create an Angular 2 directive but can't find a way to reference the target element (which could be anywhere on the page) to ...
2017/03/09
[ "https://Stackoverflow.com/questions/42699637", "https://Stackoverflow.com", "https://Stackoverflow.com/users/464435/" ]
I'm adding this as a separate answer because it does something different than the original answer, and I think both could potentially be useful to anyone who sees this in the future. Apologies for the haphazard state of [this plunker](https://plnkr.co/edit/R6qN2e86swBInsVGscJF?p=preview), @Aydus-Matthew. It's kinda be...
Have a look at this plunker: <https://plnkr.co/edit/oB6QJzncNbMAe1sIfVQ8?p=preview> What you should do is create a component specifically for your overlay, and then add that to any components you wish to have a message on: ```js @Component({ selector: 'my-tooltip', template: `<span>{{ Message }}</span>`, sty...
42,699,637
In Angular 2, I need to absolute position an element relative to another element. In jQuery this can be done using jQueryUI .position() <https://api.jqueryui.com/1.8/position/> I've attempted to create an Angular 2 directive but can't find a way to reference the target element (which could be anywhere on the page) to ...
2017/03/09
[ "https://Stackoverflow.com/questions/42699637", "https://Stackoverflow.com", "https://Stackoverflow.com/users/464435/" ]
Here's a rough implementation that needs more work! Note that this is implemented in an Ionic 2 environment. **Overview** Create an "introduction" component that the contains overlay and tooltips/hints. I chose to open this component as an Ionic 2 popover (Ionic will auto add the overlay). Pass relative elements as p...
Have a look at this plunker: <https://plnkr.co/edit/oB6QJzncNbMAe1sIfVQ8?p=preview> What you should do is create a component specifically for your overlay, and then add that to any components you wish to have a message on: ```js @Component({ selector: 'my-tooltip', template: `<span>{{ Message }}</span>`, sty...
6,347,009
How can callback function that belong to a JavaScript object prototype access the object members? the callback can't be closure, everything must be defined as follows: ``` function Obji(param){ this.element = param; } Obji.prototype.func(){ database.get("someKey",this.cb); } Obji.prototype.cb(){ //here I wo...
2011/06/14
[ "https://Stackoverflow.com/questions/6347009", "https://Stackoverflow.com", "https://Stackoverflow.com/users/381211/" ]
`database.get("someKey",this.cb.bind(this));` [`.bind`](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function/bind), [ES5 shim](https://github.com/kriskowal/es5-shim) for older browsers
In javascript `this` always points to the object on which the function is invoked or the global object if it's not invoked on anything. Can you do it this way? ``` Obji.prototype.func = function(){ var ref = this; database.get("someKey", function(){ref.cb()}); } ```
9,941,266
I initially asked this on Superuser, but somebody advised me to repost here. I am using recent versions of APEX (4.1.1) and Oracle (11.2.0.3). I am uploading CSV data to a set of tables. I have been trying it out and am encountering some problems which I haven’t seen before. As an example, I tried to import data to ...
2012/03/30
[ "https://Stackoverflow.com/questions/9941266", "https://Stackoverflow.com", "https://Stackoverflow.com/users/704817/" ]
A colleague of mine finds this (not totally satisfying) solution: if the columns you require are both at the beginning, it works, like this: ``` engineer no,engineer name,equipment code,cust desc,eng desc,call log no,contract_no,call date,agreed date,agreed time,actual arrive 654,Flynn Hobbs,d,e,f,a,b,c,22-Mar-06,1,2...
In CSV ``` call log no,contract_no,call date,agreed date,agreed time,actual arrive,engineer no,engineer name,equipment code,cust desc,eng desc a,b,c,22-Mar-06,1,23/03/2006 15:00,654,Flynn Hobbs,d,e,f a,b,c,22-Mar-06,2,23/03/2006 15:00,654,Flynn Hobbs,d,e,f a,b,c,19-Mar-06,3,19/03/2006 09:15,351,Rory Juarez,d,e,f ```...
9,941,266
I initially asked this on Superuser, but somebody advised me to repost here. I am using recent versions of APEX (4.1.1) and Oracle (11.2.0.3). I am uploading CSV data to a set of tables. I have been trying it out and am encountering some problems which I haven’t seen before. As an example, I tried to import data to ...
2012/03/30
[ "https://Stackoverflow.com/questions/9941266", "https://Stackoverflow.com", "https://Stackoverflow.com/users/704817/" ]
A colleague of mine finds this (not totally satisfying) solution: if the columns you require are both at the beginning, it works, like this: ``` engineer no,engineer name,equipment code,cust desc,eng desc,call log no,contract_no,call date,agreed date,agreed time,actual arrive 654,Flynn Hobbs,d,e,f,a,b,c,22-Mar-06,1,2...
I am not quite sure why it didn't work for you. It worked fine for me, using the Apex Data Workshop with copy and paste. (Version 5.0.4) Of course, I was only able to upload two of those three results, one of them had a duplicate ID value. But it worked. PS: For the larger data set where you may have ',' as a part of...
1,269,958
I'm interested in knowing what is the meaning of the various equality symbols: $=,\sim, \cong,\approx,\equiv$. For example, the speed of a car $V$ in m/s: what would be the meaning of each of these statements? $$V = 30\\ V\sim 30\\ V \cong 30\\ V \approx 30\\ V \equiv 30$$
2015/05/06
[ "https://math.stackexchange.com/questions/1269958", "https://math.stackexchange.com", "https://math.stackexchange.com/users/121047/" ]
If your example is about speed, then this a question for physicists and not for logicians. The most important thing is that these symbols are precisely that - *symbols*. They can be defined to mean whatever you want them to. Of course, we try to keep some common basis of definitions across a particular topic. But even...
Many of the symbols you list, unless they have meanings I'm unaware of, are meaningless in this context. In general: $=$ means, as I assume you know, is 'equal to' (there is a certain subtlety here, but I'm hoping you don't want to go into it). $\approx$ means 'approximately equal to.' $\sim$ means, in the contex...
1,269,958
I'm interested in knowing what is the meaning of the various equality symbols: $=,\sim, \cong,\approx,\equiv$. For example, the speed of a car $V$ in m/s: what would be the meaning of each of these statements? $$V = 30\\ V\sim 30\\ V \cong 30\\ V \approx 30\\ V \equiv 30$$
2015/05/06
[ "https://math.stackexchange.com/questions/1269958", "https://math.stackexchange.com", "https://math.stackexchange.com/users/121047/" ]
Maybe instead of handling your example, because the context is not always relevant, let's look at possible groupings of the symbols. **Equality** * $=$ is usually used for equality. * $\equiv$ is occasionally used for "identically equal to," which is in a sense stronger than equality, by denoting that the thing on th...
Many of the symbols you list, unless they have meanings I'm unaware of, are meaningless in this context. In general: $=$ means, as I assume you know, is 'equal to' (there is a certain subtlety here, but I'm hoping you don't want to go into it). $\approx$ means 'approximately equal to.' $\sim$ means, in the contex...
1,269,958
I'm interested in knowing what is the meaning of the various equality symbols: $=,\sim, \cong,\approx,\equiv$. For example, the speed of a car $V$ in m/s: what would be the meaning of each of these statements? $$V = 30\\ V\sim 30\\ V \cong 30\\ V \approx 30\\ V \equiv 30$$
2015/05/06
[ "https://math.stackexchange.com/questions/1269958", "https://math.stackexchange.com", "https://math.stackexchange.com/users/121047/" ]
Many of the symbols you list, unless they have meanings I'm unaware of, are meaningless in this context. In general: $=$ means, as I assume you know, is 'equal to' (there is a certain subtlety here, but I'm hoping you don't want to go into it). $\approx$ means 'approximately equal to.' $\sim$ means, in the contex...
**ISO 80000-2:2009** entitled "Quantities and units — Part 2: Mathematical signs and symbols to be used in the natural sciences and technology" should cover them.
1,269,958
I'm interested in knowing what is the meaning of the various equality symbols: $=,\sim, \cong,\approx,\equiv$. For example, the speed of a car $V$ in m/s: what would be the meaning of each of these statements? $$V = 30\\ V\sim 30\\ V \cong 30\\ V \approx 30\\ V \equiv 30$$
2015/05/06
[ "https://math.stackexchange.com/questions/1269958", "https://math.stackexchange.com", "https://math.stackexchange.com/users/121047/" ]
If your example is about speed, then this a question for physicists and not for logicians. The most important thing is that these symbols are precisely that - *symbols*. They can be defined to mean whatever you want them to. Of course, we try to keep some common basis of definitions across a particular topic. But even...
Maybe instead of handling your example, because the context is not always relevant, let's look at possible groupings of the symbols. **Equality** * $=$ is usually used for equality. * $\equiv$ is occasionally used for "identically equal to," which is in a sense stronger than equality, by denoting that the thing on th...
1,269,958
I'm interested in knowing what is the meaning of the various equality symbols: $=,\sim, \cong,\approx,\equiv$. For example, the speed of a car $V$ in m/s: what would be the meaning of each of these statements? $$V = 30\\ V\sim 30\\ V \cong 30\\ V \approx 30\\ V \equiv 30$$
2015/05/06
[ "https://math.stackexchange.com/questions/1269958", "https://math.stackexchange.com", "https://math.stackexchange.com/users/121047/" ]
If your example is about speed, then this a question for physicists and not for logicians. The most important thing is that these symbols are precisely that - *symbols*. They can be defined to mean whatever you want them to. Of course, we try to keep some common basis of definitions across a particular topic. But even...
**ISO 80000-2:2009** entitled "Quantities and units — Part 2: Mathematical signs and symbols to be used in the natural sciences and technology" should cover them.
1,269,958
I'm interested in knowing what is the meaning of the various equality symbols: $=,\sim, \cong,\approx,\equiv$. For example, the speed of a car $V$ in m/s: what would be the meaning of each of these statements? $$V = 30\\ V\sim 30\\ V \cong 30\\ V \approx 30\\ V \equiv 30$$
2015/05/06
[ "https://math.stackexchange.com/questions/1269958", "https://math.stackexchange.com", "https://math.stackexchange.com/users/121047/" ]
Maybe instead of handling your example, because the context is not always relevant, let's look at possible groupings of the symbols. **Equality** * $=$ is usually used for equality. * $\equiv$ is occasionally used for "identically equal to," which is in a sense stronger than equality, by denoting that the thing on th...
**ISO 80000-2:2009** entitled "Quantities and units — Part 2: Mathematical signs and symbols to be used in the natural sciences and technology" should cover them.
612,740
Definition of a [block universe](https://en.wikipedia.org/wiki/Eternalism_(philosophy_of_time)) - The idea that the whole universe exists simultaneously and time doesn’t flow. For those who favor this kind of theory (the few of you), what is the role of the laws of physics in such a universe? Are the laws of physics j...
2021/02/06
[ "https://physics.stackexchange.com/questions/612740", "https://physics.stackexchange.com", "https://physics.stackexchange.com/users/286661/" ]
A block universe is simply one in which all the laws of physics are deterministic and reversible. In such a universe, complete and precise knowledge of the configuration of the universe at one point in time (or across one "slice" of the block) contains enough information *in principle* to determine the configuration of...
Laws of physics arise from noticing that there are patterns in nature that appear to recur reliably. For instance, Newton's laws of motion and quantum mechanics. These suggest that the universe is not an arbitrary, eternal collection of blocks, but an emergent phenomenon that arose out of some basic principles that pro...
612,740
Definition of a [block universe](https://en.wikipedia.org/wiki/Eternalism_(philosophy_of_time)) - The idea that the whole universe exists simultaneously and time doesn’t flow. For those who favor this kind of theory (the few of you), what is the role of the laws of physics in such a universe? Are the laws of physics j...
2021/02/06
[ "https://physics.stackexchange.com/questions/612740", "https://physics.stackexchange.com", "https://physics.stackexchange.com/users/286661/" ]
What is physics? Physics is the discipline that studies numerically nature and uses mathematical models, the theories, in order to describe the data and , important, predict new situations. Laws (also postulates, principles) of physics are **extra axioms** to the mathematical axioms in order to pick from the infinity o...
Laws of physics arise from noticing that there are patterns in nature that appear to recur reliably. For instance, Newton's laws of motion and quantum mechanics. These suggest that the universe is not an arbitrary, eternal collection of blocks, but an emergent phenomenon that arose out of some basic principles that pro...
612,740
Definition of a [block universe](https://en.wikipedia.org/wiki/Eternalism_(philosophy_of_time)) - The idea that the whole universe exists simultaneously and time doesn’t flow. For those who favor this kind of theory (the few of you), what is the role of the laws of physics in such a universe? Are the laws of physics j...
2021/02/06
[ "https://physics.stackexchange.com/questions/612740", "https://physics.stackexchange.com", "https://physics.stackexchange.com/users/286661/" ]
A block universe is simply one in which all the laws of physics are deterministic and reversible. In such a universe, complete and precise knowledge of the configuration of the universe at one point in time (or across one "slice" of the block) contains enough information *in principle* to determine the configuration of...
What is physics? Physics is the discipline that studies numerically nature and uses mathematical models, the theories, in order to describe the data and , important, predict new situations. Laws (also postulates, principles) of physics are **extra axioms** to the mathematical axioms in order to pick from the infinity o...
612,740
Definition of a [block universe](https://en.wikipedia.org/wiki/Eternalism_(philosophy_of_time)) - The idea that the whole universe exists simultaneously and time doesn’t flow. For those who favor this kind of theory (the few of you), what is the role of the laws of physics in such a universe? Are the laws of physics j...
2021/02/06
[ "https://physics.stackexchange.com/questions/612740", "https://physics.stackexchange.com", "https://physics.stackexchange.com/users/286661/" ]
What is physics? Physics is the discipline that studies numerically nature and uses mathematical models, the theories, in order to describe the data and , important, predict new situations. Laws (also postulates, principles) of physics are **extra axioms** to the mathematical axioms in order to pick from the infinity o...
This: "The idea that the whole universe exists simultaneously" is not what the block universe is. Rather, what it is, is that there is simply the absence of any distinguished point in time corresponding to "now", and of any distinguished point in space-time corresponding to "here and now"; so that all points are equa...
612,740
Definition of a [block universe](https://en.wikipedia.org/wiki/Eternalism_(philosophy_of_time)) - The idea that the whole universe exists simultaneously and time doesn’t flow. For those who favor this kind of theory (the few of you), what is the role of the laws of physics in such a universe? Are the laws of physics j...
2021/02/06
[ "https://physics.stackexchange.com/questions/612740", "https://physics.stackexchange.com", "https://physics.stackexchange.com/users/286661/" ]
Laws of physics arise from noticing that there are patterns in nature that appear to recur reliably. For instance, Newton's laws of motion and quantum mechanics. These suggest that the universe is not an arbitrary, eternal collection of blocks, but an emergent phenomenon that arose out of some basic principles that pro...
This: "The idea that the whole universe exists simultaneously" is not what the block universe is. Rather, what it is, is that there is simply the absence of any distinguished point in time corresponding to "now", and of any distinguished point in space-time corresponding to "here and now"; so that all points are equa...
612,740
Definition of a [block universe](https://en.wikipedia.org/wiki/Eternalism_(philosophy_of_time)) - The idea that the whole universe exists simultaneously and time doesn’t flow. For those who favor this kind of theory (the few of you), what is the role of the laws of physics in such a universe? Are the laws of physics j...
2021/02/06
[ "https://physics.stackexchange.com/questions/612740", "https://physics.stackexchange.com", "https://physics.stackexchange.com/users/286661/" ]
If you think of the block universe as the name suggests, as a "block" of unchanging structure, then the "laws of physics" are simply a compressed representation of the patterns that are etched into that block. Their existence means that the Universe's pattern is, however apparently complex, one that is "just so" as to ...
There is a possibility that the "flow" of time may primarily be an analogy traceable to medieval water clocks: Einstein does appear to have consistently regarded time as a dimension comparable to the spatial ones, although the directionality of passage through it is limited to the familiar past-to-future one through it...
612,740
Definition of a [block universe](https://en.wikipedia.org/wiki/Eternalism_(philosophy_of_time)) - The idea that the whole universe exists simultaneously and time doesn’t flow. For those who favor this kind of theory (the few of you), what is the role of the laws of physics in such a universe? Are the laws of physics j...
2021/02/06
[ "https://physics.stackexchange.com/questions/612740", "https://physics.stackexchange.com", "https://physics.stackexchange.com/users/286661/" ]
A block universe is simply one in which all the laws of physics are deterministic and reversible. In such a universe, complete and precise knowledge of the configuration of the universe at one point in time (or across one "slice" of the block) contains enough information *in principle* to determine the configuration of...
This: "The idea that the whole universe exists simultaneously" is not what the block universe is. Rather, what it is, is that there is simply the absence of any distinguished point in time corresponding to "now", and of any distinguished point in space-time corresponding to "here and now"; so that all points are equa...
612,740
Definition of a [block universe](https://en.wikipedia.org/wiki/Eternalism_(philosophy_of_time)) - The idea that the whole universe exists simultaneously and time doesn’t flow. For those who favor this kind of theory (the few of you), what is the role of the laws of physics in such a universe? Are the laws of physics j...
2021/02/06
[ "https://physics.stackexchange.com/questions/612740", "https://physics.stackexchange.com", "https://physics.stackexchange.com/users/286661/" ]
If you think of the block universe as the name suggests, as a "block" of unchanging structure, then the "laws of physics" are simply a compressed representation of the patterns that are etched into that block. Their existence means that the Universe's pattern is, however apparently complex, one that is "just so" as to ...
Laws of physics arise from noticing that there are patterns in nature that appear to recur reliably. For instance, Newton's laws of motion and quantum mechanics. These suggest that the universe is not an arbitrary, eternal collection of blocks, but an emergent phenomenon that arose out of some basic principles that pro...
612,740
Definition of a [block universe](https://en.wikipedia.org/wiki/Eternalism_(philosophy_of_time)) - The idea that the whole universe exists simultaneously and time doesn’t flow. For those who favor this kind of theory (the few of you), what is the role of the laws of physics in such a universe? Are the laws of physics j...
2021/02/06
[ "https://physics.stackexchange.com/questions/612740", "https://physics.stackexchange.com", "https://physics.stackexchange.com/users/286661/" ]
What is physics? Physics is the discipline that studies numerically nature and uses mathematical models, the theories, in order to describe the data and , important, predict new situations. Laws (also postulates, principles) of physics are **extra axioms** to the mathematical axioms in order to pick from the infinity o...
There is a possibility that the "flow" of time may primarily be an analogy traceable to medieval water clocks: Einstein does appear to have consistently regarded time as a dimension comparable to the spatial ones, although the directionality of passage through it is limited to the familiar past-to-future one through it...
612,740
Definition of a [block universe](https://en.wikipedia.org/wiki/Eternalism_(philosophy_of_time)) - The idea that the whole universe exists simultaneously and time doesn’t flow. For those who favor this kind of theory (the few of you), what is the role of the laws of physics in such a universe? Are the laws of physics j...
2021/02/06
[ "https://physics.stackexchange.com/questions/612740", "https://physics.stackexchange.com", "https://physics.stackexchange.com/users/286661/" ]
There is a possibility that the "flow" of time may primarily be an analogy traceable to medieval water clocks: Einstein does appear to have consistently regarded time as a dimension comparable to the spatial ones, although the directionality of passage through it is limited to the familiar past-to-future one through it...
This: "The idea that the whole universe exists simultaneously" is not what the block universe is. Rather, what it is, is that there is simply the absence of any distinguished point in time corresponding to "now", and of any distinguished point in space-time corresponding to "here and now"; so that all points are equa...
17,739,787
I want to create a SQL tabled-value function that will receive a query as n parameter through my API. In my function I want execute that query. The query will be a SELECT statement. This is what I have done so far and what to achieve but it is not the correct way to do so. ``` CREATE FUNCTION CUSTOM_EXPORT_RESULTS ( ...
2013/07/19
[ "https://Stackoverflow.com/questions/17739787", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1912756/" ]
Try this one - ``` CREATE PROCEDURE dbo.sp_CUSTOM_EXPORT_RESULTS @query NVARCHAR(MAX) = 'SELECT * FROM dbo.test' , @guid UNIQUEIDENTIFIER , @tableName VARCHAR(200) = 'test2' AS BEGIN SELECT @query = REPLACE(@query, 'FROM', 'INTO [' + @tableName + '] F...
You can use stored procedure as well, here is the code that you can try. ``` CREATE FUNCTION CUSTOM_EXPORT_RESULTS ( @query varchar(max), @guid uniqueidentifier, @tableName varchar(200) ) RETURNS TABLE AS RETURN ( declare @strQuery nvarchar(max) -- Execute query into a table SET @strQuery...
17,739,787
I want to create a SQL tabled-value function that will receive a query as n parameter through my API. In my function I want execute that query. The query will be a SELECT statement. This is what I have done so far and what to achieve but it is not the correct way to do so. ``` CREATE FUNCTION CUSTOM_EXPORT_RESULTS ( ...
2013/07/19
[ "https://Stackoverflow.com/questions/17739787", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1912756/" ]
Try this one - ``` CREATE PROCEDURE dbo.sp_CUSTOM_EXPORT_RESULTS @query NVARCHAR(MAX) = 'SELECT * FROM dbo.test' , @guid UNIQUEIDENTIFIER , @tableName VARCHAR(200) = 'test2' AS BEGIN SELECT @query = REPLACE(@query, 'FROM', 'INTO [' + @tableName + '] F...
What I see in your question is encapsulation of: * taking a dynamic SQL expression * executing it to fill a parametrized table Why do you want to have such an encapsulation? First, this can have a negative impact on your database performance. Please read [this on EXEC() and sp\_executesql()](http://www.sommarskog.se...
17,739,787
I want to create a SQL tabled-value function that will receive a query as n parameter through my API. In my function I want execute that query. The query will be a SELECT statement. This is what I have done so far and what to achieve but it is not the correct way to do so. ``` CREATE FUNCTION CUSTOM_EXPORT_RESULTS ( ...
2013/07/19
[ "https://Stackoverflow.com/questions/17739787", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1912756/" ]
What I see in your question is encapsulation of: * taking a dynamic SQL expression * executing it to fill a parametrized table Why do you want to have such an encapsulation? First, this can have a negative impact on your database performance. Please read [this on EXEC() and sp\_executesql()](http://www.sommarskog.se...
You can use stored procedure as well, here is the code that you can try. ``` CREATE FUNCTION CUSTOM_EXPORT_RESULTS ( @query varchar(max), @guid uniqueidentifier, @tableName varchar(200) ) RETURNS TABLE AS RETURN ( declare @strQuery nvarchar(max) -- Execute query into a table SET @strQuery...
65,492,421
Not sure what I'm doing wrong but I'm struggling getting the index per row of the last column (among several columns) that is not NA. Using tidyverse and across, I'm getting as many output columns as input columns where I'd expect one single output column with the index of the respective column. ``` dat <- data.frame...
2020/12/29
[ "https://Stackoverflow.com/questions/65492421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2725773/" ]
The problems with your current flow: 1. `across` is going to pass one *column* at a time to the function/expression; your code needs a row or a matrix/frame. For this, `across` is not appropriate. 2. Your desired output of `NA` for the last row is inconsistent with the logic: `!is.na(.x)` should return `c(F,F,F)`, *wh...
An R base solution: ``` dat$last = apply(dat[,2:4], 1, FUN = function(x) ifelse(max(which(is.na(x))) == length(x), NA, max(which(is.na(x)))+1 )) dat # id x y z last # 1 1 1 NA 3 3 # 2 2 NA NA 1 3 # 3 3 NA NA NA NA ```
65,492,421
Not sure what I'm doing wrong but I'm struggling getting the index per row of the last column (among several columns) that is not NA. Using tidyverse and across, I'm getting as many output columns as input columns where I'd expect one single output column with the index of the respective column. ``` dat <- data.frame...
2020/12/29
[ "https://Stackoverflow.com/questions/65492421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2725773/" ]
The problems with your current flow: 1. `across` is going to pass one *column* at a time to the function/expression; your code needs a row or a matrix/frame. For this, `across` is not appropriate. 2. Your desired output of `NA` for the last row is inconsistent with the logic: `!is.na(.x)` should return `c(F,F,F)`, *wh...
You want to use `c_across()` and `rowwise()` to do this. `rowwise()` works similar to `group_by_all()`, except it is more explicit. `c_across()` creates flat vectors out of columns (whereas `across()` creates tibbles). If we first define a function seperately to pull out the last non-`NA` value, or return `NA` if ther...
65,492,421
Not sure what I'm doing wrong but I'm struggling getting the index per row of the last column (among several columns) that is not NA. Using tidyverse and across, I'm getting as many output columns as input columns where I'd expect one single output column with the index of the respective column. ``` dat <- data.frame...
2020/12/29
[ "https://Stackoverflow.com/questions/65492421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2725773/" ]
The problems with your current flow: 1. `across` is going to pass one *column* at a time to the function/expression; your code needs a row or a matrix/frame. For this, `across` is not appropriate. 2. Your desired output of `NA` for the last row is inconsistent with the logic: `!is.na(.x)` should return `c(F,F,F)`, *wh...
`base` R ```r df <- data.frame(id = c(1, 2, 3), x = c(1, NA, NA), y = c(NA, NA, NA), z = c(3, 1, NA)) df$last <- apply(df[-1], 1, function(x) max(as.vector(!is.na(x)) * seq_len(length(x)))) df$last[df$last == 0] <- NA df #> id x y z last ...
65,492,421
Not sure what I'm doing wrong but I'm struggling getting the index per row of the last column (among several columns) that is not NA. Using tidyverse and across, I'm getting as many output columns as input columns where I'd expect one single output column with the index of the respective column. ``` dat <- data.frame...
2020/12/29
[ "https://Stackoverflow.com/questions/65492421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2725773/" ]
The problems with your current flow: 1. `across` is going to pass one *column* at a time to the function/expression; your code needs a row or a matrix/frame. For this, `across` is not appropriate. 2. Your desired output of `NA` for the last row is inconsistent with the logic: `!is.na(.x)` should return `c(F,F,F)`, *wh...
Starting with a vector of NAs, you could step through each col and if the given element passes your `check_fun` returning `TRUE`, assign the index of that col to that element. The difference from the other answers here is that this does not check the condition row-wise or create a matrix from the data. Not sure whether...
65,492,421
Not sure what I'm doing wrong but I'm struggling getting the index per row of the last column (among several columns) that is not NA. Using tidyverse and across, I'm getting as many output columns as input columns where I'd expect one single output column with the index of the respective column. ``` dat <- data.frame...
2020/12/29
[ "https://Stackoverflow.com/questions/65492421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2725773/" ]
`tidyverse` isn't really suitable for row-wise operation. Most of the times reshaping the data into long format (as shown in @Rui Barradas answer) is a good approach. Here is one way using `rowwise` keeping the data wide. ``` library(dplyr) dat %>% rowwise() %>% mutate(last = {ind = which(!is.na(c_across(x:z)));...
An R base solution: ``` dat$last = apply(dat[,2:4], 1, FUN = function(x) ifelse(max(which(is.na(x))) == length(x), NA, max(which(is.na(x)))+1 )) dat # id x y z last # 1 1 1 NA 3 3 # 2 2 NA NA 1 3 # 3 3 NA NA NA NA ```
65,492,421
Not sure what I'm doing wrong but I'm struggling getting the index per row of the last column (among several columns) that is not NA. Using tidyverse and across, I'm getting as many output columns as input columns where I'd expect one single output column with the index of the respective column. ``` dat <- data.frame...
2020/12/29
[ "https://Stackoverflow.com/questions/65492421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2725773/" ]
`tidyverse` isn't really suitable for row-wise operation. Most of the times reshaping the data into long format (as shown in @Rui Barradas answer) is a good approach. Here is one way using `rowwise` keeping the data wide. ``` library(dplyr) dat %>% rowwise() %>% mutate(last = {ind = which(!is.na(c_across(x:z)));...
You want to use `c_across()` and `rowwise()` to do this. `rowwise()` works similar to `group_by_all()`, except it is more explicit. `c_across()` creates flat vectors out of columns (whereas `across()` creates tibbles). If we first define a function seperately to pull out the last non-`NA` value, or return `NA` if ther...
65,492,421
Not sure what I'm doing wrong but I'm struggling getting the index per row of the last column (among several columns) that is not NA. Using tidyverse and across, I'm getting as many output columns as input columns where I'd expect one single output column with the index of the respective column. ``` dat <- data.frame...
2020/12/29
[ "https://Stackoverflow.com/questions/65492421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2725773/" ]
`tidyverse` isn't really suitable for row-wise operation. Most of the times reshaping the data into long format (as shown in @Rui Barradas answer) is a good approach. Here is one way using `rowwise` keeping the data wide. ``` library(dplyr) dat %>% rowwise() %>% mutate(last = {ind = which(!is.na(c_across(x:z)));...
`base` R ```r df <- data.frame(id = c(1, 2, 3), x = c(1, NA, NA), y = c(NA, NA, NA), z = c(3, 1, NA)) df$last <- apply(df[-1], 1, function(x) max(as.vector(!is.na(x)) * seq_len(length(x)))) df$last[df$last == 0] <- NA df #> id x y z last ...
65,492,421
Not sure what I'm doing wrong but I'm struggling getting the index per row of the last column (among several columns) that is not NA. Using tidyverse and across, I'm getting as many output columns as input columns where I'd expect one single output column with the index of the respective column. ``` dat <- data.frame...
2020/12/29
[ "https://Stackoverflow.com/questions/65492421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2725773/" ]
`tidyverse` isn't really suitable for row-wise operation. Most of the times reshaping the data into long format (as shown in @Rui Barradas answer) is a good approach. Here is one way using `rowwise` keeping the data wide. ``` library(dplyr) dat %>% rowwise() %>% mutate(last = {ind = which(!is.na(c_across(x:z)));...
Starting with a vector of NAs, you could step through each col and if the given element passes your `check_fun` returning `TRUE`, assign the index of that col to that element. The difference from the other answers here is that this does not check the condition row-wise or create a matrix from the data. Not sure whether...
14,033,708
> > **Possible Duplicate:** > > [What is the meaning of “this” in Java?](https://stackoverflow.com/questions/3728062/what-is-the-meaning-of-this-in-java) > > > I'm still very new to learning Android programming, and I noticed that "this" was used often in parameters for method calls in the language. I'm follow...
2012/12/25
[ "https://Stackoverflow.com/questions/14033708", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1923016/" ]
`this` refers to the instance of the class you are currently coding within. You cannot use it in a static context because in this situation you are not within any object context. Therefore `this` doesn't exist. ``` public class MyClass { public void myMethod(){ this.otherMethod(); // Here you don't need ...
``` public class YourClass { private int YourInt; public setTheInt(int YourInt) { this.YourInt = YourInt; } } ``` "this" is used to see whether an attribute or function belongs to the class we're working on, clearer. Also, you see that setTheInt operation gets an integer named as the same ...
14,033,708
> > **Possible Duplicate:** > > [What is the meaning of “this” in Java?](https://stackoverflow.com/questions/3728062/what-is-the-meaning-of-this-in-java) > > > I'm still very new to learning Android programming, and I noticed that "this" was used often in parameters for method calls in the language. I'm follow...
2012/12/25
[ "https://Stackoverflow.com/questions/14033708", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1923016/" ]
In android `class.this` is used to pass context around. Formal definition of context: It allows access to application-specific resources and classes, as well as up-calls for application-level operations such as launching activities. That means if you need to access resources (including R and user interface) you will ...
``` public class YourClass { private int YourInt; public setTheInt(int YourInt) { this.YourInt = YourInt; } } ``` "this" is used to see whether an attribute or function belongs to the class we're working on, clearer. Also, you see that setTheInt operation gets an integer named as the same ...
64,728,178
Here I am facing a strange issue after calling a modal form, the navbar dropdowns stop working. Any clue? here is the link to my code: <https://codesandbox.io/s/great-stonebraker-hfcln?fontsize=14&hidenavigation=1&theme=dark> To reproduce the issue: from Navbar go to Master data > customers > the modal form will ope...
2020/11/07
[ "https://Stackoverflow.com/questions/64728178", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1131905/" ]
You have to use the onPress prop that you are passing like below ``` export const MediumButton = ({ title,onPress }) => { return ( <TouchableOpacity style={styles.mediumButton} onPress={onPress}> <Text style={styles.buttonText}>{title}</Text> </TouchableOpacity> ); }; ```
Try to pass the `onPress` handler to `TouchableOpacity`: ``` export const MediumButton = ({ title, onPress }) => { return ( <TouchableOpacity style={styles.mediumButton} onPress={onPress}> <Text style={styles.buttonText}>{title}</Text> </TouchableOpacity> ); }; ```
74,504,821
I am trying to build an isomorphic React app, but for now I will just limit my question to the server side rendering portion. I want to render some React JS components on the server side of my application. I am able to do so with the method `ReactDomServer.renderToString`. However I am unable to get the CSS (or my SASS...
2022/11/20
[ "https://Stackoverflow.com/questions/74504821", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8929431/" ]
You forgot to change the type of "command[1]" in the if. The following code works: ``` cart = [] while True: command = str(input("Command: ")).split() if "add" in command: cart.append(int(command[1])) elif "remove" in command: if int(command[1]) in cart: # There you forgot to check command[...
``` cart = [] while True: command = str(input("Command: ")).lower().split() print(command) # I assume that add and remove will be 2-word commands if len(command) == 2: try: number = int(command[1]) if "add" == command[0]: cart.append(number) el...
34,736,965
I need regular expression that converts links in plain text to HTML links. my code is: ``` preg_replace('/(((f|ht){1}tps:\/\/)[-a-zA-Z0-9@:%_\+.~#?&\/\/=]+)/i', '<a href="\\1" target="_blank">\\1</a>', $text); ``` but this expression will make the image url to href as well. so my question is how t...
2016/01/12
[ "https://Stackoverflow.com/questions/34736965", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4938843/" ]
It's possible using negative lookbehind operator `(?<!text)`, though probably not the most efficient way since the engine will back track a lot. Maybe you could do `strip_tags('img')` before `preg_replace`? Another drawback of lookbehind is that it has to be fixed length. This means you cannot grab onto `img` since th...
Why do you have it twice? The only difference I see is the s in the https, but that you could achieve like this: ``` preg_replace('/(((f|ht){1}tps?:\/\/)[-a-zA-Z0-9@:%_\+.~#?&\/\/=]+)/i', '<a href="\\1" target="_blank">\\1</a>', $text); ``` IMHO you got the result because the 1st line did what you wan...
16,629,972
Below you will see some code that I am having trouble with. The basic idea is a simple copy of one existing text file to a new one, but if the new one exists, you are given three options. The other switch cases work flawlessly, but this third and final case does not work as I want it to at all! Basically this is the c...
2013/05/18
[ "https://Stackoverflow.com/questions/16629972", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2035824/" ]
The way you've written it there isn't very robust if you have a more complicated class hierarchy since if you have a class `D <: C`, then `classOf[D] != classOf[C]`. So you don't really want to pattern-match anyway. But you could; you can't call `classOf[X]` in the middle of a pattern-match, but you can ``` def zFor[T...
I am not sure if this fits your problem (as you have probably shown a simplified example). But this kind of functionality can be created without using reflection. It is quite a common pattern that allows you to create add more combinations without modifying the original code. ``` // the - here allows D to return the ...
15,353
I have been involved with developing threat models for several software products and features, and I'd like to formalize this process a little bit and create some documentation for my company's devs. Can you guys recommend a good book that describes all the essential components of building a good threat model? I've sk...
2012/05/25
[ "https://security.stackexchange.com/questions/15353", "https://security.stackexchange.com", "https://security.stackexchange.com/users/10199/" ]
What does this nonsense all mean? [What can I do about TLS 1.0 javascript injection vulnerability on my server?](https://security.stackexchange.com/q/7416/836) What should I change to? [Should I ignore the BEAST SSL exploit and continue to prefer AES?](https://security.stackexchange.com/q/7720/836) An in-depth look a...
we are using this SSLProtocol all -SSLv2 -TLSv1 SSLCipherSuite ECDHE-RSA-AES256-SHA384:!AES:!AES256-SHA256:!AES256-SHA256:RC4:HIGH:!MD5:!SSLv2:!ADH:!aNULL:!eNULL:!NULL:!DH:!ADH:!EDH:!AESGCM:!DES-CBC3-SHA But, we are failing 403labs PCI scan anyway (looks like they are using same plugin/nessus), and Qualys SSL labs te...
2,438,320
How does one determine the (x,y) coordinates while dragging "dragover" and after the drop ("drop") in HTML5 DnD? I found a webpage that describes x,y for dragover (look at e.offsetX and e.layerX to see if set for various browsers but for the life of me they ARE NOT set). What do you use for the drop(e) function to fi...
2010/03/13
[ "https://Stackoverflow.com/questions/2438320", "https://Stackoverflow.com", "https://Stackoverflow.com/users/239171/" ]
The properties `clientX` and `clientY` should be set (in modern browsers): ``` function drag_over(event) { console.log(event.clientX); console.log(event.clientY); event.preventDefault(); return false; } function drop(event) { console.log(event.clientX); console.log(event.clientY); event.pre...
To build on top of robertc's answer and work around the issue: > > The clientX and clientY are going to be inaccurate proportional to the distance of the cursor from the upper left corner of the element which was dropped. > > > You may simply calculate the delta distance by subtracting the client coords recorded ...
2,697,887
I understand that the existence of the powerset is usually taken as an axiom in ZFC, but why not simply view the powerset a function? I know that you can define the powerset to be a function $P : V\_\kappa \rightarrow V\_{\kappa +1} $ where $V\_{\kappa}$ is a stage on the Neumann universe, but recall that the stages o...
2018/03/18
[ "https://math.stackexchange.com/questions/2697887", "https://math.stackexchange.com", "https://math.stackexchange.com/users/296508/" ]
You can take some other presentation of set theory as a basis where powersets aren't taken as axiomatic. For example, the presentation of an [elementary topos](https://ncatlab.org/nlab/show/topos#ElementaryTopos) as a finitely complete, cartesian closed category with a subobject classifier effectively takes the set of ...
As you know the collection of all sets is not a set at all. Thus defining the power set as a function requires some domain different from the collection of all sets. The power set is well defined but as if we try to define power set as a function with a domain and a codomain we will get into paradoxes.
2,697,887
I understand that the existence of the powerset is usually taken as an axiom in ZFC, but why not simply view the powerset a function? I know that you can define the powerset to be a function $P : V\_\kappa \rightarrow V\_{\kappa +1} $ where $V\_{\kappa}$ is a stage on the Neumann universe, but recall that the stages o...
2018/03/18
[ "https://math.stackexchange.com/questions/2697887", "https://math.stackexchange.com", "https://math.stackexchange.com/users/296508/" ]
You can take some other presentation of set theory as a basis where powersets aren't taken as axiomatic. For example, the presentation of an [elementary topos](https://ncatlab.org/nlab/show/topos#ElementaryTopos) as a finitely complete, cartesian closed category with a subobject classifier effectively takes the set of ...
Let $P$ denote the Power Set Axiom. We have Con($ZF - P)\implies$ Con (($ZF -P)+(\neg P)).$ Otherwise $P$ would be a theorem of ($ZF - P$) and $ZF$ would be euivalent to $(ZF -P).$ But in $ZF$ we can show that $H\_{\omega\_1},$ the set of hereditarily countable sets, is a model for $(ZF-P)+(\neg P).$ So any def'n, in...
73,063,486
I am aiming to deploy a web-app written with Sreamlit, [![File Structure](https://i.stack.imgur.com/fPC98.png)](https://i.stack.imgur.com/fPC98.png) I can run this on my local machine by running `streamlit run Home.py` in my command line. However, I'm not sure how to create the docker file. Any advice?
2022/07/21
[ "https://Stackoverflow.com/questions/73063486", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14784770/" ]
You cannot pass a temporary resulting from converting the `Foo` to a `std::variant<Foo,Bar>` to `f2`. C++ disallows this because binding a temporary to a non-const reference is most likely a bug. If it was possible you'd have no way to inspect the modified value anyhow. You can workaround this by using a `std::variant...
> > So second question: how can I achieve this behaviour? > > > It seems you use `std::variant` to restrict possible argument. If that is the case, template might be an alternative solution: ``` template <typename T> constexpr bool isFooBar = std::is_same_v<T, Foo> || std::is_same_v<T, Bar>; template <typename ...