Skip to content

Instantly share code, notes, and snippets.

@rentalcustard
rentalcustard / gist:1134714
Created August 9, 2011 17:53
Things in SICP that blew my mind
; Observe that our model of evaluation allows for combinations whose operators are compound
; expressions. Use this observation to describe the behaviour of the following procedure:
(define (a-plus-abs-b a b)
((if (> b 0) + -) a b))
; (p. 21)
@rentalcustard
rentalcustard / gist:1031669
Created June 17, 2011 15:42
Chef/EC2/Java problem
#Running knife bootstrap, I get this:
ec2-46-137-58-164.eu-west-1.compute.amazonaws.com [Fri, 17 Jun 2011 15:03:45 +0000] INFO: execute[apt-get update] ran successfully
ec2-46-137-58-164.eu-west-1.compute.amazonaws.com [Fri, 17 Jun 2011 15:03:45 +0000] INFO: Processing ruby_block[reload_ohai] action nothing (java::default line 24)
ec2-46-137-58-164.eu-west-1.compute.amazonaws.com [Fri, 17 Jun 2011 15:03:45 +0000] INFO: Processing execute[update-java-alternatives] action nothing (java::default line 33)
ec2-46-137-58-164.eu-west-1.compute.amazonaws.com [Fri, 17 Jun 2011 15:03:45 +0000] INFO: Processing package[sun-java6-jre] action install (java::default line 42)
ec2-46-137-58-164.eu-west-1.compute.amazonaws.com [Fri, 17 Jun 2011 15:03:45 +0000] INFO: Processing cookbook_file[/var/chef/cache/preseed/java/sun-java6-jre-6.24-1build0.10.04.1.seed] action create (dynamically defined)
ec2-46-137-58-164.eu-west-1.compute.amazonaws.com [Fri, 17 Jun 2011 15:03:45 +0000] INFO: cookbook_file[/var/chef/cache/preseed/java
@rentalcustard
rentalcustard / arrange_act_assert.rb
Created June 5, 2011 15:29
Mocks suck - code for embedding into my blog post on this topic
#Arrange
my_thing = Thing.new :colour => :yellow
#Act
my_thing.bleach!
#Assert
my_thing.colour.should == :white
@rentalcustard
rentalcustard / gist:968505
Created May 12, 2011 13:38
Ruby's ftp gem
Ξ ~ → gem install ftp
Fetching: ftp-0.069.gem (100%)
Successfully installed ftp-0.069
1 gem installed
Installing ri documentation for ftp-0.069...
File not found: lib
ERROR: While generating documentation for ftp-0.069
... MESSAGE: exit
... RDOC args: --ri --op /Users/Tom/.rvm/gems/ree-1.8.7-2011.03@rails21/doc/ftp-0.069/ri lib --title ftp-0.069 Documentation --quiet
↑1 ~ → cd ~/.rvm/gems/ree-1.8.7-2011.03@rails21/gems/ftp-0.069/
@rentalcustard
rentalcustard / README.markdown
Created April 11, 2011 10:30
Command-line wikipedia using DNS

This uses the awesome Wikipedia over dns hack to bring quick wikipedia lookups to your shell.

#Usage

Ξ ~ → qiki bacon
Bacon is a cut of meat taken from the sides, belly, or back of a pig, then cured, smoked,
or both. Meat from other animals, such as beef, lamb, chicken, goat, or turkey, may also 
be cut, cured, or otherwise prepared to resemble bacon. Bacon may be eaten f" "ried, baked,
or grilled, or used as a minor ingredient to flavor dishes. Bacon is also used for barding

and larding roasts... http://a.vu/w:Bacon

L
inu
xSy
ste
mAd
min
ist
ratorJo bDesc
rip tionThi spo
sit ionisre spo

#Linux System Administrator

##Job Description This position is responsible for installation, configuration, maintenance and monitoring of all Linux systems.The systems administrator will support daily operations and help develop strategies to improve availability and utilization of Linux environments.

##Essential Functions

  • Personally identify and carry out administration tasks on the servers when required.
  • Manage your own priorities and work flow
  • Identify new requirements and implement them
==> cmake . -DCMAKE_INSTALL_PREFIX='/usr/local/Cellar/kde-phonon/4.4.2' -DCMAKE_BUILD_TYPE=None -Wno-dev
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Checking whether C compiler has -isysroot
-- Checking whether C compiler has -isysroot - yes
-- Checking whether C compiler supports OSX deployment target flag
-- Checking whether C compiler supports OSX deployment target flag - yes
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
source 'http://rubygems.org'
gem 'aasm', '2.2.0'
gem 'activeresource', '2.3.11'
gem 'activesupport', '2.3.11'
gem 'acts-as-taggable-on', '2.0.6'
gem 'block_helpers', '0.3.3'
gem 'coderay', '0.9.7'
gem 'fcgi', '0.8.8'
gem 'hoe', '2.9.1'
class String
def replace_line_break
return String.new if self.nil?
return_str = String.new
return_str = self.gsub(/[\x0D|\x0A]/,'<br />')
return return_str
end
end