Skip to content

Instantly share code, notes, and snippets.

View cookrn's full-sized avatar
👻

Ryan Cook cookrn

👻
View GitHub Profile
@cookrn
cookrn / links.md
Created March 20, 2012 19:51
How to Create and Apply a Patch w/ Git Across Similar Repositories
@cookrn
cookrn / install.bash
Created February 28, 2012 02:02
Simple Bash Script To Bootstrap Ubuntu Server
#!/bin/bash
## README
# To run this script
# => scp it to the server
# => run `sudo bash install.bash`
# Preparations
echo "deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen" | tee -a /etc/apt/sources.list # MongoDB Prep
apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10 # MongoDB Prep
@cookrn
cookrn / instructions.md
Last active March 29, 2017 15:12
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.

Usage

  1. Place or symlink into your path (I symlink as ns)
  2. Ensure the script is executable
@cookrn
cookrn / screenfetched.rb
Created May 27, 2016 17:00
An easy way to cache `screenfetch` results for a set amount of time so that every new terminal doesn't re-run it
#!/usr/bin/env ruby
if fetched_file_blank? or fetched_file_expired?
fetch!
end
write_cached_screenfetch!
BEGIN {
COMMAND = 'screenfetch'.freeze
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
cookrn / a.rb
Last active January 2, 2016 21:59
What would a library for Ruby look like that implemented some sort of runtime type checking?
class Printer
attr_reader :printer
deftyped :initialize , :printer => [ Proc ] do
@printer = printer
end
deftyped :print , :string => { :splat => true , :type => String } do
printer.call string.join( ' ' )
end
@cookrn
cookrn / _requirements.md
Last active December 28, 2015 22:49
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 Settings.app > 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
# 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)
render
@cookrn
cookrn / client.rb
Created December 15, 2015 04:53
A tiny, standard-library only example of attaching to a running process over the network for inspection
#!/usr/bin/env ruby
require 'drb'
require 'irb'
DRb.start_service
$context = DRbObject.new_with_uri('druby://localhost:9876')
IRB.start