Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Sierpinski triangle</title>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
</head>
<body>
<script type="text/javascript">
//Width and height
@jraines
jraines / deferred_thing.js.coffee
Created March 14, 2013 16:20
Use deferreds in a loop, but keep a reference to something that only exists in each loop iteration
saveQueue: =>
for draft_item in @items.models
attrs = _.clone draft_item.attributes
delete attrs.id
item = new StyliticsBackbone.Models.Item(attrs)
notifyFunction = @_afterSaveFunc(draft_item)
item.save().success(notifyFunction).error(@_notifyError)
_afterSaveFunc: (draft_item) =>
=>
<!DOCTYPE html>
<html>
<head>
<title>D3Play</title>
<link href="/assets/application.css?body=1" media="all" rel="stylesheet" type="text/css" />
<link href="/assets/app.css?body=1" media="all" rel="stylesheet" type="text/css" />
<link href="/assets/swimmers.css?body=1" media="all" rel="stylesheet" type="text/css" />
<script src="/assets/jquery.js?body=1" type="text/javascript"></script>
<script src="/assets/jquery_ujs.js?body=1" type="text/javascript"></script>
# An attempt to do object oriented d3 graphing
#
# This graphs a swimmer's progress through a challenge set.
#
# x is the swim (1 of 5, 2 of 5, etc)
# y is their time in seconds
#
# radius of orange circles is the swimmers heart rate after 1 swim
#
@jraines
jraines / clean_remotes.sh
Created December 27, 2011 21:19
Go through your remote branches that contain some substring (or prefix) and prompt for deletion
#!/bin/bash
echo 'Clean up branches containing: '
read prefix
while read line; do
branch=$(echo $line | sed 's/origin\///')
echo "Delete this $line? [y/n]"
#can't just read from stdin while inside loop
read answer </dev/tty
if [ "$answer" == "y" ]; then
# Hash for each brand.
# Each key is an item of that brand, in a format like 'id:type:name'.
# Each value is a json string representing an array of user ids.
# For this query we would:
# iterate over each brand
# pull the the keys that match our type ('*jeans*') and
# get the user ids array for each brand of jeans.
LoadModule proxy_module
LoadModule proxy_balancer_module
<Proxy balancer://mycluster>
BalancerMember http://www.lessonplanet.com/ loadfactor=10
BalancerMember http://beta.lessonplanet.com/ loadfactor=1
ProxySet stickysession=_session_id
</Proxy>
ProxyPass / balancer://mycluster
@jraines
jraines / html5css3.md
Created August 14, 2011 16:44
HTML5 course notes

High Level Tags

Doctype

<!Doctype html>

Links

No longer need type attributes, such as type='text/css'

Header tag

@jraines
jraines / life.coffee
Created August 11, 2011 16:44
Conway's game of life for iPad
win = Ti.UI.createWindow()
wrapNorth = (y) ->
if y is 0
36
else
y - 1
wrapSouth = (y) ->
if y is 36