Skip to content

Instantly share code, notes, and snippets.

Make it real

Ideas are cheap. Make a prototype, sketch a CLI session, draw a wireframe. Discussions around concrete examples, not handy-waving abstractions. Don't say you did something, provide a URL that proves it.

Ship it

Nothing is real until it's being used by a real user. This doesn't mean you make a prototype in the morning and blog about it in the evening. It means you find one person you believe your product will help and try to get them to use it.

Do it with style

githubAccount() { # Syntax: githubAccount <file>
# Check for Github account name
if [[ "$githubAccount" == '' ]]; then
if [[ ! -f "$file" ]]; then
# If .github doesn't exist then ask for the name and save it
echo -n "What is your Github name? "
read githubAccount
touch "$file"
echo "$githubAccount" > "$file"
else
@crcastle
crcastle / counter.rb
Created July 4, 2012 07:11 — forked from luigi/counter.rb
Calculate the percentage of tweets linking to a website that came from the Tweet button
#
# Before running:
# $ gem install twitter
#
# To run:
# $ ruby counter.rb sleazywebsite.com
#
# Context:
# http://luigimontanez.com/2012/actually-social-media-buttons-work-really-well
#
@crcastle
crcastle / memoize.py
Created April 12, 2012 02:36
Expensive function that gets called frequently? Memoize it.
def memoize(fn):
stored_results = {}
def memoized(*args):
try:
# try to get the cached result
return stored_results[args]
except KeyError:
# nothing was cached for those args. let's fix that.
result = stored_results[args] = fn(*args)
@crcastle
crcastle / git-svn notes.txt
Created March 12, 2012 18:26 — forked from dcarney/git-svn notes.txt
Some hastily-scribbled notes about using git-svn with our existing git repos
Set the SVN_EDITOR var:
# export SVN_EDITOR=vim
==================================
SETTING UP A NEW SVN PROJECT
==================================
Create a new SVN "repo" (aka folder):
(NOTE: https is required for our new SVN, as well as --username)
# svn mkdir https://some/url/path/to/newRepo --username first.last
@crcastle
crcastle / gist:1568276
Created January 6, 2012 00:58
generic startup script file to put in /etc/init.d
#!/bin/bash
PATH=/bin:/usr/bin:/sbin:/usr/sbin
case "$1" in
start)
echo -n "Starting"
cd /to/somewhere
run_something.sh
@crcastle
crcastle / gist:1524814
Created December 27, 2011 19:04 — forked from arnorhs/gist:1517095
gitopen - Open all files from a git diff or show command
#!/bin/bash
# This script will open all files from a git diff or a git show in vim.
# My bash skills are a bit primitive so this can probably be done more intelligently
# Usage:
# gitopen -- opens all added files that have changed since HEAD
# gitopen diff HEAD -- these are the default parameters
# gitopen diff master -- opens files that have changed from master
@crcastle
crcastle / gist:1295761
Created October 18, 2011 15:46
What to do if a BigTuna build job hangs
# log on to big tuna box
# become tuna user
sudo su tuna
# stop the delayed_job process
cd /home/tuna/bigtuna
RAILS_ENV=production ./script/delayed_job stop
# clear the job queue
RAILS_ENV=production bundle exec rake jobs:clear
@crcastle
crcastle / autoclose_janus
Created September 5, 2011 23:51 — forked from jackkinsella/autoclose_janus
How to add autoclose to Janus
#~/.janus.rake file
vim_plugin_task "autoclose", "git://github.com/Townk/vim-autoclose.git"
#~/vimrc.local file
let g:AutoClosePairs = {'(': ')', '{': '}', '[': ']', '"': '"', "'": "'", '#{': '}', '|':'|' }
let g:AutoCloseProtectedRegions = ["Character"]
// Production steps of ECMA-262, Edition 5, 15.4.4.18
// Reference: http://es5.github.com/#x15.4.4.18
if (!Array.prototype.forEach) {
Array.prototype.forEach = function( callback, thisArg ) {
var T, k;
if ( this == null ) {
throw new TypeError( " this is null or not defined" );
}
var O = Object(this);
var len = O.length >>> 0;