The fool proof network copy & paste program. Well, maybe someday.
> nwcopy /Users/josh/Dropbox/nwcopy/f314eee55161b14f140ee07b358ba63ef54112ac > nwpaste https://github.com/j05h/nwcopy
namespace :test do | |
desc "Ensures there are no dependencies between test classes." | |
task :each => %w(each:functional each:unit each:integration) | |
namespace :each do | |
def each_test(tests) | |
# This is where the magic happens | |
ENV['TESTOPTS'] = '--verbose=progress' unless ENV['TESTOPTS'] | |
tests.each do |path| | |
puts "\n#{path}" |
awk '{ sub(/([0-9]+\.?)+/, ":id", $3); | |
sub(/[0-9]+/, ":id", $3); | |
sub(/=.*&/, "=:param\\&", $3); | |
sub(/=.*$/, "=:param", $3); | |
sub(/\?[:a-z0-9]+$/, "", $3); | |
print $1, $2, $3, $4 | |
}' | sort | uniq -c | sort |
class A | |
class B | |
def self.const_get(n) | |
self.const_set(n,Class.new(self){ | |
self.const_set("D",Class.new(self)) | |
}) | |
end | |
end | |
end | |
puts A::B::C::D rescue puts $! |
# this is a stupid simple random stringifier | |
"#{10.times.map{(rand(26) + 97).chr}.join}_#{Time.now.to_i.to_s}" | |
#=> "qnoqszbiam_1285701912" |
module Crypto | |
class UnexpectedAlgorithmException < Exception | |
end | |
class << self | |
def hashtext thing, *extras | |
Digest::SHA1.hexdigest(([thing] + extras).join(" ")) | |
end | |
# Always returns a different hex salt, using +extras+ for added |
class Numeric | |
def to_rad | |
self * Math::PI / 180 | |
end | |
end | |
# http://www.movable-type.co.uk/scripts/latlong.html | |
# loc1 and loc2 are arrays of [latitude, longitude] | |
def distance loc1, loc2 | |
lat1, lon1 = loc1 |
#!/usr/bin/env ruby | |
# This class will check search rubygems.org for all gems in a given Gemfile. | |
# If a given gem is not available on rubygems.org, it will tell you such. | |
class VerifyGems | |
def initialize _file, _source | |
@file = _file || 'Gemfile' | |
@source = _source || 'http://rubygems.org' | |
@gems = [] | |
@verbose = false |
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'mechanize' | |
def download path, site | |
url = "http://reddpics.com/moreimages/#{site}/#{path}" | |
agent = Mechanize.new | |
page = agent.get url | |
page.links_with(:href => /i.imgur.com/).map(&:href).uniq.each do |img| |
#!/bin/sh | |
# | |
# init.d script for single or multiple unicorn installations. Expects at least one .conf | |
# file in /etc/unicorn | |
# | |
# Modified by [email protected] http://github.com/jaygooby | |
# based on http://gist.github.com/308216 by http://github.com/mguterl | |
# | |
## A sample /etc/unicorn/my_app.conf | |
## |