This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'open-uri' | |
class UrlFetcher | |
def self.fetch(url) | |
returnval = nil | |
begin | |
open(url) {|stream| returnval = stream.read} | |
rescue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Module | |
def attr_flag(*args) | |
args.each do |sym| | |
module_eval <<-EOS | |
attr_writer :#{sym} | |
def #{sym}? | |
@#{sym} | |
end | |
EOS | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Array | |
def sum | |
inject(0.0) { |result, el| result + el } | |
end | |
def mean | |
sum / size | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'processor.rb' | |
task :parse do | |
p = Processor.new | |
p.parse | |
end | |
task :default => :parse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Array | |
def sum | |
inject(0.0) { |result, el| result + el } | |
end | |
def mean | |
sum / size | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SICP Exercise 1.4 | |
If b is greater than 0 then add a and b; otherwise subtract b from a. |
NewerOlder