Skip to content

Instantly share code, notes, and snippets.

View blaix's full-sized avatar

Justin Blake blaix

View GitHub Profile
@blaix
blaix / factory_girl_steps.rb
Created July 22, 2010 13:37
A modified version of the cucumber steps included in factory_girl. But I'd like to find a way to simply redefine the steps it creates without raising an ambiguos step error...
# Stolen from: http://github.com/thoughtbot/factory_girl/blob/master/lib/factory_girl/step_definitions.rb
# and slightly modified so that steps which create only a single record, save
# that record to an instance variable, so you can do things like:
#
# Given I am logged in as an admin
# And a post exists with a title of "Awesome Post"
# When I go to the post
# Then I should see "Awesome Post"
# And I should see a link to edit the post
#
@blaix
blaix / iterm_pastel_theme.sh
Created July 23, 2010 17:14
iTerm light-on-dark profile.
#!/bin/bash
# Pretty light-on-dark theme for iTerm.
# Copied from here:
# http://kpumuk.info/mac-os-x/customizing-iterm-creating-a-display-profile-with-pastel-colors/
# Run in terminal then restart iTerm.
# Profile is listed as "Pastel" under Bookmarks => Manage Profiles...
PASTEL='{
@blaix
blaix / chat-client.html
Created September 2, 2010 04:59
Playing with websockets and EventMachine in the most cliche way possible.
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<title>omgsockets</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script>
$(document).ready(function() {
var ws = new WebSocket('ws://localhost:3000');
ws.onmessage = function(msg) {
@blaix
blaix / about.md
Created August 9, 2011 15:08 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer

Programming Achievements: How to Level Up as a Developer

  1. Select a particular experience to pursue.
  2. Pursue that experience to completion. (Achievement unlocked!)
  3. Reflect on that experience. Really soak it in. Maybe a blog post would be in order?
  4. Return to Step 1, this time selecting a new experience.

This gist is a fork of the gist from this blog post.

@jeffrafter
jeffrafter / ie6.sh
Created August 11, 2011 16:04
Setup a VirtualBox instance that allows you to test IE Locally from OSX
#!/bin/bash
# Much of this came from a few blog articles and one base script that I can't find now
# It is updated for the current VHD files (which supposedly expired on Aug 9th, 2011
# but still work.
#
# Requirements: Virtual Box installed, unrar (from homebrew is fine)
#
# If you want to remove stuff, open up Virtual Box and remove the VM and delete files.
#
@blaix
blaix / struct-play.rb
Created September 3, 2011 13:34
Struct with an OpenStruct-style initializer
class Struct
def self.create(params = {})
self.new.tap do |obj|
params.each do |key, val|
obj.send("#{key}=", val)
end
end
end
end
@blaix
blaix / defaults-10.7.sh
Created September 10, 2011 13:13
Sane OS X 10.7 Settings
# Enable tabbing to everything
defaults write NSGlobalDomain AppleKeyboardUIMode -int 3
# 2D Dock
defaults write com.apple.dock no-glass -bool true
# Always expand save dialog
defaults write -g NSNavPanelExpandedStateForSaveMode -bool true
# Don't hide ~/Library folder
@blaix
blaix / mock-with-arg-verification.py
Created March 30, 2012 23:25
Mocking new instance of class and verifying the arguments in python with flexmock
# Mock new instances of a class (verify that it's initialized with specific arguments)
# First argument to __new__ is the class, so pass `object` because we don't care about that part
flexmock(MyClass).should_receive('__new__').once.with_args(object, 'arg1', 'arg2').and_return(fake_object)
MyClass('wrong', 'arguments') # => MethodSignatureError
MyClass('arg1', 'arg2') # => <fake_object>
#!/bin/bash
set -e
echo "-----------------------------------------------------"
echo "Installing the essentials..."
echo "-----------------------------------------------------"
sudo apt-get update
sudo apt-get -y upgrade

Things that programmers don't know but should

(A book that I might eventually write!)

Gary Bernhardt

I imagine each of these chapters being about 2,000 words, making the whole book about the size of a small novel. For comparison, articles in large papers like the New York Times average about 1,200 words. Each topic gets whatever level of detail I can fit into that space. For simple topics, that's a lot of space: I can probably walk through a very basic, but working, implementation of the IP protocol.