Skip to content

Instantly share code, notes, and snippets.

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)
http://🐷🍉🎮💣🍟🍍🐊🍎.🍕💩.ws

Keybase proof

I hereby claim:

  • I am danielmorrison on github.
  • I am danielmorrison (https://keybase.io/danielmorrison) on keybase.
  • I have a public key whose fingerprint is 44D2 A17B 5B7B DD20 FD60 F6DF A1C6 359B 1FAF 4A90

To claim this, I am signing this object:

@danielmorrison
danielmorrison / spec_helper.rb
Created January 31, 2014 20:46
put inside spec/spec_helper.rb inside the RSpec.configure block
config.before(:suite) do
DatabaseCleaner.strategy = :truncation
DatabaseCleaner.clean_with(:truncation)
end
config.around(:each) do |example|
DatabaseCleaner.start
example.run
DatabaseCleaner.clean
end
@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.
@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