Skip to content

Instantly share code, notes, and snippets.

@jpallen
jpallen / gist:2762417
Created May 21, 2012 13:49
Add a .findOrBuild() method to Backbone Models
// Finding and creating models
// ===========================
//
// We might need to get a reference to a model from anywhere in our code
// and we want to make sure that these references all point to the same model.
// Otherwise updates to one copy of the model won't affect another.
//
// The methods here let you get models through a wrapper that will either
// create the model if it doesn't exist anywhere, or return a reference to
// the existing model. E.g.
var gulp = require('gulp');
var browserify = require('gulp-browserify');
var concat = require('gulp-concat');
var styl = require('gulp-styl');
var refresh = require('gulp-livereload');
var lr = require('tiny-lr');
var server = lr();
var paths = {
js: 'src/**/*.js',
@jmblog
jmblog / 960gs.scss
Created May 18, 2011 06:57
960gs.scss
/*-----------------------------------------------------
960 Grid System ~ Core CSS.
Learn more ~ http://960.gs/
Licensed under GPL and MIT.
-------------------------------------------------------*/
/* Grid Settings
---------------------------*/
// 12-column grid

Preview build: Container grouping and stack composition

NOTE: this is out of date - refer to moby/moby#9694

Here is a preview build of two new features we’re working on concurrently: container grouping (docker groups) and stack composition (docker up). Together, they will eventually form a complete replacement for Fig.

@andyedinborough
andyedinborough / jquery.oauth.js
Created June 7, 2011 19:30
Introduces $.oauth() to make using OAuth from jQuery as easy as using $.ajax()
(function (window, document, $, undefined) {
if (!$.Deferred) throw 'jQuery 1.5 is required to use the jQuery.oauth script!';
function require(name, url) {
if (window[name] === undefined)
return $.ajax({ type: 'GET', cache: true, dataType: 'script', url: url });
}
$.oauth = function (options) {
var d = $.Deferred();
@epicserve
epicserve / Django Enviroment Setup on Mac OSX 10.6.2 (Snow Leopard).markdown
Created February 22, 2010 15:29
Django Enviroment Setup on Mac OSX 10.6.2 (Snow Leopard)

Django Enviroment Setup on Mac OSX 10.6.2 (Snow Leopard)

Install Homebrew

sudo mkdir /usr/local
sudo chown -R `whoami` /usr/local
curl -L http://github.com/mxcl/homebrew/tarball/master | tar xz --strip 1 -C /usr/local
brew install git
cd /usr/local
git init
@jhickner
jhickner / reload_chrome.sh
Created November 15, 2012 22:37
Reload Chrome then refocus iTerm
#!/bin/sh
exec <"$0" || exit; read v; read v; exec /usr/bin/osascript - "$@"; exit
-- the above is some shell trickery that lets us write the rest of
-- the file in plain applescript
tell application "Google Chrome"
activate
tell application "System Events"
tell process "Google Chrome"
@webmat
webmat / dashboards.rb
Created February 22, 2012 20:46
First draft of an active_admin-based view for Delayed::Job
ActiveAdmin::Dashboards.build do
# Add this section in your dashboard...
section "Background Jobs" do
now = Time.now.getgm
ul do
li do
jobs = Delayed::Job.where('failed_at is not null').count(:id)
link_to "#{jobs} failing jobs", admin_jobs_path(q: {failed_at_is_not_null: true}), style: 'color: red'
end
@dbreunig
dbreunig / ReporterSaveFileDescription.md
Last active January 22, 2021 16:07
A description of the data written to the Reporter App Dropbox save folder.

#Reporter Save File Schema

##The Reporter Export File

Reporter saves to your Dropbox account with plaintext JSON files, one for each day. When a Report is entered in the app a file is created for that day if it does not exist. Otherwise, the report is appended to the existing file. The save folder is located in 'Dropbox/Apps/Reporter-App/'.

Reporter save files are named according to the following convention:

YYYY-MM-DD-reporter-export.json
@perusio
perusio / gist:1326701
Created October 31, 2011 01:28
Mobile device detection in Nginx with just 7 lines of configuration
### Testing if the client is a mobile or a desktop.
### The selection is based on the usual UA strings for desktop browsers.
## Testing a user agent using a method that reverts the logic of the
## UA detection. Inspired by notnotmobile.appspot.com.
map $http_user_agent $is_desktop {
default 0;
~*linux.*android|windows\s+(?:ce|phone) 0; # exceptions to the rule
~*spider|crawl|slurp|bot 1; # bots
~*windows|linux|os\s+x\s*[\d\._]+|solaris|bsd 1; # OSes