Questions

New to unit testing, how to write great tests?

I'm fairly new to the unit testing world, and I just decided to add test coverage for my existing app this week. This is a huge task, mostly because of the number of classes to test but also because ...

15 Jul at 19:26

How to place div side by side

I have a main wrapper div that is set 100% width. Inside that i would like to have two divs, one that is fixed width and the other that fills the rest of the space. How do i float the second div to fi...

14 Apr at 13:28

Android 1.6: "android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application"

I'm trying to open a dialog window, but every time I try to open it it throws this exception: ``` Uncaught handler: thread main exiting due to uncaught exception android.view.WindowManager$BadTokenEx...

How to deal with page breaks when printing a large HTML table

I have a project which requires printing an HTML table with many rows. My problem is the way the table is printed over multiple page. It will sometimes cut a row in half, making it unreadable because...

22 Jun at 19:37

fastest MD5 Implementation in JavaScript

There are many MD5 JavaScript implementations out there. Does anybody know which one is the most advanced, most bugfixed and fastest? I need it for [this](http://www.bruechner.de/md5file/js/) tool....

22 Jul at 20:36

Why is Spring's ApplicationContext.getBean considered bad?

I asked a general Spring question: [Auto-cast Spring Beans](https://stackoverflow.com/questions/812178/auto-cast-spring-beans) and had multiple people respond that calling Spring's `ApplicationContext...

23 May at 12:26

How should I log while using multiprocessing in Python?

Right now I have a central module in a framework that spawns multiple processes using the Python 2.6 [multiprocessing module](http://docs.python.org/library/multiprocessing.html?#module-multiprocessin...

9 Jun at 13:8

Jump to function definition

How can I jump to a function definition using Vim? For example with Visual Assist, I can type + under a function and it opens a context menu listing the files with definitions. How can I do something ...

7 Jun at 11:35

Select unique or distinct values from a list in UNIX shell script

I have a ksh script that returns a long list of values, newline separated, and I want to see only the unique/distinct values. It is possible to do this? For example, say my output is file suffixes in...

6 Mar at 10:33

How do I dump an object's fields to the console?

When I'm running a simple Ruby script, what's the easiest way to dump an object's fields to the console? I'm looking for something similar to PHP's `print_r()` that will work with arrays as well.

9 Dec at 08:13

Does using "new" on a struct allocate it on the heap or stack?

When you create an instance of a class with the `new` operator, memory gets allocated on the heap. When you create an instance of a struct with the `new` operator where does the memory get allocated, ...

22 Jan at 04:43

How much faster is C++ than C#?

Or is it now the other way around? From what I've heard there are some areas in which C# proves to be faster than C++, but I've never had the guts to test it by myself. Thought any of you could expl...

9 Oct at 13:40

How can I detect the encoding/codepage of a text file?

In our application, we receive text files (`.txt`, `.csv`, etc.) from diverse sources. When reading, these files sometimes contain garbage, because the files where created in a different/unknown codep...

26 Aug at 19:59

Best Tips for documenting code using doxygen?

My team is starting to document our C code using doxygen, paying particular attention to our public API headers. There appears to be a lot of flexibility and different special commands in doxygen, wh...

6 Jun at 22:2

How do you create a static class in C++?

How do you create a static class in C++? I should be able to do something like: ``` cout << "bit 5 is " << BitParser::getBitAt(buffer, 5) << endl; ``` Assuming I created the `BitParser` class. What...

13 Mar at 17:17

How to print the value of a Tensor object in TensorFlow?

I have been using the introductory example of matrix multiplication in TensorFlow. ``` matrix1 = tf.constant([[3., 3.]]) matrix2 = tf.constant([[2.],[2.]]) product = tf.matmul(matrix1, matrix2) ``` ...

21 May at 12:2

React proptype array with shape

Is there a built-in way to use proptypes to ensure that an array of objects being passed to a component is actually an array of objects of a specific shape? Maybe something like this? ``` annotation...

5 Nov at 21:22

How to get http headers in flask?

Using Flask, how can I read HTTP headers? I want to check the authorization header which is sent by the client.

How to access a child's state in React

I have the following structure: `FormEditor` - holds multiple instances of FieldEditor `FieldEditor` - edits a field of the form and saving various values about it in its state When a button is clicke...

24 May at 16:52

Changing navigation bar color in Swift

I am using a Picker View to allow the user to choose the colour theme for the entire app. I am planning on changing the colour of the navigation bar, background and possibly the tab bar (if that is p...

7 Jan at 00:48

How to print pandas DataFrame without index

I want to print the whole dataframe, but I don't want to print the index Besides, one column is datetime type, I just want to print time, not date. The dataframe looks like: ``` User ID E...

9 Aug at 10:33

How to process SIGTERM signal gracefully?

Let's assume we have such a trivial daemon written in python: ``` def mainloop(): while True: # 1. do # 2. some # 3. important # 4. job # 5. sleep mainloo...

Storing JSON in database vs. having a new column for each key

I am implementing the following model for storing user related data in my table - I have 2 columns - `uid` (primary key) and a `meta` column which stores other data about the user in JSON format. `...

SQL Server principal "dbo" does not exist,

I am getting the following error ``` Cannot execute as the database principal because the principal "dbo" does not exist, this type of principal cannot be impersonated, or you do not have permission...

11 Dec at 15:43

Quickest way to compare two generic lists for differences

What is the quickest (and least resource intensive) to compare two massive (>50.000 items) and as a result have two lists like the ones below: 1. items that show up in the first list but not in the ...

19 Aug at 19:44