Skip to content

Instantly share code, notes, and snippets.

@mostlygeek
mostlygeek / fireworks.js
Last active December 21, 2015 00:09
Fireforks
/*
* http://jsfiddle.net/mostlygeek/etz43/
*
* much credit goes to: http://thecodeplayer.com/walkthrough/canvas-fireworks-tutorial
* tweaked a few things out for performance:
*
* - revised the animation loop to stop animating when no more particles/fireworks
* - use `|0` to round off to nearest pixel
* - use a clock algorithm for trails, instead of pop() and unshift() on the array
*/
#!/bin/bash
# update the system
sudo apt-get --yes update
sudo apt-get --yes upgrade
# node.js using PPA (for statsd)
sudo apt-get install --yes python-software-properties
sudo apt-add-repository ppa:chris-lea/node.js
sudo apt-get update --yes
#!/usr/bin/env python
#
# s3-download.py - a quick-and-dirty download script to download from S3
# implemented using Boto, which automatically applies AWS IAM role credentials
#
# This code is distributed under the MIT license from
# http://opensource.org/licenses/MIT:
#
# Copyright (c) 2013 Martijn Koster
#
@mostlygeek
mostlygeek / heredoc.sh
Created April 11, 2013 16:39
what does quoting do w/ a bash heredoc?
#!/bin/sh
greeting="What's up"
# notice `EOF` is not quoted
cat << EOF
No quotes mean I do var substitution:
$greeting
EOF
@mostlygeek
mostlygeek / start.sh
Created April 10, 2013 05:44
MongoDB shell starter (osx) dev env.
#!/bin/sh
BASE=$(dirname $0)
cd $BASE
./bin/mongod \
--noprealloc \
--cpu \
--dbpath $BASE
@mostlygeek
mostlygeek / .tmux.conf
Last active December 15, 2015 08:59
.tmux.conf
# fix for broken pbcopy in tmux
# see: http://superuser.com/questions/231130/unable-to-use-pbcopy-while-in-tmux-session
set-option -g default-command "reattach-to-user-namespace -l bash"
unbind C-b
set -g prefix C-a
# allow mouse navigation (on mac) between panes
bind -n M-Left select-pane -L
@mostlygeek
mostlygeek / rename-files.sh
Created March 12, 2013 19:35
This gist is a collection of random things i've needed to do on the command line. Usually it is moving files around or scripting commands to run over a set of files.
#
# Source, a directory full of files like: t01-open.png, t02-open.png, etc.
# Output, rename the files so t01-open.png turns into t00-open.png (start at zero instead of 1)
# loop through all the numbers ...
for i in {1..20}
do
# turn 1, 2, 3, 4... into 01, 02, 03, 04
f=$(echo $i | awk '{printf "%02s", $1}')
@mostlygeek
mostlygeek / file-list.txt
Created March 7, 2013 07:39
Wrote this little bash script to go though a directory of PNG files and find the smallest width/height for a DOM element that fits any image in a set. The set of images is made up of a "close", "open" and "stroke" image sprites.
t01-close.png
t01-open.png
t01-stroke.png
t02-close.png
t02-open.png
t02-stroke.png
t03-close.png
t03-open.png
t03-stroke.png
t04-close.png
@mostlygeek
mostlygeek / turing.sed
Created February 20, 2013 08:02
sed is turing complete...
#! /bin/sed -f
#
# turing.sed -- emulate a Turing machine
#
# Christophe Blaess <[email protected]>
# http://perso.club-internet.fr/ccb/
# See text file for information about Turing Machine script.
# Read all the instructions, and add a final newline.
Actor = (function() {
var my,own,internal,state = 0;
return {
onMessage: function(msg) {
if (msg == "inc") { my = my + 1 }
// ...
}
}