Questions

Insert into ... values ( SELECT ... FROM ... )

I am trying to `INSERT INTO` a table using the input from another table. Although this is entirely feasible for many database engines, I always seem to struggle to remember the correct syntax for the ...

How can I avoid Java code in JSP files, using JSP 2?

I know that something like the following three lines ``` <%= x+1 %> <%= request.getParameter("name") %> <%! counter++; %> ``` is an old school way of coding and in JSP version 2 there exists a method...

28 Dec at 23:44

How do I perform an IF...THEN in an SQL SELECT?

How do I perform an `IF...THEN` in an `SQL SELECT` statement? For example: ``` SELECT IF(Obsolete = 'N' OR InStock = 'Y' ? 1 : 0) AS Saleable, * FROM Product ```

26 Mar at 06:9

Difference between sh and Bash

When writing shell programs, we often use `/bin/sh` and `/bin/bash`. I usually use `bash`, but I don't know what's the difference between them. What's main difference between Bash and `sh`? What do we...

25 Oct at 19:20

Is there a "previous sibling" selector?

The plus sign selector (`+`) is for selecting the next adjacent sibling. Is there an equivalent for the previous sibling?

1 Nov at 13:53

Is < faster than <=?

Is `if (a < 901)` faster than `if (a <= 900)`? Not exactly as in this simple example, but there are slight performance changes on loop complex code. I suppose this has to do something with generated m...

Git diff against a stash

How can I see the changes un-stashing will make to the current working tree? I would like to know what changes will be made before applying them!

13 Apr at 16:15

Parse JSON in JavaScript?

I want to parse a JSON string in JavaScript. The response is something like ``` var response = '{"result":true,"count":1}'; ``` How can I get the values `result` and `count` from this?

22 Mar at 16:17

Table Naming Dilemma: Singular vs. Plural Names

Academia has it that table names should be the singular of the entity that they store attributes of. I dislike any T-SQL that requires square brackets around names, but I have renamed a `Users` tab...

5 Nov at 04:11

Extracting extension from filename in Python

Is there a function to extract the extension from a filename?

16 Sep at 19:11

Convert form data to JavaScript object with jQuery

How do I convert all elements of my form to a JavaScript object? I'd like to have some way of automatically building a JavaScript object from my form, without having to loop over each element. I do ...

25 Aug at 04:17

How can I selectively merge or pick changes from another branch in Git?

I'm using Git on a new project that has two parallel -- but currently experimental -- development branches: - `master`- `exp1`- `exp2` `exp1` and `exp2` represent two very different architectural appr...

How do I create a Java string from the contents of a file?

I've been using the idiom below for some time now. And it seems to be the most wide-spread, at least on the sites I've visited. Is there a better/different way to read a file into a string in Java? ...

12 Sep at 17:54

Proper way to declare custom exceptions in modern Python?

What's the proper way to declare custom exception classes in modern Python? My primary goal is to follow whatever standard other exception classes have, so that (for instance) any extra string I inclu...

9 Feb at 10:34

What is the difference between const int*, const int * const, and int const *?

I always mess up how to use `const int*`, `const int * const`, and `int const *` correctly. Is there a set of rules defining what you can and cannot do? I want to know all the do's and all don'ts in ...

19 Dec at 19:14

JavaScript post request like a form submit

I'm trying to direct a browser to a different page. If I wanted a GET request, I might say ``` document.location.href = 'http://example.com/q=a'; ``` But the resource I'm trying to access won't respo...

27 Dec at 19:51

How can I reconcile detached HEAD with master/origin?

I'm new at the branching complexities of Git. I always work on a single branch and commit changes and then periodically push to my remote origin. Somewhere recently, I did a reset of some files to ge...

29 May at 18:21

Make a Bash alias that takes a parameter?

I used to use CShell ([csh](/questions/tagged/csh)), which lets you make an alias that takes a parameter. The notation was something like ``` alias junk="mv \\!* ~/.Trash" ``` In Bash, this does no...

1 Mar at 19:32

How to vertically align an image inside a div

How can you align an image inside of a containing `div`? ## Example In my example, I need to vertically center the `<img>` in the `<div>` with `class ="frame`": ``` <div class="frame" style="height...

20 Jun at 09:12

How to remove focus border (outline) around text/input boxes? (Chrome)

Can anyone explain how to remove the orange or blue border (outline) around text/input boxes? I think it only happens on Chrome to show that the input box is active. Here's the input CSS I'm using: `...

19 Apr at 10:35

Differences between Lodash and Underscore.js

Why would someone prefer either the [Lodash](http://lodash.com/) or [Underscore.js](http://underscorejs.org/) utility library over the other? Lodash seems to be a drop-in replacement for underscore, t...

14 Oct at 19:8

What is the difference between an abstract method and a virtual method?

What is the difference between an abstract method and a virtual method? In which cases is it recommended to use abstract or virtual methods? Which one is the best approach?

.gitignore is ignored by Git

My `.gitignore` file seems to be being ignored by Git - could the `.gitignore` file be corrupt? Which file format, locale or culture does Git expect? My `.gitignore`: ``` # This is a comment debug.l...

1 Feb at 00:10

How does the Java 'for each' loop work?

Consider: ``` List<String> someList = new ArrayList<String>(); // add "monkey", "donkey", "skeleton key" to someList ``` ``` for (String item : someList) { System.out.println(item); } ``` W...

23 Feb at 13:21

What does the [Flags] Enum Attribute mean in C#?

From time to time I see an enum like the following: ``` [Flags] public enum Options { None = 0, Option1 = 1, Option2 = 2, Option3 = 4, Option4 = 8 } ``` I don't understand w...

6 Apr at 09:18