Skip to content

Instantly share code, notes, and snippets.

View nadinengland's full-sized avatar
💭
Technical Director at @few-far

Thomas Nadin nadinengland

💭
Technical Director at @few-far
View GitHub Profile
@hatarist
hatarist / ensure_csrf_cookie_mixin.py
Created July 16, 2015 15:37
EnsureCsrfCookieMixin for Django's Class-Based Views
Go Rust
----------- ------
break break
case (syntax)
chan (library)
const const
continue loop
default (syntax)
defer
else else
@m4nuC
m4nuC / gist:4052863
Created November 10, 2012 22:56
Jasmine Object instance Matchers and typeof matcher
beforeEach(function() {
this.addMatchers({
toBeInstanceOf : function( expected ) {
return this.actual instanceof expected && this.actual.length > 0;
},
toBeA: function( expected ) {
return typeof this.actual === expected;
}
});
@nijikokun
nijikokun / example-user.js
Created May 3, 2012 20:46
Beautiful Validation... Why have I never thought of this before?!
var user = {
validateCredentials: function (username, password) {
return (
(!(username += '') || username === '') ? { error: "No Username Given.", field: 'name' }
: (!(username += '') || password === '') ? { error: "No Password Given.", field: 'pass' }
: (username.length < 3) ? { error: "Username is less than 3 Characters.", field: 'name' }
: (password.length < 4) ? { error: "Password is less than 4 Characters.", field: 'pass' }
: (!/^([a-z0-9_-]+)$/i.test(username)) ? { error: "Username contains invalid characters.", field: 'name' }
: false
);
@jrf0110
jrf0110 / class.js
Created April 23, 2012 22:05
Simple extendable classes in javascript
/* This WAS a two-line function until an awesome reddit user pointed out my logical flaw. Now It's a 5-line function :( */
var Class = function(d){
d.constructor.extend = function(def){
for (var k in d) if (!def.hasOwnProperty(k)) def[k] = d[k];
return Class(def);
};
return (d.constructor.prototype = d).constructor;
};
@HashNuke
HashNuke / gist:608259
Created October 3, 2010 04:13
to undo push and commits
# to undo a git push
git push -f origin HEAD^:master
# to get to previous commit (preserves working tree)
git reset --soft HEAD
# to get back to previous commit (you'll lose working tree)
git reset --hard HEAD^