Skip to content

Instantly share code, notes, and snippets.

View ethagnawl's full-sized avatar
🐢

Pete Doherty ethagnawl

🐢
View GitHub Profile
@ethagnawl
ethagnawl / rAF.js
Created March 4, 2014 17:40 — forked from paulirish/rAF.js
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
@ethagnawl
ethagnawl / rAF.js
Created March 4, 2014 17:50 — forked from paulirish/rAF.js
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
"use strict";
define(function () {
#
# Wide-open CORS config for nginx
#
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
#
/*
* Set up factories, then create them in tests with (for example):
*
* LineItemFactory();
*
* Or with attributes / overrides:
*
* LineItemFactory({
* "id": 123,
* "order": OrderFactory({"firstName": "Example Associated Record Override"}),
@ethagnawl
ethagnawl / resource.coffee
Created June 16, 2014 19:31
Conditionally Export Resource via Require.js
factory = ->
class MyClass
do (root = window, factory = factory) ->
if (typeof define is 'function' && define.amd)
define -> factory()
@ethagnawl
ethagnawl / gist:0486850a491e81ed4bc3
Created June 25, 2014 18:25
Reproduce Rails Destroy Bug
export app_name="reproduce_rails_routing_bug"
echo $app_name
rails new ${app_name}
cd ${app_name}
rails g scaffold foo
cd config
sed -i '/^$/d' routes.rb
sed -i '/#/d' routes.rb
cd ..
rails destroy scaffold foo
function fif {
grep -lir "$*" *
}
function fifp {
grep -RnisI "$*" *
}
function fifvo {
vim -O $(fif $*)
@ethagnawl
ethagnawl / gist:d132909c514aeeae64b6
Last active August 29, 2015 14:04
Haskell Inspired `any` using `foldr` in JavaScript
// From Real World Haskell - Chapter 4, Exercise 7
// any_foldr p xs = foldr (||) False (map p xs) => http://haskell.elkstein.org/2009/04/solutions-to-chapter-4-p-97.html
var any = function (pred, list) {
var xs = _.map(list, pred);
return _.reduceRight(xs, function (acc, x) {
@ethagnawl
ethagnawl / gist:85fbe81b8b4a844d2d1f
Last active August 29, 2015 14:05
New Mac Setup
brew
====
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)" && brew install curl rlwrap tmux htop reattach-to-user-namespace
.vimrc
======
set clipboard=unnamed
aliases
=======
@ethagnawl
ethagnawl / gist:0d241a509243b2f7fb5f
Last active August 29, 2015 14:06
Social Share URLs
Pinterest: http://www.pinterest.com/pin/create/button/?url=URL&media=IMAGE&description=DESCRIPTION
# appears to be deprecated
Facebook: http://www.facebook.com/sharer.php?s=100&p[url]=URL&p[title]=TITLE&p[summary]=SUMMARY&p[images][0]=IMAGE
Twitter: http://twitter.com/share/?text=TEXT&url=URL