This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Rake task to launch multiple Resque workers in development/production with simple management included | |
require 'resque/tasks' # Require Resque tasks | |
namespace :workers do | |
# = $ rake workers:start | |
# | |
# Launch multiple Resque workers with the Rails environment loaded, | |
# so they have access to your models, etc. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
doc = Nokogiri::HTML(doc,nil,'UTF-8') | |
doc.search('script').remove | |
doc.search('meta').remove | |
doc.search('style').remove | |
doc.search('link').remove | |
doc.search('base').remove | |
doc.search('iframe').remove | |
doc.search('embed').remove | |
doc.search('object').remove | |
doc.css("a.blippr-inline-smiley").remove |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra' | |
require 'redis' | |
require 'json' | |
require 'date' | |
class String | |
def &(str) | |
result = '' | |
result.force_encoding("BINARY") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'wirble' | |
require 'thread' | |
Wirble.init | |
def rails?(*args) | |
version=args.first | |
v2 = ($0 == 'irb' && ENV['RAILS_ENV']) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# activerecord logging methods | |
# very useful for digging into | |
# queries | |
require 'logger' | |
require 'activerecord' if rails?(2) | |
require 'hirb' | |
Hirb.enable | |
def enable_logger |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def l(filename) | |
if rails?(2) | |
load RAILS_ROOT + '/tmp/' + "#{filename}.rb" | |
else | |
load Rails.root.join("tmp/#{filename}.rb") | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
export PATH=/bin:/usr/bin:/sbin:/usr/sbin | |
usage=$( | |
cat <<EOF | |
$0 [OPTIONS] start/stop | |
-s set speed default 256Kbit/s | |
-p set port default 3000 | |
-d set delay default 350ms |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'sequel' | |
require 'fileutils' | |
require 'yaml' | |
# NOTE: This converter requires Sequel and the MySQL gems. | |
# The MySQL gem can be difficult to install on OS X. Once you have MySQL | |
# installed, running the following commands should work: | |
# $ sudo gem install sequel | |
# $ sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :db do | |
task :load_config => :rails_env do | |
require 'active_record' | |
ActiveRecord::Base.configurations = Rails::Configuration.new.database_configuration | |
end | |
desc "Create Sample Data for the application" | |
task(:truncate => :load_config) do | |
begin | |
config = ActiveRecord::Base.configurations[RAILS_ENV] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
isp=$(dig +noall +stats 2>&1 | awk '$2~/^SERVER:$/{split($3,dnsip,"#");print dnsip[1]}'); | |
m="-------------------------------------------------------------------------------"; | |
s=" "; | |
h="+${m:0:25}+${m:0:12}+${m:0:12}+${m:0:12}+${m:0:12}+${m:0:12}+"; | |
header=("Domain${s:0:23}" "Your ISP${s:0:10}" "Google${s:0:10}" "4.2.2.2${s:0:10}" "OpenDNS${s:0:10}" "DNS Adv.${s:0:10}"); | |
echo "${h}"; | |
echo "| ${header[0]:0:23} | ${header[1]:0:10} | ${header[2]:0:10} | ${header[3]:0:10} | ${header[4]:0:10} | ${header[5]:0:10} |"; | |
echo "${h}"; | |
for i in "lifehacker.com" "facebook.com" "manu-j.com" "reddit.com" "tb4.fr" "bbc.co.uk"; |