Questions

How do I get the current branch name in Git?

How do I get the name of the current branch in Git?

8 Jul at 06:38

Get the values from the "GET" parameters (JavaScript)

I have a URL with some GET parameters as follows: ``` www.test.com/t.html?a=1&b=3&c=m2-m3-m4-m5 ``` I need to get the whole value of `c`. I tried to read the URL, but I got only `m2`. How do I do t...

6 Oct at 15:36

Is there a standard function to check for null, undefined, or blank variables in JavaScript?

Is there a universal JavaScript function that checks that a variable has a value and ensures that it's not `undefined` or `null`? I've got this code, but I'm not sure if it covers all cases: ``` func...

11 May at 09:13

How do I loop through or enumerate a JavaScript object?

I have a JavaScript object like the following: ``` var p = { "p1": "value1", "p2": "value2", "p3": "value3" }; ``` How do I loop through all of `p`'s elements (`p1`, `p2`, `p3`...) and ge...

8 May at 17:29

Why can't Python parse this JSON data?

I have this JSON in a file: ``` { "maps": [ { "id": "blabla", "iscategorical": "0" }, { "id": "blabla", "iscategorical": "0"...

1 Jul at 21:31

git error: failed to push some refs to remote

I can't push now, though I could do it yesterday. When I use `git push origin master`, I get an error: ``` $ git remote -v origin https://github.com/REDACTED.git (fetch) origin https://github.com/RE...

9 Aug at 11:5

Set cellpadding and cellspacing in CSS?

In an HTML table, the `cellpadding` and `cellspacing` can be set like this: ``` <table cellspacing="1" cellpadding="1"> ``` How can the same be accomplished using CSS?

6 Jun at 19:40

How can I create a two dimensional array in JavaScript?

I have been reading online and some places say it isn't possible, some say it is and then give an example and others refute the example, etc. 1. How do I declare a 2 dimensional array in JavaScript...

HTML text input allow only numeric input

Is there a quick way to set an HTML text input (`<input type=text />`) to only allow numeric keystrokes (plus '.')?

22 Nov at 07:38

Find all files in a directory with extension .txt in Python

How can I find all the files in a directory having the extension `.txt` in python?

12 Apr at 15:56

How to align content of a div to the bottom

Say I have the following CSS and HTML code: ``` #header { height: 150px; } ``` ``` <div id="header"> <h1>Header title</h1> Header content (one or multiple lines) </div> ``` The header sectio...

19 Apr at 10:51

How are parameters sent in an HTTP POST request?

In an HTTP request, parameters are sent as a : In an HTTP request, the parameters are not sent along with the URI. In the request header? In the request body? What does it look like?

17 Dec at 10:21

How do I convert a string to a number in PHP?

I want to convert these types of values, `'3'`, `'2.34'`, `'0.234343'`, etc. to a number. In JavaScript we can use `Number()`, but is there any similar method available in PHP? ``` Input ...

24 Jun at 19:42

How to disable text selection highlighting

For anchors that act like buttons (for example, the buttons on the sidebar of this Stack Overflow page titled , , and ) or tabs, is there a CSS standard way to disable the highlighting effect if the u...

How do I set a variable to the output of a command in Bash?

I have a pretty simple script that is something like the following: ``` #!/bin/bash VAR1="$1" MOREF='sudo run command against $VAR1 | grep name | cut -c7-' echo $MOREF ``` When I run this script ...

11 Apr at 11:54

How to add a new column to an existing DataFrame?

I have the following indexed DataFrame with named columns and rows not- continuous numbers: ``` a b c d 2 0.671399 0.101208 -0.181532 0.241273 3 0.446172 -0.243316 0.0517...

How to make a div 100% height of the browser window

I have a layout with two columns - a left `div` and a right `div`. The right `div` has a grey `background-color`, and I need it to expand vertically depending on the height of the user's browser windo...

17 Jan at 18:58

How do I import other Python files?

How do I import files in Python? I want to import: 1. a file (e.g. file.py) 2. a folder 3. a file dynamically at runtime, based on user input 4. one specific part of a file (e.g. a single function) ...

Get unique values from a list in python

I want to get the unique values from the following list: ``` ['nowplaying', 'PBS', 'PBS', 'nowplaying', 'job', 'debate', 'thenandnow'] ``` The output which I require is: ``` ['nowplaying', 'PBS', ...

2 Oct at 13:9

Save plot to image file instead of displaying it using Matplotlib

This displays the figure in a GUI: ``` import matplotlib.pyplot as plt plt.plot([1, 2, 3], [1, 4, 9]) plt.show() ``` But how do I instead save the figure to a file (e.g. foo.png)?

25 Aug at 03:36

How can I remove a key from a Python dictionary?

I want to remove a key from a dictionary if it is present. I currently use this code: ``` if key in my_dict: del my_dict[key] ``` Without the `if` statement, the code will raise `KeyError` if the...

23 Feb at 08:25

How do I determine whether an array contains a particular value in Java?

I have a `String[]` with values like so: ``` public static final String[] VALUES = new String[] {"AB","BC","CD","AE"}; ``` Given `String s`, is there a good way of testing whether `VALUES` contains...

5 Jan at 09:6

What is the difference between "INNER JOIN" and "OUTER JOIN"?

Also, how do `LEFT OUTER JOIN`, `RIGHT OUTER JOIN`, and `FULL OUTER JOIN` fit in?

28 Aug at 04:26

Disable/enable an input with jQuery?

``` $input.disabled = true; ``` or ``` $input.disabled = "disabled"; ``` Which is the standard way? And, conversely, how do you enable a disabled input?

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

I installed [LAMP](http://en.wikipedia.org/wiki/LAMP_%28software_bundle%29) on [Ubuntu 12.04 LTS](http://en.wikipedia.org/wiki/List_of_Ubuntu_releases#Ubuntu_12.04_LTS_.28Precise_Pangolin.29) (Precise...