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
20,404,449
I need to read the text from a .dat file that goes as such: ``` 4 Mary 13.99 Ruth 22.04 Anne 12.39 Talor 18.34 ``` I used a buffered reader that looks like this: ``` public class Tester{ public static void main(String [] args){ BufferedReader reader = null; try { File file = new File...
2013/12/05
[ "https://Stackoverflow.com/questions/20404449", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3070681/" ]
Don't split the first line. Do split second line onward. ``` reader.readLine(); //added this line while ((line = reader.readLine()) != null){ } ```
1 is out of range for that first row. `String.split()` will return an array with 1 element (the entire line) for that first line, and then an array with 2 elements for all other lines. What's the general format of this .dat file? Is it always a single number on the first line, then name/number pairs for all subsequent...
20,404,449
I need to read the text from a .dat file that goes as such: ``` 4 Mary 13.99 Ruth 22.04 Anne 12.39 Talor 18.34 ``` I used a buffered reader that looks like this: ``` public class Tester{ public static void main(String [] args){ BufferedReader reader = null; try { File file = new File...
2013/12/05
[ "https://Stackoverflow.com/questions/20404449", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3070681/" ]
Don't split the first line. Do split second line onward. ``` reader.readLine(); //added this line while ((line = reader.readLine()) != null){ } ```
If your input file is *guaranteed* to be in the format you posted, you can simply do this: ``` reader.readLine(); while ((line = reader.readLine()) != null) { ... ``` This would cause your reader to consume the first line of the file and ignore it completely. That said, the file you've posted *suggests* that the...
20,404,449
I need to read the text from a .dat file that goes as such: ``` 4 Mary 13.99 Ruth 22.04 Anne 12.39 Talor 18.34 ``` I used a buffered reader that looks like this: ``` public class Tester{ public static void main(String [] args){ BufferedReader reader = null; try { File file = new File...
2013/12/05
[ "https://Stackoverflow.com/questions/20404449", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3070681/" ]
Don't split the first line. Do split second line onward. ``` reader.readLine(); //added this line while ((line = reader.readLine()) != null){ } ```
Try this ``` int count =Integer.parseInt(reader.readLine()); String line; while (count>0) { line = reader.readLine(); //System.out.println(line); //split will go here String[] str1Array = line.split(" "); System.out.println(str1Array[0]); //works /* for (String ret...
20,404,449
I need to read the text from a .dat file that goes as such: ``` 4 Mary 13.99 Ruth 22.04 Anne 12.39 Talor 18.34 ``` I used a buffered reader that looks like this: ``` public class Tester{ public static void main(String [] args){ BufferedReader reader = null; try { File file = new File...
2013/12/05
[ "https://Stackoverflow.com/questions/20404449", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3070681/" ]
If your input file is *guaranteed* to be in the format you posted, you can simply do this: ``` reader.readLine(); while ((line = reader.readLine()) != null) { ... ``` This would cause your reader to consume the first line of the file and ignore it completely. That said, the file you've posted *suggests* that the...
The `String.split(String)` method discards all emtpy Strings at the end of the array as per API-Documentation. If you ned to get back fixed-size arrays use `line.split(" ",-1)` - but be prepared to handle empty Strings in the result.
20,404,449
I need to read the text from a .dat file that goes as such: ``` 4 Mary 13.99 Ruth 22.04 Anne 12.39 Talor 18.34 ``` I used a buffered reader that looks like this: ``` public class Tester{ public static void main(String [] args){ BufferedReader reader = null; try { File file = new File...
2013/12/05
[ "https://Stackoverflow.com/questions/20404449", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3070681/" ]
If your input file is *guaranteed* to be in the format you posted, you can simply do this: ``` reader.readLine(); while ((line = reader.readLine()) != null) { ... ``` This would cause your reader to consume the first line of the file and ignore it completely. That said, the file you've posted *suggests* that the...
1 is out of range for that first row. `String.split()` will return an array with 1 element (the entire line) for that first line, and then an array with 2 elements for all other lines. What's the general format of this .dat file? Is it always a single number on the first line, then name/number pairs for all subsequent...
20,404,449
I need to read the text from a .dat file that goes as such: ``` 4 Mary 13.99 Ruth 22.04 Anne 12.39 Talor 18.34 ``` I used a buffered reader that looks like this: ``` public class Tester{ public static void main(String [] args){ BufferedReader reader = null; try { File file = new File...
2013/12/05
[ "https://Stackoverflow.com/questions/20404449", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3070681/" ]
If your input file is *guaranteed* to be in the format you posted, you can simply do this: ``` reader.readLine(); while ((line = reader.readLine()) != null) { ... ``` This would cause your reader to consume the first line of the file and ignore it completely. That said, the file you've posted *suggests* that the...
Try this ``` int count =Integer.parseInt(reader.readLine()); String line; while (count>0) { line = reader.readLine(); //System.out.println(line); //split will go here String[] str1Array = line.split(" "); System.out.println(str1Array[0]); //works /* for (String ret...
166,237
I'm trying to implement an access callback per role for a specific menu item, but other roles can view that menu item also. Any tip is welcome. ``` /** * Implements hook_menu(); */ function MODULENAME_menu() { global $user; $items['admin/backoffice/production/taxonomie'] = array( 'title' => 'Taxonomie', ...
2015/07/21
[ "https://drupal.stackexchange.com/questions/166237", "https://drupal.stackexchange.com", "https://drupal.stackexchange.com/users/5808/" ]
To have a single `access callback` handle a dynamic number of roles which varies per menu link, try something like this in `hook_menu()`... ``` // hook_menu() $items['foo'] = array( /* ... */ 'access callback' => 'MODULENAME_user_has_role', 'access arguments' => array('éditeur taxonomie', 'administrator'), )...
A small addition I would make would be to do a check for UID = 1 like the rest of D7. A little late but hope it might helps some one. ``` function MODULE_user_has_role() { global $user; if ($user->uid == 1) { return TRUE; } $roles = func_get_args(); foreach ($roles as $role) { if (in_array($role, $us...
42,375,333
How to make a stateless architecture design so that if a user(A) is loggedIn and the Json web token is generated by Server(**X1**) and returned to user-A. And again user-A sends the request to server and the purpose is served by Server(**X2**) without making the user re-authenticate. So that the architecture is highly ...
2017/02/21
[ "https://Stackoverflow.com/questions/42375333", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4359284/" ]
Thanks guys for your help, here is how I have solved it by writing a serializer: ``` public class BigDecimalSerializer extends JsonSerializer<BigDecimal> { @Override public void serialize(BigDecimal value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException ...
Your **rounding** is **working fine**. The **reason** why you are not getting trailing zeros is that **you** are **returning** the **response** as `BigDecimal`, **instead you need** to return as `String`(as mentioned by others as well). There is simple way of doing it using `@JsonFormat` **annotation** with `shape` as...
16,839,151
I have a data frame called p, it content is as below: ``` structure(list(AGENT = c(45693, 45693, 45693, 45693, 45693, 45693, 45693, 45693, 42627, 42627, 42627, 42627, 42627, 42627)), .Names = "AGENT", row.names = c(NA, -14L), class = "data.frame") ``` I would like to add two more columns to this data frame called ...
2013/05/30
[ "https://Stackoverflow.com/questions/16839151", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1471980/" ]
you have to make p a data.table before you can use data.table syntax on it. ``` p<-data.table(p) #create(update) column called LOCATION and set it to Dallas if AGENT==45693 p[AGENT==45693,LOCATION:="Dallas"] ``` the first argument in the brackets is the filter and the second is called the J where you can either sele...
The anser of @Dean is very good. Mine just to mention the fact that you can also use `:=` assignment operator to create a vector of names. Here 2 versions: ``` library(data.table) p <- data.table(dat) p[AGENT==45693,c('LOCATION','Provider') := list("Dallas",'ATT')] DT <- data.table(dat) DT[AGENT==45693, `:=`(LOCATION...
55,707,835
My apps are organized like this: ``` apps/ code/ libglobal/ funglobal.py tests/ project/ liblocal/ funlocal.py main.py ``` In *main.py* I have: ``` import liblocal.funlocal ``` In *funlocal.py* I try to import *funglobal.py* with: ``` fr...
2019/04/16
[ "https://Stackoverflow.com/questions/55707835", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2235673/" ]
As the script being executed has its `__name__` set as `__main__` and defines itself to be on the top level of the package, it refuses to recognize scripts in sibling directories. You can fix this with a `sys.path` hack: ``` import sys, os sys.path.insert(0, os.path.abspath('../..')) ``` or an interseting alternati...
Have you a `__init__.py` script in each folder ? If no, you should create an empty script named `__init__.py` in each folder.
3,021,439
I have a list a vertices and a list of triangles. I'd like to split this single mesh into, say 5, randomly shaped meshes. When the 5 randomly shaped meshes are in place the sphere should all line up and look like 1 solid mesh. I need a algorithm to do this programmatically, not a tool to do it form me. Any pointers wo...
2010/06/11
[ "https://Stackoverflow.com/questions/3021439", "https://Stackoverflow.com", "https://Stackoverflow.com/users/308079/" ]
You could make a crack by walking a random walk across the edges, until the number of pieces you want is achieved. If you want to have mostly big pieces, you could modify the randomness of the walk by reducing the attractiveness of edges that are close to an existing crack.
Select 3 random points and split along that plane. What is the problem?
3,021,439
I have a list a vertices and a list of triangles. I'd like to split this single mesh into, say 5, randomly shaped meshes. When the 5 randomly shaped meshes are in place the sphere should all line up and look like 1 solid mesh. I need a algorithm to do this programmatically, not a tool to do it form me. Any pointers wo...
2010/06/11
[ "https://Stackoverflow.com/questions/3021439", "https://Stackoverflow.com", "https://Stackoverflow.com/users/308079/" ]
Similar to Svante's proposal but a slightly different approach: 1. Select five random vertices, mark these vertices as "visited" with the number 1 to 5 2. From each of the visited vertices, go to all adjacent vertices. Store the same number there as well. 3. If you visit a vertex which already has a number assigned, s...
Select 3 random points and split along that plane. What is the problem?
3,021,439
I have a list a vertices and a list of triangles. I'd like to split this single mesh into, say 5, randomly shaped meshes. When the 5 randomly shaped meshes are in place the sphere should all line up and look like 1 solid mesh. I need a algorithm to do this programmatically, not a tool to do it form me. Any pointers wo...
2010/06/11
[ "https://Stackoverflow.com/questions/3021439", "https://Stackoverflow.com", "https://Stackoverflow.com/users/308079/" ]
Similar to Svante's proposal but a slightly different approach: 1. Select five random vertices, mark these vertices as "visited" with the number 1 to 5 2. From each of the visited vertices, go to all adjacent vertices. Store the same number there as well. 3. If you visit a vertex which already has a number assigned, s...
You could make a crack by walking a random walk across the edges, until the number of pieces you want is achieved. If you want to have mostly big pieces, you could modify the randomness of the walk by reducing the attractiveness of edges that are close to an existing crack.
3,021,439
I have a list a vertices and a list of triangles. I'd like to split this single mesh into, say 5, randomly shaped meshes. When the 5 randomly shaped meshes are in place the sphere should all line up and look like 1 solid mesh. I need a algorithm to do this programmatically, not a tool to do it form me. Any pointers wo...
2010/06/11
[ "https://Stackoverflow.com/questions/3021439", "https://Stackoverflow.com", "https://Stackoverflow.com/users/308079/" ]
You could make a crack by walking a random walk across the edges, until the number of pieces you want is achieved. If you want to have mostly big pieces, you could modify the randomness of the walk by reducing the attractiveness of edges that are close to an existing crack.
When you split a triangle along a plane you end up in one of two situations: either the plane doesn't intersect either line segments in the triangle or it intersects exactly two line segments. Only triangles that are intersected are interesting. If you have triangle (A, B, C), with A, B and C being vertices. Assume t...
3,021,439
I have a list a vertices and a list of triangles. I'd like to split this single mesh into, say 5, randomly shaped meshes. When the 5 randomly shaped meshes are in place the sphere should all line up and look like 1 solid mesh. I need a algorithm to do this programmatically, not a tool to do it form me. Any pointers wo...
2010/06/11
[ "https://Stackoverflow.com/questions/3021439", "https://Stackoverflow.com", "https://Stackoverflow.com/users/308079/" ]
Similar to Svante's proposal but a slightly different approach: 1. Select five random vertices, mark these vertices as "visited" with the number 1 to 5 2. From each of the visited vertices, go to all adjacent vertices. Store the same number there as well. 3. If you visit a vertex which already has a number assigned, s...
When you split a triangle along a plane you end up in one of two situations: either the plane doesn't intersect either line segments in the triangle or it intersects exactly two line segments. Only triangles that are intersected are interesting. If you have triangle (A, B, C), with A, B and C being vertices. Assume t...
22,490,790
Note: I am a beginner. For some reason, my links that were working don't work at all anymore. What am I doing wrong? Here's the HTML: ``` <!doctype html> <html> <head> <meta charset="UTF-8"> <link rel="stylesheet" type="text/css" href="portfoliostyles.css"> <title>Home</title> </head> <body> <div class="header">...
2014/03/18
[ "https://Stackoverflow.com/questions/22490790", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3434998/" ]
basically you would do something like this: ``` for(var i in array) { if(array.hasOwnProperty(i)){ alert(array[i]); } } ``` EDITED: to check for presence of key in object.
``` function logArrayElements(element, index, array) { console.log("a[" + index + "] = " + element); } [2, 5, 9].forEach(logArrayElements); // logs: // a[0] = 2 // a[1] = 5 // a[2] = 9 ``` (taken from [here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach)) Note tha...
22,490,790
Note: I am a beginner. For some reason, my links that were working don't work at all anymore. What am I doing wrong? Here's the HTML: ``` <!doctype html> <html> <head> <meta charset="UTF-8"> <link rel="stylesheet" type="text/css" href="portfoliostyles.css"> <title>Home</title> </head> <body> <div class="header">...
2014/03/18
[ "https://Stackoverflow.com/questions/22490790", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3434998/" ]
basically you would do something like this: ``` for(var i in array) { if(array.hasOwnProperty(i)){ alert(array[i]); } } ``` EDITED: to check for presence of key in object.
``` for (var a = 0, b = array.length; a < b; a++) { alert(array[a]); } ``` Defining `b = array.length` speeds up the loop as `a < array.length` would re-check the length of the array on each iteration. Here's [why you shouldn't use `for ... in`](https://stackoverflow.com/a/3010848/11047).
22,490,790
Note: I am a beginner. For some reason, my links that were working don't work at all anymore. What am I doing wrong? Here's the HTML: ``` <!doctype html> <html> <head> <meta charset="UTF-8"> <link rel="stylesheet" type="text/css" href="portfoliostyles.css"> <title>Home</title> </head> <body> <div class="header">...
2014/03/18
[ "https://Stackoverflow.com/questions/22490790", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3434998/" ]
``` function logArrayElements(element, index, array) { console.log("a[" + index + "] = " + element); } [2, 5, 9].forEach(logArrayElements); // logs: // a[0] = 2 // a[1] = 5 // a[2] = 9 ``` (taken from [here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach)) Note tha...
``` for (var a = 0, b = array.length; a < b; a++) { alert(array[a]); } ``` Defining `b = array.length` speeds up the loop as `a < array.length` would re-check the length of the array on each iteration. Here's [why you shouldn't use `for ... in`](https://stackoverflow.com/a/3010848/11047).
80,522
In *The Godfather Part 1* (I haven't seen Parts 2 or 3 yet, if they're relevant) it's seen that The Corleone family does a lot of "favors" for Johnny Fontane - as was explained early on in the film - and [the Wikipedia page](https://en.wikipedia.org/wiki/Johnny_Fontane) > > \* They got him out of his original contra...
2017/09/18
[ "https://movies.stackexchange.com/questions/80522", "https://movies.stackexchange.com", "https://movies.stackexchange.com/users/43166/" ]
> > So what's in it for the Corleones to help Fontane? > > > Almost nothing...but in the case of Johnny Fontane it's not business related...it's *family*...not "Family". Fontane is Vito's **actual** godson..as Hagen explains > > “I don’t think you understand the situation. Mr. Corleone is Johnny Fontane’s Godfa...
Three quarters into the movie when Michael visits las Vegas he asks Johnny if he will perform at one of the Corleme owned hotels 4 times a year , Johnny didn't look too excited about this but agrees after thinking about Vito. Michael also asks if Johnny can persuade his Hollywood pals to perform to. So that is how the ...
80,522
In *The Godfather Part 1* (I haven't seen Parts 2 or 3 yet, if they're relevant) it's seen that The Corleone family does a lot of "favors" for Johnny Fontane - as was explained early on in the film - and [the Wikipedia page](https://en.wikipedia.org/wiki/Johnny_Fontane) > > \* They got him out of his original contra...
2017/09/18
[ "https://movies.stackexchange.com/questions/80522", "https://movies.stackexchange.com", "https://movies.stackexchange.com/users/43166/" ]
> > So what's in it for the Corleones to help Fontane? > > > Almost nothing...but in the case of Johnny Fontane it's not business related...it's *family*...not "Family". Fontane is Vito's **actual** godson..as Hagen explains > > “I don’t think you understand the situation. Mr. Corleone is Johnny Fontane’s Godfa...
For the favor, They got him to perform in Vegas in the hotels they plan to take from Moe Green when he's out of the way, Michael ask him if he could perform at the hotel a couple of times a year and ask his celebrity friends to do the same too!
80,522
In *The Godfather Part 1* (I haven't seen Parts 2 or 3 yet, if they're relevant) it's seen that The Corleone family does a lot of "favors" for Johnny Fontane - as was explained early on in the film - and [the Wikipedia page](https://en.wikipedia.org/wiki/Johnny_Fontane) > > \* They got him out of his original contra...
2017/09/18
[ "https://movies.stackexchange.com/questions/80522", "https://movies.stackexchange.com", "https://movies.stackexchange.com/users/43166/" ]
> > So what's in it for the Corleones to help Fontane? > > > Almost nothing...but in the case of Johnny Fontane it's not business related...it's *family*...not "Family". Fontane is Vito's **actual** godson..as Hagen explains > > “I don’t think you understand the situation. Mr. Corleone is Johnny Fontane’s Godfa...
This is best explained in the books. As others have said, Johnny is Vito's godson as such Vito will help him in any way he can. However; After the Woltz horse head in the bed incident Vito wonders how a weak man such as Woltz is able to become so rich and powerful in the movie business. He realizes that if Woltz c...
2,890,184
Will there be any measurable performance difference when passing data as values instead of as reference in PHP? It seems like few people are aware of that variables can be passed as values instead of references. Is this common sense or not?
2010/05/22
[ "https://Stackoverflow.com/questions/2890184", "https://Stackoverflow.com", "https://Stackoverflow.com/users/198128/" ]
If you are passing a large variable by value (which is the default for everything except objects in PHP5+), then yes, you can take a performance hit. For example, if the user submits a large amount of POST data, if you were to pass that to a function normally (aka pass by value), the whole array would have to be copie...
If there is a performance difference, it's negligible. Don't worry about these sorts of micro-optimizations unless you *know* that passing by reference is causing a performance hit (except I can't imagine a situation where that is true). On a side note, people generally advise against passing arguments by reference be...
2,890,184
Will there be any measurable performance difference when passing data as values instead of as reference in PHP? It seems like few people are aware of that variables can be passed as values instead of references. Is this common sense or not?
2010/05/22
[ "https://Stackoverflow.com/questions/2890184", "https://Stackoverflow.com", "https://Stackoverflow.com/users/198128/" ]
From my understanding, PHP 5 passes simple data types and arrays by value, but when it comes to objects it passes by reference. It seems this is a behaviour you should be aware of - I assume arrays are passed by value and therefore large ones may well incur a performance hit if you do not require a copy to be made. I'...
If there is a performance difference, it's negligible. Don't worry about these sorts of micro-optimizations unless you *know* that passing by reference is causing a performance hit (except I can't imagine a situation where that is true). On a side note, people generally advise against passing arguments by reference be...
2,890,184
Will there be any measurable performance difference when passing data as values instead of as reference in PHP? It seems like few people are aware of that variables can be passed as values instead of references. Is this common sense or not?
2010/05/22
[ "https://Stackoverflow.com/questions/2890184", "https://Stackoverflow.com", "https://Stackoverflow.com/users/198128/" ]
If you are passing a large variable by value (which is the default for everything except objects in PHP5+), then yes, you can take a performance hit. For example, if the user submits a large amount of POST data, if you were to pass that to a function normally (aka pass by value), the whole array would have to be copie...
Objects are always passed by reference if you use a recent version of PHP. As of the other type, the main concern are the strings / array. For those it depends. PHP's implementation of strings makes that if you don't modify the string you are passing to the function's argument (you only read it / scan it), it never wil...
2,890,184
Will there be any measurable performance difference when passing data as values instead of as reference in PHP? It seems like few people are aware of that variables can be passed as values instead of references. Is this common sense or not?
2010/05/22
[ "https://Stackoverflow.com/questions/2890184", "https://Stackoverflow.com", "https://Stackoverflow.com/users/198128/" ]
From my understanding, PHP 5 passes simple data types and arrays by value, but when it comes to objects it passes by reference. It seems this is a behaviour you should be aware of - I assume arrays are passed by value and therefore large ones may well incur a performance hit if you do not require a copy to be made. I'...
Objects are always passed by reference if you use a recent version of PHP. As of the other type, the main concern are the strings / array. For those it depends. PHP's implementation of strings makes that if you don't modify the string you are passing to the function's argument (you only read it / scan it), it never wil...
16,154,129
So, I was wondering if you were to launch this query: ``` INSERT INTO users (name, gender, location) VALUES ('Ricky-Bobby', 'm', 'Daytona Beach, FL'); ``` And suppose that `users` has another auto-incrementing columns for the primary key, how would you be able to get the value of that primary key without launching a...
2013/04/22
[ "https://Stackoverflow.com/questions/16154129", "https://Stackoverflow.com", "https://Stackoverflow.com/users/553566/" ]
codeigniter makes this available with `$this->db->last_insert_id()` <http://ellislab.com/codeigniter/user-guide/database/helpers.html>
You could use this if you are using PDO <http://php.net/manual/en/pdo.lastinsertid.php>
16,154,129
So, I was wondering if you were to launch this query: ``` INSERT INTO users (name, gender, location) VALUES ('Ricky-Bobby', 'm', 'Daytona Beach, FL'); ``` And suppose that `users` has another auto-incrementing columns for the primary key, how would you be able to get the value of that primary key without launching a...
2013/04/22
[ "https://Stackoverflow.com/questions/16154129", "https://Stackoverflow.com", "https://Stackoverflow.com/users/553566/" ]
codeigniter makes this available with `$this->db->last_insert_id()` <http://ellislab.com/codeigniter/user-guide/database/helpers.html>
You can combine [`LAST_INSERT_ID()`](http://dev.mysql.com/doc/refman/5.0/en/information-functions.html#function_last-insert-id) with your query: ``` INSERT INTO users (name, gender, location) VALUES ('Ricky-Bobby', 'm', 'Daytona Beach, FL'); SELECT LAST_INSERT_ID(); ```
16,154,129
So, I was wondering if you were to launch this query: ``` INSERT INTO users (name, gender, location) VALUES ('Ricky-Bobby', 'm', 'Daytona Beach, FL'); ``` And suppose that `users` has another auto-incrementing columns for the primary key, how would you be able to get the value of that primary key without launching a...
2013/04/22
[ "https://Stackoverflow.com/questions/16154129", "https://Stackoverflow.com", "https://Stackoverflow.com/users/553566/" ]
Codeigniter simplifies the MySQL query `SELECT LAST_INSERT_ID()` through the function `$this->db->insert_id()`. Although this *is* a query, it's a very light one that won't be a performance issue. One thing to have in note is this: * If you want the ID on the row you inserted; `$this->db->insert_id()` * If you want t...
codeigniter makes this available with `$this->db->last_insert_id()` <http://ellislab.com/codeigniter/user-guide/database/helpers.html>
16,154,129
So, I was wondering if you were to launch this query: ``` INSERT INTO users (name, gender, location) VALUES ('Ricky-Bobby', 'm', 'Daytona Beach, FL'); ``` And suppose that `users` has another auto-incrementing columns for the primary key, how would you be able to get the value of that primary key without launching a...
2013/04/22
[ "https://Stackoverflow.com/questions/16154129", "https://Stackoverflow.com", "https://Stackoverflow.com/users/553566/" ]
You can combine [`LAST_INSERT_ID()`](http://dev.mysql.com/doc/refman/5.0/en/information-functions.html#function_last-insert-id) with your query: ``` INSERT INTO users (name, gender, location) VALUES ('Ricky-Bobby', 'm', 'Daytona Beach, FL'); SELECT LAST_INSERT_ID(); ```
You could use this if you are using PDO <http://php.net/manual/en/pdo.lastinsertid.php>
16,154,129
So, I was wondering if you were to launch this query: ``` INSERT INTO users (name, gender, location) VALUES ('Ricky-Bobby', 'm', 'Daytona Beach, FL'); ``` And suppose that `users` has another auto-incrementing columns for the primary key, how would you be able to get the value of that primary key without launching a...
2013/04/22
[ "https://Stackoverflow.com/questions/16154129", "https://Stackoverflow.com", "https://Stackoverflow.com/users/553566/" ]
Codeigniter simplifies the MySQL query `SELECT LAST_INSERT_ID()` through the function `$this->db->insert_id()`. Although this *is* a query, it's a very light one that won't be a performance issue. One thing to have in note is this: * If you want the ID on the row you inserted; `$this->db->insert_id()` * If you want t...
You could use this if you are using PDO <http://php.net/manual/en/pdo.lastinsertid.php>
16,154,129
So, I was wondering if you were to launch this query: ``` INSERT INTO users (name, gender, location) VALUES ('Ricky-Bobby', 'm', 'Daytona Beach, FL'); ``` And suppose that `users` has another auto-incrementing columns for the primary key, how would you be able to get the value of that primary key without launching a...
2013/04/22
[ "https://Stackoverflow.com/questions/16154129", "https://Stackoverflow.com", "https://Stackoverflow.com/users/553566/" ]
Codeigniter simplifies the MySQL query `SELECT LAST_INSERT_ID()` through the function `$this->db->insert_id()`. Although this *is* a query, it's a very light one that won't be a performance issue. One thing to have in note is this: * If you want the ID on the row you inserted; `$this->db->insert_id()` * If you want t...
You can combine [`LAST_INSERT_ID()`](http://dev.mysql.com/doc/refman/5.0/en/information-functions.html#function_last-insert-id) with your query: ``` INSERT INTO users (name, gender, location) VALUES ('Ricky-Bobby', 'm', 'Daytona Beach, FL'); SELECT LAST_INSERT_ID(); ```
28,327,285
I was wondering if anyone has found a way to determine the intention of a master communicating with an stm32f40x chip? From the perspective of the firmware on the stm32f40x chip, the ADDRess sent by the master is not available, and the r/w bit (bit 0 of the address) contained therein is also not available. So how can I...
2015/02/04
[ "https://Stackoverflow.com/questions/28327285", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
There is another (rougher) method [found here](http://www.contextures.com/Excel-VBA-ComboBox-Lists.html) to do this if you so choose. Also make sure you define the Sheet name you are sourcing the data from: ``` Sub AddItemsToBox() Dim itemcell As Range For Each itemcell in Sheets("Source Sheet Name").Range("...
Using ComboBox, you can use `.List` property of the same to populate worksheet values to combox box. Check this below example: ``` ComboBox1.List = Worksheets("Sheet1").Range("A1:A5").Value ``` If you want to use Array, ``` Dim Arr As Variant Arr = Worksheets("Sheet1").Range("A1:A5").Value ComboBox1.List = Arr ...
28,327,285
I was wondering if anyone has found a way to determine the intention of a master communicating with an stm32f40x chip? From the perspective of the firmware on the stm32f40x chip, the ADDRess sent by the master is not available, and the r/w bit (bit 0 of the address) contained therein is also not available. So how can I...
2015/02/04
[ "https://Stackoverflow.com/questions/28327285", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Using ComboBox, you can use `.List` property of the same to populate worksheet values to combox box. Check this below example: ``` ComboBox1.List = Worksheets("Sheet1").Range("A1:A5").Value ``` If you want to use Array, ``` Dim Arr As Variant Arr = Worksheets("Sheet1").Range("A1:A5").Value ComboBox1.List = Arr ...
I am just getting into VBA and I am doing exactly this. I think the way I found is pretty easy and straightforward. I'll share it in case it can help someone 1. Declare variable to store table from Worksheet as "range". Make sure it's outside of sub routines so it can be called by any function `Dim myTable As Range`...
28,327,285
I was wondering if anyone has found a way to determine the intention of a master communicating with an stm32f40x chip? From the perspective of the firmware on the stm32f40x chip, the ADDRess sent by the master is not available, and the r/w bit (bit 0 of the address) contained therein is also not available. So how can I...
2015/02/04
[ "https://Stackoverflow.com/questions/28327285", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
There is another (rougher) method [found here](http://www.contextures.com/Excel-VBA-ComboBox-Lists.html) to do this if you so choose. Also make sure you define the Sheet name you are sourcing the data from: ``` Sub AddItemsToBox() Dim itemcell As Range For Each itemcell in Sheets("Source Sheet Name").Range("...
I am just getting into VBA and I am doing exactly this. I think the way I found is pretty easy and straightforward. I'll share it in case it can help someone 1. Declare variable to store table from Worksheet as "range". Make sure it's outside of sub routines so it can be called by any function `Dim myTable As Range`...
10,927,577
Is there any way to achieve this effect (3D CANVAS VIEW) for displaying an image within a website? [Click here to view the image effect](http://i49.tinypic.com/2cigydg.jpg) Is there any JavaScript Library or maybe HTML5 Canvas solution or it can be done via PHP? Thanks! EDIT: To be more explicit this is the eff...
2012/06/07
[ "https://Stackoverflow.com/questions/10927577", "https://Stackoverflow.com", "https://Stackoverflow.com/users/786466/" ]
We do something pretty similar here, and it all works well within JIRA / Greenhopper: 1. Product owner creates Epics / Themes / User stories in JIRA/Grasshopper 2. Backlog grooming occurs, story thrashed out a bit, and story points entered into user story 3. Sprint planning: Stories are selected for upcoming sprint, a...
It sounds like your process is reasonably straightforward. I'd recommend that you have a go with the new Rapid Boards in GreenHopper 5.10.1. The Rapid Board's have a clear Plan > Work > Report flow to them. Looking at your specifics I'd recommend the following: * First create a Rapid Board for the general developme...
55,227,304
I want made loop like of this on twig template: ``` for($i=1;$i<100;$i++) { echo $i; } ``` I solved this problem as: ``` {% if k > 0 %} {% for i in 0..k - 1 %} <div></div> {% endfor %} {% endif %} if k = 0 -> no loop if k = 1 -> 1 loop if k = 100 -> 100 lopp ``` May be is other solve?
2019/03/18
[ "https://Stackoverflow.com/questions/55227304", "https://Stackoverflow.com", "https://Stackoverflow.com/users/556432/" ]
You can use [range](https://twig.symfony.com/doc/2.x/functions/range.html) to reproduce loop output similar to the first php example ``` {% for i in range(1, 100-1) %} {{ i }} {% endfor %} ```
You can add the `if` inside the `loop` ``` {% for i in 0..k if k > 0 %} {{ i }} {% endfor %} ``` [demo](https://twigfiddle.com/4scv20) --- *edit: This doesn't work anymore in twig 3.X. You have to place the `if` inside the codeblock*
70,757,810
I have problems with vs-code Jupyter Notebook colors ( after install ohmyzsh default theme ) .. where can I change the color values ​​to remove this annoying yellow background? [![Example](https://i.stack.imgur.com/UX6JO.png)](https://i.stack.imgur.com/UX6JO.png)
2022/01/18
[ "https://Stackoverflow.com/questions/70757810", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3319579/" ]
I find a solution. To find all possible vs-code color customization ran: press F1 then write `Developer: Generate Color Theme from Current Settings` then press F1 -> setting.json on setting json add ``` "workbench.colorCustomizations": { "terminal.ansiYellow": "#8400ffe1", } ```
To clarify @Marco idea, press F1: `Preferences: Open workspace settings (Json)` add this line to that json, Ctrl + S to save ``` "workbench.colorCustomizations": { "terminal.ansiYellow": "#8400ffe1", } ``` The background would turn to purple [![enter image description here](https://i.stack.imgur.com/5sjCA....
58,182,553
Below is my DTO class. ``` public class AbstractDTO extends BaseDTO { private Integer createdBy; @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DATE_FORMAT) @NotNull(message = "createdDate may not be null") private LocalDateTime createdDate; private Integer lastModifiedBy; @JsonForma...
2019/10/01
[ "https://Stackoverflow.com/questions/58182553", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6298969/" ]
Your DTO class is correct. You have to use `@Valid` annotation. For example : ``` @Controller public class Controller { @PostMapping("/") public String checkPersonInfo(@Valid AbstractDTO abstractDTO, BindingResult bindingResult) { if (bindingResult.hasErrors()) { return "some-page"; ...
Have you got the right import ? I use `import javax.validation.constraints.NotNull;`
58,182,553
Below is my DTO class. ``` public class AbstractDTO extends BaseDTO { private Integer createdBy; @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DATE_FORMAT) @NotNull(message = "createdDate may not be null") private LocalDateTime createdDate; private Integer lastModifiedBy; @JsonForma...
2019/10/01
[ "https://Stackoverflow.com/questions/58182553", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6298969/" ]
You have an endpoint with some request body like; ``` @RestController public class TheController { @PostMapping(path = "/doSomething", consumes = "application/json", produces = "application/json") public void post(@Valid @RequestBody AbstractDTO request) { //code } } ``` You need to have `@Valid...
Have you got the right import ? I use `import javax.validation.constraints.NotNull;`
58,182,553
Below is my DTO class. ``` public class AbstractDTO extends BaseDTO { private Integer createdBy; @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DATE_FORMAT) @NotNull(message = "createdDate may not be null") private LocalDateTime createdDate; private Integer lastModifiedBy; @JsonForma...
2019/10/01
[ "https://Stackoverflow.com/questions/58182553", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6298969/" ]
Your DTO class is correct. You have to use `@Valid` annotation. For example : ``` @Controller public class Controller { @PostMapping("/") public String checkPersonInfo(@Valid AbstractDTO abstractDTO, BindingResult bindingResult) { if (bindingResult.hasErrors()) { return "some-page"; ...
You have an endpoint with some request body like; ``` @RestController public class TheController { @PostMapping(path = "/doSomething", consumes = "application/json", produces = "application/json") public void post(@Valid @RequestBody AbstractDTO request) { //code } } ``` You need to have `@Valid...
15,699,775
I am trying to create a function where my php calendar can be updated. This set of code is supposed to send $\_POST["showmonth"] and $\_POST["showyear"] to the controller but apparently it isn't working, causing the undefined index error. To be honest I am a total newbie in javascript and was just follow a tutorial on ...
2013/03/29
[ "https://Stackoverflow.com/questions/15699775", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2223623/" ]
One way (Output is tab-separated): ``` perl -lane'print join "\t",@F[2..$#F]' file ``` For right-aligned output: ``` perl -lane'printf "%10s",$_ for @F[2..$#F];print "";' file ```
Using sed to remove first two columns: ``` sed 's/^[ \t]*[0-9.]*[ \t]*[0-9.]*[ \t]*//' input1 input2 ``` You can increase the number of `[ \t]*[0-9.]*`s if you want to remove more columns.
15,699,775
I am trying to create a function where my php calendar can be updated. This set of code is supposed to send $\_POST["showmonth"] and $\_POST["showyear"] to the controller but apparently it isn't working, causing the undefined index error. To be honest I am a total newbie in javascript and was just follow a tutorial on ...
2013/03/29
[ "https://Stackoverflow.com/questions/15699775", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2223623/" ]
One way (Output is tab-separated): ``` perl -lane'print join "\t",@F[2..$#F]' file ``` For right-aligned output: ``` perl -lane'printf "%10s",$_ for @F[2..$#F];print "";' file ```
awk can do the same allowing you to switch easily the columns and change the separator in input and output if needed: ``` awk '{print $3,$4,$5}' test 3.3 4.2 5.1 ``` hope it helps
15,699,775
I am trying to create a function where my php calendar can be updated. This set of code is supposed to send $\_POST["showmonth"] and $\_POST["showyear"] to the controller but apparently it isn't working, causing the undefined index error. To be honest I am a total newbie in javascript and was just follow a tutorial on ...
2013/03/29
[ "https://Stackoverflow.com/questions/15699775", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2223623/" ]
One way (Output is tab-separated): ``` perl -lane'print join "\t",@F[2..$#F]' file ``` For right-aligned output: ``` perl -lane'printf "%10s",$_ for @F[2..$#F];print "";' file ```
``` awk '{$1=$2="";gsub("^ ","",$0);}1' your_file ``` or ``` perl -lane 'print "@F[2..scalar(@F)]"' your_file ```
15,699,775
I am trying to create a function where my php calendar can be updated. This set of code is supposed to send $\_POST["showmonth"] and $\_POST["showyear"] to the controller but apparently it isn't working, causing the undefined index error. To be honest I am a total newbie in javascript and was just follow a tutorial on ...
2013/03/29
[ "https://Stackoverflow.com/questions/15699775", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2223623/" ]
Using sed to remove first two columns: ``` sed 's/^[ \t]*[0-9.]*[ \t]*[0-9.]*[ \t]*//' input1 input2 ``` You can increase the number of `[ \t]*[0-9.]*`s if you want to remove more columns.
``` awk '{$1=$2="";gsub("^ ","",$0);}1' your_file ``` or ``` perl -lane 'print "@F[2..scalar(@F)]"' your_file ```
15,699,775
I am trying to create a function where my php calendar can be updated. This set of code is supposed to send $\_POST["showmonth"] and $\_POST["showyear"] to the controller but apparently it isn't working, causing the undefined index error. To be honest I am a total newbie in javascript and was just follow a tutorial on ...
2013/03/29
[ "https://Stackoverflow.com/questions/15699775", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2223623/" ]
awk can do the same allowing you to switch easily the columns and change the separator in input and output if needed: ``` awk '{print $3,$4,$5}' test 3.3 4.2 5.1 ``` hope it helps
``` awk '{$1=$2="";gsub("^ ","",$0);}1' your_file ``` or ``` perl -lane 'print "@F[2..scalar(@F)]"' your_file ```
50,336,317
I' ve inserted the followings input for the follow program: ``` a b c d e ``` After the e letter I've pressed Enter, but the program blocks on scanf for i equal to 3. Seems that scanf is not able to fetch other character from stdin. Thanks in advance for your help. ``` #include <stdio.h> #include <stdlib.h>...
2018/05/14
[ "https://Stackoverflow.com/questions/50336317", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7866539/" ]
It doesn't block when i == 3 -- it completes that iteration -- it blocks when i == 4. That's because of the space after the `%c` in the scanf format -- a space causes scanf to read input and skip whitespace up until it finds a non-whitespace character. That non-whitespace character will then be left in the FILE input ...
Using scanf to fetch a single character at a time from stdin is not a good idea. If the user types more than one character, you can overflow the buffer as there is no room for the null character. This also leaves excess characters in stdin. Another idea is to use a special format string flag to fetch 5 characters at o...
19,903,536
I'm trying to take an output from xml document using c#. But I don't receive any output to the grid and no error messages are generated. I assume this should be a mistake that i'm doing when using XmlnamespaceManager. I will show the coding that I'm using. Can somebody please help me to identify where am I going wrong....
2013/11/11
[ "https://Stackoverflow.com/questions/19903536", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1125081/" ]
Pretty sure it is just your xpath - the odd `@xmlns:ns2` looks out of place. ``` public void InitializePatchListArray() { ArrayPatchList[0, 0] = "Installed Patch"; ArrayPatchList[0, 1] = "/compositeReport/eisRecommendedPatchReport/ns2:recommendedPatchList/ns2:recommendedPatch/ns2:installedPatchId"; } ``` should ...
I think that using **serialization** may be more elegant and clear. Moreover, if you're using Visual Studio 2012, you can create a class from XML automatically and then, where serializing or deserializing, point the namespaces in a simple way
66,564,247
Coming from python and need to translate some old app i made to C#. I have a ListView with Checkboxes. XAML ``` <ListView Name ="spored" SelectionMode="Multiple" HorizontalAlignment="Left" VerticalAlignment="Stretch" Margin="10,10,10,10" Width="750"> <ListView.View> <GridView> <Grid...
2021/03/10
[ "https://Stackoverflow.com/questions/66564247", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9418280/" ]
Use [`Series.str.extract`](http://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.str.extract.html) first for numeric and non numeric part, convert numeric part to integers and divide by `2`, then join with multiple value by `-1` in [`concat`](http://pandas.pydata.org/pandas-docs/stable/reference/api/p...
it is something that can easily be done using the melt function. ``` # recreate your dataframe df = pd.DataFrame(columns=['fr','var']) df['fr']=[1.1,2.9] df['var']=['10px','12pz'] # split the var into its two components by creating two new columns df['vard_p'] = df['var'].str[:-2] df['vard_p'] = df['vard_p'].astype(f...
6,398,937
Let's say I have a folder in my "Resources" folder of my iPhone application called "Documents". Is there a way that I can get an array or some type of list of all the files included in that folder at run time? So, in code, it would look like: ``` NSMutableArray *myFiles = [...get a list of files in Resources/Documen...
2011/06/18
[ "https://Stackoverflow.com/questions/6398937", "https://Stackoverflow.com", "https://Stackoverflow.com/users/412082/" ]
You can get the path to the `Resources` directory like this, ``` NSString * resourcePath = [[NSBundle mainBundle] resourcePath]; ``` Then append the `Documents` to the path, ``` NSString * documentsPath = [resourcePath stringByAppendingPathComponent:@"Documents"]; ``` Then you can use any of the directory listing...
Swift version: ``` if let files = try? FileManager.default.contentsOfDirectory(atPath: Bundle.main.bundlePath ){ for file in files { print(file) } } ```
6,398,937
Let's say I have a folder in my "Resources" folder of my iPhone application called "Documents". Is there a way that I can get an array or some type of list of all the files included in that folder at run time? So, in code, it would look like: ``` NSMutableArray *myFiles = [...get a list of files in Resources/Documen...
2011/06/18
[ "https://Stackoverflow.com/questions/6398937", "https://Stackoverflow.com", "https://Stackoverflow.com/users/412082/" ]
Swift ===== *Updated for Swift 3* ``` let docsPath = Bundle.main.resourcePath! + "/Resources" let fileManager = FileManager.default do { let docsArray = try fileManager.contentsOfDirectory(atPath: docsPath) } catch { print(error) } ``` **Further reading:** * [NSFileManager class reference](https://develop...
Swift 4: -------- If you have to do with subdirs **"Relative to project"** (blue folders) you could write: ``` func getAllPListFrom(_ subdir:String)->[URL]? { guard let fURL = Bundle.main.urls(forResourcesWithExtension: "plist", subdirectory: subdir) else { return nil } return fURL } ``` **Usage**: ``` if ...
6,398,937
Let's say I have a folder in my "Resources" folder of my iPhone application called "Documents". Is there a way that I can get an array or some type of list of all the files included in that folder at run time? So, in code, it would look like: ``` NSMutableArray *myFiles = [...get a list of files in Resources/Documen...
2011/06/18
[ "https://Stackoverflow.com/questions/6398937", "https://Stackoverflow.com", "https://Stackoverflow.com/users/412082/" ]
You can get the path to the `Resources` directory like this, ``` NSString * resourcePath = [[NSBundle mainBundle] resourcePath]; ``` Then append the `Documents` to the path, ``` NSString * documentsPath = [resourcePath stringByAppendingPathComponent:@"Documents"]; ``` Then you can use any of the directory listing...
**Swift 3** (and returning URLs) ``` let url = Bundle.main.resourceURL! do { let urls = try FileManager.default.contentsOfDirectory(at: url, includingPropertiesForKeys:[], options: FileManager.DirectoryEnumerationOptions.skipsHiddenFiles) } catch { print(error) } ```
6,398,937
Let's say I have a folder in my "Resources" folder of my iPhone application called "Documents". Is there a way that I can get an array or some type of list of all the files included in that folder at run time? So, in code, it would look like: ``` NSMutableArray *myFiles = [...get a list of files in Resources/Documen...
2011/06/18
[ "https://Stackoverflow.com/questions/6398937", "https://Stackoverflow.com", "https://Stackoverflow.com/users/412082/" ]
Swift ===== *Updated for Swift 3* ``` let docsPath = Bundle.main.resourcePath! + "/Resources" let fileManager = FileManager.default do { let docsArray = try fileManager.contentsOfDirectory(atPath: docsPath) } catch { print(error) } ``` **Further reading:** * [NSFileManager class reference](https://develop...
You can try this code also: ``` NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSError * error; NSArray * directoryContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:docum...
6,398,937
Let's say I have a folder in my "Resources" folder of my iPhone application called "Documents". Is there a way that I can get an array or some type of list of all the files included in that folder at run time? So, in code, it would look like: ``` NSMutableArray *myFiles = [...get a list of files in Resources/Documen...
2011/06/18
[ "https://Stackoverflow.com/questions/6398937", "https://Stackoverflow.com", "https://Stackoverflow.com/users/412082/" ]
Swift version: ``` if let files = try? FileManager.default.contentsOfDirectory(atPath: Bundle.main.bundlePath ){ for file in files { print(file) } } ```
Listing All Files In A Directory ``` NSFileManager *fileManager = [NSFileManager defaultManager]; NSURL *bundleURL = [[NSBundle mainBundle] bundleURL]; NSArray *contents = [fileManager contentsOfDirectoryAtURL:bundleURL includingPropertiesForKeys:@[] ...
6,398,937
Let's say I have a folder in my "Resources" folder of my iPhone application called "Documents". Is there a way that I can get an array or some type of list of all the files included in that folder at run time? So, in code, it would look like: ``` NSMutableArray *myFiles = [...get a list of files in Resources/Documen...
2011/06/18
[ "https://Stackoverflow.com/questions/6398937", "https://Stackoverflow.com", "https://Stackoverflow.com/users/412082/" ]
Swift ===== *Updated for Swift 3* ``` let docsPath = Bundle.main.resourcePath! + "/Resources" let fileManager = FileManager.default do { let docsArray = try fileManager.contentsOfDirectory(atPath: docsPath) } catch { print(error) } ``` **Further reading:** * [NSFileManager class reference](https://develop...
Swift version: ``` if let files = try? FileManager.default.contentsOfDirectory(atPath: Bundle.main.bundlePath ){ for file in files { print(file) } } ```
6,398,937
Let's say I have a folder in my "Resources" folder of my iPhone application called "Documents". Is there a way that I can get an array or some type of list of all the files included in that folder at run time? So, in code, it would look like: ``` NSMutableArray *myFiles = [...get a list of files in Resources/Documen...
2011/06/18
[ "https://Stackoverflow.com/questions/6398937", "https://Stackoverflow.com", "https://Stackoverflow.com/users/412082/" ]
You can get the path to the `Resources` directory like this, ``` NSString * resourcePath = [[NSBundle mainBundle] resourcePath]; ``` Then append the `Documents` to the path, ``` NSString * documentsPath = [resourcePath stringByAppendingPathComponent:@"Documents"]; ``` Then you can use any of the directory listing...
Swift 4: -------- If you have to do with subdirs **"Relative to project"** (blue folders) you could write: ``` func getAllPListFrom(_ subdir:String)->[URL]? { guard let fURL = Bundle.main.urls(forResourcesWithExtension: "plist", subdirectory: subdir) else { return nil } return fURL } ``` **Usage**: ``` if ...
6,398,937
Let's say I have a folder in my "Resources" folder of my iPhone application called "Documents". Is there a way that I can get an array or some type of list of all the files included in that folder at run time? So, in code, it would look like: ``` NSMutableArray *myFiles = [...get a list of files in Resources/Documen...
2011/06/18
[ "https://Stackoverflow.com/questions/6398937", "https://Stackoverflow.com", "https://Stackoverflow.com/users/412082/" ]
Swift version: ``` if let files = try? FileManager.default.contentsOfDirectory(atPath: Bundle.main.bundlePath ){ for file in files { print(file) } } ```
**Swift 3** (and returning URLs) ``` let url = Bundle.main.resourceURL! do { let urls = try FileManager.default.contentsOfDirectory(at: url, includingPropertiesForKeys:[], options: FileManager.DirectoryEnumerationOptions.skipsHiddenFiles) } catch { print(error) } ```
6,398,937
Let's say I have a folder in my "Resources" folder of my iPhone application called "Documents". Is there a way that I can get an array or some type of list of all the files included in that folder at run time? So, in code, it would look like: ``` NSMutableArray *myFiles = [...get a list of files in Resources/Documen...
2011/06/18
[ "https://Stackoverflow.com/questions/6398937", "https://Stackoverflow.com", "https://Stackoverflow.com/users/412082/" ]
You can get the path to the `Resources` directory like this, ``` NSString * resourcePath = [[NSBundle mainBundle] resourcePath]; ``` Then append the `Documents` to the path, ``` NSString * documentsPath = [resourcePath stringByAppendingPathComponent:@"Documents"]; ``` Then you can use any of the directory listing...
You can try this code also: ``` NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSError * error; NSArray * directoryContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:docum...
6,398,937
Let's say I have a folder in my "Resources" folder of my iPhone application called "Documents". Is there a way that I can get an array or some type of list of all the files included in that folder at run time? So, in code, it would look like: ``` NSMutableArray *myFiles = [...get a list of files in Resources/Documen...
2011/06/18
[ "https://Stackoverflow.com/questions/6398937", "https://Stackoverflow.com", "https://Stackoverflow.com/users/412082/" ]
Swift ===== *Updated for Swift 3* ``` let docsPath = Bundle.main.resourcePath! + "/Resources" let fileManager = FileManager.default do { let docsArray = try fileManager.contentsOfDirectory(atPath: docsPath) } catch { print(error) } ``` **Further reading:** * [NSFileManager class reference](https://develop...
**Swift 3** (and returning URLs) ``` let url = Bundle.main.resourceURL! do { let urls = try FileManager.default.contentsOfDirectory(at: url, includingPropertiesForKeys:[], options: FileManager.DirectoryEnumerationOptions.skipsHiddenFiles) } catch { print(error) } ```
72,048,955
I am unsure why I have this error. Could you please take a look and advise? ``` import React from 'react'; import { client, urlFor } from '../../lib/client'; const ProductDetails = ({ product, products }) => { const { image, name, details, price } = product; return ( <div> <div className...
2022/04/28
[ "https://Stackoverflow.com/questions/72048955", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18979562/" ]
I saw this tutorial about sanity, if you get this error when you click on the banner product you have to make sure that you have a Product with the slug name that is the same as your "Product" input in the Banner item. I don't know if my explanations are clear but when you create a Banner item on Sanity you don't crea...
The answer is shown in the provided error-message: > > TypeError: Cannot destructure property 'image' of 'product' as it is > null. > > > The product that you use as a prop to instantiate ProductDetails is null.
72,048,955
I am unsure why I have this error. Could you please take a look and advise? ``` import React from 'react'; import { client, urlFor } from '../../lib/client'; const ProductDetails = ({ product, products }) => { const { image, name, details, price } = product; return ( <div> <div className...
2022/04/28
[ "https://Stackoverflow.com/questions/72048955", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18979562/" ]
I was following a YouTube tutorial for an e-commerce website and had this same problem. It ended up being an issue in the Product.jsx file where I used a ' instead of a `. I recommend rechecking that file for any small mistakes, especially the line: <Link href={`/product/${slug.current}`}>
The answer is shown in the provided error-message: > > TypeError: Cannot destructure property 'image' of 'product' as it is > null. > > > The product that you use as a prop to instantiate ProductDetails is null.
72,048,955
I am unsure why I have this error. Could you please take a look and advise? ``` import React from 'react'; import { client, urlFor } from '../../lib/client'; const ProductDetails = ({ product, products }) => { const { image, name, details, price } = product; return ( <div> <div className...
2022/04/28
[ "https://Stackoverflow.com/questions/72048955", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18979562/" ]
I saw this tutorial about sanity, if you get this error when you click on the banner product you have to make sure that you have a Product with the slug name that is the same as your "Product" input in the Banner item. I don't know if my explanations are clear but when you create a Banner item on Sanity you don't crea...
If the above code is an accurate representation which is hard to tell due to the way the question is laid out then the error is in your queries to sanity. The getStaticProps and getStaticPaths functions are not querying correctly and returning null instead of your products. I believe this is as you are missing quotes...
72,048,955
I am unsure why I have this error. Could you please take a look and advise? ``` import React from 'react'; import { client, urlFor } from '../../lib/client'; const ProductDetails = ({ product, products }) => { const { image, name, details, price } = product; return ( <div> <div className...
2022/04/28
[ "https://Stackoverflow.com/questions/72048955", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18979562/" ]
I was following a YouTube tutorial for an e-commerce website and had this same problem. It ended up being an issue in the Product.jsx file where I used a ' instead of a `. I recommend rechecking that file for any small mistakes, especially the line: <Link href={`/product/${slug.current}`}>
If the above code is an accurate representation which is hard to tell due to the way the question is laid out then the error is in your queries to sanity. The getStaticProps and getStaticPaths functions are not querying correctly and returning null instead of your products. I believe this is as you are missing quotes...
50,256,872
I have a JSON file like this: ``` { "result": { "id": "123456789012345", "name": "Example data", }, "parents": { "p1": { "parentGender": "M", "parentName": "George", "kids": { "1": { ...
2018/05/09
[ "https://Stackoverflow.com/questions/50256872", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9765512/" ]
If you want a `purrr` functional approach, you could do: ``` library(tidyverse) parents <- es$parents %>% enframe('parentID', 'parentInfo') result_df <- parents %>% mutate(parent_gender = parentInfo %>% map_chr("parentGender"), parent_name = parentInfo %>% map_chr("parentName"), kid_info = parent...
If your JSON has different counts in collections, a "*for in*" loop is enough. The following code should do the trick: ``` library(jsonlite) es<-fromJSON("./json_example2.json" ) parentId <- names(es$parents) df <- data.frame() for(i in 1:length(parentId)) { p <- es$parents[[i]] id <- parentId[i] parentGender <...
42,766,425
I can't figure out the correct second argument of `strptime` for the following date format ``` a = datetime.strptime('2017-03-09 14:00:00.000000+0000', '%y-%m-%d %H:%M:%S.%f+%z') ``` The error I get is: ``` ValueError: time data '2017-03-09 14:00:00.000000+0000' does not match format '%y-%m-%d %H:%M:%S.%f+%z' ``` ...
2017/03/13
[ "https://Stackoverflow.com/questions/42766425", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1937872/" ]
The correct format string is: ``` %Y-%m-%d %H:%M:%S.%f%z ``` You can figure this out more easily next time by using `strftime()` to write a datetime using a given format. For example, your original: ``` datetime.datetime.now().astimezone(tz=None).strftime('%y-%m-%d %H:%M:%S.%f+%z') ``` gives: ``` 17-03-13 22:53:...
This is how it goes: ``` import datetime output_date = datetime.datetime.now(tz = datetime.datetime.now().astimezone().tzinfo).isoformat(timespec='milliseconds') print(output_date) ``` Gives: ``` "2021-04-20T16:56:29.800+02:00" ``` Which is in ISO 8601 yyyy-MM-dd'T'HH:mm:ss.SSSXXX format.
42,766,425
I can't figure out the correct second argument of `strptime` for the following date format ``` a = datetime.strptime('2017-03-09 14:00:00.000000+0000', '%y-%m-%d %H:%M:%S.%f+%z') ``` The error I get is: ``` ValueError: time data '2017-03-09 14:00:00.000000+0000' does not match format '%y-%m-%d %H:%M:%S.%f+%z' ``` ...
2017/03/13
[ "https://Stackoverflow.com/questions/42766425", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1937872/" ]
The correct format string is: ``` %Y-%m-%d %H:%M:%S.%f%z ``` You can figure this out more easily next time by using `strftime()` to write a datetime using a given format. For example, your original: ``` datetime.datetime.now().astimezone(tz=None).strftime('%y-%m-%d %H:%M:%S.%f+%z') ``` gives: ``` 17-03-13 22:53:...
The other answers are fine, it is just that I guess that the question about one example case arose from a full column of a dataframe that needs to be converted to datetime. Just for those who have a dataframe instead and need to reformat the whole column like me: ``` pd.to_datetime(df['MY_STR_TIMESTAMP_COLUMN_NAME'])...
42,766,425
I can't figure out the correct second argument of `strptime` for the following date format ``` a = datetime.strptime('2017-03-09 14:00:00.000000+0000', '%y-%m-%d %H:%M:%S.%f+%z') ``` The error I get is: ``` ValueError: time data '2017-03-09 14:00:00.000000+0000' does not match format '%y-%m-%d %H:%M:%S.%f+%z' ``` ...
2017/03/13
[ "https://Stackoverflow.com/questions/42766425", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1937872/" ]
This is how it goes: ``` import datetime output_date = datetime.datetime.now(tz = datetime.datetime.now().astimezone().tzinfo).isoformat(timespec='milliseconds') print(output_date) ``` Gives: ``` "2021-04-20T16:56:29.800+02:00" ``` Which is in ISO 8601 yyyy-MM-dd'T'HH:mm:ss.SSSXXX format.
The other answers are fine, it is just that I guess that the question about one example case arose from a full column of a dataframe that needs to be converted to datetime. Just for those who have a dataframe instead and need to reformat the whole column like me: ``` pd.to_datetime(df['MY_STR_TIMESTAMP_COLUMN_NAME'])...
74,491,856
I am learning Redux Toolkit. From a React POV it seems very intuitive to access whatever part of the state you need from within useSelector using an inline arrow function, and then conduct any calculations. As an example consider a cart item with its data (like item count) in redux store. ``` function CartItemCounter(...
2022/11/18
[ "https://Stackoverflow.com/questions/74491856", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18620006/" ]
The information that is out there is essentially talking about different levels of optimization while using `useSelector`. What you need to understand before anything else, is how `useSelector` works internally. How does `useSelector` work? ---------------------------- When you pass a function to `useSelector` (obvio...
> > But I'm seeing all this information saying you should define your selectors beside your slice, use createSelector and all. > > > That's the way to go if you're deriving something from the state, which ends up being an expensive computation or something that's reused often throughout your app. Imagine, for exam...
581,682
Inside `nvidia-settings` (running with `sudo` elevated privileges), I am unable to get a second X Screen to work. Here is a step-by-step description of one thing I have tried: 1. On the left, select "X Server Display Configuration" 2. Select the secondary display (the one that goes to receiver) 3. In the "Configuratio...
2020/04/22
[ "https://unix.stackexchange.com/questions/581682", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/368291/" ]
After much research and experimentation (with `.conf` files and otherwise) I was never able to determine the root cause of this issue. I did eventually get two X Screens working again by doing a full re-installation of Fedora and being extra diligent while installing the proprietary Nvidia drivers. The issue may have b...
Let me give you an example of configuration file, which I am using successfully on CentOS7 and CentOS8 for two screens. They are very similar to Fedora that you are using. On previous systems (CentOS5) I used xorg.conf, but now I put this into `/etc/X11/xorg.conf.d/20-nvidia-graphics.conf`: ``` Section "ServerLayout" ...
6,909,559
I have a few links on my site that will need to show a modal dialog when the user clicks on one of them. The modal will contain a message like: `You are now leaving the "SECTION NAME" part of "SITE NAME"`. The user will then either accept which will allow the user to continue on with their request or cancel which will ...
2011/08/02
[ "https://Stackoverflow.com/questions/6909559", "https://Stackoverflow.com", "https://Stackoverflow.com/users/302533/" ]
I just had to solve the same problem. The key to getting this to work was that the `dialog` must be partially initialized in the `click` event handler for the link you want to use the confirmation functionality with (if you want to use this for more than one link). This is because the target URL for the link must be in...
I think this plugin may be help <http://jqueryui.com/demos/dialog/#modal-confirmation>
6,909,559
I have a few links on my site that will need to show a modal dialog when the user clicks on one of them. The modal will contain a message like: `You are now leaving the "SECTION NAME" part of "SITE NAME"`. The user will then either accept which will allow the user to continue on with their request or cancel which will ...
2011/08/02
[ "https://Stackoverflow.com/questions/6909559", "https://Stackoverflow.com", "https://Stackoverflow.com/users/302533/" ]
I just had to solve the same problem. The key to getting this to work was that the `dialog` must be partially initialized in the `click` event handler for the link you want to use the confirmation functionality with (if you want to use this for more than one link). This is because the target URL for the link must be in...
Heres an example of how you can do it: <http://jsfiddle.net/yFkgR/3/> Or to do something besides cancel <http://jsfiddle.net/yFkgR/4/> You can just define your own buttons. You can style the dialog box anyway you want, i just used the default. also to use ajax to load the html you can take a look at: [jQuery UI D...
234,985
We have this code to do a "+" / "-" button to expand or collapse all groups. ``` <script type="text/javascript"> function expandAll() { $("img.ms-commentexpand-icon").click(); } function collapseAll() { $("img.ms-commentcollapse-icon").click(); } var expandButton = "<a href='#' on...
2018/01/30
[ "https://sharepoint.stackexchange.com/questions/234985", "https://sharepoint.stackexchange.com", "https://sharepoint.stackexchange.com/users/28364/" ]
> > If we use Expanded for the grouping...and the group has 900 items, you > have to go through all 900 items to get to the 2nd group. With the > jQuery route, we don't. > > > Not sure I understand how this works... if you use jQuery to expand a group that has 900 items on page load, then you would still have to...
Sharepoint stores list of expanded groups in cookie. So you can put to cookie your list of groups you want to expand. ``` var GROUP_DELIMITER = ";#"; function SetExpandedGroups(viewId, groups) { var encoded = groups.map(function(group) { return encodeURIComponent(GROUP_DELIMITER + group + GROUP_DELIMIT...
234,985
We have this code to do a "+" / "-" button to expand or collapse all groups. ``` <script type="text/javascript"> function expandAll() { $("img.ms-commentexpand-icon").click(); } function collapseAll() { $("img.ms-commentcollapse-icon").click(); } var expandButton = "<a href='#' on...
2018/01/30
[ "https://sharepoint.stackexchange.com/questions/234985", "https://sharepoint.stackexchange.com", "https://sharepoint.stackexchange.com/users/28364/" ]
Was able to resolve via: ``` <script> $(window).load(function () { $(".ms-commentexpand-icon").click(); }); </script> ```
Sharepoint stores list of expanded groups in cookie. So you can put to cookie your list of groups you want to expand. ``` var GROUP_DELIMITER = ";#"; function SetExpandedGroups(viewId, groups) { var encoded = groups.map(function(group) { return encodeURIComponent(GROUP_DELIMITER + group + GROUP_DELIMIT...
148,873
I am a long time user of LaTeX. I have found, however, that using Markdown gives me a document which is "easier on the eyes". LaTeX often looks like textbooks. Does anyone know LaTeX classes (or something else) which replicate Markdown styles such as "Github", "Github v2", "Markdown Pro" and "Real". These titles come...
2013/12/07
[ "https://tex.stackexchange.com/questions/148873", "https://tex.stackexchange.com", "https://tex.stackexchange.com/users/16168/" ]
So if I understood your question correctly, you want to do something like GitHub's markdown style. So I created some commands and environments to supply a GitHub-like style based on [Adam Pritchard's Markdown Cheatsheet](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet). I used [Source Sans Pro](http:/...
My [latex-to-internet](https://github.com/loopspace/latex-to-internet) class can produce Markdown output. As Markdown is more limited than LaTeX, my advice is to write the document knowing in advance that it is going to be converted to Markdown otherwise formatting information will be lost.
37,560,325
I populate my google maps with number of `Markers` based on my server data. MY server data contains `ProfilePic , Name , Designation , & lat long etc...` When I click on my `Marker` I open `BottomSheet` that display the details like `ProfilePic , Name , Designation` . **just like google map does** I don't know how d...
2016/06/01
[ "https://Stackoverflow.com/questions/37560325", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4432176/" ]
You can set custom adapters of infowindow for marker in google map.. check this example--<http://androidfreakers.blogspot.in/2013/08/display-custom-info-window-with.html>
Solution 1-> You can use HashMap for mapping of markers and your server data list. Solution 2-> You can append the id or position to marker title with token(comma, semicolon...) and then onClick marker you can break them for further mapping to your server data list. In this case you also need to override customInfoWi...
355,295
I have recently inherited a network with a Cisco ASA (running version 8.2). I am trying to configure it to allow communication between two interfaces configured with the same security level (DMZ-DMZ) "same-security-traffic permit inter-interface" has been set, but hosts are unable to communicate between the interfa...
2012/01/31
[ "https://serverfault.com/questions/355295", "https://serverfault.com", "https://serverfault.com/users/105866/" ]
These are logically in the same DMZ so the firewall should only see the traffic as layer 2 and not apply any policy to it. You can try the `same-security-traffic permit intra-interface` command to see if this alleviates the problem but I suspect a misconfiguration on one of your hosts. Make sure the subnet masks on you...
Go to ADDM and see if you have the checkbox enabled at the bottom of the Configuration > Interfaces page. The checkbox says Enable traffic between two or more hosts connected to the same interface
19,431,867
We have a result set that has three fields and each of those fields is either null or contains a comma separated list of strings. We need to combine all three into one comma separated list and eliminate duplicates. What is the best way to do that? I found a nice function that can split a string and return a table...
2013/10/17
[ "https://Stackoverflow.com/questions/19431867", "https://Stackoverflow.com", "https://Stackoverflow.com/users/829608/" ]
Here's an example using the SplitString function you referenced. ``` DECLARE @X varchar(max) = 'A, C, F' , @Y varchar(max) = null , @Z varchar(max) = 'A, D, E, A' ;WITH SplitResults as ( -- Note: the function does not remove leading spaces. SELECT LTRIM([Name]) [Name] FROM SplitString(@X) UNION SELECT...
I would not store data as a comma separated string in a single field. Separate the string to a new table and combine it to a string again when you need to. Finding duplicates and managing the data will also be much easier. I've used this function before (I didn't write it, and unfortunately cannot remember where I fo...
51,210,834
``` #include<iostream> using namespace std; class Node{ private: int data; Node *left; Node *right; public: Node(int data){ // node():data(data) ,left(nullptr), right(nullptr) {}; this->data=data; this->left=nullptr; this->right=nullptr; } int get_data(...
2018/07/06
[ "https://Stackoverflow.com/questions/51210834", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9925282/" ]
You [cannot](https://timsong-cpp.github.io/cppwp/n4659/dcl.fct.default#9) use `this` (i.e. your current object) in the context of default parameters, which is what you are effectively trying to do: <https://godbolt.org/g/MtGDbV> What you could do instead is using `nullptr` as the default, check if `tree == nullptr` an...
Write this before the class as: ```cpp class Node; Node *root; ``` and make the root point at the root in the function that insert nodes.
59,244,179
Trying to create a deployment from an image `kubectl create deployment hello-minikube --image=k8s.gcr.io/echoserver:1.10` and then do `kubectl get pods` and check the logs of hello-minikube pod using `kubectl pod describe <pod-name>` throws following error ``` Type Reason Age From ...
2019/12/09
[ "https://Stackoverflow.com/questions/59244179", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10450863/" ]
This error can be solved using : 1. Check whether any docker machine is running or not by `docker-machine ls` 2. If no machine exist, then create one using `docker-machine create <machine-name>` 3. Then get this machine IP using `docker-machine ip <machine-name>` 4. Then first delete any existing minikube cluster usin...
From the events it looks like the call to a DNS server at `192.168.64.1:53` to resolve k8s.gcr.io is failing. Check if there's a DNS server running at that IP. It may be configured in `/etc/resolv.conf` (if Linux) on the minikube host.
2,778,377
Is there a Pattern in Scala that can add a method to an Array object? I am thinking of the implicit conversion of Int to RichInt. But that can't be done as Array is a final class.
2010/05/06
[ "https://Stackoverflow.com/questions/2778377", "https://Stackoverflow.com", "https://Stackoverflow.com/users/194980/" ]
As long as you avoid name collisions with any other implicit on `Array` (e.g. `ArrayOps` in 2.8, which adds the collections methods), you can extend using the normal implicit pimp-my-library pattern: ``` class FooArray[T](at: Array[T]) { def foo() = at.length*at.length } implicit def array2foo[T](at: Array[T]) = new...
Implicit conversions are not prevented by the `final`-ness of the input class. `String`, for example, has an implicit conversion to `RichString` (Scala 2.7) or `StringOps` (Scala 2.8). So you're free to define implicit conversions for `Array` *with one key caveat*: You must forgo Scala's built-in implicit conversion f...
55,798,797
Below is my code ``` export const redirectDomain: any = (lang, ctx, res) => { let redirectString; const getData = async () => { try { const response = await fetch('https://www.example.com'); const data= await response.json(); return data; } catch (error) {...
2019/04/22
[ "https://Stackoverflow.com/questions/55798797", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2567859/" ]
Things outside the `async` function won't wait for the promise to get resolved. And hence `data` is still `undefined` when you `split` it. So here's one of the solutions... ``` export const redirectDomain: any = async (lang, ctx, res) => { let redirectString; const getData = async () => { try { ...
Simply await `getData`, `redirectDomain` must be `async` to do this ``` -export const redirectDomain: any = (lang, ctx, res) => { +export const redirectDomain: any = async (lang, ctx, res) => { let redirectString; const getData = async () => { try { const response = await fetch('https://ww...
55,798,797
Below is my code ``` export const redirectDomain: any = (lang, ctx, res) => { let redirectString; const getData = async () => { try { const response = await fetch('https://www.example.com'); const data= await response.json(); return data; } catch (error) {...
2019/04/22
[ "https://Stackoverflow.com/questions/55798797", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2567859/" ]
Things outside the `async` function won't wait for the promise to get resolved. And hence `data` is still `undefined` when you `split` it. So here's one of the solutions... ``` export const redirectDomain: any = async (lang, ctx, res) => { let redirectString; const getData = async () => { try { ...
You get this error because you data is undefined Try `axios` library, alternative to fetch ``` const resp = axios.get('https://www.example.com'); ``` return resp.data;
55,798,797
Below is my code ``` export const redirectDomain: any = (lang, ctx, res) => { let redirectString; const getData = async () => { try { const response = await fetch('https://www.example.com'); const data= await response.json(); return data; } catch (error) {...
2019/04/22
[ "https://Stackoverflow.com/questions/55798797", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2567859/" ]
Simply await `getData`, `redirectDomain` must be `async` to do this ``` -export const redirectDomain: any = (lang, ctx, res) => { +export const redirectDomain: any = async (lang, ctx, res) => { let redirectString; const getData = async () => { try { const response = await fetch('https://ww...
You get this error because you data is undefined Try `axios` library, alternative to fetch ``` const resp = axios.get('https://www.example.com'); ``` return resp.data;
69,361,109
I want to be able to get the size of the underlying data type of an `Any` variable in Swift. I expected this to be possible by running `MemoryLayout.size(ofValue: anyObject)`, but that expression always returns `32`, regardless of the the underlying data type of the `Any` object. I assume `32` is the size of the intern...
2021/09/28
[ "https://Stackoverflow.com/questions/69361109", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14055362/" ]
I'll begin with some technical details about the limitations of `Any` in this case. So, what is `Any`? It's an empty protocol to which every type implicitly conforms to. And how does the compiler represent variables of protocol types? It's by wrapping the actual value in an existential container. So basically when yo...
What I would do is cast Any to all supported types. Why would you cast Int as `Any` when you know what type is it! anyway? ```swift var value: Any = Int(2) as Any switch value { case value is Int: // ... other cases here } ```
20,457,268
I have a select element that I fill with file names using ajax. The HTML is: ``` <select id='load_dropdown' name=loads help_token="load_dropdown" title=""> <option value='' selected='selected'>LOAD</option> </select> ``` The call to fill the element is: ``` $('select#load_dropdown') .load('getFiles.php'...
2013/12/08
[ "https://Stackoverflow.com/questions/20457268", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1008834/" ]
> > Ive read that putting UIPickerViews in activity sheets is not a good > idea anymore, any suggestions? > > > In all honesty, it was never a good idea but it became kind of an underground standard. If you are displaying it after the user sets the text field as the firstResponder, you can set the UIPickerView as...
When you have an `UITableView` perhaps you can use this: <https://github.com/aberger/ABMExpandingTableViewCells>
34,057,691
When I try to assemble this using masm32, I get a "symbol not defined" error for each line (beginning with `MOV EAX, 05h`) where 32-bit register names are used (lines 3, 5, 8, 9, 10, 11, 12). Why is this? The command I use to assemble it is `ml.exe /Zm /Bl link.exe filepath\filename` If I remove the `/Zm`switch, I sti...
2015/12/03
[ "https://Stackoverflow.com/questions/34057691", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5474788/" ]
`fold` function looks good. You just need to call it with correct arguments: ``` def biggest_even_number(xs): l = [i for i in xs if i % 2 == 0] return fold(max, float("-inf"), l) ``` If it is not a homework, you can use builtin [`reduce()`](https://docs.python.org/2/library/functions.html#reduce) which basic...
Do something like the following: ``` def fold(l): biggest = float("-inf") for i in l: biggest = max(i, biggest) return biggest def biggest_even_number(xs): l = [i for i in xs if i % 2 == 0] return fold(l) ```
68,842
I have two questions that are inspired by a couple of questions here on MO (referenced below), as well as by a conversation with some other grad students at a summer school. *Caveat*: I'm not a symplectic geometer, nor a differential topologist in the 'classical' sense, so my questions might have a well-known answer, ...
2011/06/26
[ "https://mathoverflow.net/questions/68842", "https://mathoverflow.net", "https://mathoverflow.net/users/13119/" ]
The answer to your second question is yes (in some cases). See Abouzaid's paper "Framed bordism and Lagrangian embeddings of exotic spheres", available [here](http://arxiv.org/abs/0812.4781).
**Edit:** I misunderstood the question... ~~The answer to the first question for closed orientable manifolds in dimension 4 is negative.~~ The [Dold-Whitney theorem](http://www.jstor.org/pss/1970030) states that two oriented 4-plane bundles over the same 4-manifold $M$ are isomorphic if and only if they share the ...
68,842
I have two questions that are inspired by a couple of questions here on MO (referenced below), as well as by a conversation with some other grad students at a summer school. *Caveat*: I'm not a symplectic geometer, nor a differential topologist in the 'classical' sense, so my questions might have a well-known answer, ...
2011/06/26
[ "https://mathoverflow.net/questions/68842", "https://mathoverflow.net", "https://mathoverflow.net/users/13119/" ]
The answer to your second question is yes (in some cases). See Abouzaid's paper "Framed bordism and Lagrangian embeddings of exotic spheres", available [here](http://arxiv.org/abs/0812.4781).
Let's make an example for Question 1 using classical smoothing theory. If $K$ is a finite cell complex then for any vector bundle $\xi$ on $K$ you can make a high-dimensional smooth manifold $M$ having a homotopy equivalence $f:M\to K$ such that the tangent bundle is stably $f^\star \xi$. (Embed $K$ in a big $\mathbb...
68,842
I have two questions that are inspired by a couple of questions here on MO (referenced below), as well as by a conversation with some other grad students at a summer school. *Caveat*: I'm not a symplectic geometer, nor a differential topologist in the 'classical' sense, so my questions might have a well-known answer, ...
2011/06/26
[ "https://mathoverflow.net/questions/68842", "https://mathoverflow.net", "https://mathoverflow.net/users/13119/" ]
I wrote a little expository piece about this and related matters in the Newsletter of the European Mathematical Society: <http://www.ems-ph.org/journals/newsletter/pdf/2010-03-75.pdf> The classical topology of $X:=T^\ast L$ can be taken to include a little more than its diffeomorphism type: there's also an almost com...
The answer to your second question is yes (in some cases). See Abouzaid's paper "Framed bordism and Lagrangian embeddings of exotic spheres", available [here](http://arxiv.org/abs/0812.4781).
68,842
I have two questions that are inspired by a couple of questions here on MO (referenced below), as well as by a conversation with some other grad students at a summer school. *Caveat*: I'm not a symplectic geometer, nor a differential topologist in the 'classical' sense, so my questions might have a well-known answer, ...
2011/06/26
[ "https://mathoverflow.net/questions/68842", "https://mathoverflow.net", "https://mathoverflow.net/users/13119/" ]
The answer to your second question is yes (in some cases). See Abouzaid's paper "Framed bordism and Lagrangian embeddings of exotic spheres", available [here](http://arxiv.org/abs/0812.4781).
The questions at hand are much easier to answer for open manifolds than for closed manifolds. Here is a large family of simple examples: There are uncountably many diffeomorphism types of exotic $\mathbb{R}^4$s. As mentioned already in the question, the total space of the cotangent bundle of each exotic $\mathbb{R}^4$ ...
68,842
I have two questions that are inspired by a couple of questions here on MO (referenced below), as well as by a conversation with some other grad students at a summer school. *Caveat*: I'm not a symplectic geometer, nor a differential topologist in the 'classical' sense, so my questions might have a well-known answer, ...
2011/06/26
[ "https://mathoverflow.net/questions/68842", "https://mathoverflow.net", "https://mathoverflow.net/users/13119/" ]
I wrote a little expository piece about this and related matters in the Newsletter of the European Mathematical Society: <http://www.ems-ph.org/journals/newsletter/pdf/2010-03-75.pdf> The classical topology of $X:=T^\ast L$ can be taken to include a little more than its diffeomorphism type: there's also an almost com...
**Edit:** I misunderstood the question... ~~The answer to the first question for closed orientable manifolds in dimension 4 is negative.~~ The [Dold-Whitney theorem](http://www.jstor.org/pss/1970030) states that two oriented 4-plane bundles over the same 4-manifold $M$ are isomorphic if and only if they share the ...
68,842
I have two questions that are inspired by a couple of questions here on MO (referenced below), as well as by a conversation with some other grad students at a summer school. *Caveat*: I'm not a symplectic geometer, nor a differential topologist in the 'classical' sense, so my questions might have a well-known answer, ...
2011/06/26
[ "https://mathoverflow.net/questions/68842", "https://mathoverflow.net", "https://mathoverflow.net/users/13119/" ]
I wrote a little expository piece about this and related matters in the Newsletter of the European Mathematical Society: <http://www.ems-ph.org/journals/newsletter/pdf/2010-03-75.pdf> The classical topology of $X:=T^\ast L$ can be taken to include a little more than its diffeomorphism type: there's also an almost com...
Let's make an example for Question 1 using classical smoothing theory. If $K$ is a finite cell complex then for any vector bundle $\xi$ on $K$ you can make a high-dimensional smooth manifold $M$ having a homotopy equivalence $f:M\to K$ such that the tangent bundle is stably $f^\star \xi$. (Embed $K$ in a big $\mathbb...
68,842
I have two questions that are inspired by a couple of questions here on MO (referenced below), as well as by a conversation with some other grad students at a summer school. *Caveat*: I'm not a symplectic geometer, nor a differential topologist in the 'classical' sense, so my questions might have a well-known answer, ...
2011/06/26
[ "https://mathoverflow.net/questions/68842", "https://mathoverflow.net", "https://mathoverflow.net/users/13119/" ]
I wrote a little expository piece about this and related matters in the Newsletter of the European Mathematical Society: <http://www.ems-ph.org/journals/newsletter/pdf/2010-03-75.pdf> The classical topology of $X:=T^\ast L$ can be taken to include a little more than its diffeomorphism type: there's also an almost com...
The questions at hand are much easier to answer for open manifolds than for closed manifolds. Here is a large family of simple examples: There are uncountably many diffeomorphism types of exotic $\mathbb{R}^4$s. As mentioned already in the question, the total space of the cotangent bundle of each exotic $\mathbb{R}^4$ ...
1,795
The number of [questions asked per day](http://stackexchange.com/sites?expand=true) for this site has stayed around 20/day for a pretty long while now. This number is also significantly lower than the number for AskUbuntu (~50) and Mathematics (~55). It is similar to smaller SE 2.0 sites (in terms of visits and users) ...
2011/02/13
[ "https://gaming.meta.stackexchange.com/questions/1795", "https://gaming.meta.stackexchange.com", "https://gaming.meta.stackexchange.com/users/4103/" ]
You should remember that starting from the end of February (post-GDC) a new season of gaming releases starts, which should see a bunch of new releases that naturally will cause a flow of new questions and therefore potentially new users. Right after the holiday season most publishers lay low, because these games don't...
I don't think we should be encouraging people to use our site more. It's up to the user base if they'll decide to use the site and for what reasons, and simply using the site more for the sake of a pretty statistic is sort of petty, at least in my view. I can't really be the one to comment on whether or not this is a ...
1,795
The number of [questions asked per day](http://stackexchange.com/sites?expand=true) for this site has stayed around 20/day for a pretty long while now. This number is also significantly lower than the number for AskUbuntu (~50) and Mathematics (~55). It is similar to smaller SE 2.0 sites (in terms of visits and users) ...
2011/02/13
[ "https://gaming.meta.stackexchange.com/questions/1795", "https://gaming.meta.stackexchange.com", "https://gaming.meta.stackexchange.com/users/4103/" ]
You should remember that starting from the end of February (post-GDC) a new season of gaming releases starts, which should see a bunch of new releases that naturally will cause a flow of new questions and therefore potentially new users. Right after the holiday season most publishers lay low, because these games don't...
I feel it's important to remember that if you're programming, or cooking, or doing math, running into a problem that you can't figure out the answer to is usually an opportunity to grow as a programmer / mathematician / chef. But if you're playing a game and you run into a problem you can't figure out, it's generally...
15,696,276
I have created an app that lets you take a picture and send it through a text message in windows phone, but the image doesn't show up in the message instead it says the name of the image control. No picture is there. this is my code: ``` void cameraCaptureTask_Completed(object sender, PhotoResult e) { ...
2013/03/29
[ "https://Stackoverflow.com/questions/15696276", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1917189/" ]
You are using sms messages right? SMS is text based, so what is happening is that the ToString method of the image object is being called. It seems that send MMS is not supported in Windows Phone 7.
you can not sent a pic via sms, because : > > However, it was necessary to limit the length of the messages to 128 > bytes (later improved to 140 bytes, or 160 seven-bit characters) so > that the messages could fit into the existing signaling formats. > > > <http://en.wikipedia.org/wiki/Short_Message_Service>
15,696,276
I have created an app that lets you take a picture and send it through a text message in windows phone, but the image doesn't show up in the message instead it says the name of the image control. No picture is there. this is my code: ``` void cameraCaptureTask_Completed(object sender, PhotoResult e) { ...
2013/03/29
[ "https://Stackoverflow.com/questions/15696276", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1917189/" ]
You are using sms messages right? SMS is text based, so what is happening is that the ToString method of the image object is being called. It seems that send MMS is not supported in Windows Phone 7.
First, ToString() doesn't mean "convert anything to string" in every case. You are calling ToString() on a Image.Source so the expected behavior is it will say "BitmapImage". Second, to send images via text you need MMS, but Windows Phone 7 doesn't seem to have a MMS API. So your best choice is an external MMS service...
15,696,276
I have created an app that lets you take a picture and send it through a text message in windows phone, but the image doesn't show up in the message instead it says the name of the image control. No picture is there. this is my code: ``` void cameraCaptureTask_Completed(object sender, PhotoResult e) { ...
2013/03/29
[ "https://Stackoverflow.com/questions/15696276", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1917189/" ]
You are using sms messages right? SMS is text based, so what is happening is that the ToString method of the image object is being called. It seems that send MMS is not supported in Windows Phone 7.
take a look at <http://en.wikipedia.org/wiki/Smart_Messaging#Picture_message> there are java implementations of <http://smsj.sourceforge.net/apidocs/org/marre/sms/nokia/OtaBitmap.html> , so if you will reverse engineer it, you can do it in .NET. But the image wil be too small (72x28 px)
2,375,328
I had to revert to a previous commit by running: ``` git revert <HASH> ``` So I go push the changes back into my remote repo and it failed with: ``` ! [rejected] ci_172 -> ci_172 (non-fast-forward) To prevent you from losing history, non-fast-forward updates were rejected Merge the remote changes before ...
2010/03/03
[ "https://Stackoverflow.com/questions/2375328", "https://Stackoverflow.com", "https://Stackoverflow.com/users/166836/" ]
Doesn't `ReadFile()` return and error and `GetLastError()` then return `ERROR_BROKEN_PIPE`?
`ReadFile()` + `GetLastError()` do the job well. Here is how they can be used with I/O Completion Ports (my implementation is in python+ctypes, but the idea should be clear): ``` def connect(): GetQueuedCompletionStatus() receive() def receive(): while True: ret_code = ReadFile() if ret_co...
3,795,737
I am using mvvm architecture view first approach in my project. I mean I have view-viewmodel binding defined in resource file. But i'm unable to open multiple instances of same view...If I open the the new viewmodel will refer to the first view.
2010/09/25
[ "https://Stackoverflow.com/questions/3795737", "https://Stackoverflow.com", "https://Stackoverflow.com/users/298891/" ]
you can use md5 hash or sha1 ``` function process_dir($path) { if ($handle = opendir($path)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { if (is_dir($path . "/" . $file)) { process_dir($path . "/" . $file); } else { ...
Here's a solution I figured out. I didn't do all of it in PHP though it'd be easy enough to do if you wanted: ``` $fh = popen('find /home/admin -type f | xargs sha1sum', 'r'); $files = array(); while ($line = fgets($fh)) { list($hash,$file) = explode(' ', trim($line)); $files[$hash][] = $file; } $dupes = arr...
3,795,737
I am using mvvm architecture view first approach in my project. I mean I have view-viewmodel binding defined in resource file. But i'm unable to open multiple instances of same view...If I open the the new viewmodel will refer to the first view.
2010/09/25
[ "https://Stackoverflow.com/questions/3795737", "https://Stackoverflow.com", "https://Stackoverflow.com/users/298891/" ]
I've been working on this problem for much too long. I'm on my third (and hopefully final) rewrite. Generally speaking, I recommend SHA1 because it has no known collisions (whereas MD5 collisions [can be found in minutes](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.60.3776&rep=rep1&type=pdf)), and SHA1 do...
Here's a solution I figured out. I didn't do all of it in PHP though it'd be easy enough to do if you wanted: ``` $fh = popen('find /home/admin -type f | xargs sha1sum', 'r'); $files = array(); while ($line = fgets($fh)) { list($hash,$file) = explode(' ', trim($line)); $files[$hash][] = $file; } $dupes = arr...