qid
int64
1
74.7M
question
stringlengths
0
58.3k
date
stringlengths
10
10
metadata
list
response_j
stringlengths
2
48.3k
response_k
stringlengths
2
40.5k
3,159,644
gcc 4.4.4 c89 I am using the code below. However, I keep getting the same number: ``` size_t i = 0; for(i = 0; i < 3; i++) { /* Initialize random number */ srand((unsigned int)time(NULL)); /* Added random number (simulate seconds) */ add((rand() % 30) + 1); } ``` I would...
2010/07/01
[ "https://Stackoverflow.com/questions/3159644", "https://Stackoverflow.com", "https://Stackoverflow.com/users/70942/" ]
You're seeding *inside* the loop (with the same value because of how quickly the loop will be executed), which causes the random number generated to be the same each time. You need to move your seed function *outside* the loop: ``` /* Initialize random number */ srand((unsigned int)time(NULL)); for(i = 0; i < 3; i++...
It is completely possible that the 3 times 17 are still completely random. There is an about 1 in 10 chance of getting two numbers the same when using a range of 1-30 and three picks. (this is due to the [birthday problem](http://en.wikipedia.org/wiki/Birthday_problem) ) Now, getting three the same results has still ...
3,159,644
gcc 4.4.4 c89 I am using the code below. However, I keep getting the same number: ``` size_t i = 0; for(i = 0; i < 3; i++) { /* Initialize random number */ srand((unsigned int)time(NULL)); /* Added random number (simulate seconds) */ add((rand() % 30) + 1); } ``` I would...
2010/07/01
[ "https://Stackoverflow.com/questions/3159644", "https://Stackoverflow.com", "https://Stackoverflow.com/users/70942/" ]
You're seeding *inside* the loop (with the same value because of how quickly the loop will be executed), which causes the random number generated to be the same each time. You need to move your seed function *outside* the loop: ``` /* Initialize random number */ srand((unsigned int)time(NULL)); for(i = 0; i < 3; i++...
You need to do `srand((unsigned int)time(NULL))` only once before the loop.
3,159,644
gcc 4.4.4 c89 I am using the code below. However, I keep getting the same number: ``` size_t i = 0; for(i = 0; i < 3; i++) { /* Initialize random number */ srand((unsigned int)time(NULL)); /* Added random number (simulate seconds) */ add((rand() % 30) + 1); } ``` I would...
2010/07/01
[ "https://Stackoverflow.com/questions/3159644", "https://Stackoverflow.com", "https://Stackoverflow.com/users/70942/" ]
You're seeding *inside* the loop (with the same value because of how quickly the loop will be executed), which causes the random number generated to be the same each time. You need to move your seed function *outside* the loop: ``` /* Initialize random number */ srand((unsigned int)time(NULL)); for(i = 0; i < 3; i++...
You need to call srand just once, at the beginning of your program. `srand` initializes the pseudo random number generator using time in seconds. If you initialize it with a particular number, you will always get the same sequence of numbers. That's why you usually want to initialize it at the beginning using the time...
22,316,620
I have been pulling my hair off since the last few hours trying to get my friendly urls work. I have apache 2.4 with php set up. the app is built using laravel 4 so while this `http://machinename:90/helpsystem/index.php/categories` works the following does **not** work `http://machinename:90/helpsystem/categories` ...
2014/03/11
[ "https://Stackoverflow.com/questions/22316620", "https://Stackoverflow.com", "https://Stackoverflow.com/users/412628/" ]
AllowOverride All should fix your problem, after restarting apache2 ``` <Directory c:/Apache24/htdocs/helpsystem/public/> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory> ```
Check out [Apache's upgrade guide from 2.2 to 2.4](http://httpd.apache.org/docs/2.4/upgrading.html). Since 2.4+ is shipped out on most linux distros now (particularly Debian/Ubuntu), you'll see this crop up a lot. I see you're on Windows, so it looks like whatever you happen to be using as updated as well! Specificall...
62,670,698
Here is my buttons with different values. ``` <div id="RAM_BtnGroup" class="btn-group" role="group" aria-label="Basic example" name='ram'> <button type="button" value="8GB" class="btn btn-outline-success">8GB </button> <button type="button" value="16GB" class="btn btn-outline-success">16GB </button> <butto...
2020/07/01
[ "https://Stackoverflow.com/questions/62670698", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13844964/" ]
You can't extend [DriverManager](https://docs.oracle.com/javase/8/docs/api/java/sql/DriverManager.html), but you can implement `DataSource` instead > > NOTE: The DataSource interface, new in the JDBC 2.0 API, provides another way to connect to a data source. The use of a DataSource object is the preferred means of co...
Every constructor's first line is either a call to its super class constructor or to any current class constructor, so even if you don't keep it compiler will keep a `super();` as first line. Now coming to `DriverManager` its only constructor is `private` and when you extend it to your class, its constructor will try ...
50,202,897
I came across this error message in [another question](https://stackoverflow.com/questions/50179683/index-error-message-incorrect-for-third-parameter) and I would like to know what is the meaning of the $: part of the signature, please? ``` Cannot resolve caller index(Str: Str, Any); none of these signatures match: ...
2018/05/06
[ "https://Stackoverflow.com/questions/50202897", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9146565/" ]
The `$:` is two distinct unrelated tokens, a `$` and a `:`, that have been smooshed together. --- The `$` represents a single item1 aka a scalar2. The single item / scalar hasn't been given a name, so there's no way to reference it. And there's already enough of a parameter (the `Str:D`) to let you and the compiler ...
The `:` mark the first argument as an [invocant](https://docs.perl6.org/type/Signature#Parameter_Separators). ``` my $word = "bananarama"; say $word.index( "r", 0 ); ``` In this case, it indicates the invocant is going to be treated as an scalar, since it's constrained by a single `$`
522,549
I know how to get the wave equation of light from Maxwell's equation, but I never understood why it is called the solution of the Maxwell equations. If say we have a positive charge standing still from our frame of reference, it generates an electric field that is solution of the Maxwell equations (Gauss law) but it do...
2020/01/01
[ "https://physics.stackexchange.com/questions/522549", "https://physics.stackexchange.com", "https://physics.stackexchange.com/users/250618/" ]
The field of a charge in otherwise empty space obeys the wave equation everywhere but at the position of the charge. Because it has zero frequency it cannot propagate. It also is a solution of Poisson's equation, which has no propagating solutions. To generate propagating, non zero frequency solutions, time dependent ...
Maxwell equations are a set of 4 vectorial differential equations. Given a charge distribution and current (basically think of filling up space with things) that may or may not move, those equations will spit out an electric field and a magnetic field. If you arrange your charge distribution in some specific ways, you...
43,898,731
My friend and I are working on an asp.net project and we want to work at same time, he is working on business classes and I want to use his methods. Is there any way to connect our computers, like local Team Foundation Server, and my computer gets latest changes from his computer? I know git but the question is how ca...
2017/05/10
[ "https://Stackoverflow.com/questions/43898731", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1081336/" ]
`typename` is not used like this, so both cases are invalid and should produce a compilation error, like this: ``` main.cpp:4:20: error: expected a qualified name after 'typename' const typename T* x; ^ ``` Here you would need something like `T::myType` to go on. Or even this, which is worse...
There's no point in using `typename` here. You'll have to use if you want to access an alias type like `T::type` where you can't have `const` between `typename` and `T::type` ``` const typename T::type * x; // ok typename T::type const * x; // ok typename const T::type * x; // error ```
43,898,731
My friend and I are working on an asp.net project and we want to work at same time, he is working on business classes and I want to use his methods. Is there any way to connect our computers, like local Team Foundation Server, and my computer gets latest changes from his computer? I know git but the question is how ca...
2017/05/10
[ "https://Stackoverflow.com/questions/43898731", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1081336/" ]
`typename` needs to go with the type your are trying to get. For example if you have ``` template <typename T> void foo(T& t) { typename const T::iterator bar = t.begin(); } int main() { std::vector<int> bar{1,2,3} foo(bar); } ``` You will get a compiler error for `typename const T::const_iterator bar =...
There's no point in using `typename` here. You'll have to use if you want to access an alias type like `T::type` where you can't have `const` between `typename` and `T::type` ``` const typename T::type * x; // ok typename T::type const * x; // ok typename const T::type * x; // error ```
3,775,228
Is it possible to store a collection of embedded classes in Google App Engine (Java)? If so, how would I annotate it? This is my class: ``` @PersistenceCapable public class Employee { @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) Key key; @Persistent(embeddedElement = "true") ...
2010/09/23
[ "https://Stackoverflow.com/questions/3775228", "https://Stackoverflow.com", "https://Stackoverflow.com/users/455746/" ]
I don't know if you need the answer still but putting the List into the defaultFetchGroup solved this issue for me: ``` @PersistenceCapable public class Employee { @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) Key key; @Persistent(embeddedElement = "true", defaultFetchGroup = "...
With JDO you would do it as per the DataNucleus docs <http://www.datanucleus.org/products/accessplatform_2_2/jdo/orm/embedded.html#Collection> The example shows XML, but the annotation names are approximately equivalent. Whether GAE/J's plugin supports this I couldn't say since it's Google's responsibility. Maybe try ...
2,055,975
I have a program which models manufacturing process. In each stage of the process , objects are created. Specific objects can be created only in certain stage . The objects created in later stage, are using the objects created in earlier stages i.e output of previous stage is input to later stage.Which design pattern t...
2010/01/13
[ "https://Stackoverflow.com/questions/2055975", "https://Stackoverflow.com", "https://Stackoverflow.com/users/152508/" ]
You probably want the [Builder Pattern](http://en.wikipedia.org/wiki/Builder_pattern) (Wikipedia) building a [Composite](http://en.wikipedia.org/wiki/Composite_pattern). More resources [here](http://c2.com/cgi/wiki?BuilderPattern) (c2com) and [here](http://www.allapplabs.com/java_design_patterns/builder_pattern.htm) (...
Maybe you can model you application on a [Finite State Machine](http://en.wikipedia.org/wiki/Finite-state_machine)?
2,055,975
I have a program which models manufacturing process. In each stage of the process , objects are created. Specific objects can be created only in certain stage . The objects created in later stage, are using the objects created in earlier stages i.e output of previous stage is input to later stage.Which design pattern t...
2010/01/13
[ "https://Stackoverflow.com/questions/2055975", "https://Stackoverflow.com", "https://Stackoverflow.com/users/152508/" ]
what about Pipeline ?
Maybe you can model you application on a [Finite State Machine](http://en.wikipedia.org/wiki/Finite-state_machine)?
3,959,740
Let $G=\Bbb Z\_{p\_1^{\alpha\_1}}\times \dots \times \Bbb Z\_{p\_n^{\alpha\_n}}$ be listed as $G=\{a\_1,\dots,a\_k\}$, where: * $p\_1\dots,p\_n$ are primes; * $\alpha\_1,\dots,\alpha\_n$ are nonnegative integers; * $k:=\prod\_{i=1}^np\_i^{\alpha\_i}$. As an example, let's take: \begin{alignat}{1} \Bbb Z\_{2^2} \time...
2020/12/23
[ "https://math.stackexchange.com/questions/3959740", "https://math.stackexchange.com", "https://math.stackexchange.com/users/-1/" ]
Write as $$(101-t)p(t)=(101-(t-1))p(t-1).$$ As this works for all $t$, the two members are a constant, equal to $$(101-1)\frac1{100}.$$
Hint: Write it as a product and use $1+\frac{1}{101-n}=\frac{102-n}{101-n}$, then you can apply the telescoping technique.
3,959,740
Let $G=\Bbb Z\_{p\_1^{\alpha\_1}}\times \dots \times \Bbb Z\_{p\_n^{\alpha\_n}}$ be listed as $G=\{a\_1,\dots,a\_k\}$, where: * $p\_1\dots,p\_n$ are primes; * $\alpha\_1,\dots,\alpha\_n$ are nonnegative integers; * $k:=\prod\_{i=1}^np\_i^{\alpha\_i}$. As an example, let's take: \begin{alignat}{1} \Bbb Z\_{2^2} \time...
2020/12/23
[ "https://math.stackexchange.com/questions/3959740", "https://math.stackexchange.com", "https://math.stackexchange.com/users/-1/" ]
Write as $$(101-t)p(t)=(101-(t-1))p(t-1).$$ As this works for all $t$, the two members are a constant, equal to $$(101-1)\frac1{100}.$$
$$p(t)=\frac{102-t}{101-t}\, p(t-1)$$ for $t=1$ initial condition is $p(1)=\frac{1}{100}=\frac{1}{101-1}$ for $t=2$ we have $p(2)=\frac{100}{99}\,p(1)=\frac{100}{99}\,\frac{1}{100}=\frac{1}{99}=\frac{1}{101-2}$ for $t=3$, $p(3)=\frac{99}{98}\,p(2)=\frac{100}{99}\,\frac{99}{98}\frac{1}{100}=\frac{1}{98}=\frac{1}{101-3...
25,614,858
I have a code that looks like the code below. ``` public class Controller { public void test(){ Model1 model1 = new Model1(); Test test = new Test(model1); } } public class Test { private Model1 model1; public Test(Model1 model1) { this.model1 = model1;//this line } ...
2014/09/02
[ "https://Stackoverflow.com/questions/25614858", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3814676/" ]
No, assigning to a field does not allocate memory. Objects are only created when you (directly or indirectly) call a constructor. > > Another question is does this line is passed by reference and does passed > by reference is good in memory? > > > Technically, everything in Java is passed by value. However, in...
You have created just one object of class Model. Basically, you create objects only by using the operator `new`. In java, objects are always passed by value regardless of their type. For non-primitive types (objects), you only have access through reference. So in your case you are passing a reference by value. Pass...
25,614,858
I have a code that looks like the code below. ``` public class Controller { public void test(){ Model1 model1 = new Model1(); Test test = new Test(model1); } } public class Test { private Model1 model1; public Test(Model1 model1) { this.model1 = model1;//this line } ...
2014/09/02
[ "https://Stackoverflow.com/questions/25614858", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3814676/" ]
There is only one object in memory, by the line: ``` Model1 model1 = new Model1(); ``` And the variable `model1` is a reference to this object. On the constructor ``` public Test(Model1 model1) { this.model1 = model1;//this line } ``` You will have another reference to the same object in memory.
You have created just one object of class Model. Basically, you create objects only by using the operator `new`. In java, objects are always passed by value regardless of their type. For non-primitive types (objects), you only have access through reference. So in your case you are passing a reference by value. Pass...
240,377
From within a `bash` script, how can I use `sed` to write to a file where the filename is stored in a bash variable? Output redirection won't do because I want to edit one file in place, pulling lines that match a regex into a different file and deleting them in the first file. Something like: ``` sed -i '/^my regex ...
2015/11/03
[ "https://unix.stackexchange.com/questions/240377", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/135943/" ]
I found the answer on [Stackoverflow](https://stackoverflow.com/q/11158835/5419599) under "How do I let sed 'w' command know where the filename ends?" As terdon pointed out, the issue is not the variable—but it has nothing to do with curly brackets, either; try `sed '/^l/w testing;p'` and you will see it doesn't throw...
Use the double quotes instead the single ones in to quote the sed command. And don't forget to escape suitable characters. More info about quoting variables in bash in this [link](http://www.tldp.org/LDP/abs/html/quotingvar.html "link")
240,377
From within a `bash` script, how can I use `sed` to write to a file where the filename is stored in a bash variable? Output redirection won't do because I want to edit one file in place, pulling lines that match a regex into a different file and deleting them in the first file. Something like: ``` sed -i '/^my regex ...
2015/11/03
[ "https://unix.stackexchange.com/questions/240377", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/135943/" ]
Because you're using a single `sed` expression, everything that follows after the `w` (including the `}`) is [interpreted as the *wfile* name](http://pubs.opengroup.org/onlinepubs/9699919799/utilities/sed.html): > > The argument `wfile` shall terminate the editing command. > > > You can see that if you add a sec...
Use the double quotes instead the single ones in to quote the sed command. And don't forget to escape suitable characters. More info about quoting variables in bash in this [link](http://www.tldp.org/LDP/abs/html/quotingvar.html "link")
240,377
From within a `bash` script, how can I use `sed` to write to a file where the filename is stored in a bash variable? Output redirection won't do because I want to edit one file in place, pulling lines that match a regex into a different file and deleting them in the first file. Something like: ``` sed -i '/^my regex ...
2015/11/03
[ "https://unix.stackexchange.com/questions/240377", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/135943/" ]
Because you're using a single `sed` expression, everything that follows after the `w` (including the `}`) is [interpreted as the *wfile* name](http://pubs.opengroup.org/onlinepubs/9699919799/utilities/sed.html): > > The argument `wfile` shall terminate the editing command. > > > You can see that if you add a sec...
I found the answer on [Stackoverflow](https://stackoverflow.com/q/11158835/5419599) under "How do I let sed 'w' command know where the filename ends?" As terdon pointed out, the issue is not the variable—but it has nothing to do with curly brackets, either; try `sed '/^l/w testing;p'` and you will see it doesn't throw...
41,243,639
Hi I have strcture when I create a new BsonDocument in MongoDB ``` var doct = new BsonDocument { { "fbId", "" }, { "Name", NameTxt.Text.ToString() }, { "pass", PasswTxt.Text.ToString() }, { "Watchtbl", new BsonArray ...
2016/12/20
[ "https://Stackoverflow.com/questions/41243639", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5547912/" ]
Let's pick up our discussion from your [keystone issue](https://github.com/keystonejs/keystone/issues/3814) here. The reason should be that `find()` returns a [Promise](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise), so the operation is ran asynchronously. Therefore, at the mome...
``` var gc = test; ????? ``` obviously test is not defined. from Javascript perspective. JS expects test to be a variable. and it dont know what is DB at that moment.
7,615,213
I just watched such an example which shows how to get all cols by date here it is... ``` DECLARE @MyGetDate DATETIME SELECT @MyGetDate = '2 Mar 2003 21:40' SELECT * FROM @Table WHERE convert(varchar, @MyGetDate, 14) BETWEEN convert(varchar, startDate, 14) AND convert(varchar, endDate, 14) ``` ... but the thing i...
2011/09/30
[ "https://Stackoverflow.com/questions/7615213", "https://Stackoverflow.com", "https://Stackoverflow.com/users/592704/" ]
I assume your `my_date_col` is DateTime column, then you don't need the casting. Casting is needed because the sample uses string representation of dates. ``` DECLARE @date DATETIME SET @date = GETDATE() SELECT value, my_date_col FROM myTable WHERE my_date_col BETWEEN dateadd(minute, -50, @date) AND @date ```
This should work just fine, assuming `my_date_col` is a `DATETIME`: ``` SELECT value, my_date_col FROM myTable WHERE my_date_col BETWEEN dateadd(minute, -50, getdate()) AND getdate() ``` If nothing is returned, there are *no* rows with a `my_date_col` in the last 50 minutes.
7,615,213
I just watched such an example which shows how to get all cols by date here it is... ``` DECLARE @MyGetDate DATETIME SELECT @MyGetDate = '2 Mar 2003 21:40' SELECT * FROM @Table WHERE convert(varchar, @MyGetDate, 14) BETWEEN convert(varchar, startDate, 14) AND convert(varchar, endDate, 14) ``` ... but the thing i...
2011/09/30
[ "https://Stackoverflow.com/questions/7615213", "https://Stackoverflow.com", "https://Stackoverflow.com/users/592704/" ]
I assume your `my_date_col` is DateTime column, then you don't need the casting. Casting is needed because the sample uses string representation of dates. ``` DECLARE @date DATETIME SET @date = GETDATE() SELECT value, my_date_col FROM myTable WHERE my_date_col BETWEEN dateadd(minute, -50, @date) AND @date ```
Get rid of the CONVERT statements, you want to compare dates, not varchars. ``` SELECT value, my_date_col FROM myTable WHERE my_date_col BETWEEN dateadd(minute, -50, getdate()) AND getdate(), 14 ```
7,615,213
I just watched such an example which shows how to get all cols by date here it is... ``` DECLARE @MyGetDate DATETIME SELECT @MyGetDate = '2 Mar 2003 21:40' SELECT * FROM @Table WHERE convert(varchar, @MyGetDate, 14) BETWEEN convert(varchar, startDate, 14) AND convert(varchar, endDate, 14) ``` ... but the thing i...
2011/09/30
[ "https://Stackoverflow.com/questions/7615213", "https://Stackoverflow.com", "https://Stackoverflow.com/users/592704/" ]
I assume your `my_date_col` is DateTime column, then you don't need the casting. Casting is needed because the sample uses string representation of dates. ``` DECLARE @date DATETIME SET @date = GETDATE() SELECT value, my_date_col FROM myTable WHERE my_date_col BETWEEN dateadd(minute, -50, @date) AND @date ```
``` select value1, date_column from @Table WHERE date_column between date1 and date2 ```
7,615,213
I just watched such an example which shows how to get all cols by date here it is... ``` DECLARE @MyGetDate DATETIME SELECT @MyGetDate = '2 Mar 2003 21:40' SELECT * FROM @Table WHERE convert(varchar, @MyGetDate, 14) BETWEEN convert(varchar, startDate, 14) AND convert(varchar, endDate, 14) ``` ... but the thing i...
2011/09/30
[ "https://Stackoverflow.com/questions/7615213", "https://Stackoverflow.com", "https://Stackoverflow.com/users/592704/" ]
This should work just fine, assuming `my_date_col` is a `DATETIME`: ``` SELECT value, my_date_col FROM myTable WHERE my_date_col BETWEEN dateadd(minute, -50, getdate()) AND getdate() ``` If nothing is returned, there are *no* rows with a `my_date_col` in the last 50 minutes.
Get rid of the CONVERT statements, you want to compare dates, not varchars. ``` SELECT value, my_date_col FROM myTable WHERE my_date_col BETWEEN dateadd(minute, -50, getdate()) AND getdate(), 14 ```
7,615,213
I just watched such an example which shows how to get all cols by date here it is... ``` DECLARE @MyGetDate DATETIME SELECT @MyGetDate = '2 Mar 2003 21:40' SELECT * FROM @Table WHERE convert(varchar, @MyGetDate, 14) BETWEEN convert(varchar, startDate, 14) AND convert(varchar, endDate, 14) ``` ... but the thing i...
2011/09/30
[ "https://Stackoverflow.com/questions/7615213", "https://Stackoverflow.com", "https://Stackoverflow.com/users/592704/" ]
This should work just fine, assuming `my_date_col` is a `DATETIME`: ``` SELECT value, my_date_col FROM myTable WHERE my_date_col BETWEEN dateadd(minute, -50, getdate()) AND getdate() ``` If nothing is returned, there are *no* rows with a `my_date_col` in the last 50 minutes.
``` select value1, date_column from @Table WHERE date_column between date1 and date2 ```
44,913,282
I am having trouble inserting a guid Id each time a log is written in the database. It throws these errors: ``` Exception thrown: 'System.Data.SqlClient.SqlException' in System.Data.SqlClient.dll Exception thrown: 'System.Data.SqlClient.SqlException' in NLog.dll ``` What I have so far: ``` @"INSERT INTO [dbo].[...
2017/07/04
[ "https://Stackoverflow.com/questions/44913282", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3034572/" ]
Ended up doing this: ``` @"INSERT INTO [dbo].[Nlogs] (Id,Message) values (NewID(),@Message)"; databaseTarget.Parameters.Add(new DatabaseParameterInfo("@Message", "${message}")); ```
> > How would I get it to create a new Guid for each entry? > > > Use [`${guid}`](https://github.com/nlog/nlog/wiki/Guid-Layout-Renderer) or [event properties](https://github.com/nlog/nlog/wiki/EventProperties-Layout-Renderer) for example: ```xml <target name="db" xsi:type="Database" connectionSt...
17,666,867
I have an XPATH query I am running in PHP against the following XML from CWE: ``` <Weaknesses> <Weakness ID="211" Name="Test" Weakness_Abstraction="Base" Status="Incomplete"> <Description> <Description_Summary> The software performs an operation that triggers an external diagnostic or error message that is not directl...
2013/07/16
[ "https://Stackoverflow.com/questions/17666867", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1995565/" ]
What you can read from a file depends on what's in the file. If you wrote the names of your variables into the file, then you should be able to read them, too. If not, then you can't. Variables names are not inherently written to files when you wrote data, though. Identify the technique used to write the names into yo...
Pretty Simple... You need to save your variable mineralsWalkable to a string representation of your eBlockTypes. You'll use GetEnumName to do that. You then need to convert your string representation of your eBlockTypes to an actual eBlockType and then add that to your mineralsWalkable. You'll use GetEnumValue to do th...
35,732
### Challenge Challenge is writing a program that takes a **positive** numbers `a` and a **nonzero** number `b` and outputs `a^b` (a raised to the power b). You can only use `+ - * / abs()` as mathematical functions/operators. These can only be applied to scalar values, but not to whole lists or arrays. Examples: `...
2014/08/04
[ "https://codegolf.stackexchange.com/questions/35732", "https://codegolf.stackexchange.com", "https://codegolf.stackexchange.com/users/24877/" ]
JavaScript (E6) 155 ~~174 191~~ =============================== **Edit 2** As suggested by @bebe, using recursive function (performe worse but shorter) Slightly changed R function to avoid 'too much recursion' Test suite added. The function performs well for bases < 3000 and exponent in range -50..50. **Edit*...
JS (ES6), 103 bytes ------------------- ```js t=(x,m,f)=>{for(r=i=s=u=1;i<1<<7+f;r+=s/(u=i++*(f?1:u)))s*=m;return r};e=(a,b)=>t(b,t(a,1-1/a,9)*b-b,0) ``` Examples : ``` e(1.234,5.678) = 3.299798925315965 e(4.5,4.5) = 869.8739233782269 e(4.5,-4.5) = 0.0011495918812070608 ``` Use Taylor series. `b^x = 1 +...
35,732
### Challenge Challenge is writing a program that takes a **positive** numbers `a` and a **nonzero** number `b` and outputs `a^b` (a raised to the power b). You can only use `+ - * / abs()` as mathematical functions/operators. These can only be applied to scalar values, but not to whole lists or arrays. Examples: `...
2014/08/04
[ "https://codegolf.stackexchange.com/questions/35732", "https://codegolf.stackexchange.com", "https://codegolf.stackexchange.com/users/24877/" ]
JavaScript (E6) 155 ~~174 191~~ =============================== **Edit 2** As suggested by @bebe, using recursive function (performe worse but shorter) Slightly changed R function to avoid 'too much recursion' Test suite added. The function performs well for bases < 3000 and exponent in range -50..50. **Edit*...
[golflua](http://mniip.com/misc/conv/golflua/) 120 ================================================== I use the fact that ``` a^b = exp(log(a^b)) = exp(b*log(a)) ``` and wrote my own `log` & `exp` functions. The values `a` and `b` need to be entered on newlines when run in the terminal: ``` \L(x)g=0~@ i=1,50 c=(x-...
35,732
### Challenge Challenge is writing a program that takes a **positive** numbers `a` and a **nonzero** number `b` and outputs `a^b` (a raised to the power b). You can only use `+ - * / abs()` as mathematical functions/operators. These can only be applied to scalar values, but not to whole lists or arrays. Examples: `...
2014/08/04
[ "https://codegolf.stackexchange.com/questions/35732", "https://codegolf.stackexchange.com", "https://codegolf.stackexchange.com/users/24877/" ]
Haskell, 85 ~~90~~ ================== Standard exp-log algorithm. Now with different name, shaving off a few more characters: ```hs a%b|a>1=1/(1/a)%b|0<1=sum$scanl((/).((-b*foldr1(\n b->(1-a)*(b+1/n))c)*))1c c=[1..99] ``` `raise` is now called `(%)`, or `%` in infix notation, even making its use consume fewer bytes...
JS (ES6), 103 bytes ------------------- ```js t=(x,m,f)=>{for(r=i=s=u=1;i<1<<7+f;r+=s/(u=i++*(f?1:u)))s*=m;return r};e=(a,b)=>t(b,t(a,1-1/a,9)*b-b,0) ``` Examples : ``` e(1.234,5.678) = 3.299798925315965 e(4.5,4.5) = 869.8739233782269 e(4.5,-4.5) = 0.0011495918812070608 ``` Use Taylor series. `b^x = 1 +...
35,732
### Challenge Challenge is writing a program that takes a **positive** numbers `a` and a **nonzero** number `b` and outputs `a^b` (a raised to the power b). You can only use `+ - * / abs()` as mathematical functions/operators. These can only be applied to scalar values, but not to whole lists or arrays. Examples: `...
2014/08/04
[ "https://codegolf.stackexchange.com/questions/35732", "https://codegolf.stackexchange.com", "https://codegolf.stackexchange.com/users/24877/" ]
Python, 77 ========== As with some other answers this is based on log and exp. But the functions are computed by numerically solving ordinary differential equations. ``` def f(a,b,y=1): if a<1:a=1/a;b=-b while a>1:a/=1e-7+1;y*=b*1e-7+1 return y ``` Does it satisfy the requirements? For the examples in the questi...
JS (ES6), 103 bytes ------------------- ```js t=(x,m,f)=>{for(r=i=s=u=1;i<1<<7+f;r+=s/(u=i++*(f?1:u)))s*=m;return r};e=(a,b)=>t(b,t(a,1-1/a,9)*b-b,0) ``` Examples : ``` e(1.234,5.678) = 3.299798925315965 e(4.5,4.5) = 869.8739233782269 e(4.5,-4.5) = 0.0011495918812070608 ``` Use Taylor series. `b^x = 1 +...
35,732
### Challenge Challenge is writing a program that takes a **positive** numbers `a` and a **nonzero** number `b` and outputs `a^b` (a raised to the power b). You can only use `+ - * / abs()` as mathematical functions/operators. These can only be applied to scalar values, but not to whole lists or arrays. Examples: `...
2014/08/04
[ "https://codegolf.stackexchange.com/questions/35732", "https://codegolf.stackexchange.com", "https://codegolf.stackexchange.com/users/24877/" ]
Haskell, 85 ~~90~~ ================== Standard exp-log algorithm. Now with different name, shaving off a few more characters: ```hs a%b|a>1=1/(1/a)%b|0<1=sum$scanl((/).((-b*foldr1(\n b->(1-a)*(b+1/n))c)*))1c c=[1..99] ``` `raise` is now called `(%)`, or `%` in infix notation, even making its use consume fewer bytes...
[golflua](http://mniip.com/misc/conv/golflua/) 120 ================================================== I use the fact that ``` a^b = exp(log(a^b)) = exp(b*log(a)) ``` and wrote my own `log` & `exp` functions. The values `a` and `b` need to be entered on newlines when run in the terminal: ``` \L(x)g=0~@ i=1,50 c=(x-...
35,732
### Challenge Challenge is writing a program that takes a **positive** numbers `a` and a **nonzero** number `b` and outputs `a^b` (a raised to the power b). You can only use `+ - * / abs()` as mathematical functions/operators. These can only be applied to scalar values, but not to whole lists or arrays. Examples: `...
2014/08/04
[ "https://codegolf.stackexchange.com/questions/35732", "https://codegolf.stackexchange.com", "https://codegolf.stackexchange.com/users/24877/" ]
Python, 77 ========== As with some other answers this is based on log and exp. But the functions are computed by numerically solving ordinary differential equations. ``` def f(a,b,y=1): if a<1:a=1/a;b=-b while a>1:a/=1e-7+1;y*=b*1e-7+1 return y ``` Does it satisfy the requirements? For the examples in the questi...
[golflua](http://mniip.com/misc/conv/golflua/) 120 ================================================== I use the fact that ``` a^b = exp(log(a^b)) = exp(b*log(a)) ``` and wrote my own `log` & `exp` functions. The values `a` and `b` need to be entered on newlines when run in the terminal: ``` \L(x)g=0~@ i=1,50 c=(x-...
24,950,412
I'm working on typing speed app and I need to know what's the Formula of calculating WPM (Words Per Minute) Edit: indeed i know: ``` wpm = correct_characters_in_60_seconds / 5 ``` but i have no idea what should i do with decimal numbers like 22.6 or 19.7 and... for example if user typed 158 keystrokes in 60 second...
2014/07/25
[ "https://Stackoverflow.com/questions/24950412", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3237755/" ]
WPM (Word per minute) For the purpose of typing measurement, each word is standardized to be five characters or keystrokes long, including spaces and punctuation. For example, the phrase "I run" counts as one word, but "rhinoceros" and "let's talk" both count as two. So the formula is: ``` Number_of_keystroke / time...
Words per minute(WPM) should be rounded off to the closest decimal value. In your case 158/5 = 31.6 should be reported as 32 and not 31. However if the the value was 156/5 = 31.2 then it should be rounded off to 31 to approximate the closest decimal value and hence averaging the overall error. > > if WPM<=x.5 the...
48,883,287
I have a datafile in the following format ``` 1|col2|col3|105,230,3,44,59,62|col5 2|col2|col3|43,44|col5 3|col2|col3|1,2,3,4,5,6,7,8|col5 4|col2|col3|1,2,37|col5 ``` * Delimiter is "|" * 4th column is a comma separated set of numbers. * I need records that have the number "3" individually in their 4th column but num...
2018/02/20
[ "https://Stackoverflow.com/questions/48883287", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4132504/" ]
Short GNU **`awk`** solution: ``` awk -F'|' '$4 ~ /\<3\>/' file ``` * `\<` and `\>` - stand for the *start* and *end* of the *word* respectively The output: ``` 1|col2|col3|105,230,3,44,59,62|col5 3|col2|col3|1,2,3,4,5,6,7,8|col5 ``` --- Or a more unified/portable one: ``` awk -F'|' '$4 ~ /(^|,)3(,|$)/' file ...
In case you want to have any values in 4th column which has `3` in it then print the line, if yes then following `awk` may help you on same: ``` awk -F"|" '{num=split($4, array,",");for(i=1;i<=num;i++){if(array[i]==3){print;next}}}' Input_file ```
48,883,287
I have a datafile in the following format ``` 1|col2|col3|105,230,3,44,59,62|col5 2|col2|col3|43,44|col5 3|col2|col3|1,2,3,4,5,6,7,8|col5 4|col2|col3|1,2,37|col5 ``` * Delimiter is "|" * 4th column is a comma separated set of numbers. * I need records that have the number "3" individually in their 4th column but num...
2018/02/20
[ "https://Stackoverflow.com/questions/48883287", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4132504/" ]
In case you want to have any values in 4th column which has `3` in it then print the line, if yes then following `awk` may help you on same: ``` awk -F"|" '{num=split($4, array,",");for(i=1;i<=num;i++){if(array[i]==3){print;next}}}' Input_file ```
There is an idiomatic way to deal with splitting fields into sub-fields with GNU awk (although it is overkill in this context). The basic process is this: 1. Save the current record `rec = $0` 2. Save the current field separator `oFS = FS` 3. Choose a new field separator `FS=","` 4. Set `$0` to the field you are inter...
48,883,287
I have a datafile in the following format ``` 1|col2|col3|105,230,3,44,59,62|col5 2|col2|col3|43,44|col5 3|col2|col3|1,2,3,4,5,6,7,8|col5 4|col2|col3|1,2,37|col5 ``` * Delimiter is "|" * 4th column is a comma separated set of numbers. * I need records that have the number "3" individually in their 4th column but num...
2018/02/20
[ "https://Stackoverflow.com/questions/48883287", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4132504/" ]
Short GNU **`awk`** solution: ``` awk -F'|' '$4 ~ /\<3\>/' file ``` * `\<` and `\>` - stand for the *start* and *end* of the *word* respectively The output: ``` 1|col2|col3|105,230,3,44,59,62|col5 3|col2|col3|1,2,3,4,5,6,7,8|col5 ``` --- Or a more unified/portable one: ``` awk -F'|' '$4 ~ /(^|,)3(,|$)/' file ...
There is an idiomatic way to deal with splitting fields into sub-fields with GNU awk (although it is overkill in this context). The basic process is this: 1. Save the current record `rec = $0` 2. Save the current field separator `oFS = FS` 3. Choose a new field separator `FS=","` 4. Set `$0` to the field you are inter...
30,983,202
I get output from Junos Switches in such format: ``` Physical interface: ge-0/0/7, Enabled, Physical link is Up Queue counters: Queued packets Transmitted packets Dropped packets 0 N4M-Q1 0 42210774942 1163342 ``` I need only the interface name and dropped packets valu...
2015/06/22
[ "https://Stackoverflow.com/questions/30983202", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4977702/" ]
It's extremely hard to guess with just one block of sample input, but this may be what you want: ``` $ awk -v RS= '{print $3, $NF}' file ge-0/0/7, 1163342 ``` If not, post a few blocks of your input file instead of just one so we can get a better idea what it is you're trying to parse. Given your newly posted sampl...
Totally fragile: ``` $ cat test.txt Physical interface: ge-0/0/7, Enabled, Physical link is Up Queue counters: Queued packets Transmitted packets Dropped packets 0 N4M-Q1 0 42210774942 1163342 $ echo $(grep -Po "Physical interface: \K[^,]*" test.txt) "-" \ $(awk ...
30,983,202
I get output from Junos Switches in such format: ``` Physical interface: ge-0/0/7, Enabled, Physical link is Up Queue counters: Queued packets Transmitted packets Dropped packets 0 N4M-Q1 0 42210774942 1163342 ``` I need only the interface name and dropped packets valu...
2015/06/22
[ "https://Stackoverflow.com/questions/30983202", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4977702/" ]
Totally fragile: ``` $ cat test.txt Physical interface: ge-0/0/7, Enabled, Physical link is Up Queue counters: Queued packets Transmitted packets Dropped packets 0 N4M-Q1 0 42210774942 1163342 $ echo $(grep -Po "Physical interface: \K[^,]*" test.txt) "-" \ $(awk ...
Ok, after almost 2 days of struggling (I am a beginner in unix scripting) i have got this: ``` cat myfile | sed -n -e '/Physical/,$p' | egrep -v 'Dropped|master' | awk '{gsub(/Physical interface:|Enabled,|Physical link is|0 N4M-Q1/,"")}1' | sed '/^\s*$/d' | sed -e 's/ \+/ /g' | xargs -n 4 | awk '{ print $1" "$4 }' ...
30,983,202
I get output from Junos Switches in such format: ``` Physical interface: ge-0/0/7, Enabled, Physical link is Up Queue counters: Queued packets Transmitted packets Dropped packets 0 N4M-Q1 0 42210774942 1163342 ``` I need only the interface name and dropped packets valu...
2015/06/22
[ "https://Stackoverflow.com/questions/30983202", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4977702/" ]
It's extremely hard to guess with just one block of sample input, but this may be what you want: ``` $ awk -v RS= '{print $3, $NF}' file ge-0/0/7, 1163342 ``` If not, post a few blocks of your input file instead of just one so we can get a better idea what it is you're trying to parse. Given your newly posted sampl...
Ok, after almost 2 days of struggling (I am a beginner in unix scripting) i have got this: ``` cat myfile | sed -n -e '/Physical/,$p' | egrep -v 'Dropped|master' | awk '{gsub(/Physical interface:|Enabled,|Physical link is|0 N4M-Q1/,"")}1' | sed '/^\s*$/d' | sed -e 's/ \+/ /g' | xargs -n 4 | awk '{ print $1" "$4 }' ...
20,806,784
##I need to iterate over commas to break the characters between comma in xslt. There can be at the max 15 words separated by comma## ``` For example `Input <root> <child>A,B,C,D</child> </root> Output <root> <List>A</List> <List>B</List> <List>C</List> <List>D</List> ` ```
2013/12/27
[ "https://Stackoverflow.com/questions/20806784", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1268935/" ]
Define a class in your CSS: ``` .stroked{ text-decoration: line-through; } ``` then just: ``` $(document).ready(function() { $(".button1").click(function() { $("ul li:nth-child(1)").toggleClass('stroked'); }); }); ``` Edit: as you are learning the basics of jQuery, consider caching your selectors [if ...
You should instead use [`.toggleClass()`](http://api.jquery.com/toggleClass/) ``` $(document).ready(function() { $(".button1").click(function() { $("ul li:nth-child(1)").toggleClass("test"); }); }); ``` CSS: ``` .test { text-decoration: line-through; } ```
20,806,784
##I need to iterate over commas to break the characters between comma in xslt. There can be at the max 15 words separated by comma## ``` For example `Input <root> <child>A,B,C,D</child> </root> Output <root> <List>A</List> <List>B</List> <List>C</List> <List>D</List> ` ```
2013/12/27
[ "https://Stackoverflow.com/questions/20806784", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1268935/" ]
Define a class in your CSS: ``` .stroked{ text-decoration: line-through; } ``` then just: ``` $(document).ready(function() { $(".button1").click(function() { $("ul li:nth-child(1)").toggleClass('stroked'); }); }); ``` Edit: as you are learning the basics of jQuery, consider caching your selectors [if ...
You could use an if statement, if you wanted to keep it purely jQuery: ``` $(document).ready(function() { $(".button1").click(function() { if($("ul li:nth-child(1)").attr('text-decoration')){ $("ul li:nth-child(1)").removeAttr('text-decoration'); } Else{ $("ul li:nth-child(1)").css("text-...
20,806,784
##I need to iterate over commas to break the characters between comma in xslt. There can be at the max 15 words separated by comma## ``` For example `Input <root> <child>A,B,C,D</child> </root> Output <root> <List>A</List> <List>B</List> <List>C</List> <List>D</List> ` ```
2013/12/27
[ "https://Stackoverflow.com/questions/20806784", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1268935/" ]
Define a class in your CSS: ``` .stroked{ text-decoration: line-through; } ``` then just: ``` $(document).ready(function() { $(".button1").click(function() { $("ul li:nth-child(1)").toggleClass('stroked'); }); }); ``` Edit: as you are learning the basics of jQuery, consider caching your selectors [if ...
You could also use the `.css()` callback function: ``` $("ul li:nth-child(1)").css("text-decoration", function(_, td) { return td.indexOf("line-through") == -1 ? "line-through" : "none"; }); ```
20,806,784
##I need to iterate over commas to break the characters between comma in xslt. There can be at the max 15 words separated by comma## ``` For example `Input <root> <child>A,B,C,D</child> </root> Output <root> <List>A</List> <List>B</List> <List>C</List> <List>D</List> ` ```
2013/12/27
[ "https://Stackoverflow.com/questions/20806784", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1268935/" ]
Define a class in your CSS: ``` .stroked{ text-decoration: line-through; } ``` then just: ``` $(document).ready(function() { $(".button1").click(function() { $("ul li:nth-child(1)").toggleClass('stroked'); }); }); ``` Edit: as you are learning the basics of jQuery, consider caching your selectors [if ...
Or you can do it simple like this: ``` if (condition) { $("#yourId").wrap("<strike>"); } else { $("#yourId").unwrap(); //to remove the strike } ```
20,806,784
##I need to iterate over commas to break the characters between comma in xslt. There can be at the max 15 words separated by comma## ``` For example `Input <root> <child>A,B,C,D</child> </root> Output <root> <List>A</List> <List>B</List> <List>C</List> <List>D</List> ` ```
2013/12/27
[ "https://Stackoverflow.com/questions/20806784", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1268935/" ]
You should instead use [`.toggleClass()`](http://api.jquery.com/toggleClass/) ``` $(document).ready(function() { $(".button1").click(function() { $("ul li:nth-child(1)").toggleClass("test"); }); }); ``` CSS: ``` .test { text-decoration: line-through; } ```
You could use an if statement, if you wanted to keep it purely jQuery: ``` $(document).ready(function() { $(".button1").click(function() { if($("ul li:nth-child(1)").attr('text-decoration')){ $("ul li:nth-child(1)").removeAttr('text-decoration'); } Else{ $("ul li:nth-child(1)").css("text-...
20,806,784
##I need to iterate over commas to break the characters between comma in xslt. There can be at the max 15 words separated by comma## ``` For example `Input <root> <child>A,B,C,D</child> </root> Output <root> <List>A</List> <List>B</List> <List>C</List> <List>D</List> ` ```
2013/12/27
[ "https://Stackoverflow.com/questions/20806784", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1268935/" ]
You should instead use [`.toggleClass()`](http://api.jquery.com/toggleClass/) ``` $(document).ready(function() { $(".button1").click(function() { $("ul li:nth-child(1)").toggleClass("test"); }); }); ``` CSS: ``` .test { text-decoration: line-through; } ```
Or you can do it simple like this: ``` if (condition) { $("#yourId").wrap("<strike>"); } else { $("#yourId").unwrap(); //to remove the strike } ```
20,806,784
##I need to iterate over commas to break the characters between comma in xslt. There can be at the max 15 words separated by comma## ``` For example `Input <root> <child>A,B,C,D</child> </root> Output <root> <List>A</List> <List>B</List> <List>C</List> <List>D</List> ` ```
2013/12/27
[ "https://Stackoverflow.com/questions/20806784", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1268935/" ]
You could also use the `.css()` callback function: ``` $("ul li:nth-child(1)").css("text-decoration", function(_, td) { return td.indexOf("line-through") == -1 ? "line-through" : "none"; }); ```
You could use an if statement, if you wanted to keep it purely jQuery: ``` $(document).ready(function() { $(".button1").click(function() { if($("ul li:nth-child(1)").attr('text-decoration')){ $("ul li:nth-child(1)").removeAttr('text-decoration'); } Else{ $("ul li:nth-child(1)").css("text-...
20,806,784
##I need to iterate over commas to break the characters between comma in xslt. There can be at the max 15 words separated by comma## ``` For example `Input <root> <child>A,B,C,D</child> </root> Output <root> <List>A</List> <List>B</List> <List>C</List> <List>D</List> ` ```
2013/12/27
[ "https://Stackoverflow.com/questions/20806784", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1268935/" ]
You could also use the `.css()` callback function: ``` $("ul li:nth-child(1)").css("text-decoration", function(_, td) { return td.indexOf("line-through") == -1 ? "line-through" : "none"; }); ```
Or you can do it simple like this: ``` if (condition) { $("#yourId").wrap("<strike>"); } else { $("#yourId").unwrap(); //to remove the strike } ```
13,924,318
I am trying to use libsndfile. I am also not very good with g++. The way to install libsndfile seems to be use "make install." I can really do that so I compiled it in a directory. I was trying to compile the tutorial here: <http://parumi.wordpress.com/2007/12/16/how-to-write-wav-files-in-c-using-libsndfile/> whe...
2012/12/18
[ "https://Stackoverflow.com/questions/13924318", "https://Stackoverflow.com", "https://Stackoverflow.com/users/742172/" ]
If you configure and install libsndfile with: ``` ./configure --prefix=$HOME/local make make install ``` you should then set/modify your LD\_LIBRARY\_PATH variable: ``` export $LD_LIBRARY_PATH=$HOME/local/lib ``` and then compile with ``` g++ -I $HOME/local/include -L $HOME/local/lib -lsndfile testsnd.c -o test...
In GNU/Linux Debian squeeze I have installed the libsndfile1 libraries and the program compiles without problem. ``` # apt-get install libsndfile1-dev $ g++ -w -o testsnd testsnd.c -lsndfile ``` You need to install the library with you package manager or from source code.
72,198,067
Master Data ----------- Group-Value pairs ``` 1 | 1 1 | 2 1 | 3 2 | 5 2 | 8 3 | 10 3 | 12 ``` Work Data --------- Group-Value pairs + desired result ``` 1 | 4 | 3 (3≤4, max in group 1) 1 | 2 | 2 (2≤2, max in group 1) 2 | 6 | 5 (5≤6, max in group 2) 3 | 7 | no result (both 10 and 12 > than 7) ``` --- The t...
2022/05/11
[ "https://Stackoverflow.com/questions/72198067", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5372400/" ]
The TraMineRextras package has functions `sorti` and `sortv` that respectively return the sort index and the sort variable. To sorting the data, you need the `sorti` variable. Here is an example using the `actcal` data. ``` library(TraMineRextras) # actcal data set data(actcal) # using only sequence 11 to 20 actcal....
It's a little bit unclear which data frame you are alluding to, but I assume you are talking about your sequence data. The sorting is done in a two-step procedure: 1. Create a sort index using `order` 2. sort data using this index Below you find an example drawing on `{TraMineR}`'s example data `actcal`. ```r > lib...
5,218
What is the best way to accurately measure wavelength between crests from a pier?
2015/07/20
[ "https://earthscience.stackexchange.com/questions/5218", "https://earthscience.stackexchange.com", "https://earthscience.stackexchange.com/users/3207/" ]
One simple way is to measure the period $T$ by timing the arrival of each crest and estimate the wave speed $c$ from the depth of the water column $d$. Then one can compute a wavelength $\lambda$. Assuming the waves are shallow-water waves ($d/\lambda < 1/11$) and linear (modeled by a sine or cosine function), the er...
Ideally you'd like to avoid having to estimate anything. Depending on the shape and orientation of the pier relative to the waves, you might be able to find some volunteers (at least 1 anyway) and space them out at approximately the right distance. Then get them to raise a hand when a crest passes them. Adjust their ...
14,402,503
i am developing a new android application,and using a webview to view my website in one the website pages there is a link for login with facebook * after logging directly, it returns a blank and embty webview * i have seen couple of topics here regarding the same issue but it is not exactly like mine please note that ...
2013/01/18
[ "https://Stackoverflow.com/questions/14402503", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1990921/" ]
It seems you are looking for `Password store`. You can have a look into [vault 0.2](http://pypi.python.org/pypi/vault)
[PyCrypto](https://www.dlitz.net/software/pycrypto/) is a well known and mature library for this kind of thing, and should do what you are looking for.
14,402,503
i am developing a new android application,and using a webview to view my website in one the website pages there is a link for login with facebook * after logging directly, it returns a blank and embty webview * i have seen couple of topics here regarding the same issue but it is not exactly like mine please note that ...
2013/01/18
[ "https://Stackoverflow.com/questions/14402503", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1990921/" ]
PyCrypto.Blowfish should be very nice for that purpose: <https://www.dlitz.net/software/pycrypto/api/current/Crypto.Cipher.Blowfish.BlowfishCipher-class.html> Although you'd have to specify key manually on each startup of your "password server" obviously.
[PyCrypto](https://www.dlitz.net/software/pycrypto/) is a well known and mature library for this kind of thing, and should do what you are looking for.
14,402,503
i am developing a new android application,and using a webview to view my website in one the website pages there is a link for login with facebook * after logging directly, it returns a blank and embty webview * i have seen couple of topics here regarding the same issue but it is not exactly like mine please note that ...
2013/01/18
[ "https://Stackoverflow.com/questions/14402503", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1990921/" ]
It seems you are looking for `Password store`. You can have a look into [vault 0.2](http://pypi.python.org/pypi/vault)
PyCrypto.Blowfish should be very nice for that purpose: <https://www.dlitz.net/software/pycrypto/api/current/Crypto.Cipher.Blowfish.BlowfishCipher-class.html> Although you'd have to specify key manually on each startup of your "password server" obviously.
10,531,711
I am trying to get a method from the file Duality.java to be run in Min.Java when a button is clicked. Below are the two files and what I am currently trying to do, which is not working. How do I get the method duality() to run when the button is clicked within Min.java? Duality.java ``` package com.android.control; ...
2012/05/10
[ "https://Stackoverflow.com/questions/10531711", "https://Stackoverflow.com", "https://Stackoverflow.com/users/614460/" ]
You're only *constructing an instance* of the `duality` class - you're not calling the `duality()` method on it. This might be because you wanted that method to be a constructor - but it's not, because you specified a `void` return type, so it's just a conventional method. (By the way, it's conventional in Java to gi...
Both `Min` and `duality` are in the `com.android.control` package so they should be able to see eachother without imports. It's recommended to capitalize class names. In fact, since your method has the same name as the class it might be conflicting with the constructor name. I suggest this: ``` public class Duality {...
10,531,711
I am trying to get a method from the file Duality.java to be run in Min.Java when a button is clicked. Below are the two files and what I am currently trying to do, which is not working. How do I get the method duality() to run when the button is clicked within Min.java? Duality.java ``` package com.android.control; ...
2012/05/10
[ "https://Stackoverflow.com/questions/10531711", "https://Stackoverflow.com", "https://Stackoverflow.com/users/614460/" ]
You're only *constructing an instance* of the `duality` class - you're not calling the `duality()` method on it. This might be because you wanted that method to be a constructor - but it's not, because you specified a `void` return type, so it's just a conventional method. (By the way, it's conventional in Java to gi...
1. make sure that the class name and file name use same case combination in names. 2. if u want to call the constructor, remove the void from: public void duality() 3. if it is supposed to b a function and not constructor, call it using: object\_name.duality(); 4. u r calling createBut() and have given code for creat...
2,906,433
I noticed that if I leave off the terminating double quote for a string constant in Visual Studio 2010, there is no error or even a warning, i.e. ``` Dim foo as String = "hi ``` However, the continuous integration tool we are using flags an error: ``` error BC30648: String constants must end with a double quote. `...
2010/05/25
[ "https://Stackoverflow.com/questions/2906433", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16012/" ]
That's not according to spec as section 2.4.4 of the spec states: *A string literal is a sequence of zero or more Unicode characters beginning and ending with an ASCII double-quote character* <http://msdn.microsoft.com/en-us/library/aa711651%28v=VS.71%29.aspx> Normally Visual Studio will automatically add the ending...
I noticed if you have this option on, "Pretty listing (reformatting) of code" Visual Studio will add the the terminating double quote for you, whether you want it or not. With that option off it allows the, what seems to be, invalid syntax.
2,906,433
I noticed that if I leave off the terminating double quote for a string constant in Visual Studio 2010, there is no error or even a warning, i.e. ``` Dim foo as String = "hi ``` However, the continuous integration tool we are using flags an error: ``` error BC30648: String constants must end with a double quote. `...
2010/05/25
[ "https://Stackoverflow.com/questions/2906433", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16012/" ]
Actually, historically, the BASIC language never REQUIRED a closing quote. This dates back to the 70's. GW-Basic, BasicA, QBASIC, QuickBasic, even older Tandy and TRS-80 computers NEVER required a closing quote. This is nothing new. The reason for this is because BASIC is not a free flow language, like C or C#. This me...
I noticed if you have this option on, "Pretty listing (reformatting) of code" Visual Studio will add the the terminating double quote for you, whether you want it or not. With that option off it allows the, what seems to be, invalid syntax.
2,906,433
I noticed that if I leave off the terminating double quote for a string constant in Visual Studio 2010, there is no error or even a warning, i.e. ``` Dim foo as String = "hi ``` However, the continuous integration tool we are using flags an error: ``` error BC30648: String constants must end with a double quote. `...
2010/05/25
[ "https://Stackoverflow.com/questions/2906433", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16012/" ]
Are you using MSBuild in your integrations tool? If you are, make sure you are pointing to the same MSBuild as Visual Studio is using. There is a good article I found here: [MSDN - MSBuild is now part of Visual Studio](http://blogs.msdn.com/b/visualstudio/archive/2013/07/24/msbuild-is-now-part-of-visual-studio.aspx) ...
I noticed if you have this option on, "Pretty listing (reformatting) of code" Visual Studio will add the the terminating double quote for you, whether you want it or not. With that option off it allows the, what seems to be, invalid syntax.
2,906,433
I noticed that if I leave off the terminating double quote for a string constant in Visual Studio 2010, there is no error or even a warning, i.e. ``` Dim foo as String = "hi ``` However, the continuous integration tool we are using flags an error: ``` error BC30648: String constants must end with a double quote. `...
2010/05/25
[ "https://Stackoverflow.com/questions/2906433", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16012/" ]
Actually, historically, the BASIC language never REQUIRED a closing quote. This dates back to the 70's. GW-Basic, BasicA, QBASIC, QuickBasic, even older Tandy and TRS-80 computers NEVER required a closing quote. This is nothing new. The reason for this is because BASIC is not a free flow language, like C or C#. This me...
That's not according to spec as section 2.4.4 of the spec states: *A string literal is a sequence of zero or more Unicode characters beginning and ending with an ASCII double-quote character* <http://msdn.microsoft.com/en-us/library/aa711651%28v=VS.71%29.aspx> Normally Visual Studio will automatically add the ending...
2,906,433
I noticed that if I leave off the terminating double quote for a string constant in Visual Studio 2010, there is no error or even a warning, i.e. ``` Dim foo as String = "hi ``` However, the continuous integration tool we are using flags an error: ``` error BC30648: String constants must end with a double quote. `...
2010/05/25
[ "https://Stackoverflow.com/questions/2906433", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16012/" ]
Actually, historically, the BASIC language never REQUIRED a closing quote. This dates back to the 70's. GW-Basic, BasicA, QBASIC, QuickBasic, even older Tandy and TRS-80 computers NEVER required a closing quote. This is nothing new. The reason for this is because BASIC is not a free flow language, like C or C#. This me...
Are you using MSBuild in your integrations tool? If you are, make sure you are pointing to the same MSBuild as Visual Studio is using. There is a good article I found here: [MSDN - MSBuild is now part of Visual Studio](http://blogs.msdn.com/b/visualstudio/archive/2013/07/24/msbuild-is-now-part-of-visual-studio.aspx) ...
38,533,964
I have to parse a json object that can be a string, array, array of strings and array of object. I realised that it's not good from the beginning that one object can be many types, but I can't change the code from upstream so I'll have to deal it in my code instead. I'm building a pixel library for modern browser so I...
2016/07/22
[ "https://Stackoverflow.com/questions/38533964", "https://Stackoverflow.com", "https://Stackoverflow.com/users/635162/" ]
After searching through the entire Sheets API, googling, and just general soul-searching, I had no choice but to include the Drive API and use it to do my bidding. Here's the solution I came up with. Hope this helps someone else out there! Used this script from Google for the client-side JS library in the `index.html`...
As you have concluded, it is not possible through the Sheets API today and is only possible through the Drive API (using the `PATCH https://www.googleapis.com/drive/v3/files/fileId/revisions/revisionId` request, documented at <https://developers.google.com/drive/v3/reference/revisions/update>).
28,659,623
i have a requirement where i have files starting with say :- M8585858 and UM966696. I have already written a code to read these files using the for loop like the one below :- ``` cd C:\Input\ echo M files .......... for %%f in (M*.*) do ( rem echo %%~nfAPSI set v=%%~nfAPSI ) echo %v% echo UM files .......... ...
2015/02/22
[ "https://Stackoverflow.com/questions/28659623", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4588623/" ]
The following python code illustrates what I thought would be a solution: ```py import re words=['A','CAT','CATTLE','AT','LEAD'] exp=words[0] for i in range(1,len(words)): exp=exp+'|'+words[i] p = re.compile(exp) s = 'ACATTLEAD' p.findall(s) ``` unfortunately, the output is: ``` ['A', 'CAT', 'LEAD'] ``` CA...
There are, but more often than not, for exact matches, the word list is turned into a finite automaton, deterministic or not. With natural languages, things sure get more interesting with number, cases, tenses, pre- and affixes, compound words, …
133,177
I'm trying to add a new line in checkbox note items in Google Keep app using Android Keyboard (AOSP); but instead, a new checkbox item is added when I do : * double tap on shift key → enter * drag from shift key to enter * long press enter key I can accomplish the purpose nicely in PC (Google Keep Chrome Extension) w...
2016/01/02
[ "https://android.stackexchange.com/questions/133177", "https://android.stackexchange.com", "https://android.stackexchange.com/users/144268/" ]
This is not possible at the moment. Only thing I can think of is to use a clipboard app and copy-paste a soft linebreak into Google keep.
Android (AOSP) keyboard: When you hit the shift key (the one for the capital letters), automatically the key for the smiley (that is at the bottom right) becomes the key to start a new line. SwiftKey Keyboard: (when keyboard of the letters (alphabetical)). (from the keyboard of the letters .(a b c ..) simply hold for...
45,939,570
I'm using Symfony 3.2 (PHP Framework) and Google API for Manage Google Spreadsheet using code. I use `google/apiclient`, and `asimlqt/php-google-spreadsheet-client` library for manage Google Sheets. As usually, I also created Application in [console.developers.google.com](https://console.developers.google.com/). Eve...
2017/08/29
[ "https://Stackoverflow.com/questions/45939570", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3124813/" ]
I'm not familiar with gspread, which appears to be a third-party client for the Google Sheets API, but it looks like you should be using [`get_all_values`](https://github.com/burnash/gspread#getting-all-values-from-a-worksheet-as-a-list-of-lists) rather than `get_all_records`. That will give you a list of lists, rather...
Python dictionaries are unordered. There is the [OrderedDict](https://docs.python.org/3.6/library/collections.html#collections.OrderedDict) in collections, but hard to say more about what the best course of action should be without more insight into why you need this dictionary ordered...
34,924,168
How can i execute code every second when only using the current time? (*no extra variables*, it doesn't have the be exactly every second, I'm quite happy with a variation between 800 to 1200 ms) I did try: ``` //code repeated every 30-100ms if ((System.currentTimeMillis() % 1000) == 0) { //execute code ``` But this...
2016/01/21
[ "https://Stackoverflow.com/questions/34924168", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5411388/" ]
The only way I can think of to do this would be to check that we are in the time window, perform the action and then use `Thread.sleep` long enough to ensure we are out of the time window. ``` private static final long WINDOW = 200; void doItOncePerSecond(long time) throws InterruptedException { // Check the time...
You can use java.util.Timer for this, but you can't do this scheduled operation without defining extra variable or it will be in infinity mode. You can try this: ``` new Timer().schedule(task, delay, period); ```
34,924,168
How can i execute code every second when only using the current time? (*no extra variables*, it doesn't have the be exactly every second, I'm quite happy with a variation between 800 to 1200 ms) I did try: ``` //code repeated every 30-100ms if ((System.currentTimeMillis() % 1000) == 0) { //execute code ``` But this...
2016/01/21
[ "https://Stackoverflow.com/questions/34924168", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5411388/" ]
The only way I can think of to do this would be to check that we are in the time window, perform the action and then use `Thread.sleep` long enough to ensure we are out of the time window. ``` private static final long WINDOW = 200; void doItOncePerSecond(long time) throws InterruptedException { // Check the time...
This does something every 1 second ``` while (true) { System.out.println("a second has passed"); Thread.sleep(1000); } ```
34,924,168
How can i execute code every second when only using the current time? (*no extra variables*, it doesn't have the be exactly every second, I'm quite happy with a variation between 800 to 1200 ms) I did try: ``` //code repeated every 30-100ms if ((System.currentTimeMillis() % 1000) == 0) { //execute code ``` But this...
2016/01/21
[ "https://Stackoverflow.com/questions/34924168", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5411388/" ]
``` while(true) { //execute your code here Thread.sleep(1000); } ```
The only way I can think of to do this would be to check that we are in the time window, perform the action and then use `Thread.sleep` long enough to ensure we are out of the time window. ``` private static final long WINDOW = 200; void doItOncePerSecond(long time) throws InterruptedException { // Check the time...
34,924,168
How can i execute code every second when only using the current time? (*no extra variables*, it doesn't have the be exactly every second, I'm quite happy with a variation between 800 to 1200 ms) I did try: ``` //code repeated every 30-100ms if ((System.currentTimeMillis() % 1000) == 0) { //execute code ``` But this...
2016/01/21
[ "https://Stackoverflow.com/questions/34924168", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5411388/" ]
The best way to do this is to use `ScheduledExecutorService` ``` ScheduledExecutorService service = Executors.newSingleThreadScheduledExecutor(); Future future = service.scheduleAtFixedRate(runnable, 0, 1, TimeUnit.SECONDS); ``` When you no longer need it, you can cancel execution ``` future.cancel(true); ```
The only way I can think of to do this would be to check that we are in the time window, perform the action and then use `Thread.sleep` long enough to ensure we are out of the time window. ``` private static final long WINDOW = 200; void doItOncePerSecond(long time) throws InterruptedException { // Check the time...
34,924,168
How can i execute code every second when only using the current time? (*no extra variables*, it doesn't have the be exactly every second, I'm quite happy with a variation between 800 to 1200 ms) I did try: ``` //code repeated every 30-100ms if ((System.currentTimeMillis() % 1000) == 0) { //execute code ``` But this...
2016/01/21
[ "https://Stackoverflow.com/questions/34924168", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5411388/" ]
The best way to do this is to use `ScheduledExecutorService` ``` ScheduledExecutorService service = Executors.newSingleThreadScheduledExecutor(); Future future = service.scheduleAtFixedRate(runnable, 0, 1, TimeUnit.SECONDS); ``` When you no longer need it, you can cancel execution ``` future.cancel(true); ```
``` while(true) { //execute your code here Thread.sleep(1000); } ```
34,924,168
How can i execute code every second when only using the current time? (*no extra variables*, it doesn't have the be exactly every second, I'm quite happy with a variation between 800 to 1200 ms) I did try: ``` //code repeated every 30-100ms if ((System.currentTimeMillis() % 1000) == 0) { //execute code ``` But this...
2016/01/21
[ "https://Stackoverflow.com/questions/34924168", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5411388/" ]
``` while(true) { //execute your code here Thread.sleep(1000); } ```
This does something every 1 second ``` while (true) { System.out.println("a second has passed"); Thread.sleep(1000); } ```
34,924,168
How can i execute code every second when only using the current time? (*no extra variables*, it doesn't have the be exactly every second, I'm quite happy with a variation between 800 to 1200 ms) I did try: ``` //code repeated every 30-100ms if ((System.currentTimeMillis() % 1000) == 0) { //execute code ``` But this...
2016/01/21
[ "https://Stackoverflow.com/questions/34924168", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5411388/" ]
The best way to do this is to use `ScheduledExecutorService` ``` ScheduledExecutorService service = Executors.newSingleThreadScheduledExecutor(); Future future = service.scheduleAtFixedRate(runnable, 0, 1, TimeUnit.SECONDS); ``` When you no longer need it, you can cancel execution ``` future.cancel(true); ```
This does something every 1 second ``` while (true) { System.out.println("a second has passed"); Thread.sleep(1000); } ```
34,924,168
How can i execute code every second when only using the current time? (*no extra variables*, it doesn't have the be exactly every second, I'm quite happy with a variation between 800 to 1200 ms) I did try: ``` //code repeated every 30-100ms if ((System.currentTimeMillis() % 1000) == 0) { //execute code ``` But this...
2016/01/21
[ "https://Stackoverflow.com/questions/34924168", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5411388/" ]
The best way to do this is to use `ScheduledExecutorService` ``` ScheduledExecutorService service = Executors.newSingleThreadScheduledExecutor(); Future future = service.scheduleAtFixedRate(runnable, 0, 1, TimeUnit.SECONDS); ``` When you no longer need it, you can cancel execution ``` future.cancel(true); ```
You can use java.util.Timer for this, but you can't do this scheduled operation without defining extra variable or it will be in infinity mode. You can try this: ``` new Timer().schedule(task, delay, period); ```
34,924,168
How can i execute code every second when only using the current time? (*no extra variables*, it doesn't have the be exactly every second, I'm quite happy with a variation between 800 to 1200 ms) I did try: ``` //code repeated every 30-100ms if ((System.currentTimeMillis() % 1000) == 0) { //execute code ``` But this...
2016/01/21
[ "https://Stackoverflow.com/questions/34924168", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5411388/" ]
The only way I can think of to do this would be to check that we are in the time window, perform the action and then use `Thread.sleep` long enough to ensure we are out of the time window. ``` private static final long WINDOW = 200; void doItOncePerSecond(long time) throws InterruptedException { // Check the time...
You can try this to get seconds and use it the way you would like to ... ``` long timeMillis = System.currentTimeMillis(); long timeSeconds = TimeUnit.MILLISECONDS.toSeconds(timeMillis); ```
34,924,168
How can i execute code every second when only using the current time? (*no extra variables*, it doesn't have the be exactly every second, I'm quite happy with a variation between 800 to 1200 ms) I did try: ``` //code repeated every 30-100ms if ((System.currentTimeMillis() % 1000) == 0) { //execute code ``` But this...
2016/01/21
[ "https://Stackoverflow.com/questions/34924168", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5411388/" ]
The only way I can think of to do this would be to check that we are in the time window, perform the action and then use `Thread.sleep` long enough to ensure we are out of the time window. ``` private static final long WINDOW = 200; void doItOncePerSecond(long time) throws InterruptedException { // Check the time...
This if statement would do it as per you request (between 800ms and 1200ms) but it is very inefficient and my previous answer or some of the other answers would be a lot better at doing what you want ``` if ((System.currentTimeMillis() % 1000) < 200 || (System.currentTimeMillis() % 1000) > 800) { } ``` or since you...
24,382,382
Recently I've written a custom DataGridViewColumn to host a progress bar. The column class itself has a property that I'd like to propagate to all the cells of the column. I use this code to implement it:- ``` <DefaultValue(5I)> _ Public Property BlockWidth() As Integer Get Return _blockWidth End Get ...
2014/06/24
[ "https://Stackoverflow.com/questions/24382382", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1050207/" ]
``` static readonly string scriptSuccessUpdate = "<script language=\"javascript\">\n" + "alert(\"Update Successful - Please surf to other pages to shop\");\n </script>"; ``` the last quote is diff please correct it
You Use **”** . Correct Code : static readonly string scriptSuccessUpdate = "\n" + "alert(\"Update Successful - Please surf to other pages to shop\");\n ";
24,382,382
Recently I've written a custom DataGridViewColumn to host a progress bar. The column class itself has a property that I'd like to propagate to all the cells of the column. I use this code to implement it:- ``` <DefaultValue(5I)> _ Public Property BlockWidth() As Integer Get Return _blockWidth End Get ...
2014/06/24
[ "https://Stackoverflow.com/questions/24382382", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1050207/" ]
``` static readonly string scriptSuccessUpdate = "<script language=\"javascript\">\n" + "alert(\"Update Successful - Please surf to other pages to shop\");\n </script>"; ``` the last quote is diff please correct it
This is because use of wrong quotes symbol: ``` static readonly string scriptSuccessUpdate = "<script language=\"javascript\">\n" + "alert(\"Update Successful - Please surf to other pages to shop\");\n </script>”; ``` You need to use this : ``` static readonly string scriptSuccessUpdate = "<script language='javasc...
24,382,382
Recently I've written a custom DataGridViewColumn to host a progress bar. The column class itself has a property that I'd like to propagate to all the cells of the column. I use this code to implement it:- ``` <DefaultValue(5I)> _ Public Property BlockWidth() As Integer Get Return _blockWidth End Get ...
2014/06/24
[ "https://Stackoverflow.com/questions/24382382", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1050207/" ]
This is because use of wrong quotes symbol: ``` static readonly string scriptSuccessUpdate = "<script language=\"javascript\">\n" + "alert(\"Update Successful - Please surf to other pages to shop\");\n </script>”; ``` You need to use this : ``` static readonly string scriptSuccessUpdate = "<script language='javasc...
You Use **”** . Correct Code : static readonly string scriptSuccessUpdate = "\n" + "alert(\"Update Successful - Please surf to other pages to shop\");\n ";
59,740
I'm preparing a present for a friend, which is a collection of photos and items from a couple of of travels we've done together. An idea I had was to somehow display our itinerary with notes and perhaps some pictures for each trip, like it is done here this one (although I would prefer it if the lines followed roads):...
2015/12/10
[ "https://travel.stackexchange.com/questions/59740", "https://travel.stackexchange.com", "https://travel.stackexchange.com/users/37289/" ]
Although not technically an online tool, [ITN Converter](http://www.benichou-software.com/index.php?option=com_content&view=article&id=4&Itemid=3&lang=en) allows you create precise itineraries following roads traced on top of maps from Google Maps. With ITN converter you can create journeys and way-points to be uploade...
If you have an itinerary in GPX format (with routes and route points) you can create a printable PDF map on [Inkatlas](https://inkatlas.com). Smaller maps (6 pages or fewer) are free. Full disclosure: this is my project.
31,215
Suppose a doctor prescribes a family member (who lives in the same home) some test for an infectious disease, and then that family member tests positive. Is it a violation of medical ethics to fail to disclose this illness to other members of the household, given that the illness is highly contagious? <https://www1.ny...
2022/06/09
[ "https://health.stackexchange.com/questions/31215", "https://health.stackexchange.com", "https://health.stackexchange.com/users/25276/" ]
Whether it's ethical or not is a moot question because in the US it would be illegal under federal law to do so unless the doctor has the patient's written permission to inform the others. The law that prohibits this is known as the Health Insurance Portability and Accountability Act of 1996 (HIPAA). Specifically, the...
Failure of ethics for whom? * If the contagious **patient** does not disclose the risk for her/his family (and fails to protect them otherwise), endangering their health is a clear unethical violation. * For **medical staff**: at least depending on the jurisdiction, there are areas where all patient data is highly con...
10,154,739
I have a label that appears after a gesture and I want to fade the label out. The following code works, but if I do several gestures in a row, the last ones don't finish the fade and display but then stop abruptly. Here is my code: ``` - (void) gestureLabelAppear:(NSString *)theLabelText { myLabel = [[UILabel allo...
2012/04/14
[ "https://Stackoverflow.com/questions/10154739", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1203475/" ]
You can use a Linq query to check if a game exists before saving. Assuming in my example a field Name is enough to identify a game review you can do like that ``` [HttpPost] public ActionResult Create(tblGame tblgame, HttpPostedFileBase image1, HttpPostedFileBase image2) { try { ...
From the code you provided, you should change your `Create` action method: ``` [HttpPost] public ActionResult Create(tblGame tblgame, // tblGame is the new game being created HttpPostedFileBase image1, HttpPostedFileBase image2) { try { if (ModelState.IsValid) { /* Go...
10,154,739
I have a label that appears after a gesture and I want to fade the label out. The following code works, but if I do several gestures in a row, the last ones don't finish the fade and display but then stop abruptly. Here is my code: ``` - (void) gestureLabelAppear:(NSString *)theLabelText { myLabel = [[UILabel allo...
2012/04/14
[ "https://Stackoverflow.com/questions/10154739", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1203475/" ]
From the code you provided, you should change your `Create` action method: ``` [HttpPost] public ActionResult Create(tblGame tblgame, // tblGame is the new game being created HttpPostedFileBase image1, HttpPostedFileBase image2) { try { if (ModelState.IsValid) { /* Go...
> > I have had extermly hard time trying to see if game allreday exsits as > i have code that makes users unique. I need this code otherwise I > could have had a statment that checks the database for all games and > throw an error if a game exsisted with this code i have added its a > bit hard for me that is why i...
10,154,739
I have a label that appears after a gesture and I want to fade the label out. The following code works, but if I do several gestures in a row, the last ones don't finish the fade and display but then stop abruptly. Here is my code: ``` - (void) gestureLabelAppear:(NSString *)theLabelText { myLabel = [[UILabel allo...
2012/04/14
[ "https://Stackoverflow.com/questions/10154739", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1203475/" ]
You can use a Linq query to check if a game exists before saving. Assuming in my example a field Name is enough to identify a game review you can do like that ``` [HttpPost] public ActionResult Create(tblGame tblgame, HttpPostedFileBase image1, HttpPostedFileBase image2) { try { ...
> > I have had extermly hard time trying to see if game allreday exsits as > i have code that makes users unique. I need this code otherwise I > could have had a statment that checks the database for all games and > throw an error if a game exsisted with this code i have added its a > bit hard for me that is why i...
49,365,968
Please, I need help with are problem, I changing the syntax Swift 3 for swift 4 and now i have many problems for identification of all my bugs.The Error its on the function savePhoto in the last line., completionHandler: { \_ in ``` func takePhoto(_ previewLayer: AVCaptureVideoPreviewLayer, location: CLLocation?, comp...
2018/03/19
[ "https://Stackoverflow.com/questions/49365968", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9028796/" ]
Rewrite it to: ``` }, completionHandler: { (_, _) in ``` As per [documentation](https://developer.apple.com/documentation/photos/phphotolibrary/1620743-performchanges), completion handler in `performChanges(_:completionHandler:)` accepts two parameters, not just one. `_ in`, what you have used, is a placeholder for ...
As you can clearly see in the error message the `completionHandler` passes **two** parameters rather than just one. So you have to write ``` }, completionHandler: { (_, _) in ``` but you are strongly encouraged to handle the result and a potential error. Ignoring errors causes bad user experience.
9,146,366
``` $arr = array('a' => 1, 'b' => 2); $xxx = &$arr['a']; unset($xxx); print_r($arr); // still there :( ``` so unset only breaks the reference... Do you know a way to unset the element in the referenced array? Yes, I know I could just use `unset($arr['a'])` in the code above, but this is only possible when I kno...
2012/02/05
[ "https://Stackoverflow.com/questions/9146366", "https://Stackoverflow.com", "https://Stackoverflow.com/users/376947/" ]
I may be wrong but I think the only way to unset the element in the array would be to look up the index that matches the value referenced by the variable you have, then unsetting that element. ``` $arr = array('a' => 1, 'b' => 2); $xxx = &$arr['a']; $keyToUnset = null; foreach($arr as $key => $value) { if(...
When you unset the reference, you just break the binding between variable name and variable content. This does not mean that variable content will be destroyed. And with respect to the code above - I do not think there is need in separate key ``` foreach($arr as $key => $value) { if($value === $xxx) { ...
9,146,366
``` $arr = array('a' => 1, 'b' => 2); $xxx = &$arr['a']; unset($xxx); print_r($arr); // still there :( ``` so unset only breaks the reference... Do you know a way to unset the element in the referenced array? Yes, I know I could just use `unset($arr['a'])` in the code above, but this is only possible when I kno...
2012/02/05
[ "https://Stackoverflow.com/questions/9146366", "https://Stackoverflow.com", "https://Stackoverflow.com/users/376947/" ]
I may be wrong but I think the only way to unset the element in the array would be to look up the index that matches the value referenced by the variable you have, then unsetting that element. ``` $arr = array('a' => 1, 'b' => 2); $xxx = &$arr['a']; $keyToUnset = null; foreach($arr as $key => $value) { if(...
The simple answer: ``` $arr = array('a' => 1, 'b' => 2); $xxx = 'a'; unset($arr[$xxx]); print_r($arr); // gone :) ``` i.e.. You probably don't ever really need a reference. Just set `$xxx` to the appropriate key.
9,146,366
``` $arr = array('a' => 1, 'b' => 2); $xxx = &$arr['a']; unset($xxx); print_r($arr); // still there :( ``` so unset only breaks the reference... Do you know a way to unset the element in the referenced array? Yes, I know I could just use `unset($arr['a'])` in the code above, but this is only possible when I kno...
2012/02/05
[ "https://Stackoverflow.com/questions/9146366", "https://Stackoverflow.com", "https://Stackoverflow.com/users/376947/" ]
When you unset the reference, you just break the binding between variable name and variable content. This does not mean that variable content will be destroyed. And with respect to the code above - I do not think there is need in separate key ``` foreach($arr as $key => $value) { if($value === $xxx) { ...
The simple answer: ``` $arr = array('a' => 1, 'b' => 2); $xxx = 'a'; unset($arr[$xxx]); print_r($arr); // gone :) ``` i.e.. You probably don't ever really need a reference. Just set `$xxx` to the appropriate key.
18,547,829
Im trying to send bulk of emails containing passwords to the students taking an exam in a particular subject.Now, Im having an error "SMTP Error: Could not connect to SMTP host. Mailer Error () SMTP Error: Could not connect to SMTP host." What could possibly be the problem? my code as follows: ``` <?php //error_repo...
2013/08/31
[ "https://Stackoverflow.com/questions/18547829", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2691911/" ]
The compiler is also confused about first line; you can't take the address of a type. As for following void pointers, you've got the right idea: cast it to the type of pointer you wish to treat it as.
Here is a fixed version which actually compiles and works without errors: ``` #include <string.h> #include <stdio.h> typedef struct { char Buf[20]; char Str[20]; } Sample; typedef struct { char Data[20]; int i; } Test; typedef struct { void *New; int j; } Datastruct; int main() { Datastruct d; Samp...
17,846,610
I'm creating a `HashMap` inline with double braces inside a function: ``` public void myFunction(String key, String value) { myOtherFunction( new JSONSerializer().serialize( new HashMap<String , String>() {{ put("key", key); put("value", value.); }} ...
2013/07/24
[ "https://Stackoverflow.com/questions/17846610", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Declare your parameters as `final`: ``` public void myFunction(final String key, final String value) ``` Also, you might want to take a look at [Efficiency of Java "Double Brace Initialization"?](https://stackoverflow.com/q/924285/758280)
Compiler will complain if you use non final local variables in inner classes, fix it with this: ``` public void myFunction(final String key, final String value) { myOtherFunction( new JSONSerializer().serialize( new HashMap<String , String>() {{ put("key", key); pu...
32,730,007
When using the Dialog module in Electron and .showSaveDialog() to save a file, is there a way to make the filename in the Save As window populate with the actual filename?
2015/09/23
[ "https://Stackoverflow.com/questions/32730007", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5100015/" ]
This can be accomplished with the `defaultPath` property in [`dialog.showSaveDialog()`](https://github.com/atom/electron/blob/master/docs/api/dialog.md). It should be noted that, since it's the `defaultPath`, you must specify the full file path, not just the name+extension: ``` dialog.showSaveDialog( { defaultPath:...
According to [Electron Docs](https://www.electronjs.org/docs/api/dialog#dialogshowsavedialogbrowserwindow-options), `defaultPath` String (optional) - Absolute directory path, absolute file path, or file name to use by default. This means if you just pass the file name in the `defaultPath` like the following without us...
13,045,279
I have a form on one page that submits to another page. There, it checks if the input `mail` is filled. If so then do something and if it is not filled, do something else. I don't understand why it always says that it is set, even if I send an empty form. What is missing or wrong? `step2.php`: ``` <form name="new use...
2012/10/24
[ "https://Stackoverflow.com/questions/13045279", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1016409/" ]
Use `!empty` instead of `isset`. isset return true for `$_POST` because `$_POST` array is superglobal and always exists (set). Or better use `$_SERVER['REQUEST_METHOD'] == 'POST'`
You can simply use: ``` if($_POST['username'] and $_POST['password']){ $username = $_POST['username']; $password = $_POST['password']; } ``` Alternatively, use [empty()](http://php.net/manual/en/function.empty.php) ``` if(!empty($_POST['username']) and !empty($_POST['password'])){ $username = $_POST['username...
13,045,279
I have a form on one page that submits to another page. There, it checks if the input `mail` is filled. If so then do something and if it is not filled, do something else. I don't understand why it always says that it is set, even if I send an empty form. What is missing or wrong? `step2.php`: ``` <form name="new use...
2012/10/24
[ "https://Stackoverflow.com/questions/13045279", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1016409/" ]
Most form inputs are always set, even if not filled up, so you must check for the emptiness too. Since `!empty()` is already checks for both, you can use this: ``` if (!empty($_POST["mail"])) { echo "Yes, mail is set"; } else { echo "No, mail is not set"; } ```
``` <form name="new user" method="post" action="step2_check.php"> <input type="text" name="mail" required="required"/> <br /> <input type="password" name="password" required="required"/><br /> <input type="submit" value="continue"/> </form> <?php if (!empty($_POST["mail"])) { echo "Yes, mail is set"; }...
13,045,279
I have a form on one page that submits to another page. There, it checks if the input `mail` is filled. If so then do something and if it is not filled, do something else. I don't understand why it always says that it is set, even if I send an empty form. What is missing or wrong? `step2.php`: ``` <form name="new use...
2012/10/24
[ "https://Stackoverflow.com/questions/13045279", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1016409/" ]
Check to see if the FORM has been submitted first, then the field. You should also sanitize the field to prevent hackers. ``` form name="new user" method="post" action="step2_check.php"> <input type="text" name="mail"/> <br /> <input type="password" name="password"/><br /> <input type="submit" id="Submit...
``` <form name="new user" method="post" action="step2_check.php"> <input type="text" name="mail" required="required"/> <br /> <input type="password" name="password" required="required"/><br /> <input type="submit" value="continue"/> </form> <?php if (!empty($_POST["mail"])) { echo "Yes, mail is set"; }...
13,045,279
I have a form on one page that submits to another page. There, it checks if the input `mail` is filled. If so then do something and if it is not filled, do something else. I don't understand why it always says that it is set, even if I send an empty form. What is missing or wrong? `step2.php`: ``` <form name="new use...
2012/10/24
[ "https://Stackoverflow.com/questions/13045279", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1016409/" ]
Use `!empty` instead of `isset`. isset return true for `$_POST` because `$_POST` array is superglobal and always exists (set). Or better use `$_SERVER['REQUEST_METHOD'] == 'POST'`
[From php.net](http://us2.php.net/isset), isset > > Returns TRUE if var exists and has value other than NULL, FALSE > otherwise. > > > empty space is considered as set. You need to use empty() for checking all null options.
13,045,279
I have a form on one page that submits to another page. There, it checks if the input `mail` is filled. If so then do something and if it is not filled, do something else. I don't understand why it always says that it is set, even if I send an empty form. What is missing or wrong? `step2.php`: ``` <form name="new use...
2012/10/24
[ "https://Stackoverflow.com/questions/13045279", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1016409/" ]
Check to see if the FORM has been submitted first, then the field. You should also sanitize the field to prevent hackers. ``` form name="new user" method="post" action="step2_check.php"> <input type="text" name="mail"/> <br /> <input type="password" name="password"/><br /> <input type="submit" id="Submit...
To answer the posted question: isset and empty together gives three conditions. This can be used by Javascript with an ajax command as well. ``` $errMess="Didn't test"; // This message should not show if(isset($_POST["foo"])){ // does it exist or not $foo = $_POST["foo"]; // save $foo from POST made by HTTP requ...
13,045,279
I have a form on one page that submits to another page. There, it checks if the input `mail` is filled. If so then do something and if it is not filled, do something else. I don't understand why it always says that it is set, even if I send an empty form. What is missing or wrong? `step2.php`: ``` <form name="new use...
2012/10/24
[ "https://Stackoverflow.com/questions/13045279", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1016409/" ]
Most form inputs are always set, even if not filled up, so you must check for the emptiness too. Since `!empty()` is already checks for both, you can use this: ``` if (!empty($_POST["mail"])) { echo "Yes, mail is set"; } else { echo "No, mail is not set"; } ```
If you send the form empty, `$_POST['mail']` will still be sent, but the value is empty. To check if the field is empty you need to check ``` if(isset($_POST["mail"]) && trim($_POST["mail"]) != "") { .. } ```
13,045,279
I have a form on one page that submits to another page. There, it checks if the input `mail` is filled. If so then do something and if it is not filled, do something else. I don't understand why it always says that it is set, even if I send an empty form. What is missing or wrong? `step2.php`: ``` <form name="new use...
2012/10/24
[ "https://Stackoverflow.com/questions/13045279", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1016409/" ]
Add the following attribute to the input text form: `required="required"`. If the form is not filled, it will not allow the user to submit the form. Your new code will be: ```html <form name="new user" method="post" action="step2_check.php"> <input type="text" name="mail" required="required"/> <br /> <input type="pa...
``` <form name="new user" method="post" action="step2_check.php"> <input type="text" name="mail" required="required"/> <br /> <input type="password" name="password" required="required"/><br /> <input type="submit" value="continue"/> </form> <?php if (!empty($_POST["mail"])) { echo "Yes, mail is set"; }...
13,045,279
I have a form on one page that submits to another page. There, it checks if the input `mail` is filled. If so then do something and if it is not filled, do something else. I don't understand why it always says that it is set, even if I send an empty form. What is missing or wrong? `step2.php`: ``` <form name="new use...
2012/10/24
[ "https://Stackoverflow.com/questions/13045279", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1016409/" ]
Use `!empty` instead of `isset`. isset return true for `$_POST` because `$_POST` array is superglobal and always exists (set). Or better use `$_SERVER['REQUEST_METHOD'] == 'POST'`
To answer the posted question: isset and empty together gives three conditions. This can be used by Javascript with an ajax command as well. ``` $errMess="Didn't test"; // This message should not show if(isset($_POST["foo"])){ // does it exist or not $foo = $_POST["foo"]; // save $foo from POST made by HTTP requ...
13,045,279
I have a form on one page that submits to another page. There, it checks if the input `mail` is filled. If so then do something and if it is not filled, do something else. I don't understand why it always says that it is set, even if I send an empty form. What is missing or wrong? `step2.php`: ``` <form name="new use...
2012/10/24
[ "https://Stackoverflow.com/questions/13045279", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1016409/" ]
Use `!empty` instead of `isset`. isset return true for `$_POST` because `$_POST` array is superglobal and always exists (set). Or better use `$_SERVER['REQUEST_METHOD'] == 'POST'`
Maybe you can try this one: ``` if (isset($_POST['mail']) && ($_POST['mail'] !=0)) { echo "Yes, mail is set"; } else { echo "No, mail is not set"; } ``` ---
13,045,279
I have a form on one page that submits to another page. There, it checks if the input `mail` is filled. If so then do something and if it is not filled, do something else. I don't understand why it always says that it is set, even if I send an empty form. What is missing or wrong? `step2.php`: ``` <form name="new use...
2012/10/24
[ "https://Stackoverflow.com/questions/13045279", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1016409/" ]
Lets Think this is your HTML Form in step2.php > > step2.php > > > ``` <form name="new user" method="post" action="step2_check.php"> <input type="text" name="mail"/> <br /> <input type="password" name="password"/><br /> <input type="submit" value="continue"/> </form> ``` I think you need it for yo...
You can try, ``` <?php if (isset($_POST["mail"])) { echo "Yes, mail is set"; }else{ echo "N0, mail is not set"; } ?> ```