Skip to content

Instantly share code, notes, and snippets.

@ericdouglas
ericdouglas / super-tip.txt
Last active February 25, 2024 10:09
Change 4 spaces to 2 spaces indentation and change tab to spaces - Vim tip
// 4 spaces to 2 spaces
%s;^\(\s\+\);\=repeat(' ', len(submatch(0))/2);g
// Tab to 2 spaces
:%s/\t/ /g
@abyx
abyx / angular-error-handling.js
Last active February 4, 2022 19:19
AngularJS HTTP Error Handling Mechanism
var HEADER_NAME = 'MyApp-Handle-Errors-Generically';
var specificallyHandleInProgress = false;
angular.module('myApp').factory('RequestsErrorHandler', ['$q', function($q) {
return {
// --- The user's API for claiming responsiblity for requests ---
specificallyHandled: function(specificallyHandledBlock) {
specificallyHandleInProgress = true;
try {
return specificallyHandledBlock();
@lttlrck
lttlrck / gist:9628955
Created March 18, 2014 20:34
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@mhluongo
mhluongo / api.py
Last active December 18, 2015 13:19
A quick example using neo4django with tastypie adapted from the tastypie tutorial (http://django-tastypie.readthedocs.org/en/latest/tutorial.html).
from tastypie.resources import ModelResource
from .models import Entry
class EntryResource(ModelResource):
class Meta:
queryset = Entry.objects.all()
resource_name = 'entry'
@coolgarifTech
coolgarifTech / gist:5671071
Created May 29, 2013 15:14
HydraGraph script for exposing GraphDatabase in Neo4j using Python and Flask by Coolgarif Tech
from neo4jrestclient.client import GraphDatabase
from neo4jrestclient.constants import RAW
from neo4jrestclient.client import Node
from urlparse import urlparse
import re, json
from flask import Flask, Response, json, jsonify, request, Blueprint, render_template
app = Flask(__name__)
@simonsmith
simonsmith / amd-jquery-plugin.js
Last active April 29, 2020 15:28
AMD compatible plugin for jQuery
// UMD dance - https://github.com/umdjs/umd
!function(root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery'], factory);
} else {
factory(root.jQuery);
}
}(this, function($) {
'use strict';