What's an appropriate HTTP status code to return by a REST API service for a validation failure?
I'm currently returning 401 Unauthorized whenever I encounter a validation failure in my [Django](http://djangoproject.com/)/[Piston](https://bitbucket.org/jespern/django-piston/wiki/Home) based REST ...
- Modified
- 16 Dec at 02:58
What is the string length of a GUID?
I want to create a varchar column in SQL that should contain `N'guid'` while `guid` is a generated GUID by .NET ([Guid.NewGuid](https://learn.microsoft.com/en-us/dotnet/api/system.guid.newguid)) - cla...
- Modified
- 21 Mar at 15:7
jQuery get the rendered height of an element?
How do you get the rendered height of an element? Let's say you have a `<div>` element with some content inside. This content inside is going to stretch the height of the `<div>`. How do you get the ...
Split List into Sublists with LINQ
Is there any way I can separate a `List<SomeObject>` into several separate lists of `SomeObject`, using the item index as the delimiter of each split? Let me exemplify: I have a `List<SomeObject>` a...
- Modified
- 17 Mar at 17:38
Python's time.clock() vs. time.time() accuracy?
Which is better to use for timing in Python? time.clock() or time.time()? Which one provides more accuracy? for example: ``` start = time.clock() ... do something elapsed = (time.clock() - start) ``...
What does "SyntaxError: Missing parentheses in call to 'print'" mean in Python?
When I try to use a `print` statement in Python, it gives me this error: ``` >>> print "Hello, World!" File "<stdin>", line 1 print "Hello, World!" ^ SyntaxError: Missin...
- Modified
- 5 Jun at 16:27
AngularJS 1.2 $injector:modulerr
When using angular 1.2 instead of 1.07 the following piece of code is not valid anymore, why? ``` 'use strict'; var app = angular.module('myapp', []); app.config(['$routeProvider', '$locationProvid...
- Modified
- 17 Aug at 09:56
How to sort a List/ArrayList?
I have a List of doubles in java and I want to sort ArrayList in descending order. Input ArrayList is as below: ``` List<Double> testList = new ArrayList(); testList.add(0.5); testList.add(0.2); te...
- Modified
- 1 Feb at 00:5
How to respond with an HTTP 400 error in a Spring MVC @ResponseBody method returning String
I'm using Spring MVC for a simple JSON API, with `@ResponseBody` based approach like the following. (I already have a service layer producing JSON directly.) ``` @RequestMapping(value = "/matches/{mat...
- Modified
- 19 Jun at 12:3
How to override trait function and call it from the overridden function?
Scenario: ``` trait A { function calc($v) { return $v+1; } } class MyClass { use A; function calc($v) { $v++; return A::calc($v); } } print (new MyClass...
Add new field to every document in a MongoDB collection
How can I add a new field to every document in an existent collection? I know how to update an existing document's field but not how to add a new field to every document in a collection. How can I do...
How to set a default value for an existing column
This isn't working in SQL Server 2008: ``` ALTER TABLE Employee ALTER COLUMN CityBorn SET DEFAULT 'SANDNES' ``` The error is: > Incorrect syntax near the keyword 'SET'. What am I doing wrong?
- Modified
- 19 May at 08:51
What is the purpose of a plus symbol before a variable?
What does the `+d` in ``` function addMonths(d, n, keepTime) { if (+d) { ``` mean?
- Modified
- 9 Jan at 15:57
Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (38)
I am having a big problem trying to connect to mysql. When I run: ``` /usr/local/mysql/bin/mysql start ``` I have the following error : ``` Can't connect to local MySQL server through socket '/var...
- Modified
- 27 Jun at 15:18
UIView with rounded corners and drop shadow?
I’ve been working on an application for a couple of years and received a simple design request: Round the corners on a UIView and add a drop shadow.To do as given below. I want a custom `UIView`... : ...
- Modified
- 10 Sep at 16:11
Are querystring parameters secure in HTTPS (HTTP + SSL)?
Do querystring parameters get encrypted in HTTPS when sent with a request?
How can I beautify JSON programmatically?
Do you know of any "JSON Beautifier" for JavaScript? ``` {"name":"Steve","surname":"Jobs","company":"Apple"} ``` ``` { "name" : "Steve", "surname" : "Jobs", "company" : "Apple" } ``` ``` so...
- Modified
- 8 May at 15:16
SQL join: selecting the last records in a one-to-many relationship
Suppose I have a table of customers and a table of purchases. Each purchase belongs to one customer. I want to get a list of all customers along with their last purchase in one `SELECT` statement. Wha...
- Modified
- 14 Dec at 17:47
Is there any way I can define a variable in LaTeX?
In LaTeX, how can I define a string variable whose content is used instead of the variable in the compiled PDF? Let's say I'm writing a tech doc on a software and I want to define the package name in...
How to print out the method name and line number and conditionally disable NSLog?
I'm doing a presentation on debugging in Xcode and would like to get more information on using NSLog efficiently. In particular, I have two questions: - -
- Modified
- 13 Feb at 18:27
Does a foreign key automatically create an index?
I've been told that if I foreign key two tables, that SQL Server will create something akin to an index in the child table. I have a hard time believing this to be true, but can't find much out there...
- Modified
- 15 Mar at 18:19
Select all columns except one in MySQL?
I'm trying to use a select statement to get all of the columns from a certain MySQL table except one. Is there a simple way to do this? EDIT: There are 53 columns in this table (NOT MY DESIGN)
How do you format an unsigned long long int using printf?
``` #include <stdio.h> int main() { unsigned long long int num = 285212672; //FYI: fits in 29 bits int normalInt = 5; printf("My number is %d bytes wide and its value is %ul. A normal numb...
- Modified
- 14 Sep at 02:32
Find the similarity metric between two strings
How do I get the probability of a string being similar to another string in Python? I want to get a decimal value like 0.9 (meaning 90%) etc. Preferably with standard Python and library. e.g. ``` s...
- Modified
- 26 Apr at 00:59