Questions

Adding elements to object

I need to populate a json file, now I have something like this: ``` {"element":{"id":10,"quantity":1}} ``` And I need to add another "element". My first step is putting that json in a Object type u...

24 Aug at 20:56

'IF' in 'SELECT' statement - choose output value based on column values

``` SELECT id, amount FROM report ``` I need `amount` to be `amount` if `report.type='P'` and `-amount` if `report.type='N'`. How do I add this to the above query?

15 Sep at 21:19

Styling multi-line conditions in 'if' statements?

Sometimes I break long conditions in `if`s onto several lines. The most obvious way to do this is: ``` if (cond1 == 'val1' and cond2 == 'val2' and cond3 == 'val3' and cond4 == 'val4'): do...

30 May at 17:35

What is the difference between UNION and UNION ALL?

What is the difference between `UNION` and `UNION ALL`?

26 Mar at 06:50

CS0120: An object reference is required for the nonstatic field, method, or property 'foo'

Consider: ``` namespace WindowsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_C...

12 Jun at 05:0

Who is listening on a given TCP port on Mac OS X?

On Linux, I can use `netstat -pntl | grep $PORT` or `fuser -n tcp $PORT` to find out which process (PID) is listening on the specified TCP port. How do I get the same information on Mac OS X?

12 Dec at 12:30

No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

I'm compiling a project in Eclipse using m2eclipse. I set the JDK path in Eclipse like this: ``` Windows-->preferences-->installed jres--> jdk1.7.xx path ``` But this is showing an error ``` [ERR...

31 Dec at 00:59

How do I split a list into equally-sized chunks?

How do I split a list of arbitrary length into equal sized chunks? --- [How to iterate over a list in chunks](https://stackoverflow.com/q/434287) [Split string every nth character?](https://stackov...

2 Oct at 01:6

Converting unix timestamp string to readable date

I have a string representing a unix timestamp (i.e. "1284101485") in Python, and I'd like to convert it to a readable date. When I use `time.strftime`, I get a `TypeError`: ``` >>>import time >>>print...

Difference between CR LF, LF and CR line break types?

I'd like to know the difference (with examples if possible) between `CR LF` (Windows), `LF` (Unix) and `CR` (Macintosh) line break types.

Get statistics for each group (such as count, mean, etc) using pandas GroupBy?

I have a data frame `df` and I use several columns from it to `groupby`: ``` df['col1','col2','col3','col4'].groupby(['col1','col2']).mean() ``` In the above way I almost get the table (data frame)...

How to use the PI constant in C++

I want to use the PI constant and trigonometric functions in some C++ program. I get the trigonometric functions with `include <math.h>`. However, there doesn't seem to be a definition for PI in this ...

4 Apr at 09:8

Get all table names of a particular database by SQL query?

I am working on application which can deal with multiple database servers like "MySQL" and "MS SQL Server". I want to get tables' names of a particular database using a general query which should suit...

26 Nov at 17:57

ValueError: setting an array element with a sequence

Why do the following code samples: ``` np.array([[1, 2], [2, 3, 4]]) ``` ``` np.array([1.2, "abc"], dtype=float) ``` ...all give the following error? > ValueError: setting an array element with a se...

20 Aug at 18:32

Close Bootstrap Modal

I have a bootstrap modal dialog box that I want to show initially, then when the user clicks on the page, it disappears. I have the following: ``` $(function () { $('#modal').modal(toggle) }); <...

pyplot scatter plot marker size

In the pyplot document for scatter plot: ``` matplotlib.pyplot.scatter(x, y, s=20, c='b', marker='o', cmap=None, norm=None, vmin=None, vmax=None, alpha=None, linewidths=None...

1 Feb at 15:1

How to set the y-axis limit

I need help with setting the limits of y-axis on matplotlib. Here is the code that I tried, unsuccessfully. ``` import matplotlib.pyplot as plt plt.figure(1, figsize = (8.5,11)) plt.suptitle('plot t...

14 Sep at 14:1

Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (38)

I am having a big problem trying to connect to mysql. When I run: ``` /usr/local/mysql/bin/mysql start ``` I have the following error : ``` Can't connect to local MySQL server through socket '/var...

27 Jun at 15:18

How to get the current time in YYYY-MM-DD HH:MI:Sec.Millisecond format in Java?

The code below gives me the current time. But it does not tell anything about milliseconds. ``` public static String getCurrentTimeStamp() { SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-M...

7 Feb at 12:36

Using CSS for a fade-in effect on page load

Can CSS transitions be used to allow a text paragraph to fade-in on page load? I really like how it looked on [http://dotmailapp.com/](http://web.archive.org/web/20120728071954/http://www.dotmailapp....

25 Sep at 17:20

Running JAR file on Windows

I have a JAR file named . In order to run it, I'm executing the following command in a command-line window: ``` java -jar helloworld.jar ``` This works fine, but how do I execute it with double-cli...

30 Aug at 13:16

How can I declare and use Boolean variables in a shell script?

I tried to declare a Boolean variable in a shell script using the following syntax: ``` variable=$false variable=$true ``` Is this correct? Also, if I wanted to update that variable would I use th...

23 Oct at 12:16

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder"

My application is to be deployed on both tcServer and WebSphere 6.1. This application uses ehCache and so requires slf4j as a dependency. As a result I've added the slf4j-api.jar (1.6) jar to my war f...

18 Dec at 16:9

How to add local jar files to a Maven project?

How do I add local jar files (not yet part of the Maven repository) directly in my project's library sources?

How to comment multiple lines in Visual Studio Code?

I cannot find a way to comment and uncomment multiple lines of code in [Visual Studio Code](https://code.visualstudio.com/). Is it possible to comment and uncomment multiple lines in Visual Studio Co...

10 Feb at 00:49