Questions

In Node.js, how do I "include" functions from my other files?

Let's say I have a file called app.js. Pretty simple: ``` var express = require('express'); var app = express.createServer(); app.set('views', __dirname + '/views'); app.set('view engine', 'ejs'); ap...

27 Apr at 00:9

Convert UTC date time to local date time

From the server I get a datetime variable in this format: `6/29/2011 4:52:48 PM` and it is in UTC time. I want to convert it to the current user’s browser time zone using JavaScript. How this can be d...

Using Python 3 in virtualenv

Using [virtualenv](https://virtualenv.pypa.io/en/latest/), I run my projects with the default version of Python (2.7). On one project, I need to use Python 3.4. I used `brew install python3` to inst...

16 Mar at 13:32

Split array into chunks

Let's say that I have an Javascript array looking as following: ``` ["Element 1","Element 2","Element 3",...]; // with close to a hundred elements. ``` What approach would be appropriate to chunk...

11 Sep at 00:2

How to initialize a list of strings (List<string>) with many string values

How is it possible to initialize (with a C# initializer) a list of strings? I have tried with the example below but it's not working. ``` List<string> optionList = new List<string> { "AdditionalC...

23 Sep at 18:29

ImportError: No module named matplotlib.pyplot

I am currently practicing matplotlib. This is the first example I practice. ``` #!/usr/bin/python import matplotlib.pyplot as plt radius = [1.0, 2.0, 3.0, 4.0] area = [3.14159, 12.56636, 28.27431, 5...

10 Nov at 20:1

Asynchronous vs synchronous execution. What is the difference?

What is the difference between asynchronous and synchronous execution?

25 Sep at 04:49

SQL update query using joins

I have to update a field with a value which is returned by a join of 3 tables. Example: ``` select im.itemid ,im.sku as iSku ,gm.SKU as GSKU ,mm.ManufacturerId as ManuId ,mm.Man...

If a folder does not exist, create it

I use a `FileUploader` control in my application. I want to save a file to a specified folder. If this folder does not exist, I want to first create it, and then save my file to this folder. If the f...

16 Feb at 15:7

How to parse JSON data with jQuery / JavaScript?

I have a AJAX call that returns some JSON like this: ``` $(document).ready(function () { $.ajax({ type: 'GET', url: 'http://example/functions.php', data: { get_param: '...

23 Jul at 11:40

What does the 'b' character do in front of a string literal?

Apparently, the following is the valid syntax: ``` b'The string' ``` I would like to know: 1. What does this b character in front of the string mean? 2. What are the effects of using it? 3. What are...

9 Apr at 10:16

How to write a switch statement in Ruby

How do I write a `switch` statement in Ruby?

The multi-part identifier could not be bound

I've seen similar errors on SO, but I don't find a solution for my problem. I have a SQL query like: ``` SELECT DISTINCT a.maxa , b.mahuyen , a.tenxa , b.tenhuyen , ...

15 Jan at 15:13

java.net.SocketException: Connection reset

I am getting the following error trying to read from a socket. I'm doing a `readInt()` on that `InputStream`, and I am getting this error. Perusing the documentation this suggests that the client part...

Converting Dictionary to List?

I'm trying to convert a Python dictionary into a Python list, in order to perform some calculations. ``` #My dictionary dict = {} dict['Capital']="London" dict['Food']="Fish&Chips" dict['2012']="Olym...

29 Jun at 18:20

urllib and "SSL: CERTIFICATE_VERIFY_FAILED" Error

I am getting the following error: ``` Exception in thread Thread-3: Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 810, i...

What is the easiest way to initialize a std::vector with hardcoded elements?

I can create an array and initialize it like this: ``` int a[] = {10, 20, 30}; ``` How do I create a `std::vector` and initialize it similarly elegant? The best way I know is: ``` std::vector<int...

4 Mar at 14:16

How to set header and options in axios?

I use Axios to perform an HTTP post like this: ``` import axios from 'axios' params = {'HTTP_CONTENT_LANGUAGE': self.language} headers = {'header1': value} axios.post(url, params, headers) ``` Is t...

4 Dec at 15:17

How to set variable from a SQL query?

I'm trying to set a variable from a SQL query: ``` declare @ModelID uniqueidentifer Select @ModelID = select modelid from models where areaid = 'South Coast' ``` Obviously I'm not doing this right...

20 Oct at 04:8

How to measure time taken by a function to execute

I need to get execution time in milliseconds. > I originally asked this question back in 2008. The accepted answer then was to use [new Date().getTime()](https://developer.mozilla.org/en-US/docs/Web/J...

22 Jul at 08:35

How to get the difference between two arrays in JavaScript?

Is there a way to return the difference between two arrays in JavaScript? For example: ``` var a1 = ['a', 'b']; var a2 = ['a', 'b', 'c', 'd']; // need ["c", "d"] ```

15 Aug at 18:57

How can I access my localhost from my Android device?

I'm able to access my laptop web server using the Android emulator, I'm using `10.0.2.2:portno` works well. But when I connect my real Android phone, the phone browser can't connect to the same web s...

3 Jul at 01:55

LINQ Orderby Descending Query

I have a LINQ query that I want to order by the most recently created date. I tried: ``` var itemList = from t in ctn.Items where !t.Items && t.DeliverySelection ...

30 May at 14:0

curl: (60) SSL certificate problem: unable to get local issuer certificate

``` root@sclrdev:/home/sclr/certs/FreshCerts# curl --ftp-ssl --verbose ftp://{abc}/ -u trup:trup --cacert /etc/ssl/certs/ca-certificates.crt * About to connect() to {abc} port 21 (#0) * Trying {abc}...

How to calculate the difference between two dates using PHP?

I have two dates of the form: ``` Start Date: 2007-03-24 End Date: 2009-06-26 ``` Now I need to find the difference between these two in the following form: ``` 2 years, 3 months and 2 days ``` ...

22 Mar at 16:23