Questions

Why does changing 0.1f to 0 slow down performance by 10x?

Why does this bit of code, ``` const float x[16] = { 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6}; const flo...

Calculate relative time in C#

Given a specific `DateTime` value, how do I display relative time, like: - `2 hours ago`- `3 days ago`- `a month ago`

<meta charset="utf-8"> vs <meta http-equiv="Content-Type">

In order to define charset for , which notation should I use? 1. Short: <meta charset="utf-8" /> 2. Long: <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

30 Oct at 09:10

Creating a div element in jQuery

How do I create a `div` element in ?

How do I profile a Python script?

[Project Euler](http://en.wikipedia.org/wiki/Project_Euler) and other coding contests often have a maximum time to run or people boast of how fast their particular solution runs. With Python, sometime...

How do I get time of a Python program's execution?

I have a command line program in Python that takes a while to finish. I want to know the exact time it takes to finish running. I've looked at the `timeit` module, but it seems it's only for small sn...

8 Jun at 19:42

Why is it important to override GetHashCode when Equals method is overridden?

Given the following class ``` public class Foo { public int FooId { get; set; } public string FooName { get; set; } public override bool Equals(object obj) { Foo fooItem = ob...

4 Jul at 15:37

How can I vertically center a div element for all browsers using CSS?

I want to center a `div` vertically with CSS. I don't want tables or JavaScript, but only pure CSS. I found some solutions, but all of them are missing Internet Explorer 6 support. ``` <body> <div...

How to fully delete a git repository created with init?

I created a git repository with `git init`. I'd like to delete it entirely and init a new one.

13 Sep at 22:48

Save plot to image file instead of displaying it using Matplotlib

This displays the figure in a GUI: ``` import matplotlib.pyplot as plt plt.plot([1, 2, 3], [1, 4, 9]) plt.show() ``` But how do I instead save the figure to a file (e.g. foo.png)?

25 Aug at 03:36

Get size of all tables in database

I have inherited a fairly large SQL Server database. It seems to take up more space than I would expect, given the data it contains. Is there an easy way to determine how much space on disk each tabl...

29 Jul at 21:14

Try-catch speeding up my code?

I wrote some code for testing the impact of try-catch, but seeing some surprising results. ``` static void Main(string[] args) { Thread.CurrentThread.Priority = ThreadPriority.Highest; Proces...

Hard reset of a single file

How do I discard the changes to a single file and overwrite it with a fresh HEAD copy? I want to do `git reset --hard` to only a single file.

25 Jul at 04:17

Why do we need virtual functions in C++?

I'm learning C++ and I'm just getting into virtual functions. From what I've read (in the book and online), virtual functions are functions in the base class that you can override in derived classes. ...

3 Sep at 16:18

Using Auto Layout in UITableView for dynamic cell layouts & variable row heights

How do you use Auto Layout within `UITableViewCell`s in a table view to let each cell's content and subviews determine the row height (itself/automatically), while maintaining smooth scrolling perform...

How do I style a <select> dropdown with only CSS?

Is there a CSS-only way to style a `<select>` dropdown? I need to style a `<select>` form as much as humanly possible, without any JavaScript. What are the properties I can use to do so in CSS? This...

How do I migrate an SVN repository with history to a new Git repository?

I read the Git manual, FAQ, Git - SVN crash course, etc. and they all explain this and that, but nowhere can you find a simple instruction like: SVN repository in: `svn://myserver/path/to/svn/repos` ...

7 Dec at 14:40

Compiling an application for use in highly radioactive environments

We are compiling an embedded C++ application that is deployed in a shielded device in an environment bombarded with [ionizing radiation](https://en.wikipedia.org/wiki/Ionizing_radiation). We are using...

24 Nov at 14:7

Fastest way to determine if an integer's square root is an integer

I'm looking for the fastest way to determine if a `long` value is a perfect square (i.e. its square root is another integer): 1. I've done it the easy way, by using the built-in Math.sqrt() functio...

What is the Python 3 equivalent of "python -m SimpleHTTPServer"

What is the Python 3 equivalent of `python -m SimpleHTTPServer`?

When should I use a struct rather than a class in C#?

When should you use struct and not class in C#? My conceptual model is that structs are used in times when the item is . A way to logically hold them all together into a cohesive whole. I came acros...

4 Jun at 09:17

Cycles in family tree software

I am the developer of some family tree software (written in C++ and Qt). I had no problems until one of my customers mailed me a bug report. The problem is that the customer has two children with thei...

13 Aug at 23:13

How do you convert a byte array to a hexadecimal string, and vice versa?

How can you convert a byte array to a hexadecimal string and vice versa?

9 Sep at 09:20

Use different Python version with virtualenv

How do I create a virtual environment for a specified version of Python?

20 Jun at 06:33

How do I remove a directory from a Git repository?

How can I delete a single directory containing files from a Git repository?

6 Sep at 16:58