Skip to content

Instantly share code, notes, and snippets.

function(response, status, xhr) {
if (checkResponse(xhr) === 'json') {
// call error handler
if (response.success !== true) {
that.get('errorHandler').check(response);
}
// check whether there is a message
/* non-form JSON request success, no error no data / TODO: Dont show anything */
{
status: 0,
data: {}
}
/* non-form JSON request success, has data, no error / TODO: Show the data */
{
status: 0,
data: {
@irfan
irfan / working with wrong json format
Created November 28, 2012 14:22
wrong data structure is wrong
/*
* data structure:
* { status: 0, data:{}}
* { status: 0, data:{}, message: "you did something" }
* { status: 1, data:{}, message: "you did something" }
* { status: 1, data:{}}
* { status: 2, data:{response:{data:{form:{global:'something going wrong'}}}}}
* { status: 2, data:{response:{data:{form:{global:'error'}}}}, message: "you did something" }
* { status: 2, data:{response:{data:{form:{global:'error'}}}}, message: "you did something" }
* { status: 2, data:{response:{data:{form:{global:'error'}}}}, message: "you did something" }
@irfan
irfan / gist:2412193
Created April 18, 2012 09:03
Display current SVN branch in the shell.
# Output:
# /projects/zidaya: TURPAR-801 $
function svn_branch () {
svn info | grep '^URL:' | egrep -o '(tags|branches)/[^/]+|trunk' | egrep -o '[^/]+$'
}
function pretty_prompt () {
_IFS=$IFS;
DIR=`pwd|sed -e "s|$HOME|~|"`;