rand() between 0 and 1
So the following code makes 0 < r < 1 ``` r = ((double) rand() / (RAND_MAX)) ``` Why does having `r = ((double) rand() / (RAND_MAX + 1))` make -1 < r < 0? Shouldn't adding one to RAND_MAX make 1...
What is difference between 'git reset --hard HEAD~1' and 'git reset --soft HEAD~1'?
I tried to undo my commit in git. Is it dangerous to use `git reset --hard HEAD~1`? What is the difference between different options for `git reset`?
SQL Server Installation - What is the Installation Media Folder?
I am installing SQL Server 2008. I have installed .NET framework 3.5. Then I got folder SQL Server 2008 and performed following steps- 1. I clicked configuration Tools. 2. Then I clicked SQL Server...
- Modified
- 23 Mar at 22:29
Best way to compare two complex objects
I have two complex objects like `Object1` and `Object2`. I need the fastest method to say if they are same or not. How could this be done in C# 4.0?
How do you create a daemon in Python?
[Searching on Google](http://www.google.co.uk/search?q=python+daemon) reveals x2 code snippets. The first result is to [this code recipe](http://code.activestate.com/recipes/278731/) which has a lot o...
What are the lengths of Location Coordinates, latitude and longitude?
How many digits can latitude and longitude have, before the decimal, and after the decimal? Here is an example I am getting from the location sent by a Windows Phone device: ``` Latitude=-635723752901...
- Modified
- 30 Jan at 21:1
Border for an Image view in Android?
How can I set a border for an `ImageView` and change its color in Android?
What is the difference between a "line feed" and a "carriage return"?
If there are two keywords then they must have their own meanings. So I want to know what makes them different and what their code is.
- Modified
- 21 Oct at 10:45
SonarQube Exclude a directory
I am trying to exclude a directory from being analyzed by Sonar. I have the following properties defined in my `sonar-project.properties` file: ``` sonar.sources=src/java sonar.exclusions=src/java/te...
- Modified
- 13 Oct at 18:58
What is the Java equivalent for LINQ?
What is Java equivalent for LINQ?
Repeat command automatically in Linux
Is it possible in Linux command line to have a command repeat every seconds? Say, I have an import running, and I am doing ``` ls -l ``` to check if the file size is increasing. I would like to h...
Android: set view style programmatically
Here's XML: ``` <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" style="@style/LightStyle" android:layout_width="fill_parent" android:layout_height="55dip" ...
- Modified
- 27 Mar at 19:13
Hide/Show Column in a HTML Table
I have an HTML table with several columns and I need to implement a column chooser using jQuery. When a user clicks on a checkbox I want to hide/show the corresponding column in the table. I would l...
- Modified
- 3 Apr at 04:1
Display curl output in readable JSON format in Unix shell script
In my Unix shell script, when I execute a curl command, the result will be displayed as below which I am redirecting to file: ``` {"type":"Show","id":"123","title":"name","description":"Funny","chann...
How do I find the text within a div in the source of a web page using C#
How can I get the `HTML` code from a website, save it, and find some text by using a `LINQ` expression? I'm using the following code to get the source of a web page: ``` public static String code(stri...
Difference between Select Unique and Select Distinct
I thought these were synonomous, but I wrote the following in Microsoft SQL: ``` Select Unique col from (select col from table1 union select col from table2) alias ``` And it failed. Changin...
- Modified
- 27 Oct at 15:17
Rails migration for change column
We have `script/generate migration add_fieldname_to_tablename fieldname:datatype` syntax for adding new columns to a model. On the same line, do we have a script/generate for changing the datatype of...
- Modified
- 28 Oct at 06:26
Accessing nested JavaScript objects and arrays by string path
I have a data structure like this : ``` var someObject = { 'part1' : { 'name': 'Part 1', 'size': '20', 'qty' : '50' }, 'part2' : { 'name': 'Part 2', ...
- Modified
- 9 Mar at 11:18
error TS2339: Property 'x' does not exist on type 'Y'
I don't understand why this code generates a TypeScript error. (It's not the original code and is a bit derived, so please ignore the non-sense in the example): ``` interface Images { [key:string]: ...
- Modified
- 9 Feb at 19:59
Rendering React Components from Array of Objects
I have some data called stations which is an array containing objects. ``` stations : [ {call:'station one',frequency:'000'}, {call:'station two',frequency:'001'} ] ``` I'd like to render a ui ...
- Modified
- 4 Jul at 00:41
LINQ Using Max() to select a single row
I'm using LINQ on an IQueryable returned from NHibernate and I need to select the row with the maximum value(s) in a couple of fields. I've simplified the bit that I'm sticking on. I need to select ...
What's a good IDE for Python on Mac OS X?
I'm about to start a new job where the coding practices are heavily centered around TDD and refactoring, and whose primary development language is Python. I come from the Java world, and have been a ...
Cross-reference (named anchor) in markdown
Is there syntax for the equivalent of: ``` Take me to <a href="#pookie">pookie</a> ... <a name="pookie">this is pookie</a> ```
"Large data" workflows using pandas
I have tried to puzzle out an answer to this question for many months while learning pandas. I use SAS for my day-to-day work and it is great for it's out-of-core support. However, SAS is horrible a...
- Modified
- 7 Dec at 19:53
How do I set hostname in docker-compose?
In my `docker-compose.yml` file, I have the following. However the container does not pick up the hostname value. Any ideas? ``` dns: image: phensley/docker-dns hostname: affy domainname: affy.c...
- Modified
- 29 Jan at 18:55