Skip to content

Instantly share code, notes, and snippets.

View benhamill's full-sized avatar
💖

Ben Hamill benhamill

💖
View GitHub Profile
[10:47 PM] ben@eris:~$ lsinitcpio -a /boot/initramfs-linux.img
==> Image: /boot/initramfs-linux.img
==> Created with mkinitcpio 0.8.4
==> Kernel: 3.2.9-1-ARCH
==> Compressed with: gzip
-> Compression ratio: .364
-> Estimated decompression time: 0.081s
==> Included modules:
ahci hid-apple hid-ezkey hid-logitech-dj hid-pl hid-roccat-kovaplus hid-twinhan libahci sr_mod
(3/8) upgrading linux [####################################################################################] 100%
>>> Updating module dependencies. Please wait ...
>>> Generating initial ramdisk, using mkinitcpio. Please wait...
==> Building image from preset: 'default'
-> -k /boot/vmlinuz-linux -c /etc/mkinitcpio.conf -g /boot/initramfs-linux.img
==> Starting build: 3.2.9-1-ARCH
-> Parsing hook: [base]
-> Parsing hook: [udev]
-> Parsing hook: [autodetect]
-> Parsing hook: [pata]

Composed Method: The idea of, rather than having a super long/complex method, you break the functionality up into lots of little methods that are, like, 1-5 lines. Folks general construe that these methods should be private.

Method Object: For a method that would normally take a huge number of arguments or has a lot of local variables that make it hard to do Composed Method, you make an object, store the variables as state and then compose your shit in there. And the original method just delegates over to the new object.

The reason I asked is that it seems like what people generally construe as "should be private" in Composed Method could reasonably be expected to be public on your Method Object. That, anyway, is what came to mind with the phrase "public on another object".

@benhamill
benhamill / README.md
Created February 21, 2012 05:20
List processes that match a string.

I named this file psg and put it in a place where my PATH could find it. You could do that, too. Also, you'll want it to be executable: chmod +x /path/to/psg.

#!/bin/bash
first=${1:0:1}
rest=${1:1:10000}
ps aux | ack "[$first]$rest"
Downloading http://rubyenterpriseedition.googlecode.com/files/ruby-enterprise-1.8.7-2011.12.tar.gz...
Installing ruby-enterprise-1.8.7-2011.12...
--2012-02-03 12:07:35-- http://bugs.ruby-lang.org/attachments/download/1931/stdout-rouge-fix.patch
Resolving bugs.ruby-lang.org... 210.251.121.216
Connecting to bugs.ruby-lang.org|210.251.121.216|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 719 [text/x-patch]
Saving to: `stdout-rouge-fix.patch'
100%[======================================================>] 719 --.-K/s in 0s
~/dev$ gem install rspec-core
Successfully installed rspec-core-2.8.0
1 gem installed
Installing ri documentation for rspec-core-2.8.0...
Building YARD (yri) index for rspec-core-2.8.0...
Installing RDoc documentation for rspec-core-2.8.0...
~/dev$ gem unpack rspec-core
Unpacked gem: '/Users/bhamill/dev/rspec-core-2.8.0'
~/dev$ cd rspec-core-2.8.0/
~/dev/rspec-core-2.8.0$ ls

I have followed the postgres 9.1 docs for pg_upgrade and gotten to the step of actually running the command. So I did this (note, I have -c so that it won't change anything until I am sure I want to go forward):

$ /usr/lib/postgresql/9.1/bin/pg_upgrade -c -b /usr/lib/postgresql/9.0/bin/ -B /usr/lib/postgresql/9.1/bin/ -d /vol/lib/postgresql/9.0/main -D /var/lib/postgresql/9.1/main -p 50433 -P 50432
Performing Consistency Checks
-----------------------------
Checking current, bin, and data directories                 ok
Checking cluster versions                                   ok

connection to database failed: could not connect to server: No such file or directory
def train!
start_training!
find_matching_messages or return fail_training("Found no matching messages in database")
messages_with_bodies = fetch_message_bodies(found_messages) or return fail_training("Unable to fetch any bodies for matching messages")
update_tags(messages_with_bodies) or return cancel_training("Failed to update tags with new message data")
finish
@benhamill
benhamill / unmerged-branches
Created September 28, 2011 00:38
Make this executable and it will list for you the remote branches that haven't been merged into the "develop" branch. You can, of course, grep for a different branch name (master?) or change the || to && to get remote branches that ARE merged in.
#! /bin/sh
if [[ -z $1 ]]; then
echo "You must provide a branch name against which to test merging."
exit 1
fi
gather_branches() {
for remote in `git for-each-ref --format='%(refname)' 'refs/remotes/'`
do