Skip to content

Instantly share code, notes, and snippets.

View cayblood's full-sized avatar

Carl Youngblood cayblood

View GitHub Profile
#!/bin/bash
# Specify the desired volume size in GiB as a command-line argument. If not specified, default to 20 GiB.
SIZE=${1:-20}
# Get the ID of the environment host Amazon EC2 instance.
INSTANCEID=$(curl http://169.254.169.254/latest/meta-data//instance-id)
# Get the ID of the Amazon EBS volume associated with the instance.
VOLUMEID=$(aws ec2 describe-instances \
@cayblood
cayblood / 0_reuse_code.js
Created September 17, 2017 15:42
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@cayblood
cayblood / build-deb-ruby-1.9.2-p290.sh
Created May 7, 2012 14:22 — forked from jacobat/build-deb-ruby-1.9.2-p290.sh
i can has ruby-1.9.2 package with fpm
#!/bin/sh
rubyversion=1.9.2-p290
rubysrc=ruby-$rubyversion.tar.bz2
checksum=096758c3e853b839dc980b183227b182
destdir=/tmp/install-$rubyversion
sudo apt-get -y install libssl-dev
gem list -i fpm || sudo gem install fpm
@cayblood
cayblood / url_fetcher.rb
Created February 9, 2012 10:20 — forked from jimweirich/url_fetcher.rb
Vital Ruby Advanced Lab 1
#!/usr/bin/env ruby
require 'open-uri'
class UrlFetcher
def self.fetch(url)
returnval = nil
begin
open(url) {|stream| returnval = stream.read}
rescue
@cayblood
cayblood / attr_flag.rb
Created February 8, 2012 12:06 — forked from jimweirich/attr_flag.rb
Vital Ruby Lab 6
class Module
def attr_flag(*args)
args.each do |sym|
module_eval <<-EOS
attr_writer :#{sym}
def #{sym}?
@#{sym}
end
EOS
end
@cayblood
cayblood / presentation.rb
Created February 8, 2012 08:57 — forked from jimweirich/read_only_proxy.rb
Vital Ruby Lab 5
class Array
def sum
inject(0.0) { |result, el| result + el }
end
def mean
sum / size
end
end
@cayblood
cayblood / Rakefile
Created February 7, 2012 13:54 — forked from jimweirich/presentation.rb
Vital Ruby Lab 4
require 'processor.rb'
task :parse do
p = Processor.new
p.parse
end
task :default => :parse
@cayblood
cayblood / x.rb
Created February 7, 2012 11:58 — forked from jimweirich/x.rb
Vital Ruby my_each
class Array
def my_each
length.times do |index|
yield(self[index])
end
end
def my_inject(initial_value)
accumulator = initial_value || self.dup.shift
my_each do |item|
@cayblood
cayblood / presentation.rb
Created February 7, 2012 08:12 — forked from jimweirich/presentation.rb
Vital Ruby Lab 3
class Array
def sum
inject(0.0) { |result, el| result + el }
end
def mean
sum / size
end
end
SICP Exercise 1.1
> 10
10
> (+ 5 3 4)
12
> (- 9 1)
8
> (/ 6 2)
3