Skip to content

Instantly share code, notes, and snippets.

@j-manu
j-manu / workers.rake
Created December 4, 2011 07:09 — forked from karmi/workers.rake
Rake taks to launch multiple Resque workers in development/production with simple management included
# 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.
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
@j-manu
j-manu / app.rb
Created November 30, 2011 21:38 — forked from cpatni/app.rb
unique calculation using redis
require 'sinatra'
require 'redis'
require 'json'
require 'date'
class String
def &(str)
result = ''
result.force_encoding("BINARY")
require 'rubygems'
require 'wirble'
require 'thread'
Wirble.init
def rails?(*args)
version=args.first
v2 = ($0 == 'irb' && ENV['RAILS_ENV'])
# activerecord logging methods
# very useful for digging into
# queries
require 'logger'
require 'activerecord' if rails?(2)
require 'hirb'
Hirb.enable
def enable_logger
def l(filename)
if rails?(2)
load RAILS_ROOT + '/tmp/' + "#{filename}.rb"
else
load Rails.root.join("tmp/#{filename}.rb")
end
end
#!/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
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
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]
#!/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";