Skip to content

Instantly share code, notes, and snippets.

@robertjwhitney
robertjwhitney / download.rb
Created February 3, 2011 17:17
simple script to download an array of images over http
require 'net/http'
require 'yaml'
files = YAML.load_file("image_list.yml")
i = 1
files.each do |file|
# use root url without protocol
response = Net::HTTP.start("farm5.static.flickr.com") do |http|
http.get("#{file}")
end
puts "#{response}"

Michael M. upgrading...

dupdraded

Jack C. i dont feel any different

Michael M. it takes a minute to propagate to NJ

Winter L. has left the room

@robertjwhitney
robertjwhitney / yui_compressor.rb
Created April 28, 2011 14:46 — forked from seth/yui_compressor.rb
A Nanoc filter for minifying CSS and Javascript using the YUI Compressor
YUI_JAR = File.dirname(__FILE__) + "/../tools/yuicompressor-2.4.2.jar"
class YuiCompressor < Nanoc3::Filter
identifier :yui_compress
type :text => :binary
def run(content, params={})
type = type_from_extension
cmd = "java -jar #{YUI_JAR} --type #{type} -o #{output_filename}"
IO.popen(cmd, 'w') { |f| f.write(content) }
raise "yuicompressor exited with #{$?} for '#{cmd}'" unless $? == 0
@robertjwhitney
robertjwhitney / gist:1012440
Created June 7, 2011 15:07
extrating a bunch of images in subfolders
require 'fileutils'
@files = Dir.glob('/Users/BobW/desktop/test/*/*')
@files.each do |file|
FileUtils.mv(file, '/Users/BobW/desktop/test2')
end
@robertjwhitney
robertjwhitney / gist:1207453
Created September 9, 2011 22:03 — forked from ekampf/gist:847741
A ruby snippet to sanitize Html (and specifically Microsoft Word's messy HTML) (based on https://gist.github.com/139987)
# This function cleans up messy HTML that was pasted by a user to a WYSIWYG editor.
# Specifically it also handles messy Word\Outlook generated HTML while keeping its original formattings.
require 'rubygems'
require 'sanitize'
def clean_up_document(html)
elements = %w[p b h1 h2 h3 h4 h5 h6 strong li ul ol i br div pre p]
attributes = {
'a' => ['href', 'title'],
# gem install thin
# gem install rack
# thin -R static.ru start
# The static content rooted in the current working directory
# Dir.pwd =&gt; http://localhost:3000/
#
root=Dir.pwd
puts ">>> Serving: #{root}"
@robertjwhitney
robertjwhitney / heroku_deploy.rake
Created December 13, 2011 15:44 — forked from michaeldwan/heroku_deploy.rake
Simple Rake task for customizing deployment to Heroku
# rake deploy:production master
# List of environments and their heroku git remotes
ENVIRONMENTS = {
:staging => 'myapp-staging',
:production => 'myapp-production'
}
namespace :deploy do
ENVIRONMENTS.keys.each do |env|
@robertjwhitney
robertjwhitney / stupid-watcher.gemspec
Created December 22, 2011 23:24
stupid watcher is stupid
Gem::Specification.new do |s|
s.name = 'stupid-watcher'
s.version = '0.0.2'
s.platform = Gem::Platform::RUBY
s.author = 'Robert Whitney'
s.email = 'robertj.whitney@gmail.com'
s.summary = 'Stupid watcher is stupid'
s.description = 'Watches a file, does stuff when that file is updated.'
s.files = ['stupid_watcher.rb']
@robertjwhitney
robertjwhitney / digits.rb
Created January 25, 2012 04:05
get de digits
#http://thehackerolympics.com/
key = 'qwertyuiop'
string = 'iirytroyppytpeppowuiyoiuypipiyuyotyoiwiytorouqyiepyirueuiprpptwyiroqwtuyipourrrourorwipowiorutpwtwruuioquteorioriyutwqyyprptuqqquuituyywyuoewtrppqwrtiiruirpwyptpuoyyoeyerpqiotuieripurouwuwyuwrworowitoepoypeipeypiireeorrwripuuteoitpuutturruwiyryeetyrioweytueqrrrtotrpiqetoyepoipiwrwpppiritupwipruooiepoweypiuwrqywuuwyiroqpqpruioopuiuerputpwwuuiqwpiroewrtwiqerteoyeqtutwoeoipioiuqiiiouuoqtuuwtuwiiqwppqitywuqpuutrqiyoeuuutwrwtoqrqyoeyoiporuuioiwryoeruypreprqroiyuqwtuyoytoerwqryeeripryieypiwqirtriurueypiuyuypriuiwptywppupoioyrewooytreteeriiwroietuwypieeeeeqpiiiwrirtppoeyiwpooyyporpruwuoriiyowuytiwpwpryeywotoyirqypyypoeptiuwwoyprquoetepptorwiewprpiywwtuieeiweytrrwiqtwotioryoiptyyyuriiqiyroeeiqepwteuwptpruuypipieuoiiuuweeuryuuowporrooyywyyrryriqyirooitirueruptotpryoqtipippyptiurwyiryooywtryyuurtrutwqiqiiiqwouyeooueoturuowiuwrtruwwiupwopwweoo'
#split into unique pairs
array = string.scan(/../)
unique_pairs = array.keep_if {|letters| array.count(letters) == 1}
@robertjwhitney
robertjwhitney / gmail_filter.txt
Created March 7, 2012 20:37
Awful Recruiters
*@workbridgeassociates.com OR *@vtrit.com OR *@jsgeeks.com OR *@questgroups.com OR *@identified.com OR *@sysdevit.com OR *@kbretz.com OR *@brightonsearchgroup.com OR *@trajectory.us.com OR *@peakrecruit.com OR *@turner.com OR *@surrex.com OR *@strategic-staffing.com OR *@encoress.com OR *@kforce.com OR *@epro-consulting.com OR *@resourcis.com OR *@bravotech.com OR *@aplussearch.com OR *@kutirtech.com OR *@thebackplane.com OR *@sptechpartners.com OR *@aimconsulting.com OR *@jobspringpartners.com OR *@axiustek.com OR *@lumoslabs.com OR *@rivierapartners.com OR *@omegasolutioninc.com OR *@good.com OR *@marlabs.com OR *@silversearchinc.com OR *@ownpointofsale.com OR *@talent4now.com OR *@githire.com OR *@linkedin.com OR *@clearslide.com OR *@xcreek.com OR *@disys.com OR *@jinibot.com OR *@avanitechsolutions.com