Questions

How can I get current date in Android?

I wrote the following code ``` Date d = new Date(); CharSequence s = DateFormat.format("MMMM d, yyyy ", d.getTime()); ``` I want the current date in string format, like ``` 28-Dec-2011 ``` so that ...

How to create a date object from string in javascript

Having this string `30/11/2011`. I want to convert it to date object. Do I need to use : ``` Date d = new Date(2011,11,30); /* months 1..12? */ ``` or ``` Date d = new Date(2011,10,30); /...

15 Feb at 14:14

What is "pom" packaging in maven?

I was given a maven project to compile and get deployed on a tomcat server. I have never used maven before today, but I have been googling quite a bit. It seems like the top level `pom.xml` files in t...

27 Jan at 01:32

C++ auto keyword. Why is it magic?

From all the material I used to learn C++, `auto` has always been a weird storage duration specifier that didn't serve any purpose. But just recently, I encountered code that used it as a type name i...

3 May at 20:37

Setting background colour of Android layout element

I am trying to, somewhat clone the design of an activity [from a set of slides on Android UI design](https://docs.google.com/present/view?id=0AfYilHnGmJNGZGZwNnZ4dm5fNDdkY3o2M3Bqag&hl=en_GB). However ...

Configuring diff tool with .gitconfig

How do I configure Git to use a different tool for diffing with the .gitconfig file? I have this in my .gitconfig: ``` [diff] tool = git-chdiff #also tried /bin/git-chdiff ``` It does not work...

20 Jul at 23:26

Parse JSON String into a Particular Object Prototype in JavaScript

I know how to parse a JSON String and turn it into a JavaScript Object. You can use `JSON.parse()` in modern browsers (and IE9+). That's great, but how can I take that JavaScript Object and turn it...

Retrieve list of tasks in a queue in Celery

How can I retrieve a list of tasks in a queue that are yet to be processed?

4 Apr at 21:35

Right query to get the current number of connections in a PostgreSQL DB

Which of the following two is more accurate? ``` select numbackends from pg_stat_database; select count(*) from pg_stat_activity; ```

28 Mar at 09:32

Access to the path is denied when saving image

I'm trying to save an image to a folder in .NET C# but I get this exception: ``` Access to the path 'C:\inetpub\wwwroot\mysite\images\savehere' is denied.The error occured at mscorlib because at Sy...

10 Feb at 09:26

SQL Query to concatenate column values from multiple rows in Oracle

Would it be possible to construct SQL to concatenate column values from multiple rows? The following is an example: Table A Table B Output of the SQL should be - So basically the Desc col...

7 Oct at 05:1

Visual Studio - Resx File default 'internal' to 'public'

Every time I edit a resource file in VS, it regenerates the corresponding code and sets the class access modifier to internal. It's a pain to Ctrl-F -> ReplaceAll every time I edit the resx. Is there ...

Static implicit operator

I recently found this code: ``` public static implicit operator XElement(XmlBase xmlBase) { return xmlBase.Xml; } ``` What does `static implicit operator` mean?

23 Dec at 16:31

TypeError: 'NoneType' object is not iterable in Python

What does `TypeError: 'NoneType' object is not iterable` mean? Example: ``` for row in data: # Gives TypeError! print(row) ```

6 Jun at 00:7

How to get a resource id with a known resource name?

I want to access a resource like a String or a Drawable by its name and not its int id. Which method would I use for this?

23 May at 16:47

Java code To convert byte to Hexadecimal

I have an array of bytes. I want each byte String of that array to be converted to its corresponding hexadecimal values. Is there any function in Java to convert a byte array to Hexadecimal ?

13 Jan at 04:31

How can I change UIButton title color?

I create a button programmatically.......... ``` button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [button addTarget:self action:@selector(aMethod:) forControlEvents:UIControlEventTouchDown...

18 Feb at 15:1

Unit Testing: DateTime.Now

I have some unit tests that expects the 'current time' to be different than DateTime.Now and I don't want to change the computer's time, obviously. What's the best strategy to achieve this?

How to disable logging on the standard error stream?

How to disable [logging](http://docs.python.org/library/logging.html) on the standard error stream in Python? This does not work: ``` import logging logger = logging.getLogger() logger.removeHandler(...

7 Jul at 13:57

How can I efficiently parse HTML with Java?

I do a lot of HTML parsing in my line of work. Up until now, I was using the HtmlUnit headless browser for parsing and browser automation. Now, I want to separate both the tasks. I want to use a light...

How can I account for period (AM/PM) using strftime?

Specifically I have code that simplifies to this: ``` from datetime import datetime date_string = '2009-11-29 03:17 PM' format = '%Y-%m-%d %H:%M %p' my_date = datetime.strptime(date_string, format) ...

26 Dec at 18:54

Cannot use ref or out parameter in lambda expressions

Why can't you use a ref or out parameter in a lambda expression? I came across the error today and found a workaround but I was still curious why this is a compile-time error. > [CS1628](https://lea...

21 Mar at 14:25

What is a word boundary in regex?

I'm trying to use regexes to match space-separated numbers. I can't find a precise definition of `\b` ("word boundary"). I had assumed that `-12` would be an "integer word" (matched by `\b\-?\d+\b`) ...

6 Oct at 07:10

Counting null and non-null values in a single query

I have a table ``` create table us ( a number ); ``` Now I have data like: ``` a 1 2 3 4 null null null 8 9 ``` Now I need a single query to count null not null values in column a

13 Aug at 13:28

How do I calculate the normal vector of a line segment?

Suppose I have a line segment going from (x1,y1) to (x2,y2). How do I calculate the normal vector perpendicular to the line? I can find lots of stuff about doing this for planes in 3D, but no 2D stuf...

7 Aug at 08:35