Skip to content

Instantly share code, notes, and snippets.

@michiel
michiel / cors-nginx.conf
Created July 5, 2011 10:41
Wide-open CORS config for nginx
#
# Wide-open CORS config for nginx
#
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
#
@maxbrunsfeld
maxbrunsfeld / backbone_super.js
Created December 30, 2011 23:58
A 'super' method for backbone.js (plain javascript)
// This method gives you an easier way of calling super
// when you're using Backbone in plain javascript.
// It lets you avoid writing the constructor's name multiple
// times. You still have to specify the name of the method.
//
// So instead of having to write:
//
// User = Backbone.Model.extend({
// save: function(attrs) {
// this.beforeSave(attrs);
@zacwasielewski
zacwasielewski / gist:2794562
Created May 26, 2012 16:46
Gutter-free columns for Twitter Bootstrap
/*
Occasionally you need to eliminate the gutters from your grid columns. Include
this SCSS in your project and add a class of .row-nogutter to any <div class="row">
to magically remove its gutters. Not incredibly well-tested, but works for me.
This currently only works for standard (non-fluid) grids.
*/
@adamyanalunas
adamyanalunas / jasmine.toBeTypeOf.js
Created October 21, 2012 01:14
jasmine.js matcher to test type of object
jasmine.Matchers.prototype.toBeTypeOf = function(expected) {
var actual, notText, objType;
actual = this.actual;
notText = this.isNot ? 'not ' : '';
objType = actual ? Object.prototype.toString.call(actual) : '';
this.message = function() {
return 'Expected ' + actual + notText + ' to be an array';
}
@katowulf
katowulf / gist:4741111
Last active April 11, 2024 12:07
Firebase security rules for a simple chat room model
{
"chat": {
// the list of chats may not be listed (no .read permissions here)
// a chat conversation
"$key": {
// if the chat hasn't been created yet, we allow read so there is a way
// to check this and create it; if it already exists, then authenticated
// user (specified by auth.id) must be in $key/users
@iclems
iclems / Firebase Lazy-Safe Iterator
Last active June 21, 2018 09:48
This snippet enables to iterate over a Firebase reference in a non-blocking way. If you need to iterate over a large reference, a child_added query may block your Firebase as it will query the whole data before iteration. With this snippet, children are retrieved one by one, making it slower / safer.
// By Clément Wehrung
function Iterator(queueRef, processingCallback) {
this.queueRef = queueRef;
this.processingCallback = processingCallback;
this.processed = {};
this.processNext();
}
Iterator.prototype.processNext = function() {
@prantlf
prantlf / jasmine.toBeInstanceOf.js
Last active September 2, 2018 00:12
A Jasmine matcher checking if the actual object is an instance of the expected type
// Checks if the actual object is an instance of the expected type;
// the functional object `expected` can be any ancestor prototype.
//
// Example:
// expects(new Backbone.Model()).toBeInstanceOf(Backbone.Model);
jasmine.Matchers.prototype.toBeInstanceOf = function(expected) {
var actual = this.actual,
notText = this.isNot ? ' not' : '';
this.message = function() {
return 'Expected ' + actual + notText + ' to be an instance of ' + expected;
@graceavery
graceavery / harryPotterAliases
Last active May 10, 2023 02:51
bash aliases for Harry Potter enthusiasts
alias accio=wget
alias avadaKedavra='rm -f'
alias imperio=sudo
alias priorIncantato='echo `history |tail -n2 |head -n1` | sed "s/[0-9]* //"'
alias stupefy='sleep 5'
alias wingardiumLeviosa=mv
alias sonorus='set -v'
alias quietus='set +v'