Questions

Remove all child elements of a DOM node in JavaScript

How would I go about removing all of the child elements of a DOM node in JavaScript? Say I have the following (ugly) HTML: ``` <p id="foo"> <span>hello</span> <div>world</div> </p> ``` And I ...

7 Feb at 17:47

How to make a class JSON serializable

How to make a Python class serializable? ``` class FileItem: def __init__(self, fname): self.fname = fname ``` Attempt to serialize to JSON: ``` >>> import json >>> x = FileItem('/foo/bar...

9 Apr at 10:18

If Python is interpreted, what are .pyc files?

Python is an interpreted language. But why does my source directory contain `.pyc` files, which are identified by Windows as "Compiled Python Files"?

jQuery get specific option tag text

All right, say I have this: ``` <select id='list'> <option value='1'>Option A</option> <option value='2'>Option B</option> <option value='3'>Option C</option> </select> ``` What would t...

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 overlay one div over another div

I need assistance with overlaying one individual `div` over another individual `div`. My code looks like this: ``` <div class="navi"></div> <div id="infoi"> <img src="info_icon2.png" height="20"...

15 Jul at 23:35

Retrieving the last record in each group - MySQL

There is a table `messages` that contains data as shown below: ``` Id Name Other_Columns ------------------------- 1 A A_data_1 2 A A_data_2 3 A A_data_3 4 B B...

How to get current time and date in Android

How can I get the current time and date in an Android app?

17 Jan at 22:43

What is a race condition?

When writing multithreaded applications, one of the most common problems experienced is race conditions. My questions to the community are: - - - -

Remove a git commit which has not been pushed

I did a `git commit` but I have not pushed it to the repository yet. So when I do `git status`, I get '# Your branch is ahead of 'master' by 1 commit. So if I want to roll back my top commit, can I j...

8 Mar at 18:54

How do I check if a string contains another string in Objective-C?

How can I check if a string (`NSString`) contains another smaller string? I was hoping for something like: ``` NSString *string = @"hello bla bla"; NSLog(@"%d",[string containsSubstring:@"hello"]); ...

14 Nov at 11:32

Git push rejected after feature branch rebase

OK, I thought this was a simple git scenario, what am I missing? I have a `master` branch and a `feature` branch. I do some work on `master`, some on `feature`, and then some more on `master`. I end ...

10 Dec at 13:8

Call one constructor from another

I have two constructors which feed values to readonly fields. ``` public class Sample { public Sample(string theIntAsString) { int i = int.Parse(theIntAsString); _intField = i...

20 Aug at 18:13

How to get the ASCII value of a character

How do I get the [ASCII](http://en.wikipedia.org/wiki/ASCII) value of a character as an `int` in Python?

9 Apr at 09:49

Negative matching using grep (match lines that do not contain foo)

How do I match all lines not matching a particular pattern using `grep`? I tried this: ``` grep '[^foo]' ```

14 Aug at 23:56

CSS selector for first element with class

I have a bunch of elements with a class name `red`, but I can't seem to select the first element with the `class="red"` using the following CSS rule: ``` .home .red:first-child { border: 1px solid...

13 Mar at 14:2

How do I use reflection to call a generic method?

What's the best way to call a generic method when the type parameter isn't known at compile time, but instead is obtained dynamically at runtime? Consider the following sample code - inside the `Exam...

11 Dec at 12:22

What's the difference between implementation, api and compile in Gradle?

After updating to Android Studio 3.0 and creating a new project, I noticed that in `build.gradle` there is a new way to add new dependencies instead of `compile` there is `implementation` and instead ...

How does Python's super() work with multiple inheritance?

How does `super()` work with multiple inheritance? For example, given: ``` class First(object): def __init__(self): print "first" class Second(object): def __init__(self): pri...

17 Apr at 02:0

Sort ArrayList of custom Objects by property

I read about sorting ArrayLists using a Comparator but in all of the examples people used `compareTo` which according to some research is a method for Strings. I wanted to sort an ArrayList of custom...

27 Jan at 17:18

How to overcome "datetime.datetime not JSON serializable"?

I have a basic dict as follows: ``` sample = {} sample['title'] = "String" sample['somedate'] = somedatetimehere ``` When I try to do `jsonify(sample)` I get: ``` TypeError: datetime.datetime(2012...

23 May at 07:15

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

Filename too long in Git for Windows

I'm using `Git-1.9.0-preview20140217` for Windows. As I know, this release should fix the issue with too long filenames. But not for me. Surely I'm doing something wrong: I did `git config core.longpa...

8 Apr at 07:22

Group by in LINQ

Let's suppose if we have a class like: ``` class Person { internal int PersonID; internal string car; } ``` I have a list of this class: `List<Person> persons;` And this list can have m...

11 Jun at 08:49

How do I encode and decode a base64 string?

1. How do I return a base64 encoded string given a string? 2. How do I decode a base64 encoded string into a string?

31 Jul at 15:6