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 |
|---|---|---|---|---|---|
221,954 | I'm a beginner in servers, and I was wondering if it would be possible to make a sell/buy system for lands, where players can build and do all the stuff they want while their land is protected, and at a specific time I can disable that land protection so people can build in other houses, steal their stuff, etc.
and th... | 2015/06/02 | [
"https://gaming.stackexchange.com/questions/221954",
"https://gaming.stackexchange.com",
"https://gaming.stackexchange.com/users/114366/"
] | **Note:** This guide is for Oldschool RuneScape only, as RS3 has many differences in training for XP as well as huge distinctions from OSRS in weaponry and combat.
It's extremely difficult to determine the exact order in which to train these two skills as each level provides minor marginal benefits which change based ... | It's really REALLY, debatable, I've been playing RS for many years and when I was starting out I was paying a lot of attention to numbers.
While strength increases **maximum possible hit**, the damage output is not reliable enough. Same goes for attack, higher chance to hit, however, you can't really measure how much i... |
2,442,639 | I am looking for compare utility similar for "win merge" or "beyond compare" .
That in addition for gui comparison will have api that i will be able to run on my files via my code and see if the files are the same or not and also use it in gui mode to show graphically the differences .
Any recommendations ?
thanks | 2010/03/14 | [
"https://Stackoverflow.com/questions/2442639",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/140100/"
] | Check out [Araxis Merge](http://www.araxis.com/merge/index.html) - it's a two-way or three-way diff utility, it can handle ANSI, ASCII and Unicode files (it can even compare an ANSI file to a Unicode file!), and it offers both a command-line interface, as well as an [automation API](http://www.araxis.com/merge/automati... | WinMerge IS open source, you could modify it to do what you want (even though I am pretty sure it does have command line access and an API you could use). |
2,442,639 | I am looking for compare utility similar for "win merge" or "beyond compare" .
That in addition for gui comparison will have api that i will be able to run on my files via my code and see if the files are the same or not and also use it in gui mode to show graphically the differences .
Any recommendations ?
thanks | 2010/03/14 | [
"https://Stackoverflow.com/questions/2442639",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/140100/"
] | If you're looking for a Diff API (as opposed to a standalone tool), try [DiffPlex](http://diffplex.codeplex.com/). | Check out [Araxis Merge](http://www.araxis.com/merge/index.html) - it's a two-way or three-way diff utility, it can handle ANSI, ASCII and Unicode files (it can even compare an ANSI file to a Unicode file!), and it offers both a command-line interface, as well as an [automation API](http://www.araxis.com/merge/automati... |
2,442,639 | I am looking for compare utility similar for "win merge" or "beyond compare" .
That in addition for gui comparison will have api that i will be able to run on my files via my code and see if the files are the same or not and also use it in gui mode to show graphically the differences .
Any recommendations ?
thanks | 2010/03/14 | [
"https://Stackoverflow.com/questions/2442639",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/140100/"
] | If you're looking for a Diff API (as opposed to a standalone tool), try [DiffPlex](http://diffplex.codeplex.com/). | I like [ExamDiff Pro](http://www.prestosoft.com/edp_examdiffpro.asp). There is also a [no cost version](http://www.prestosoft.com/edp_examdiff.asp). |
2,442,639 | I am looking for compare utility similar for "win merge" or "beyond compare" .
That in addition for gui comparison will have api that i will be able to run on my files via my code and see if the files are the same or not and also use it in gui mode to show graphically the differences .
Any recommendations ?
thanks | 2010/03/14 | [
"https://Stackoverflow.com/questions/2442639",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/140100/"
] | Kdiff might do what you need.
[Kdiff command line](http://kdiff3.sourceforge.net/doc/documentation.html#commandline) | Check out [Araxis Merge](http://www.araxis.com/merge/index.html) - it's a two-way or three-way diff utility, it can handle ANSI, ASCII and Unicode files (it can even compare an ANSI file to a Unicode file!), and it offers both a command-line interface, as well as an [automation API](http://www.araxis.com/merge/automati... |
2,442,639 | I am looking for compare utility similar for "win merge" or "beyond compare" .
That in addition for gui comparison will have api that i will be able to run on my files via my code and see if the files are the same or not and also use it in gui mode to show graphically the differences .
Any recommendations ?
thanks | 2010/03/14 | [
"https://Stackoverflow.com/questions/2442639",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/140100/"
] | If you're looking for a Diff API (as opposed to a standalone tool), try [DiffPlex](http://diffplex.codeplex.com/). | WinMerge IS open source, you could modify it to do what you want (even though I am pretty sure it does have command line access and an API you could use). |
2,442,639 | I am looking for compare utility similar for "win merge" or "beyond compare" .
That in addition for gui comparison will have api that i will be able to run on my files via my code and see if the files are the same or not and also use it in gui mode to show graphically the differences .
Any recommendations ?
thanks | 2010/03/14 | [
"https://Stackoverflow.com/questions/2442639",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/140100/"
] | Check out [Araxis Merge](http://www.araxis.com/merge/index.html) - it's a two-way or three-way diff utility, it can handle ANSI, ASCII and Unicode files (it can even compare an ANSI file to a Unicode file!), and it offers both a command-line interface, as well as an [automation API](http://www.araxis.com/merge/automati... | Beyond Compare 3 does support command line actions, so you should be able to hook it into any existing process that you have.
Here's the command line documentation, if you're interested:
<http://www.scootersoftware.com/help/index.html?command_line_reference.html>
Free versions are available for download. |
2,442,639 | I am looking for compare utility similar for "win merge" or "beyond compare" .
That in addition for gui comparison will have api that i will be able to run on my files via my code and see if the files are the same or not and also use it in gui mode to show graphically the differences .
Any recommendations ?
thanks | 2010/03/14 | [
"https://Stackoverflow.com/questions/2442639",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/140100/"
] | Kdiff might do what you need.
[Kdiff command line](http://kdiff3.sourceforge.net/doc/documentation.html#commandline) | You didn't mention free or not. If free, Sourcegear's DiffMerge: <http://www.sourcegear.com/diffmerge/index.html>. |
2,442,639 | I am looking for compare utility similar for "win merge" or "beyond compare" .
That in addition for gui comparison will have api that i will be able to run on my files via my code and see if the files are the same or not and also use it in gui mode to show graphically the differences .
Any recommendations ?
thanks | 2010/03/14 | [
"https://Stackoverflow.com/questions/2442639",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/140100/"
] | Check out [Araxis Merge](http://www.araxis.com/merge/index.html) - it's a two-way or three-way diff utility, it can handle ANSI, ASCII and Unicode files (it can even compare an ANSI file to a Unicode file!), and it offers both a command-line interface, as well as an [automation API](http://www.araxis.com/merge/automati... | You didn't mention free or not. If free, Sourcegear's DiffMerge: <http://www.sourcegear.com/diffmerge/index.html>. |
2,442,639 | I am looking for compare utility similar for "win merge" or "beyond compare" .
That in addition for gui comparison will have api that i will be able to run on my files via my code and see if the files are the same or not and also use it in gui mode to show graphically the differences .
Any recommendations ?
thanks | 2010/03/14 | [
"https://Stackoverflow.com/questions/2442639",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/140100/"
] | Kdiff might do what you need.
[Kdiff command line](http://kdiff3.sourceforge.net/doc/documentation.html#commandline) | WinMerge IS open source, you could modify it to do what you want (even though I am pretty sure it does have command line access and an API you could use). |
2,442,639 | I am looking for compare utility similar for "win merge" or "beyond compare" .
That in addition for gui comparison will have api that i will be able to run on my files via my code and see if the files are the same or not and also use it in gui mode to show graphically the differences .
Any recommendations ?
thanks | 2010/03/14 | [
"https://Stackoverflow.com/questions/2442639",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/140100/"
] | If you're looking for a Diff API (as opposed to a standalone tool), try [DiffPlex](http://diffplex.codeplex.com/). | Beyond Compare 3 does support command line actions, so you should be able to hook it into any existing process that you have.
Here's the command line documentation, if you're interested:
<http://www.scootersoftware.com/help/index.html?command_line_reference.html>
Free versions are available for download. |
20,425,570 | This is probably a very simple problem, but I was wondering how to find all floats in a file and surround them by some text, e.g.
Input file:
```
input1 & X & Y & Z \\
input2 & ...
```
Output file:
```
input1 & float(X) & float(Y) & float(Z) \\
input2 & ...
```
I was thinking about using sed or awk, but I don't ... | 2013/12/06 | [
"https://Stackoverflow.com/questions/20425570",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/821076/"
] | The compiler doesn't know that you *can* multiply and add `T` values - it's not the `return` part which the problem, it's the expression itself. You'll see the same effect if you split the two parts:
```
T result = a + b;
return result;
```
It will be the first line that fails - and there's no particularly clean ans... | You need to do these things:
1. Bound the generic type to Number
2. Make the `add()` etc method `abstract` and return `T`
3. Provide implementations for each type you want to support
Like this:
```
public abstract class GenericMath<T extends Number> {
public T a,b;
public abstract T add();
public abstra... |
26,257,980 | I'm so sorry if this doesn't make any sense at all. I've created a PHP file called "filmdetails.php" that will list all details of a given film:
```
<?php
require_once 'dbcon_sakila.php';
$film_id = $_GET['filmid'];
$sql = 'SELECT title, description, release_year, rental_duration, rental_rate, leng... | 2014/10/08 | [
"https://Stackoverflow.com/questions/26257980",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3221011/"
] | Because you have a One-to-Many relationship between Films and Actors, you are going to get multiple results. One record for each Actor. This is the nature of an RDBMS.
A solution would be to take the `actor` table out of your query, and in your `While` loop query the `actor` table alone with the `film_id` (which you ... | Use `GROUP BY film_actor.actor_id` at the end of your SQL statement |
39,572,776 | i am trying to write an entity to database with camel jpa component. The problem is that i get
```
javax.persistence.TransactionRequiredException: no transaction is in progress
at org.hibernate.internal.SessionImpl.checkTransactionNeeded(SessionImpl.java:3428)
at org.hibernate.internal.SessionImpl.doFlush(Sess... | 2016/09/19 | [
"https://Stackoverflow.com/questions/39572776",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/447426/"
] | Since you pass the address of an uninitialized pointer, you must allocate the structure `MY_DATA` as well:
```
void getData(struct MY_DATA **m_data) {
// create a MY_TYPE pointer & assign value to its field
struct MY_TYPE *m_type_tmp = malloc(sizeof(struct MY_TYPE));
m_type_tmp->flag = 0;
m_type_tmp->x... | >
> getData(struct MY\_DATA \*\* m\_data)
>
>
>
You don't need pointer to pointer to `MY_DATA`, pointer to `MY_DATA` would be suffice.
Then instead of `(** m_data).m_type = m_type_tmp;` you can write:
`m_data->m_type = m_type_tmp;`
Also these are incorrect:
```
struct MY_DATA *data; // <-- you haven't initial... |
39,572,776 | i am trying to write an entity to database with camel jpa component. The problem is that i get
```
javax.persistence.TransactionRequiredException: no transaction is in progress
at org.hibernate.internal.SessionImpl.checkTransactionNeeded(SessionImpl.java:3428)
at org.hibernate.internal.SessionImpl.doFlush(Sess... | 2016/09/19 | [
"https://Stackoverflow.com/questions/39572776",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/447426/"
] | >
> getData(struct MY\_DATA \*\* m\_data)
>
>
>
You don't need pointer to pointer to `MY_DATA`, pointer to `MY_DATA` would be suffice.
Then instead of `(** m_data).m_type = m_type_tmp;` you can write:
`m_data->m_type = m_type_tmp;`
Also these are incorrect:
```
struct MY_DATA *data; // <-- you haven't initial... | pass by reference means you are passing the value through the reference of other variable while pass by value means you are passing the value either string, float , character or boolean. |
39,572,776 | i am trying to write an entity to database with camel jpa component. The problem is that i get
```
javax.persistence.TransactionRequiredException: no transaction is in progress
at org.hibernate.internal.SessionImpl.checkTransactionNeeded(SessionImpl.java:3428)
at org.hibernate.internal.SessionImpl.doFlush(Sess... | 2016/09/19 | [
"https://Stackoverflow.com/questions/39572776",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/447426/"
] | Since you pass the address of an uninitialized pointer, you must allocate the structure `MY_DATA` as well:
```
void getData(struct MY_DATA **m_data) {
// create a MY_TYPE pointer & assign value to its field
struct MY_TYPE *m_type_tmp = malloc(sizeof(struct MY_TYPE));
m_type_tmp->flag = 0;
m_type_tmp->x... | pass by reference means you are passing the value through the reference of other variable while pass by value means you are passing the value either string, float , character or boolean. |
1,603,319 | I'm trying to play a "boing" sound when a ball shape hit's any other kind of shape. Which works. But works a little too well....
When the ball comes to rest, or starts to roll, it's in a permanent collision with whatever it's touching, so the "boing" sound fires constantly.
I can't find anything in the chipmunk docu... | 2009/10/21 | [
"https://Stackoverflow.com/questions/1603319",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/64586/"
] | I don't think that what I'm about to say is a good practice, but I'm sure it will solve your problem:
1. For each object, keep two state variables: (1) The last object collided with, (2) The last collision time.
2. Upon collision, only play a sound if the collided object is different (and a ball) OR a certain "delta t... | Shapes don't have velocity in chipmunk. The bodies they are attached to have it. You can access velocity like this: "myShape.body->v". I agree that you should just be able to check if the velocity is over a certain threshold to know when an 'impact' occurs. You can also check the rotational velocity to see if the ball ... |
1,603,319 | I'm trying to play a "boing" sound when a ball shape hit's any other kind of shape. Which works. But works a little too well....
When the ball comes to rest, or starts to roll, it's in a permanent collision with whatever it's touching, so the "boing" sound fires constantly.
I can't find anything in the chipmunk docu... | 2009/10/21 | [
"https://Stackoverflow.com/questions/1603319",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/64586/"
] | Couldn't you just play your "boing" sound when contact is BROKEN?
There is a callback for that in chipmunk, `typedef void (*cpCollisionSeparateFunc)(cpArbiter *arb, struct cpSpace *space, void *data)`
That way you get boings whenever it bounces, but not when it's just rolling along. 'course, you'll also get one when i... | Shapes don't have velocity in chipmunk. The bodies they are attached to have it. You can access velocity like this: "myShape.body->v". I agree that you should just be able to check if the velocity is over a certain threshold to know when an 'impact' occurs. You can also check the rotational velocity to see if the ball ... |
1,603,319 | I'm trying to play a "boing" sound when a ball shape hit's any other kind of shape. Which works. But works a little too well....
When the ball comes to rest, or starts to roll, it's in a permanent collision with whatever it's touching, so the "boing" sound fires constantly.
I can't find anything in the chipmunk docu... | 2009/10/21 | [
"https://Stackoverflow.com/questions/1603319",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/64586/"
] | Couldn't you just play your "boing" sound when contact is BROKEN?
There is a callback for that in chipmunk, `typedef void (*cpCollisionSeparateFunc)(cpArbiter *arb, struct cpSpace *space, void *data)`
That way you get boings whenever it bounces, but not when it's just rolling along. 'course, you'll also get one when i... | I don't think that what I'm about to say is a good practice, but I'm sure it will solve your problem:
1. For each object, keep two state variables: (1) The last object collided with, (2) The last collision time.
2. Upon collision, only play a sound if the collided object is different (and a ball) OR a certain "delta t... |
5,802,516 | I have added the following code in my C#.net application in visual studio 2010
```
WebRequest request = WebRequest.Create("ftp://myftp.com");
request.Method = WebRequestMethods.Ftp.MakeDirectory;
request.Credentials = new NetworkCredential("myusername", "12344");
using (var resp = ... | 2011/04/27 | [
"https://Stackoverflow.com/questions/5802516",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/634710/"
] | If you just want to check file information you should try changing the `request.Method` to `WebRequestMethods.Ftp.ListDirectoryDetails` instead:
```
WebRequest request = WebRequest.Create("ftp://myftp.com");
request.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
request.Credentials = new Network... | You must specify a sub-directory you wish to create; you can't create the root, which is what it appears you are trying to do. Hence the error. |
5,802,516 | I have added the following code in my C#.net application in visual studio 2010
```
WebRequest request = WebRequest.Create("ftp://myftp.com");
request.Method = WebRequestMethods.Ftp.MakeDirectory;
request.Credentials = new NetworkCredential("myusername", "12344");
using (var resp = ... | 2011/04/27 | [
"https://Stackoverflow.com/questions/5802516",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/634710/"
] | Uri should be ftp:// + IP or ftpServerName + / Folder\_to\_create\_Name
So, see follow code:
```
WebRequest request = WebRequest.Create("ftp://myftp.com/FOLDER_TO_CREATE/");
request.Method = WebRequestMethods.Ftp.MakeDirectory;
request.Credentials = new NetworkCredential("myusername", "12344");
using (var resp =... | You must specify a sub-directory you wish to create; you can't create the root, which is what it appears you are trying to do. Hence the error. |
5,802,516 | I have added the following code in my C#.net application in visual studio 2010
```
WebRequest request = WebRequest.Create("ftp://myftp.com");
request.Method = WebRequestMethods.Ftp.MakeDirectory;
request.Credentials = new NetworkCredential("myusername", "12344");
using (var resp = ... | 2011/04/27 | [
"https://Stackoverflow.com/questions/5802516",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/634710/"
] | If you just want to check file information you should try changing the `request.Method` to `WebRequestMethods.Ftp.ListDirectoryDetails` instead:
```
WebRequest request = WebRequest.Create("ftp://myftp.com");
request.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
request.Credentials = new Network... | Uri should be ftp:// + IP or ftpServerName + / Folder\_to\_create\_Name
So, see follow code:
```
WebRequest request = WebRequest.Create("ftp://myftp.com/FOLDER_TO_CREATE/");
request.Method = WebRequestMethods.Ftp.MakeDirectory;
request.Credentials = new NetworkCredential("myusername", "12344");
using (var resp =... |
45,238,069 | I have two hash:
```
my %hash1 = {
"GOKIN_0_1" => "alpha",
"GOKIN_4_6" => "omega",
....
}
my %hash2 = {
"alpha" => "aaa",
"omega" => "bbb",
...
```
}
What I want to do is, to print in a file lines a value of hash1 that match key of hash2 to have a file like that:
```
GOKIN_0_1 aaa
GOKIN_4_... | 2017/07/21 | [
"https://Stackoverflow.com/questions/45238069",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6614756/"
] | First, hashes are declared with `()`, not `{}`. The latter denotes a hash *reference*.
Now, what you can do is loop over the keys and values of `%hash1`, check if the value is in `%hash2` as a key, then print the required variables if the value does exist as a key:
```
use warnings;
use strict;
my %hash1 = (
"GOK... | So first off, your two hashes are declared incorrectly. You've got braces where you want regular brackets. Turning on warnings with `use warnings;` should highlight that mistake.
```
my %hash1 = (
"GOKIN_0_1" => "alpha",
"GOKIN_4_6" => "omega",
);
my %hash2 = (
"alpha" => "aaa",
"omega" => "bbb",
)... |
13,393,935 | Im having a problem I have no idea how to solve.
I have this page that contains a project. Each project has members and each member can have one or more roles. I would like to show some sort of "picklist" where all assigned roles are "checked" and its possible to add or remove roles from each member while having the m... | 2012/11/15 | [
"https://Stackoverflow.com/questions/13393935",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30719/"
] | I dont see the problem, its not even recursive as you states, If a child of project had a project as member then it would be recursive.
Create 4 ViewModels a EditProjectMembersViewModel which has a array of ProjectViewModel which has a array of MemberViewModel which has a array of RoleViewModel
Or just use autogenera... | I've posted a very basic example of how to [create a checkbox list with knockout](http://www.ecofic.com/about/blog/create-a-checkBox-list-with-knockout). My example does not have the ability to dynamically add roles like you have mentioned. However, you should be able to do that with an observableArray. |
14,894,751 | I have been using ksoap library to consume .net web service.
and I am getting this kind of error
>
> "expected: START\_TAG {<http://schemas.xmlsoap.org/soap/envelope/>}Envelope (position:START\_TAG @1:7 in java.io.InputStreamReader@40d0c7d8)"
>
>
>
I have searched every where but I couldn't find any good help.
H... | 2013/02/15 | [
"https://Stackoverflow.com/questions/14894751",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2075474/"
] | Try and get a better code. Your code sounds a bit clumsy.
>
> ["org.xmlpull.v1.XmlPullParserException: expected: START\_TAG" Error](https://stackoverflow.com/questions/5791337/org-xmlpull-v1-xmlpullparserexception-) expected-start-tag-error
>
>
>
chk this.
2. Check your methodname and url with .netcode
3. Exclud... | I also got this error. Ultimately, it got fixed by setting these values:
```
String SOAP_ACTION = "BookTypeService";
String METHOD_NAME = "bookType";
String NAMESPACE = "http://192.168.1.3:8080/MyWebService/services/";
String URL = "http://192.168.1.3:8080/MyWebService/services/BookTypeService";
```
where, 192.16... |
30,235,741 | I have implemented a TimerTask in Java and i need to stop the Thread after a period of time:
```
....
timer = new Timer(); // At this line a new Thread will be created
TimerTask timerTask = new TimerTask() {
int tweetCounter = 0;
String message;
@Override... | 2015/05/14 | [
"https://Stackoverflow.com/questions/30235741",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1296783/"
] | ```
timer.cancel();
timer.purge();
```
will work .
>
> `int java.util.Timer.purge()`
>
>
> Removes all canceled tasks from the task queue. If there are no other
> references on the tasks, then after this call they are free to be
> garbage collected.
>
>
> Returns: the number of canceled tasks that were remove... | ```
Timer timer = new Timer();
TimerTask tt = new TimerTask(){
public void run(){
Calendar cal = Calendar.getInstance(); //this is the method you should use, not the Date(), because it is desperated.
int hour = cal.get(Calendar.HOUR_OF_DAY);//get the hour number of the day, from 0 ... |
7,553,567 | I am wondering if there is a special method/trick to check if a `String` object is null. I know about the [`String.IsNullOrEmpty`](http://msdn.microsoft.com/en-us/library/system.string.isnullorempty.aspx) method but I want to differentiate a `null` String from an empty String (=`""`).
Should I simply use:
```
if (s =... | 2011/09/26 | [
"https://Stackoverflow.com/questions/7553567",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/825024/"
] | An *object* can't be null - the value of an *expression* can be null. It's worth making the difference clear in your mind. The value of `s` isn't an object - it's a *reference*, which is either null or refers to an object.
And yes, you should just use
```
if (s == null)
```
Note that this will still use the overloa... | For .net 5 (probably also for .net Core 3.1)
Different possibility to write but always the same problem.
```
string wep = test ?? "replace";
Console.WriteLine(wep);
```
result: "replace"
or
```
string test=null;
test ??= "replace";
Console.WriteLine(test);
test="";
test??="replace";
Console.WriteLine(test);
```
... |
7,553,567 | I am wondering if there is a special method/trick to check if a `String` object is null. I know about the [`String.IsNullOrEmpty`](http://msdn.microsoft.com/en-us/library/system.string.isnullorempty.aspx) method but I want to differentiate a `null` String from an empty String (=`""`).
Should I simply use:
```
if (s =... | 2011/09/26 | [
"https://Stackoverflow.com/questions/7553567",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/825024/"
] | If you are using `C# 7.0` or above you can use `is null`:
```
if (s is null) {
// blah blah...
}
```
Also, note that when working with strings you might consider also using `IsNullOrWhiteSpace` that will also validate that the string doesn't contain only spaces. | You can check with null or Number.
First, add a reference to `Microsoft.VisualBasic` in your application.
Then, use the following code:
```
bool b = Microsoft.VisualBasic.Information.IsNumeric("null");
bool c = Microsoft.VisualBasic.Information.IsNumeric("abc");
```
In the above, `b` and `c` should both be `false`... |
7,553,567 | I am wondering if there is a special method/trick to check if a `String` object is null. I know about the [`String.IsNullOrEmpty`](http://msdn.microsoft.com/en-us/library/system.string.isnullorempty.aspx) method but I want to differentiate a `null` String from an empty String (=`""`).
Should I simply use:
```
if (s =... | 2011/09/26 | [
"https://Stackoverflow.com/questions/7553567",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/825024/"
] | You can use the null coalescing double question marks to test for nulls in a string or other nullable value type:
```
textBox1.Text = s ?? "Is null";
```
The operator '??' asks if the value of 's' is null and if not it returns 's'; if it is null it returns the value on the right of the operator.
More info here:
<ht... | For .net 5 (probably also for .net Core 3.1)
Different possibility to write but always the same problem.
```
string wep = test ?? "replace";
Console.WriteLine(wep);
```
result: "replace"
or
```
string test=null;
test ??= "replace";
Console.WriteLine(test);
test="";
test??="replace";
Console.WriteLine(test);
```
... |
7,553,567 | I am wondering if there is a special method/trick to check if a `String` object is null. I know about the [`String.IsNullOrEmpty`](http://msdn.microsoft.com/en-us/library/system.string.isnullorempty.aspx) method but I want to differentiate a `null` String from an empty String (=`""`).
Should I simply use:
```
if (s =... | 2011/09/26 | [
"https://Stackoverflow.com/questions/7553567",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/825024/"
] | To be sure, you should use a function to check for null and empty as below:
```
string str = ...
if (!String.IsNullOrEmpty(str))
{
...
}
``` | For .net 5 (probably also for .net Core 3.1)
Different possibility to write but always the same problem.
```
string wep = test ?? "replace";
Console.WriteLine(wep);
```
result: "replace"
or
```
string test=null;
test ??= "replace";
Console.WriteLine(test);
test="";
test??="replace";
Console.WriteLine(test);
```
... |
7,553,567 | I am wondering if there is a special method/trick to check if a `String` object is null. I know about the [`String.IsNullOrEmpty`](http://msdn.microsoft.com/en-us/library/system.string.isnullorempty.aspx) method but I want to differentiate a `null` String from an empty String (=`""`).
Should I simply use:
```
if (s =... | 2011/09/26 | [
"https://Stackoverflow.com/questions/7553567",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/825024/"
] | You can use the null coalescing double question marks to test for nulls in a string or other nullable value type:
```
textBox1.Text = s ?? "Is null";
```
The operator '??' asks if the value of 's' is null and if not it returns 's'; if it is null it returns the value on the right of the operator.
More info here:
<ht... | If you are using `C# 7.0` or above you can use `is null`:
```
if (s is null) {
// blah blah...
}
```
Also, note that when working with strings you might consider also using `IsNullOrWhiteSpace` that will also validate that the string doesn't contain only spaces. |
7,553,567 | I am wondering if there is a special method/trick to check if a `String` object is null. I know about the [`String.IsNullOrEmpty`](http://msdn.microsoft.com/en-us/library/system.string.isnullorempty.aspx) method but I want to differentiate a `null` String from an empty String (=`""`).
Should I simply use:
```
if (s =... | 2011/09/26 | [
"https://Stackoverflow.com/questions/7553567",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/825024/"
] | If you are using `C# 7.0` or above you can use `is null`:
```
if (s is null) {
// blah blah...
}
```
Also, note that when working with strings you might consider also using `IsNullOrWhiteSpace` that will also validate that the string doesn't contain only spaces. | For .net 5 (probably also for .net Core 3.1)
Different possibility to write but always the same problem.
```
string wep = test ?? "replace";
Console.WriteLine(wep);
```
result: "replace"
or
```
string test=null;
test ??= "replace";
Console.WriteLine(test);
test="";
test??="replace";
Console.WriteLine(test);
```
... |
7,553,567 | I am wondering if there is a special method/trick to check if a `String` object is null. I know about the [`String.IsNullOrEmpty`](http://msdn.microsoft.com/en-us/library/system.string.isnullorempty.aspx) method but I want to differentiate a `null` String from an empty String (=`""`).
Should I simply use:
```
if (s =... | 2011/09/26 | [
"https://Stackoverflow.com/questions/7553567",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/825024/"
] | An *object* can't be null - the value of an *expression* can be null. It's worth making the difference clear in your mind. The value of `s` isn't an object - it's a *reference*, which is either null or refers to an object.
And yes, you should just use
```
if (s == null)
```
Note that this will still use the overloa... | You can check with null or Number.
First, add a reference to `Microsoft.VisualBasic` in your application.
Then, use the following code:
```
bool b = Microsoft.VisualBasic.Information.IsNumeric("null");
bool c = Microsoft.VisualBasic.Information.IsNumeric("abc");
```
In the above, `b` and `c` should both be `false`... |
7,553,567 | I am wondering if there is a special method/trick to check if a `String` object is null. I know about the [`String.IsNullOrEmpty`](http://msdn.microsoft.com/en-us/library/system.string.isnullorempty.aspx) method but I want to differentiate a `null` String from an empty String (=`""`).
Should I simply use:
```
if (s =... | 2011/09/26 | [
"https://Stackoverflow.com/questions/7553567",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/825024/"
] | An *object* can't be null - the value of an *expression* can be null. It's worth making the difference clear in your mind. The value of `s` isn't an object - it's a *reference*, which is either null or refers to an object.
And yes, you should just use
```
if (s == null)
```
Note that this will still use the overloa... | To be sure, you should use a function to check for null and empty as below:
```
string str = ...
if (!String.IsNullOrEmpty(str))
{
...
}
``` |
7,553,567 | I am wondering if there is a special method/trick to check if a `String` object is null. I know about the [`String.IsNullOrEmpty`](http://msdn.microsoft.com/en-us/library/system.string.isnullorempty.aspx) method but I want to differentiate a `null` String from an empty String (=`""`).
Should I simply use:
```
if (s =... | 2011/09/26 | [
"https://Stackoverflow.com/questions/7553567",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/825024/"
] | An *object* can't be null - the value of an *expression* can be null. It's worth making the difference clear in your mind. The value of `s` isn't an object - it's a *reference*, which is either null or refers to an object.
And yes, you should just use
```
if (s == null)
```
Note that this will still use the overloa... | If you are using `C# 7.0` or above you can use `is null`:
```
if (s is null) {
// blah blah...
}
```
Also, note that when working with strings you might consider also using `IsNullOrWhiteSpace` that will also validate that the string doesn't contain only spaces. |
7,553,567 | I am wondering if there is a special method/trick to check if a `String` object is null. I know about the [`String.IsNullOrEmpty`](http://msdn.microsoft.com/en-us/library/system.string.isnullorempty.aspx) method but I want to differentiate a `null` String from an empty String (=`""`).
Should I simply use:
```
if (s =... | 2011/09/26 | [
"https://Stackoverflow.com/questions/7553567",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/825024/"
] | For .net 5 (probably also for .net Core 3.1)
Different possibility to write but always the same problem.
```
string wep = test ?? "replace";
Console.WriteLine(wep);
```
result: "replace"
or
```
string test=null;
test ??= "replace";
Console.WriteLine(test);
test="";
test??="replace";
Console.WriteLine(test);
```
... | You can check with null or Number.
First, add a reference to `Microsoft.VisualBasic` in your application.
Then, use the following code:
```
bool b = Microsoft.VisualBasic.Information.IsNumeric("null");
bool c = Microsoft.VisualBasic.Information.IsNumeric("abc");
```
In the above, `b` and `c` should both be `false`... |
28,404,089 | I have an array like this.
```
array (size=4)
0 =>
array (size=1)
'serial_id' => string '214' (length=3)
1 =>
array (size=1)
'serial_id' => string '218' (length=3)
2 =>
array (size=1)
'serial_id' => string '221' (length=3)
3 =>
array (size=1)
'serial_id' => string '319' (length=3)
```
and i want thi... | 2015/02/09 | [
"https://Stackoverflow.com/questions/28404089",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4542725/"
] | Try this..this is your old array..try to arrange it..consider it as example..
```
$array = array(0 => array("serial_id"=>"214"),
1 => array("serial_id"=>"218"),
2 => array("serial_id"=>"221"),
3 => array("serial_id"=>"319")
);
```
You can use foreach to ge... | Loop through the array as in the below example to produce your new array:
```
$array = array("0" => array("serial_id"=>"214"),
"1" => array("serial_id"=>"218"),
"2" => array("serial_id"=>"221"),
"3" => array("serial_id"=>"319")
);
$new_arr=array(); ... |
28,404,089 | I have an array like this.
```
array (size=4)
0 =>
array (size=1)
'serial_id' => string '214' (length=3)
1 =>
array (size=1)
'serial_id' => string '218' (length=3)
2 =>
array (size=1)
'serial_id' => string '221' (length=3)
3 =>
array (size=1)
'serial_id' => string '319' (length=3)
```
and i want thi... | 2015/02/09 | [
"https://Stackoverflow.com/questions/28404089",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4542725/"
] | You can try this code, I see that you are update your question
```
<?php
function convert_array($a) {
for($j = 0; $j < count($a); $j++) {
$b[$j] = $a[$j]['serial_id'];
}
return $b;
}
$array = array( array('serial_id' => 214),
array('serial_id' => 218 ),
... | Loop through the array as in the below example to produce your new array:
```
$array = array("0" => array("serial_id"=>"214"),
"1" => array("serial_id"=>"218"),
"2" => array("serial_id"=>"221"),
"3" => array("serial_id"=>"319")
);
$new_arr=array(); ... |
56,498,247 | I wrote a script and saved it as test.py (code shown below). And when I run it from the script (Run Module 5), I get the result in the Python Shell.
But I have tried multiple suggestions available online to have it run from the Python Shell instead to which I fail (one error pasted below).
How can I run a python scr... | 2019/06/07 | [
"https://Stackoverflow.com/questions/56498247",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3233050/"
] | You don't need the last line for it to run. All you need is:
```
!/usr/bin/python3
print(" Hello, world!")
```
If you want to run it from another file, don't use exec. Instead, import it.
```
import test
``` | You need to pass the "test.py" as a string (use quotes).
test is not a known object. |
3,295,376 | I have a date field in a model backed form in my Rails App:
```
<%= f.date_select :birthday,
{:start_year => Time.now.year,
:end_year => 1900,
:use_short_month => true,
:order => [:month, :day, :year],
:prompt => {:month => 'Month', :day => 'Day', :year => 'Year'}},
{:class => 'year',
:id => 'user_birthd... | 2010/07/21 | [
"https://Stackoverflow.com/questions/3295376",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/269120/"
] | I think you would have to create the validation in the controller itself.
The date parts are being passed to `birthday(1i)`, `birthday(2i)` and `birthday(3i)`. The problem here is that they are assigned immediately when passing the attributes and thus before any validations occur.
You could also overwrite the `attrib... | You could override the `validate_on_create` method, like the following:
```
class MyModel < ActiveRecord::Base
def validate_on_create
Date.parse(birthday)
rescue
errors.add_to_base("Wrong date format")
end
end
``` |
3,295,376 | I have a date field in a model backed form in my Rails App:
```
<%= f.date_select :birthday,
{:start_year => Time.now.year,
:end_year => 1900,
:use_short_month => true,
:order => [:month, :day, :year],
:prompt => {:month => 'Month', :day => 'Day', :year => 'Year'}},
{:class => 'year',
:id => 'user_birthd... | 2010/07/21 | [
"https://Stackoverflow.com/questions/3295376",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/269120/"
] | Related to this [post](https://stackoverflow.com/questions/597328/how-do-i-validate-a-date-in-rails), this is the best solution I've found. **However I should add :day, :month, :year as attr\_accessible, thing I don't understand why..** (because of validation? please let me know..)
User.rb
=======
```
MONTHS = ["Janu... | You could override the `validate_on_create` method, like the following:
```
class MyModel < ActiveRecord::Base
def validate_on_create
Date.parse(birthday)
rescue
errors.add_to_base("Wrong date format")
end
end
``` |
3,295,376 | I have a date field in a model backed form in my Rails App:
```
<%= f.date_select :birthday,
{:start_year => Time.now.year,
:end_year => 1900,
:use_short_month => true,
:order => [:month, :day, :year],
:prompt => {:month => 'Month', :day => 'Day', :year => 'Year'}},
{:class => 'year',
:id => 'user_birthd... | 2010/07/21 | [
"https://Stackoverflow.com/questions/3295376",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/269120/"
] | I think you would have to create the validation in the controller itself.
The date parts are being passed to `birthday(1i)`, `birthday(2i)` and `birthday(3i)`. The problem here is that they are assigned immediately when passing the attributes and thus before any validations occur.
You could also overwrite the `attrib... | Related to this [post](https://stackoverflow.com/questions/597328/how-do-i-validate-a-date-in-rails), this is the best solution I've found. **However I should add :day, :month, :year as attr\_accessible, thing I don't understand why..** (because of validation? please let me know..)
User.rb
=======
```
MONTHS = ["Janu... |
3,295,376 | I have a date field in a model backed form in my Rails App:
```
<%= f.date_select :birthday,
{:start_year => Time.now.year,
:end_year => 1900,
:use_short_month => true,
:order => [:month, :day, :year],
:prompt => {:month => 'Month', :day => 'Day', :year => 'Year'}},
{:class => 'year',
:id => 'user_birthd... | 2010/07/21 | [
"https://Stackoverflow.com/questions/3295376",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/269120/"
] | I think you would have to create the validation in the controller itself.
The date parts are being passed to `birthday(1i)`, `birthday(2i)` and `birthday(3i)`. The problem here is that they are assigned immediately when passing the attributes and thus before any validations occur.
You could also overwrite the `attrib... | After following Benoitr's suggestions I came up with something similar using virtual attributes. On the View side there are 3 separate select's (year,mon,day) inside of a 'fields\_for'. The data is submitted to the controller's mass assignment (no modifications in controller, see [asciicasts #16](http://asciicasts.com/... |
3,295,376 | I have a date field in a model backed form in my Rails App:
```
<%= f.date_select :birthday,
{:start_year => Time.now.year,
:end_year => 1900,
:use_short_month => true,
:order => [:month, :day, :year],
:prompt => {:month => 'Month', :day => 'Day', :year => 'Year'}},
{:class => 'year',
:id => 'user_birthd... | 2010/07/21 | [
"https://Stackoverflow.com/questions/3295376",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/269120/"
] | Related to this [post](https://stackoverflow.com/questions/597328/how-do-i-validate-a-date-in-rails), this is the best solution I've found. **However I should add :day, :month, :year as attr\_accessible, thing I don't understand why..** (because of validation? please let me know..)
User.rb
=======
```
MONTHS = ["Janu... | After following Benoitr's suggestions I came up with something similar using virtual attributes. On the View side there are 3 separate select's (year,mon,day) inside of a 'fields\_for'. The data is submitted to the controller's mass assignment (no modifications in controller, see [asciicasts #16](http://asciicasts.com/... |
10,922,818 | What part of the C++ IO streams does the `\r` to `\r\n` conversion? Is it the `stream_buf` itself or is it part of the internal to external encoding conversion by `codecvt` facet?
**UPDATE 1**
You all say that it is done in streambuf/filebuf. Ok. But how does this arrangement deal with, e.g., external encodings like ... | 2012/06/06 | [
"https://Stackoverflow.com/questions/10922818",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/341065/"
] | This conversion is not (usually) performed by stream, streambuf, or facet. It is the responsibility the C library code (e.g. `fputc()`) that is called by streambuf's `overflow()` and `underflow()`.
If you need it for some reason (e.g. when implementing a dos2unix routine), there's a handy example in [boost.iostreams.]... | IFAIR it's done in streambuf implementation, `codecvt` just deals with the locale representation specifics. |
10,922,818 | What part of the C++ IO streams does the `\r` to `\r\n` conversion? Is it the `stream_buf` itself or is it part of the internal to external encoding conversion by `codecvt` facet?
**UPDATE 1**
You all say that it is done in streambuf/filebuf. Ok. But how does this arrangement deal with, e.g., external encodings like ... | 2012/06/06 | [
"https://Stackoverflow.com/questions/10922818",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/341065/"
] | This conversion is not (usually) performed by stream, streambuf, or facet. It is the responsibility the C library code (e.g. `fputc()`) that is called by streambuf's `overflow()` and `underflow()`.
If you need it for some reason (e.g. when implementing a dos2unix routine), there's a handy example in [boost.iostreams.]... | It is performed by std::filebuf, if it was open without the ios::binary flag. |
3,344,329 | Does there exist a matrix $A$ in $\Bbb{R}^{3\times 3}$ that has only $0$ as eigenvalue?
As far as I think, an upper diagonal matrix with only zeros on the diagonal is such an example.
And if I'm correct, is such a matrix diagonalizable? | 2019/09/04 | [
"https://math.stackexchange.com/questions/3344329",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/694526/"
] | The equivalences $$\lvert A\rvert< B\iff\begin{cases}B\ge 0\\ A> -B\\ A< B\end{cases}\\ \lvert A\rvert\ge B\iff B\le 0\lor \begin{cases}B> 0\\ A\le -B\end{cases}\lor\begin{cases}B>0\\ A\ge B\end{cases}$$
are a good place to start from. | For $|x|<3$, the LHS is negative and the inequation certainly holds. Now assuming $|x|>3$, we can solve the equation
$$\frac1{|x|-3}=\frac12,$$ which gives $|x|=5$. The inequation holds for $|x|\ge5$. Your resolution was right.
So the solution set is
$$(-3,3)\cup(-\infty,-5]\cup[5,\infty).$$ |
3,344,329 | Does there exist a matrix $A$ in $\Bbb{R}^{3\times 3}$ that has only $0$ as eigenvalue?
As far as I think, an upper diagonal matrix with only zeros on the diagonal is such an example.
And if I'm correct, is such a matrix diagonalizable? | 2019/09/04 | [
"https://math.stackexchange.com/questions/3344329",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/694526/"
] | Anyway, in your case, $y\ge 0$, so you should transform all this to
$$|x|<3\;\textit{ or }\; |x|\ge 5\iff -3<x<3\;\textit{ or }\; x\ge 5\;\textit{ or }\; x\le -5$$
or, as a set, the union of three intervals:
$$(-\infty,-5]\cup(-3,3)\cup[5,+\infty). $$ | The equivalences $$\lvert A\rvert< B\iff\begin{cases}B\ge 0\\ A> -B\\ A< B\end{cases}\\ \lvert A\rvert\ge B\iff B\le 0\lor \begin{cases}B> 0\\ A\le -B\end{cases}\lor\begin{cases}B>0\\ A\ge B\end{cases}$$
are a good place to start from. |
3,344,329 | Does there exist a matrix $A$ in $\Bbb{R}^{3\times 3}$ that has only $0$ as eigenvalue?
As far as I think, an upper diagonal matrix with only zeros on the diagonal is such an example.
And if I'm correct, is such a matrix diagonalizable? | 2019/09/04 | [
"https://math.stackexchange.com/questions/3344329",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/694526/"
] | Anyway, in your case, $y\ge 0$, so you should transform all this to
$$|x|<3\;\textit{ or }\; |x|\ge 5\iff -3<x<3\;\textit{ or }\; x\ge 5\;\textit{ or }\; x\le -5$$
or, as a set, the union of three intervals:
$$(-\infty,-5]\cup(-3,3)\cup[5,+\infty). $$ | For $|x|<3$, the LHS is negative and the inequation certainly holds. Now assuming $|x|>3$, we can solve the equation
$$\frac1{|x|-3}=\frac12,$$ which gives $|x|=5$. The inequation holds for $|x|\ge5$. Your resolution was right.
So the solution set is
$$(-3,3)\cup(-\infty,-5]\cup[5,\infty).$$ |
49,760,362 | So have an input field:
```
<input
id={itemId}
onChange={handleChange}
type="number"
value={packed}
/>
```
And here is my onChange function:
```
handleChange(e) {
const { items, onUpdateQuantity } = this.props;
const updateItem = items.filter((item) =>
item.itemId === e.target.id,
);
... | 2018/04/10 | [
"https://Stackoverflow.com/questions/49760362",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2127769/"
] | That is coming because your `value` is not changing anywhere. As you can see from [docs for controlled components](https://reactjs.org/docs/forms.html#controlled-components), the value of the `input` is `this.state.value` and the `onChange` method changes the value inside the `input` by changing `this.state.value`.
As... | Make sure you bind you function in the constructor
```
class bla extends Component {
constructor(props){
super(props);
this.handleChange = this.handleChange.bind(this);
}
}
```
or if using stage 0 to have you have your function in this way.
```
handleChange = () => {}
```
and if not
```
hand... |
49,760,362 | So have an input field:
```
<input
id={itemId}
onChange={handleChange}
type="number"
value={packed}
/>
```
And here is my onChange function:
```
handleChange(e) {
const { items, onUpdateQuantity } = this.props;
const updateItem = items.filter((item) =>
item.itemId === e.target.id,
);
... | 2018/04/10 | [
"https://Stackoverflow.com/questions/49760362",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2127769/"
] | That is coming because your `value` is not changing anywhere. As you can see from [docs for controlled components](https://reactjs.org/docs/forms.html#controlled-components), the value of the `input` is `this.state.value` and the `onChange` method changes the value inside the `input` by changing `this.state.value`.
As... | <https://reactjs.org/docs/handling-events.html>
You have to be careful about the meaning of this in JSX callbacks. In JavaScript, class methods are not bound by default. If you forget to bind this.handleClick and pass it to onClick, this will be undefined when the function is actually called.
This is not React-specif... |
35,928,409 | I am trying to use Siege to do stress testing on my django application. For static pages (e.g. landing page) it works just fine. However, 99% of the pages I want to test require that I be logged in.
How can I get Siege to login and test django views? The login page uses the Django Login form and view. | 2016/03/10 | [
"https://Stackoverflow.com/questions/35928409",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4400697/"
] | If it possible to test as one user logined in you can pass session cookie as Cookie header -H "Cookie: cookieValue". For more complicated scenario better to Apache Jmeter. | For basic HTTP authentication form, adding `login=SomeUsername:somepassword` to *siege.conf* directives worked for me. May be possible to use for other login schemes. |
21,406,678 | I would like to add a padding to the value of a submit button.
I am able to do for example `text-align: right;` and the value floats well right. But if i use for example `padding-left: 25px;` the value itself stays in the middle instead of moving 25px to the right. I found a lot of things about centering the Value bu... | 2014/01/28 | [
"https://Stackoverflow.com/questions/21406678",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3107003/"
] | Unfortunately, you are using duplicate value..
I mean yor are trying to `INSERT INTO` to 9 columns(CourseCode, Units, Days, Time, RoomNumber, Instructor, Course, YearLevel, Term), however, you are putting 10 values().
`txtCurDays` is duplicated. | Escape the column names that match reserved words: `TIME` by enclosing in `[]`:
```
sqlStr = "INSERT INTO cur(CourseCode, Units, Days, [Time], RoomNumber, Instructor, Course, YearLevel, Term) VALUES ("
```
You should also use paramaterized queries as what you have in vulnerable to SQL Injection. (Run with a ' in on... |
21,406,678 | I would like to add a padding to the value of a submit button.
I am able to do for example `text-align: right;` and the value floats well right. But if i use for example `padding-left: 25px;` the value itself stays in the middle instead of moving 25px to the right. I found a lot of things about centering the Value bu... | 2014/01/28 | [
"https://Stackoverflow.com/questions/21406678",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3107003/"
] | Unfortunately, you are using duplicate value..
I mean yor are trying to `INSERT INTO` to 9 columns(CourseCode, Units, Days, Time, RoomNumber, Instructor, Course, YearLevel, Term), however, you are putting 10 values().
`txtCurDays` is duplicated. | That error indicates the generated SQL statement has an error in it.
Set a breakpoint on the line:
```
adoConn.Execute sqlStr
```
Then view the SQL query (print it to the immediate window or just examine it in the locals window). Check for any syntax errors.
One likely errore in your SQL would be a apastrophe (') ... |
47,694,579 | I have a use case where I scrape some data, and for some records some keys have multiple values. The final output I want is CSV, which I have a library for, and it expects a 2-dimensional array.
So my input structure looks like `List<TreeMap<String, List<String>>>` (I use `TreeMap` to ensure stable key order), and my ... | 2017/12/07 | [
"https://Stackoverflow.com/questions/47694579",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1003113/"
] | As a first step, I wouldn’t focus on new Java 8 features, but rather Java 5+ features. Don’t deal with `Iterator`s when you can use for-each. Generally, don’t iterate over a `keySet()` to perform a map lookup for every key, as you can iterate over the `entrySet()` not requiring any lookup. Also, don’t ask for an `IntSu... | This is quite concise way to do it using some [java-8](/questions/tagged/java-8 "show questions tagged 'java-8'") features.
This solution assumes that **only the Category data is dynamic**, whereas you will have always only one price and one product name.
Considering you have the initial data
```
// your initial com... |
853 | When a post is flagged for moderator attention, does the flag expire, or is it visible to the moderators whenever they check the list of the flagged posts?
I know that comment flags age away after 4 days, but is that valid also for "moderator attention" flags? | 2011/03/22 | [
"https://english.meta.stackexchange.com/questions/853",
"https://english.meta.stackexchange.com",
"https://english.meta.stackexchange.com/users/252/"
] | According to the [blog post](http://blog.stackoverflow.com/2009/04/raising-a-red-flag/), they expire after two days. Of course, that was two years ago, and a lot has changed since then, so this may now be significantly different.
In any case, moderator flags should not be ignored for so long that they expire—they shou... | Moderator flags do not expire. In fact, even if they are dismissed, they will reappear if someone else flags the same post. |
20,609,285 | I'm trying to convert this json into an array
```
public class RestWebService {
/**
* @param args
*/
public static void main(String[] args) {
try {
URL url = new URL("http://192.168.18.171/magento/api/rest/products");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
//c... | 2013/12/16 | [
"https://Stackoverflow.com/questions/20609285",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2063723/"
] | Native J2SE can't do this. You need to use a json framework which can do this. Following link lists frameworks that are out there which can do this.
<http://www.json.org/>
Some of the heavily used frameworks are
json-lib/jackson/gson | try this
```
JSONObject jObject= new JSONObject(output);
JSONArray menuObject = new JSONArray(jObject.getString("21"));
String sku,entity_id;
for (int i = 0; i<menuObject.length(); i++)
{
entity_id=menuObject.getJSONObject(i).getString("entity_id");
sku= menuObject.getJSONObjec... |
245,181 | The GFI in our bathroom was tripping somewhat frequently when my wife used the blow dryer. Other than the vanity light there were not other things operating on this circuit. If the GFI did not trip, the plug to the hair dryer would be quite hot to the touch. To my limited knowledge, a danger sign.
After a ridiculous q... | 2022/02/22 | [
"https://diy.stackexchange.com/questions/245181",
"https://diy.stackexchange.com",
"https://diy.stackexchange.com/users/35156/"
] | My understanding is that you can have multiple 15 amp outlets on a 20 Amp circuit but not just one. GFCI's trip on a fault, not an overload so the existing GFCI was probably going bad. Hair dryers can easily use 15 amps and that would heat up the plug a bit. If the GFCI outlet was old and had been used a lot, the plug ... | >
> However, I noticed that the circuit had a 20a breaker, but the GFI was 15a. So first step, I replaced it with a new 20a GFI.
>
> How bad is it to have a 15a GFI on a 20a circuit?
>
>
>
It's not bad at all and is totally legal. There was never a problem here; you reacted to this over nothing.
>
> Do you th... |
24,034,659 | HI I am building a php page, where I can upload some csv files from Credit card terminal, to show the owner of the shop, today sales, and make some statistics.
I am using MYISAM in my database.
This is just one line, from the csv file, to show what info I got to work with.
Transaction Date: 22-05-2014 00:00:12;
Stor... | 2014/06/04 | [
"https://Stackoverflow.com/questions/24034659",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3291960/"
] | First thing. Do you do this like that:
Until lines
Read line - save data to DB;
Read next line
If so... first do this "one time".
Gather all lines, split it to affordable chunks of Update statements and run them massively.
This will save you much time.
Duplicates - If I'd hit big performance issues - i would be ... | I found a solution, to the speed issue, i'm indexing all the columns, where I got "WHERE" clause on, and I did not change any sql commands in my php script, it took down, the execution time, down from 15 minutes to 10 sec.
 |
60,221,287 | I want to create a new column with all the distinct values across the rows. Each value in a row is a string(not list).
This is how dataframe looks like:
```
+-----------------------------+-------------------------+---------------------------------------------+
| first | second |... | 2020/02/14 | [
"https://Stackoverflow.com/questions/60221287",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11620918/"
] | try this:
```
df['new_col'] = df.apply(lambda x: list(set(x['first'] + x['second']+x['third'])), axis =1)
```
its creating set of single char as your data in cell is string.
"['able', 'shovel', 'door']"
to correct this use below:
```
df['new_col'] = df.apply(lambda x: list(set(eval(x['first']) + eval(x['second'])... | You can try out below snippet
```
import json
def get_list_from_str(s):
return json.loads(s.replace("'", '"'))
def flatten_list_rows(row):
return (set(
get_list_from_str(row['first']) +
get_list_from_str(row['second']) +
get_list_from_str(row['third'])
))
df['Distinct_set'] = d... |
60,221,287 | I want to create a new column with all the distinct values across the rows. Each value in a row is a string(not list).
This is how dataframe looks like:
```
+-----------------------------+-------------------------+---------------------------------------------+
| first | second |... | 2020/02/14 | [
"https://Stackoverflow.com/questions/60221287",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11620918/"
] | try this:
```
df['new_col'] = df.apply(lambda x: list(set(x['first'] + x['second']+x['third'])), axis =1)
```
its creating set of single char as your data in cell is string.
"['able', 'shovel', 'door']"
to correct this use below:
```
df['new_col'] = df.apply(lambda x: list(set(eval(x['first']) + eval(x['second'])... | How about this:
```
import pandas as pd
import numpy as np
df = pd.DataFrame([[['able', 'shovel', 'door'], ['shovel raised'], ['shovel raised', 'raised', 'door', 'shovel']], [['grade control'], ['grade'], ['grade']], [['light telling', 'love'], ['would love', 'closed'], ['closed', 'light']]], columns=['first', 'secon... |
60,221,287 | I want to create a new column with all the distinct values across the rows. Each value in a row is a string(not list).
This is how dataframe looks like:
```
+-----------------------------+-------------------------+---------------------------------------------+
| first | second |... | 2020/02/14 | [
"https://Stackoverflow.com/questions/60221287",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11620918/"
] | How about this:
```
import pandas as pd
import numpy as np
df = pd.DataFrame([[['able', 'shovel', 'door'], ['shovel raised'], ['shovel raised', 'raised', 'door', 'shovel']], [['grade control'], ['grade'], ['grade']], [['light telling', 'love'], ['would love', 'closed'], ['closed', 'light']]], columns=['first', 'secon... | You can try out below snippet
```
import json
def get_list_from_str(s):
return json.loads(s.replace("'", '"'))
def flatten_list_rows(row):
return (set(
get_list_from_str(row['first']) +
get_list_from_str(row['second']) +
get_list_from_str(row['third'])
))
df['Distinct_set'] = d... |
31,885,885 | How to get minimum and maximum value of all the columns of a table? Please note that the columns may be both numeric, date or character. We have to find min and max of all the variables in following format:
Name\_of\_columns, minimum, maximum | 2015/08/07 | [
"https://Stackoverflow.com/questions/31885885",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3466243/"
] | Here's a macro that will do what your asking for which doesn't require you to know the variable names or their type:
```
%macro maxmin;
/* get variable names */
proc contents noprint data = test.hashval out=test.contents;run;
proc sql noprint;
select count(*) into: cnt from test.contents;quit;
%let cnt = &cnt;
proc... | ```
proc sql;
create view myExtrema_1 as
Select min(alphaVar) as alphaVar, ..., put(min(numVar),best32.) as numVar, ...
from myTable
Union
Select max(alphaVar), ..., put(max(numVar),best32.), ...
from myTable;
quit;
proc transpose data=myExtrema_1
out=myExtrema(rename=(
_name_ = Var... |
10,384 | I often come across answers flagged for LQ in the corresponding review queue which don't really fit into the categories of a LQ post - not spam, not better as a comment, not better as a question, etc. Using a broader definition, the post *is* of low quality; perhaps it's not very clear, or the physics is incorrect, but... | 2018/01/25 | [
"https://physics.meta.stackexchange.com/questions/10384",
"https://physics.meta.stackexchange.com",
"https://physics.meta.stackexchange.com/users/11053/"
] | This issue has been discussed repeatedly on mother meta. Some examples:
* [Add downvote option to Low Quality Review Queue list of potential actions](https://meta.stackexchange.com/q/228738/346882),
* [Why is voting removed from new review system?](https://meta.stackexchange.com/q/140405/346882),
* [(Up)Voting on Low-... | There's a few things going on here that I can see, and I previously ranted about that subject [here](https://physics.meta.stackexchange.com/questions/9027), about a year and a half ago. At the time I proposed trying out a change in the mods' response to VLQ flags, which I think is still in place, but we didn't really h... |
28,707,580 | This is a program I made for an assignment thats supposed to find the min and max of 3 numbers. The program works when I run it this way but I'm having trouble following the logic of why.
```
#include <iostream>
using namespace std;
int main()
{
double num1 = 0, num2 = 0, num3 = 0, max = 0, min = 0;
cout <... | 2015/02/24 | [
"https://Stackoverflow.com/questions/28707580",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4603227/"
] | ```
min = num1;
if (num2 < min)
{
min = num2;
}
else
{
min = num3;
}
```
This cannot possibly work, because `min` will never be `num1`; it is immediately overwritten by either `num2` or `num3`.
One `if` statement gives the control flow two choices in your program, which is not enough. Since this is an exerci... | You are missing some comparison between `num3` and `min`. Before assigning `num3` to `min`, you want to make sure that `num3` is actually the minimum.
You also need to remove the `else` here because you want to do both comparison `num2 < min` and `num3 < min`
```
min = num1;
if (num2 < min)
{
min = num2;
}
if (n... |
49,487,641 | I wrote this function to deeply compare two objects in JavaScript
```
Equal: function(obj1, obj2) {
var keys1 = Object.keys(obj1).sort();
var keys2 = Object.keys(obj2).sort();
if (keys1.length !== keys2.length) {
return false;
}
// first make sure have same keys.
if (!keys1.every(function(k, i) {
r... | 2018/03/26 | [
"https://Stackoverflow.com/questions/49487641",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7683487/"
] | Yep, it's the `attribute` method:
```
{% set t = [(1, 'hello'), (2, 'world')] %}
{% set t1 = t|map(attribute=1)|list %}
{{ t1 }}
``` | Jinja engine is limited in terms of python expressions as per following [quote](http://jinja.pocoo.org/docs/dev/faq/#isn-t-it-a-terrible-idea-to-put-logic-into-templates) from Jinja documentation:
>
> ...
>
> Jinja2 neither allows you to put arbitrary Python code into
> templates nor does it allow all Python ex... |
13,573,343 | ```
HttpClient client = new HttpClient();
client.BaseAddress = new Uri("http://localhost:60792");
```
Instead of localhost:60792 how do I find it dynamically on start up? Pointing me in the right direction would suffice. But if you have an answer let me know.
Update thanks for the hint. My final answer is
=======... | 2012/11/26 | [
"https://Stackoverflow.com/questions/13573343",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/475337/"
] | `string url = HttpContext.Current.Request.Url.AbsoluteUri;` | After the new update of Visual studio 2019 the answer by @webNoob will give an error
`'HttpContext' does not contain a definition for 'Current' and no accessible extension method 'Current' accepting a first argument of type 'HttpContext' could be found (are you missing a using directive or an assembly reference?)`
So... |
41,950,180 | I have a Node/Express/Mongo app and I am trying to make an AJAX call, the data is now saving fine but the page is reloading even when I user `preventDefault()` in the AJAX call. Why is this happening?
```
var categoryButton = function(){
event.preventDefault();
$("#add_category_form").submit(function (event){
eve... | 2017/01/31 | [
"https://Stackoverflow.com/questions/41950180",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3881909/"
] | **Update your code and check**
```
<section id="event_categories_section" style="display:none;" class="col-md-6">
<form id="add_category_form" method="POST" action="/user/categories/<%=user._id%>">
<label for="input_category_name">Add a category for your Events</label>... | Use `return false` at the end of your `.submit()` function
return false from within a jQuery event handler is effectively the same as calling both event.preventDefault and event.stopPropagation on the passed jQuery.Event object.
`event.preventDefault()` will prevent the default event from occurring.
`event.stopPropa... |
41,950,180 | I have a Node/Express/Mongo app and I am trying to make an AJAX call, the data is now saving fine but the page is reloading even when I user `preventDefault()` in the AJAX call. Why is this happening?
```
var categoryButton = function(){
event.preventDefault();
$("#add_category_form").submit(function (event){
eve... | 2017/01/31 | [
"https://Stackoverflow.com/questions/41950180",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3881909/"
] | **Update your code and check**
```
<section id="event_categories_section" style="display:none;" class="col-md-6">
<form id="add_category_form" method="POST" action="/user/categories/<%=user._id%>">
<label for="input_category_name">Add a category for your Events</label>... | remove the **onsubmit** attribute from the **form** and call the **categoryButton()** function when document is ready, then your submit event will bind with your **form** and everything will work properly.
I just modified little bit your code please try it and share your feedback.
```
$(function() {
categoryBut... |
376,064 | Can a new USB C dock like this for example:
[USB C dock with Power Delivery](https://rads.stackoverflow.com/amzn/click/com/B07DC25FHC)
be connected and work with an old Macbook (or other USB A gen 2.0 or 3.0 computer) using an adapter like in the picture for example?
[ system is not going to damage anything.
The old USB A plug does not support what is known as "Alternate Mode" in USB Type-C. Therefore you'll not be able to get the HDMI port on the dock wor... | Please do not use the adapters pictured for anything, they violate the USB specification and run the risk of shorting out your power supply. This could be quite dangerous and expensive.
Since your computer has a USB-A port then find a dock with an attached USB-A cable. If you need HDMI output from your dock then there... |
22,677,463 | I have a column which is of type integer array. How can I merge all of them into a single integer array?
For example: If I execute query:
```
select column_name from table_name
```
I get result set as:
```
-[RECORD 1]----------
column_name | {1,2,3}
-[RECORD 2]----------
column_name | {4,5}
```
How can I get `{... | 2014/03/27 | [
"https://Stackoverflow.com/questions/22677463",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1465266/"
] | You could use [`unnest`](http://www.postgresql.org/docs/current/interactive/functions-array.html#ARRAY-FUNCTIONS-TABLE) to open up the arrays and then [`array_agg`](http://www.postgresql.org/docs/current/interactive/functions-aggregate.html#FUNCTIONS-AGGREGATE-TABLE) to put them back together:
```
select array_agg(c)
... | You could use `lateral subquery` for that:
```
select array_agg(u.a)
from (values (array[1, 2, 3]), (array[4, 5])) t (a)
join lateral unnest(t.a) u (a) on true;
``` |
22,677,463 | I have a column which is of type integer array. How can I merge all of them into a single integer array?
For example: If I execute query:
```
select column_name from table_name
```
I get result set as:
```
-[RECORD 1]----------
column_name | {1,2,3}
-[RECORD 2]----------
column_name | {4,5}
```
How can I get `{... | 2014/03/27 | [
"https://Stackoverflow.com/questions/22677463",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1465266/"
] | Define a trivial custom aggregate:
```
CREATE AGGREGATE array_cat_agg(anyarray) (
SFUNC=array_cat,
STYPE=anyarray
);
```
and use it:
```
WITH v(a) AS ( VALUES (ARRAY[1,2,3]), (ARRAY[4,5,6,7]))
SELECT array_cat_agg(a) FROM v;
```
If you want a particular order, put it within the aggregate call, i.e. `array_cat... | to **merge** arrays you can use `||` operator [more](https://www.postgresql.org/docs/9.6/functions-array.html#:%7E:text=%7C%7C-,array%2Dto%2Darray%20concatenation,-ARRAY%5B1%2C2%2C3%5D%20%7C%7C%20ARRAY%5B4%2C5%2C6)
to put result in **flat list** use `uunest` [func](https://www.postgresql.org/docs/9.6/functions-array.h... |
22,677,463 | I have a column which is of type integer array. How can I merge all of them into a single integer array?
For example: If I execute query:
```
select column_name from table_name
```
I get result set as:
```
-[RECORD 1]----------
column_name | {1,2,3}
-[RECORD 2]----------
column_name | {4,5}
```
How can I get `{... | 2014/03/27 | [
"https://Stackoverflow.com/questions/22677463",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1465266/"
] | You could use [`unnest`](http://www.postgresql.org/docs/current/interactive/functions-array.html#ARRAY-FUNCTIONS-TABLE) to open up the arrays and then [`array_agg`](http://www.postgresql.org/docs/current/interactive/functions-aggregate.html#FUNCTIONS-AGGREGATE-TABLE) to put them back together:
```
select array_agg(c)
... | The only way you can do this is inside a function:
```
CREATE FUNCTION merge_arrays() RETURNS int[] AS $$
DECLARE
this record;
res int[];
BEGIN
FOR this IN
SELECT column_name FROM table_name
LOOP
array_cat(res, this.column_name);
END LOOP;
RETURN res;
END; $$ LANGUAGE plpgsql;
```
Then you can
... |
22,677,463 | I have a column which is of type integer array. How can I merge all of them into a single integer array?
For example: If I execute query:
```
select column_name from table_name
```
I get result set as:
```
-[RECORD 1]----------
column_name | {1,2,3}
-[RECORD 2]----------
column_name | {4,5}
```
How can I get `{... | 2014/03/27 | [
"https://Stackoverflow.com/questions/22677463",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1465266/"
] | to **merge** arrays you can use `||` operator [more](https://www.postgresql.org/docs/9.6/functions-array.html#:%7E:text=%7C%7C-,array%2Dto%2Darray%20concatenation,-ARRAY%5B1%2C2%2C3%5D%20%7C%7C%20ARRAY%5B4%2C5%2C6)
to put result in **flat list** use `uunest` [func](https://www.postgresql.org/docs/9.6/functions-array.h... | The only way you can do this is inside a function:
```
CREATE FUNCTION merge_arrays() RETURNS int[] AS $$
DECLARE
this record;
res int[];
BEGIN
FOR this IN
SELECT column_name FROM table_name
LOOP
array_cat(res, this.column_name);
END LOOP;
RETURN res;
END; $$ LANGUAGE plpgsql;
```
Then you can
... |
22,677,463 | I have a column which is of type integer array. How can I merge all of them into a single integer array?
For example: If I execute query:
```
select column_name from table_name
```
I get result set as:
```
-[RECORD 1]----------
column_name | {1,2,3}
-[RECORD 2]----------
column_name | {4,5}
```
How can I get `{... | 2014/03/27 | [
"https://Stackoverflow.com/questions/22677463",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1465266/"
] | to **merge** arrays you can use `||` operator [more](https://www.postgresql.org/docs/9.6/functions-array.html#:%7E:text=%7C%7C-,array%2Dto%2Darray%20concatenation,-ARRAY%5B1%2C2%2C3%5D%20%7C%7C%20ARRAY%5B4%2C5%2C6)
to put result in **flat list** use `uunest` [func](https://www.postgresql.org/docs/9.6/functions-array.h... | You could use `lateral subquery` for that:
```
select array_agg(u.a)
from (values (array[1, 2, 3]), (array[4, 5])) t (a)
join lateral unnest(t.a) u (a) on true;
``` |
22,677,463 | I have a column which is of type integer array. How can I merge all of them into a single integer array?
For example: If I execute query:
```
select column_name from table_name
```
I get result set as:
```
-[RECORD 1]----------
column_name | {1,2,3}
-[RECORD 2]----------
column_name | {4,5}
```
How can I get `{... | 2014/03/27 | [
"https://Stackoverflow.com/questions/22677463",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1465266/"
] | Define a trivial custom aggregate:
```
CREATE AGGREGATE array_cat_agg(anyarray) (
SFUNC=array_cat,
STYPE=anyarray
);
```
and use it:
```
WITH v(a) AS ( VALUES (ARRAY[1,2,3]), (ARRAY[4,5,6,7]))
SELECT array_cat_agg(a) FROM v;
```
If you want a particular order, put it within the aggregate call, i.e. `array_cat... | You could use `lateral subquery` for that:
```
select array_agg(u.a)
from (values (array[1, 2, 3]), (array[4, 5])) t (a)
join lateral unnest(t.a) u (a) on true;
``` |
22,677,463 | I have a column which is of type integer array. How can I merge all of them into a single integer array?
For example: If I execute query:
```
select column_name from table_name
```
I get result set as:
```
-[RECORD 1]----------
column_name | {1,2,3}
-[RECORD 2]----------
column_name | {4,5}
```
How can I get `{... | 2014/03/27 | [
"https://Stackoverflow.com/questions/22677463",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1465266/"
] | You could use [`unnest`](http://www.postgresql.org/docs/current/interactive/functions-array.html#ARRAY-FUNCTIONS-TABLE) to open up the arrays and then [`array_agg`](http://www.postgresql.org/docs/current/interactive/functions-aggregate.html#FUNCTIONS-AGGREGATE-TABLE) to put them back together:
```
select array_agg(c)
... | to **merge** arrays you can use `||` operator [more](https://www.postgresql.org/docs/9.6/functions-array.html#:%7E:text=%7C%7C-,array%2Dto%2Darray%20concatenation,-ARRAY%5B1%2C2%2C3%5D%20%7C%7C%20ARRAY%5B4%2C5%2C6)
to put result in **flat list** use `uunest` [func](https://www.postgresql.org/docs/9.6/functions-array.h... |
22,677,463 | I have a column which is of type integer array. How can I merge all of them into a single integer array?
For example: If I execute query:
```
select column_name from table_name
```
I get result set as:
```
-[RECORD 1]----------
column_name | {1,2,3}
-[RECORD 2]----------
column_name | {4,5}
```
How can I get `{... | 2014/03/27 | [
"https://Stackoverflow.com/questions/22677463",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1465266/"
] | Define a trivial custom aggregate:
```
CREATE AGGREGATE array_cat_agg(anyarray) (
SFUNC=array_cat,
STYPE=anyarray
);
```
and use it:
```
WITH v(a) AS ( VALUES (ARRAY[1,2,3]), (ARRAY[4,5,6,7]))
SELECT array_cat_agg(a) FROM v;
```
If you want a particular order, put it within the aggregate call, i.e. `array_cat... | The only way you can do this is inside a function:
```
CREATE FUNCTION merge_arrays() RETURNS int[] AS $$
DECLARE
this record;
res int[];
BEGIN
FOR this IN
SELECT column_name FROM table_name
LOOP
array_cat(res, this.column_name);
END LOOP;
RETURN res;
END; $$ LANGUAGE plpgsql;
```
Then you can
... |
22,677,463 | I have a column which is of type integer array. How can I merge all of them into a single integer array?
For example: If I execute query:
```
select column_name from table_name
```
I get result set as:
```
-[RECORD 1]----------
column_name | {1,2,3}
-[RECORD 2]----------
column_name | {4,5}
```
How can I get `{... | 2014/03/27 | [
"https://Stackoverflow.com/questions/22677463",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1465266/"
] | You could use `lateral subquery` for that:
```
select array_agg(u.a)
from (values (array[1, 2, 3]), (array[4, 5])) t (a)
join lateral unnest(t.a) u (a) on true;
``` | The only way you can do this is inside a function:
```
CREATE FUNCTION merge_arrays() RETURNS int[] AS $$
DECLARE
this record;
res int[];
BEGIN
FOR this IN
SELECT column_name FROM table_name
LOOP
array_cat(res, this.column_name);
END LOOP;
RETURN res;
END; $$ LANGUAGE plpgsql;
```
Then you can
... |
22,677,463 | I have a column which is of type integer array. How can I merge all of them into a single integer array?
For example: If I execute query:
```
select column_name from table_name
```
I get result set as:
```
-[RECORD 1]----------
column_name | {1,2,3}
-[RECORD 2]----------
column_name | {4,5}
```
How can I get `{... | 2014/03/27 | [
"https://Stackoverflow.com/questions/22677463",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1465266/"
] | You could use [`unnest`](http://www.postgresql.org/docs/current/interactive/functions-array.html#ARRAY-FUNCTIONS-TABLE) to open up the arrays and then [`array_agg`](http://www.postgresql.org/docs/current/interactive/functions-aggregate.html#FUNCTIONS-AGGREGATE-TABLE) to put them back together:
```
select array_agg(c)
... | Define a trivial custom aggregate:
```
CREATE AGGREGATE array_cat_agg(anyarray) (
SFUNC=array_cat,
STYPE=anyarray
);
```
and use it:
```
WITH v(a) AS ( VALUES (ARRAY[1,2,3]), (ARRAY[4,5,6,7]))
SELECT array_cat_agg(a) FROM v;
```
If you want a particular order, put it within the aggregate call, i.e. `array_cat... |
34,114,345 | I'm a newbie ruby on rails developer. I've just created my first application and made use of the the `bootstrap` carousel. Now, I want to add some `javascript`. My application does not have any custom `javascript` at this point. What I want to do is when the `left` or `right` button on the carousel is pressed, I want a... | 2015/12/06 | [
"https://Stackoverflow.com/questions/34114345",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2771150/"
] | Adding your custom javascript to your rails app is real easy, just follow the steps below :-
* create a file (say custom.js) under **app/assets/javascripts/**
* Open up your manifest file i.e **application.js** (this is the file where you need to include every javascript file you want to load into your rails app, add ... | For Rails 6
Add your javascript code under /app/javascript//file.js
and then in app/packs/application.js
`require("<folder name>/file")` |
28,150,847 | I am making a level for a recent project, and basically `Object7/8` animate left and right using these two functions I have `animateRight()` `animateLeft()`
I want to have `FfirstObj` To animate up and down 70px each way, but I want to use this same method as the left and right animation. I have tried 3 times in tota ... | 2015/01/26 | [
"https://Stackoverflow.com/questions/28150847",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4174614/"
] | i think this should work in your case, if i understood correctly.
```
var firstLevelMoveone = "#FfirstObj";
function animateUp() {
$(firstLevelMoveone).stop().animate({
'marginTop': "-=70px" //moves up
}, 1100, animateLeft);
}
function animateDown() {
$(firstLevelMoveone).stop().animate({
... | I have shortened your code, and editted your css a little bit just to display how to animate repeatedly your FfirstObj.
Here is the html:
```
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
<div id="outline">
<div id="FfirstObj">1</div>
</div>
```
Here is the css:
```
#outline {
height: 400p... |
1,598,823 | I have yet to find a way of setting up Python logging with Django that I'm happy with. My requirements are fairly simple:
* Different log handlers for different events - that is, I want to be able to log to different files
* Easy access to loggers in my modules. The module should be able to find its logger with little... | 2009/10/21 | [
"https://Stackoverflow.com/questions/1598823",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13055/"
] | The best way I've found so far is to initialize logging setup in settings.py - nowhere else. You can either use a configuration file or do it programmatically step-by-step - it just depends on your requirements. The key thing is that I usually add the handlers I want to the root logger, using levels and sometimes loggi... | I am currently using a logging system, which I created myself. It uses CSV format for logging.
[django-csvlog](http://bitbucket.org/oduvan/django-csvlog/)
This project still doesn't have full documentation, but I am working on it. |
1,598,823 | I have yet to find a way of setting up Python logging with Django that I'm happy with. My requirements are fairly simple:
* Different log handlers for different events - that is, I want to be able to log to different files
* Easy access to loggers in my modules. The module should be able to find its logger with little... | 2009/10/21 | [
"https://Stackoverflow.com/questions/1598823",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13055/"
] | I know this is a solved answer already, but as per django >= 1.3 there's a new logging setting.
Moving from old to new is not automatic, so I thought i'll write it down here.
And of course checkout [the django doc](http://docs.djangoproject.com/en/dev/topics/logging "Django Logging Doc") for some more.
This is the b... | I am currently using a logging system, which I created myself. It uses CSV format for logging.
[django-csvlog](http://bitbucket.org/oduvan/django-csvlog/)
This project still doesn't have full documentation, but I am working on it. |
1,598,823 | I have yet to find a way of setting up Python logging with Django that I'm happy with. My requirements are fairly simple:
* Different log handlers for different events - that is, I want to be able to log to different files
* Easy access to loggers in my modules. The module should be able to find its logger with little... | 2009/10/21 | [
"https://Stackoverflow.com/questions/1598823",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13055/"
] | The best way I've found so far is to initialize logging setup in settings.py - nowhere else. You can either use a configuration file or do it programmatically step-by-step - it just depends on your requirements. The key thing is that I usually add the handlers I want to the root logger, using levels and sometimes loggi... | We initialize logging in the top-level `urls.py` by using a `logging.ini` file.
The location of the `logging.ini` is provided in `settings.py`, but that's all.
Each module then does
```
logger = logging.getLogger(__name__)
```
To distinguish testing, development and production instances, we have different logging.... |
1,598,823 | I have yet to find a way of setting up Python logging with Django that I'm happy with. My requirements are fairly simple:
* Different log handlers for different events - that is, I want to be able to log to different files
* Easy access to loggers in my modules. The module should be able to find its logger with little... | 2009/10/21 | [
"https://Stackoverflow.com/questions/1598823",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13055/"
] | I know this is a solved answer already, but as per django >= 1.3 there's a new logging setting.
Moving from old to new is not automatic, so I thought i'll write it down here.
And of course checkout [the django doc](http://docs.djangoproject.com/en/dev/topics/logging "Django Logging Doc") for some more.
This is the b... | We initialize logging in the top-level `urls.py` by using a `logging.ini` file.
The location of the `logging.ini` is provided in `settings.py`, but that's all.
Each module then does
```
logger = logging.getLogger(__name__)
```
To distinguish testing, development and production instances, we have different logging.... |
14,150,845 | I got 4 jobs:
1, 2, 3, 4.
2's condition: s(1);
3's condition: s(2);
4's condition: s(1) & s(2) & s(3)
all these jobs are **daily jobs**
the first day is ok.
the second day, the 4th job triggered **mutilple times**:
I think when 1 success, and the status of 2 and 3 are still 'success'(the last days status),
so the ... | 2013/01/04 | [
"https://Stackoverflow.com/questions/14150845",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1583460/"
] | This is already answered on stackoverflow.com
The solution depends on the version of Autosys you are using. If it is R11, the newest version, you can set look back dependencies on job\_a to only run if job\_c has ran to S within X hours.
Full answer here:
[Autosys dependency on mainframe job](https://stackoverflow.com... | One solution is to include all the 4 jobs in a Box job, and whenever the Box jobs starts all the job will become active and will run only in the completion of all the dependencies. |
14,150,845 | I got 4 jobs:
1, 2, 3, 4.
2's condition: s(1);
3's condition: s(2);
4's condition: s(1) & s(2) & s(3)
all these jobs are **daily jobs**
the first day is ok.
the second day, the 4th job triggered **mutilple times**:
I think when 1 success, and the status of 2 and 3 are still 'success'(the last days status),
so the ... | 2013/01/04 | [
"https://Stackoverflow.com/questions/14150845",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1583460/"
] | This is already answered on stackoverflow.com
The solution depends on the version of Autosys you are using. If it is R11, the newest version, you can set look back dependencies on job\_a to only run if job\_c has ran to S within X hours.
Full answer here:
[Autosys dependency on mainframe job](https://stackoverflow.com... | Put all 4 jobs in a box. Then, you can change the run condition of job4 to just the success of job3. |
14,150,845 | I got 4 jobs:
1, 2, 3, 4.
2's condition: s(1);
3's condition: s(2);
4's condition: s(1) & s(2) & s(3)
all these jobs are **daily jobs**
the first day is ok.
the second day, the 4th job triggered **mutilple times**:
I think when 1 success, and the status of 2 and 3 are still 'success'(the last days status),
so the ... | 2013/01/04 | [
"https://Stackoverflow.com/questions/14150845",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1583460/"
] | Yes if you are running latest version of Autosys you can set the success condition depending on time.
In your case you can set as:
4's condition: s(1, 23.00) & s(2, 23.00) & s(3, 23.00)
This condition checks if the jobs 1,2,3 were successful within last 23 hours.
Format is:
S(*jobname*, *hh*.*mm*) | One solution is to include all the 4 jobs in a Box job, and whenever the Box jobs starts all the job will become active and will run only in the completion of all the dependencies. |
14,150,845 | I got 4 jobs:
1, 2, 3, 4.
2's condition: s(1);
3's condition: s(2);
4's condition: s(1) & s(2) & s(3)
all these jobs are **daily jobs**
the first day is ok.
the second day, the 4th job triggered **mutilple times**:
I think when 1 success, and the status of 2 and 3 are still 'success'(the last days status),
so the ... | 2013/01/04 | [
"https://Stackoverflow.com/questions/14150845",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1583460/"
] | Yes if you are running latest version of Autosys you can set the success condition depending on time.
In your case you can set as:
4's condition: s(1, 23.00) & s(2, 23.00) & s(3, 23.00)
This condition checks if the jobs 1,2,3 were successful within last 23 hours.
Format is:
S(*jobname*, *hh*.*mm*) | Put all 4 jobs in a box. Then, you can change the run condition of job4 to just the success of job3. |
13,881,861 | So, I just ran into an interesting problem while using the Scanner class to read contents from files. Basically, I'm trying to read several output files produced by a parsing application from a directory to compute some accuracy metrics.
Basically, my code just walks through each of the files in the directory, and op... | 2012/12/14 | [
"https://Stackoverflow.com/questions/13881861",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1757975/"
] | According to the Scanner.java source in Java 6u23 a new line is detected by
```
private static final String LINE_SEPARATOR_PATTERN =
"\r\n|[\n\r???]";
private static final String LINE_PATTERN = ".*("+LINE_SEPARATOR_PATTERN+")|.+$";
```
So you could check whether you can match ... | I would try to check if you always close the scanner after reading the file. Also do you call only hasNextLine() and nextLine(), or do you call another nextXXX() method on that scanners? |
36,493,122 | How can I convert the date to 8th April 2016 format?
```
// in your controller:
$scope.date = '20140313T00:00:00';
// in your view, date property, filtered with date filter and format 'MM dd yyyy'
<div ng-bind="date | date:'MM dd yyyy'"></div>
``` | 2016/04/08 | [
"https://Stackoverflow.com/questions/36493122",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5311796/"
] | in your angular controller
```
$scope..DayofDate = "";
$scope.Monthofdate = "";
$scope.DaySuffix = "";
$scope.getDateFormat = function (date) {
var suffixes = ["th", "st", "nd", "rd"];
var dtfilter = $filter('date')(date, 'dd');
$scope.Day... | Try this out:
```
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.8/angular.min.js"></script>
</head>
<body ng-app="myApp" ng-controller="myCtrl">
{{myDate | date: 'dd MMM yyyy'}}
<script>
//Module Declaration
var app = angular.module('myApp',[]);
//Controller Declaration
ap... |
1,276,174 | I have the need from an asp.net web site to send out many SMS messages at once, and also poll a POP3 account for an incoming mail, and then SMS that out to many recipients, one at a time.
The way I am thinking of doing this is a windows service that would connect to my sql back-end to see if there are SMS messages to ... | 2009/08/14 | [
"https://Stackoverflow.com/questions/1276174",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43754/"
] | We have implemented similar scenarios using SQL Server service broker's Queueing mechanism. The idea is that every inserted SMS record is caught by a trigger which inserts a message containing the SmsID into the service broker Queue.
You then need a stored procedure which receives messages from the Queue. If there ar... | Instead of using an Sql Server for the queuing you could use MSMQ (Microsoft Message Queuing) for this.
MSMQ is quite easy to set up and once it is up and running it is more scalable than Sql Server.
So what you could do was to setup a new queue in MSMQ that would receive the messages you wanted to send. The message... |
18,287,655 | I'm working on a function with three nested for loops that is way too slow for its intended use. The bottleneck is clearly the looping part - almost 100 % of the execution time is spent in the innermost loop.
The function takes a 2d matrix called `rM` as input and returns a 3d matrix called `ec`:
```
rows = size(rM... | 2013/08/17 | [
"https://Stackoverflow.com/questions/18287655",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1669384/"
] | Display: block tells the browser that you want a certain element displayed in a "block": it is the only element on that "line" of the browser (so you can't fit multiple elements next to each other). You can also have "inline", which is the opposite. Source: <https://developer.mozilla.org/en-US/docs/Web/CSS/display> | Here you can find all the values of the display property and its behaviour: <http://www.w3schools.com/cssref/pr_class_display.asp> |
18,287,655 | I'm working on a function with three nested for loops that is way too slow for its intended use. The bottleneck is clearly the looping part - almost 100 % of the execution time is spent in the innermost loop.
The function takes a 2d matrix called `rM` as input and returns a 3d matrix called `ec`:
```
rows = size(rM... | 2013/08/17 | [
"https://Stackoverflow.com/questions/18287655",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1669384/"
] | `float: left` or `float: right` forces `display` to have a computed value of `block`.
<http://www.w3.org/TR/CSS2/visuren.html#dis-pos-flo>
That is why removing `display: block` makes no difference. You can safely remove it if you want to.
The only possible reason to leave it there is to show your *intent* to anyone ... | Display: block tells the browser that you want a certain element displayed in a "block": it is the only element on that "line" of the browser (so you can't fit multiple elements next to each other). You can also have "inline", which is the opposite. Source: <https://developer.mozilla.org/en-US/docs/Web/CSS/display> |
18,287,655 | I'm working on a function with three nested for loops that is way too slow for its intended use. The bottleneck is clearly the looping part - almost 100 % of the execution time is spent in the innermost loop.
The function takes a 2d matrix called `rM` as input and returns a 3d matrix called `ec`:
```
rows = size(rM... | 2013/08/17 | [
"https://Stackoverflow.com/questions/18287655",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1669384/"
] | SOURCE w3c
>
> In a block formatting context, boxes are laid out one after the other,
> vertically, beginning at the top of a containing block. The vertical
> distance between two sibling boxes is determined by the 'margin'
> properties. Vertical margins between adjacent block boxes in a block
> formatting contex... | Here you can find all the values of the display property and its behaviour: <http://www.w3schools.com/cssref/pr_class_display.asp> |
18,287,655 | I'm working on a function with three nested for loops that is way too slow for its intended use. The bottleneck is clearly the looping part - almost 100 % of the execution time is spent in the innermost loop.
The function takes a 2d matrix called `rM` as input and returns a 3d matrix called `ec`:
```
rows = size(rM... | 2013/08/17 | [
"https://Stackoverflow.com/questions/18287655",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1669384/"
] | `float: left` or `float: right` forces `display` to have a computed value of `block`.
<http://www.w3.org/TR/CSS2/visuren.html#dis-pos-flo>
That is why removing `display: block` makes no difference. You can safely remove it if you want to.
The only possible reason to leave it there is to show your *intent* to anyone ... | Here you can find all the values of the display property and its behaviour: <http://www.w3schools.com/cssref/pr_class_display.asp> |
18,287,655 | I'm working on a function with three nested for loops that is way too slow for its intended use. The bottleneck is clearly the looping part - almost 100 % of the execution time is spent in the innermost loop.
The function takes a 2d matrix called `rM` as input and returns a 3d matrix called `ec`:
```
rows = size(rM... | 2013/08/17 | [
"https://Stackoverflow.com/questions/18287655",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1669384/"
] | `float: left` or `float: right` forces `display` to have a computed value of `block`.
<http://www.w3.org/TR/CSS2/visuren.html#dis-pos-flo>
That is why removing `display: block` makes no difference. You can safely remove it if you want to.
The only possible reason to leave it there is to show your *intent* to anyone ... | SOURCE w3c
>
> In a block formatting context, boxes are laid out one after the other,
> vertically, beginning at the top of a containing block. The vertical
> distance between two sibling boxes is determined by the 'margin'
> properties. Vertical margins between adjacent block boxes in a block
> formatting contex... |
458,852 | I’m trying to automate the refreshing of data in my Excel Reports. Here the script:
```
$ExcelApp = new-object -ComObject Excel.Application
$ExcelApp.Visible = $false
$ExcelApp.DisplayAlerts = $false
$Workbook = $ExcelApp.Workbooks.Open("RefreshTest.xlsx", 3, $false, 5, $null, $null, $true)
$Workbook.RefreshAll()
$Wo... | 2009/01/19 | [
"https://Stackoverflow.com/questions/458852",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Your logic seems to be fine, and this works for me (XP SP2 and PowerShell v2).
Just before you call Save(), just for fun, add this line to see what gets printed:
```
$Workbook|Get-Member *Save*
```
I tried with a blank file. Is your file big perhaps? I wonder if you have a large file, and maybe need to add a "Start... | This script works fine for me as well, as written.
I would agree with Marco that this seems like a race condition error. The error message is weird, but the fact that it works when you have human pause between the load/refresh and save portions of your script points to a long load/refresh time causing your problem.
T... |
458,852 | I’m trying to automate the refreshing of data in my Excel Reports. Here the script:
```
$ExcelApp = new-object -ComObject Excel.Application
$ExcelApp.Visible = $false
$ExcelApp.DisplayAlerts = $false
$Workbook = $ExcelApp.Workbooks.Open("RefreshTest.xlsx", 3, $false, 5, $null, $null, $true)
$Workbook.RefreshAll()
$Wo... | 2009/01/19 | [
"https://Stackoverflow.com/questions/458852",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Your logic seems to be fine, and this works for me (XP SP2 and PowerShell v2).
Just before you call Save(), just for fun, add this line to see what gets printed:
```
$Workbook|Get-Member *Save*
```
I tried with a blank file. Is your file big perhaps? I wonder if you have a large file, and maybe need to add a "Start... | I agree that this seems to be a race condition. An idiom I use takes advantage of the fact that `!$null` evaluates to `$true`,
```
# create an object that may take some time to populate
$MyWorkBook = $ap.Workbooks.Add()
# wait for the methods of MyWorkBook to be populated
while(!$MyWorkBook.activate){start-sleep -mi... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.