Skip to content

Instantly share code, notes, and snippets.

Carl Youngblood cayblood

Block or report user

Report or block cayblood

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@cayblood
cayblood / 0_reuse_code.js
Created Sep 17, 2017
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// 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 — forked from jacobat/build-deb-ruby-1.9.2-p290.sh
i can has ruby-1.9.2 package with fpm
View build-deb-ruby-1.9.2-p290.sh
#!/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 Feb 9, 2012 — forked from jimweirich/url_fetcher.rb
Vital Ruby Advanced Lab 1
View url_fetcher.rb
#!/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 Feb 8, 2012 — forked from jimweirich/attr_flag.rb
Vital Ruby Lab 6
View attr_flag.rb
class Module
def attr_flag(*args)
args.each do |sym|
module_eval <<-EOS
attr_writer :#{sym}
def #{sym}?
@#{sym}
end
EOS
end
View presentation.rb
class Array
def sum
inject(0.0) { |result, el| result + el }
end
def mean
sum / size
end
end
@cayblood
cayblood / Rakefile
Created Feb 7, 2012 — forked from jimweirich/presentation.rb
Vital Ruby Lab 4
View Rakefile
require 'processor.rb'
task :parse do
p = Processor.new
p.parse
end
task :default => :parse
@cayblood
cayblood / x.rb
Created Feb 7, 2012 — forked from jimweirich/x.rb
Vital Ruby my_each
View x.rb
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|
View presentation.rb
class Array
def sum
inject(0.0) { |result, el| result + el }
end
def mean
sum / size
end
end
View gist:193316
SICP Exercise 1.4
If b is greater than 0 then add a and b; otherwise subtract b from a.
View gist:193313
SICP Exercise 1.3
(define (square a) (* a a))
(define (sum-of-squares a b) (+ (square a) (square b)))
(define (sum-of-largest-two-squares a b c)
(cond ((and (< a b) (< a c)) (sum-of-squares b c))
((and (< b a) (< b c)) (sum-of-squares a c))
(else (sum-of-squares a b))))
You can’t perform that action at this time.