Questions

How to iterate over a JSONObject?

I use a JSON library called `JSONObject` (I don't mind switching if I need to). I know how to iterate over `JSONArrays`, but when I parse JSON data from Facebook I don't get an array, only a `JSONOb...

10 Aug at 19:10

psql - save results of command to a file

I'm using psql's `\dt` to list all tables in a database and I need to save the results. What is the syntax to export the results of a psql command to a file?

8 Jun at 23:50

Getting the SQL from a Django QuerySet

How do I get the SQL that Django will use on the database from a QuerySet object? I'm trying to debug some strange behavior, but I'm not sure what queries are going to the database.

21 Apr at 23:10

Set size on background image with CSS?

Is it possible to set the size of the background image with CSS? I want to do something like: ``` background: url('bg.gif') top repeat-y; background-size: 490px; ``` But it seems it's totally wron...

5 May at 12:32

Eclipse - Unable to install breakpoint due to missing line number attributes

I am getting this strange error in Eclipse while trying to set a breakpoint. ``` Unable to insert breakpoint Absent Line Number Information ``` I ticked the checkbox from Compiler options but no lu...

20 Sep at 14:4

Best XML parser for Java

I need to read smallish (few MB at the most, UTF-8 encoded) XML files, rummage around looking at various elements and attributes, perhaps modify a few and write the XML back out again to disk (prefera...

26 Oct at 03:22

How do I run a simple bit of code in a new thread?

I have a bit of code that I need to run in a different thread than the GUI as it currently causes the form to freeze whilst the code runs (10 seconds or so). Assume I have never created a new thread...

4 Apr at 14:41

Is there a better alternative than this to 'switch on type'?

Seeing as C# can't `switch` on a Type (which I gather wasn't added as a special case because `is` relationships mean that more than one distinct `case` might apply), is there a better way to simulate ...

16 Sep at 18:8

ReactJs: What should the PropTypes be for this.props.children?

Given a simple component that renders its children: ``` class ContainerComponent extends Component { static propTypes = { children: PropTypes.object.isRequired, } render() { return ( ...

8 Feb at 20:14

How can I export settings?

How is it possible to export all Visual Studio Code settings and plugins and import them to another machine?

5 Aug at 14:26

New lines inside paragraph in README.md

When editing an issue and clicking Preview the following markdown source: ``` a b c ``` shows every letter on a new line. However, it seems to me that pushing similar markdown source structure in ...

Using logging in multiple modules

I have a small python project that has the following structure - ``` Project -- pkg01 -- test01.py -- pkg02 -- test02.py -- logging.conf ``` I plan to use the default logging module to p...

14 Feb at 19:37

Get div height with plain JavaScript

Any ideas on how to get a div's height without using jQuery? I was searching Stack Overflow for this question and it seems like every answer is pointing to jQuery's `.height()`. I tried something like...

30 Dec at 20:43

Installed Java 7 on Mac OS X but Terminal is still using version 6

I've installed JDK 7u7 downloaded from oracle's website. But after installation, the terminal is still showing java version 6 ``` $java -version java version "1.6.0_35" Java(TM) SE Runtime Environmen...

17 Dec at 02:44

How do I define a function with optional arguments?

I have a Python function which takes several arguments. Some of these arguments could be omitted in some scenarios. ``` def some_function (self, a, b, c, d = None, e = None, f = None, g = None, h = N...

Unit testing private methods in C#

Visual Studio allows unit testing of private methods via an automatically generated accessor class. I have written a test of a private method that compiles successfully, but it fails at runtime. A fai...

9 Dec at 05:47

What is the most efficient way to loop through dataframes with pandas?

I want to perform my own complex operations on financial data in dataframes in a sequential manner. For example I am using the following MSFT CSV file taken from [Yahoo Finance](http://finance.yahoo....

What's the difference between CharField and TextField in Django?

The [documentation](https://docs.djangoproject.com/en/1.10/ref/models/fields/#django.db.models.CharField) says that `CharField()` should be used for smaller strings and `TextField()` should be used fo...

4 Oct at 13:17

Scala list concatenation, ::: vs ++

Is there any difference between `:::` and `++` for concatenating lists in Scala? ``` scala> List(1,2,3) ++ List(4,5) res0: List[Int] = List(1, 2, 3, 4, 5) scala> List(1,2,3) ::: List(4,5) res1: List...

1 May at 08:24

Folder structure for a Node.js project

I notice that Node.js projects often include folders like these: > /libs, /vendor, /support, /spec, /tests What exactly do these mean? What's the different between them, and where should I include r...

29 Dec at 10:35

How to represent multiple conditions in a shell if statement?

I want to represent multiple conditions like this: ``` if [ ( $g -eq 1 -a "$c" = "123" ) -o ( $g -eq 2 -a "$c" = "456" ) ] then echo abc; else echo efg; fi ``` but when I execute ...

26 Jan at 19:12

Tooltips for Button elements

Is it possible to create a tooltip for an html button. Its the normal HTML button and there is no Title attribute as it is there for some html controls. Any thoughts or comments?

9 Mar at 22:18

Best way to do multiple constructors in PHP

You can't put two __construct functions with unique argument signatures in a PHP class. I'd like to do this: ``` class Student { protected $id; protected $name; // etc. public function ...

Using str_replace so that it only acts on the first match?

I want a version of `str_replace()` that only replaces the first occurrence of `$search` in the `$subject`. Is there an easy solution to this, or do I need a hacky solution?

7 May at 15:51

Can't operator == be applied to generic types in C#?

According to the documentation of the `==` operator in [MSDN](http://msdn.microsoft.com/en-us/library/53k8ybth.aspx), > For predefined value types, the equality operator (==) returns true if the...