Skip to content

Instantly share code, notes, and snippets.

This is gist.
There are many like it, but this one is mine.
It is my life.
I must master it as I must master my life.
Without me gist is useless.
Without gist, I am useless.
@danielmorrison
danielmorrison / modifications.textile
Last active December 16, 2015 17:49
Raised garden bed SIPs (sub-irrigated planters)

Based on these plans: http://www.insideurbangreen.org/2010/06/subirrigated-raised-beds-anyone-can-make.html

my modifications:

  • Mine is two 2×8′s tall. That seemed to be deep enough for tomatoes/peppers/etc.
  • I used treated lumber (2nd most expensive variety at Lowe’s, IIRC) unfinished, unpainted. Treated lumber can be bad if it leeches into the potting mix, but since it doesn’t touch our mix (plastic sheeting) there’s no worry!
  • I used a 2" or 3" pvc fill pipe instead of the water bottles. Grab one at Lowe’s, and it’ll be long enough for two planters.
  • I snaked the drain pipe instead of cutting, having the two open ends flush against a wall. Was a bit difficult to keep flat. Enlist a helper or two, or cut.
  • bring the black plastic sheeting all the way up the sides. After filling with dirt, cut it flush with the sides.
  • I put black plastic on top too, tucking it into the sides. You could put mulch overtop, but I was lazy.
# call as `ruby gets_is_wierd.rb some_nonexistant_file.txt`
filename = ARGV[0]
begin
File.open(filename)
rescue Errno::ENOENT => e
print "Rats. File not found. Try another: "
# gets fails here because IO acts on the last file, not STDIN.
# chagning it to STDIN.gets works.
require "net/http"
require "cgi"
pid = 1
http = Net::HTTP.new('www.pepperjamnetwork.com', 80)
loop do
request = Net::HTTP::Get.new("/affiliate/optout.php?pid=#{pid}&optout=1")
cookie = CGI::Cookie.new("PHPSESSID", "REPLACE WITH ACTUAL SESSION ID")
request['Cookie'] = cookie.to_s
r = http.request(request)
@danielmorrison
danielmorrison / gist:3866520
Created October 10, 2012 15:57
unicode ruby tricks
# If you like this, you'll love:
# https://github.com/collectiveidea/unicode_math
# encoding: utf-8
module Kernel
define_method "√" do |number|
Math.sqrt(number)
end
end
if status_code == 0
# do stuff
elsif status_code == 1
# do stuff
elsif status_code == 2
# do stuff
end
case status_code
when 0
@danielmorrison
danielmorrison / string.rb
Created June 21, 2012 00:46
There *is* an I in team!
# Inspired by http://www.neatorama.com/2012/06/13/there-is-an-i-in-team/
class String
alias_method :original_count, :count
def count(letter)
if self == 'team' && letter.downcase == 'i'
1
else
@danielmorrison
danielmorrison / gist:1186144
Created September 1, 2011 13:16 — forked from bryckbost/gist:1040263
Capybara 1.0 and Chrome
# env.rb
Capybara.register_driver :chrome do |app|
Capybara::Selenium::Driver.new(app, :browser => :chrome)
end
Capybara.javascript_driver = :chrome
Download chromedriver from http://code.google.com/p/selenium/downloads/list
@danielmorrison
danielmorrison / dates.rb
Created March 26, 2011 19:35
Problems with Date.parse
# Ruby 1.8.7
> Date.parse('01/06/2010').to_s
=> "2010-06-01"
# Ruby 1.9.2
> Date.parse('01/06/2010').to_s
=> "2010-01-06"