Skip to content

Instantly share code, notes, and snippets.


Ryan Cook cookrn

View GitHub Profile
cookrn / install.bash
Created Feb 28, 2012
Simple Bash Script To Bootstrap Ubuntu Server
View install.bash
# To run this script
# => scp it to the server
# => run `sudo bash install.bash`
# Preparations
echo "deb dist 10gen" | tee -a /etc/apt/sources.list # MongoDB Prep
apt-key adv --keyserver --recv 7F0CEB10 # MongoDB Prep
cookrn /
Created Mar 20, 2012
How to Create and Apply a Patch w/ Git Across Similar Repositories
cookrn /
Last active Mar 29, 2017
Named Screen -- Inspired by @ahoward

Named Screen

A utility inspired by @ahoward that allows screens to be the name of the directory they were spawned from. This is mainly helpful for Terminal/iTerm tabs.

Executing this should rejoin sessions with the same name if they already exist or otherwise create them.


  1. Place or symlink into your path (I symlink as ns)
  2. Ensure the script is executable
cookrn / screenfetched.rb
Created May 27, 2016
An easy way to cache `screenfetch` results for a set amount of time so that every new terminal doesn't re-run it
View screenfetched.rb
#!/usr/bin/env ruby
if fetched_file_blank? or fetched_file_expired?
COMMAND = 'screenfetch'.freeze
View sample_nginx_config.conf
worker_processes 1;
events {
worker_connections 1024;
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
#keepalive_timeout 0;
keepalive_timeout 65;
cookrn / a.rb
Last active Jan 2, 2016
What would a library for Ruby look like that implemented some sort of runtime type checking?
View a.rb
class Printer
attr_reader :printer
deftyped :initialize , :printer => [ Proc ] do
@printer = printer
deftyped :print , :string => { :splat => true , :type => String } do string.join( ' ' )
cookrn /
Last active Dec 28, 2015
Setting up an iPad 1 to be an Ansible Node

Setting up an iPad 1 to be an Ansible Node

  1. Update the iPad (v5.1.1?) to the latest iOS and make a backup using iTunes
  2. Install the sshpass program on your laptop. Ansible will need this to connect over ssh using a password.
  3. Jailbreak the iPad using redsn0w -- you now have Cydia
  4. Use Cydia to install "MobileTerminal", "OpenSSH", "Python", and "Setup Tools"
  5. Follow the "MobileTerminal" instructions in Cydia for changing the default passwords
  6. Locate your iPad's IP address by looking in > Wi-Fi and clicking your connected networks detail ">" arrow
  7. SSH into your iPad and make sure you add IP address to list of known hosts
  8. Place IP address into an Ansible hosts file
View action.rb
# it's not critical for understanding
# but here is the associated server-side action
def version
@program = load_program!
@version = @program.versions.find(params[:version_id])
if stale?(:last_modified => @version.updated_at, :etag => @version.cache_key)
cookrn / client.rb
Created Dec 15, 2015
A tiny, standard-library only example of attaching to a running process over the network for inspection
View client.rb
#!/usr/bin/env ruby
require 'drb'
require 'irb'
$context = DRbObject.new_with_uri('druby://localhost:9876')