Questions

JavaScript sleep/wait before continuing

I have a JavaScript code that I need to add a sleep/wait function to. The code I am running is already in a function, eg: ``` function myFunction(time) { alert('time starts now'); //code to m...

1 Aug at 20:52

How to get an absolute file path in Python

Given a path such as `"mydir/myfile.txt"`, how do I find the file's absolute path in Python? E.g. on Windows, I might end up with: ``` "C:/example/cwd/mydir/myfile.txt" ```

How do I retrieve an HTML element's actual width and height?

Suppose that I have a `<div>` that I wish to center in the browser's display (viewport). To do so, I need to calculate the width and height of the `<div>` element. What should I use? Please include ...

19 Aug at 20:46

How to play audio?

I am making a game with HTML5 and JavaScript. How could I play game audio via JavaScript?

30 Jul at 20:27

Equivalent of shell 'cd' command to change the working directory?

`cd` is the shell command to change the working directory. How do I change the current working directory in Python?

10 Feb at 18:38

Error "Import Error: No module named numpy" on Windows

I have a very similar question to [this question](https://stackoverflow.com/questions/1517129/python-how-do-i-install-scipy-on-64-bit-windows), but I am still one step behind. I have only one version ...

22 Aug at 15:4

FileNotFoundError: [Errno 2] No such file or directory

I am trying to open a CSV file but for some reason python cannot locate it. Here is my code (it's just a simple code but I cannot solve the problem): ``` import csv with open('address.csv','r') as ...

9 Mar at 13:28

Does JavaScript have a method like "range()" to generate a range within the supplied bounds?

In PHP, you can do... ``` range(1, 3); // Array(1, 2, 3) range("A", "C"); // Array("A", "B", "C") ``` That is, there is a function that lets you get a range of numbers or characters by passing the ...

Place a button right aligned

I use this code to right align a button. ``` <p align="right"> <input type="button" value="Click Me" /> </p> ``` But `<p>` tags wastes some space, so looking to do the same with `<span>` or `<d...

6 Mar at 07:8

How do I see active SQL Server connections?

I am using SQL Server 2008 Enterprise. I want to see any active SQL Server connections, and the related information of all the connections, like from which IP address, connect to which database or som...

21 Jan at 21:33

How can I check whether a radio button is selected with JavaScript?

I have two radio buttons within an HTML form. A dialog box appears when one of the fields is null. How can I check whether a radio button is selected?

3 Aug at 21:38

Detecting an "invalid date" Date instance in JavaScript

I'd like to tell the difference between valid and invalid date objects in JS, but couldn't figure out how: ``` var d = new Date("foo"); console.log(d.toString()); // shows 'Invalid Date' console.log(...

5 Jul at 19:34

Alternatives for returning multiple values from a Python function

The canonical way to return multiple values in languages that support it is often [tupling](https://stackoverflow.com/questions/38508/whats-the-best-way-to-return-multiple-values-from-a-function-in-py...

How do I delete an exported environment variable?

Before installing [gnuplot](https://en.wikipedia.org/wiki/Gnuplot), I set the environment variable `GNUPLOT_DRIVER_DIR = /home/gnuplot/build/src`. During the installation, something went wrong. I want...

25 Jan at 23:38

How to read all files in a folder from Java?

How to read all the files in a folder through Java? It doesn't matter which API.

1 Mar at 22:14

How to move an element into another element

I would like to move one DIV element inside another. For example, I want to move this (including all children): ``` <div id="source"> ... </div> ``` into this: ``` <div id="destination"> ... </di...

12 Nov at 05:3

How do I compare two string variables in an 'if' statement in Bash?

I'm trying to get an `if` statement to work in [Bash](http://en.wikipedia.org/wiki/Bash_%28Unix_shell%29) (using [Ubuntu](http://en.wikipedia.org/wiki/Ubuntu_%28operating_system%29)): ``` #!/bin/bash...

17 Jan at 15:4

How do I call a JavaScript function on page load?

Traditionally, to call a JavaScript function once the page has loaded, you'd add an `onload` attribute to the body containing a bit of JavaScript (usually only calling a function) ``` <body onload="f...

8 Apr at 19:51

How do I break out of nested loops in Java?

I've got a nested loop construct like this: ``` for (Type type : types) { for (Type t : types2) { if (some condition) { // Do something and break... break; // Br...

6 Dec at 06:35

Loading local JSON file

I'm trying to load a local JSON file but it won't work. Here is my JavaScript code (using jQuery): ``` var json = $.getJSON("test.json"); var data = eval("(" +json.responseText + ")"); document.write(...

How do I create a constant in Python?

How do I declare a constant in Python? In Java, we do: ``` public static final String CONST_NAME = "Name"; ```

9 Apr at 08:55

File to byte[] in Java

How do I convert a `java.io.File` to a `byte[]`?

27 Mar at 11:32

How do I get the hash for the current commit in Git?

How do I get the hash of the current commit in Git?

25 Jul at 02:45

How do you disable browser autocomplete on web form field / input tags?

How do you disable autocomplete in the major browsers for a specific input (or form field)?

8 Apr at 23:1

Type Checking: typeof, GetType, or is?

I've seen many people use the following code: ``` Type t = obj1.GetType(); if (t == typeof(int)) // Some code here ``` But I know you could also do this: ``` if (obj1.GetType() == typeof(int)) ...

25 Nov at 14:20