Skip to content

Instantly share code, notes, and snippets.

@jrmehle
jrmehle / bike_scraper.rb
Last active August 29, 2015 14:05
A script to quickly see if any bikes I'm interested in are in stock on my favorite site to buy bikes from.
require 'nokogiri'
require 'open-uri'
require 'colorize'
class BikeScraper
BIKES_DIRECT_URL = 'http://www.bikesdirect.com/products/cross_bikes.htm'
TARGET_BIKE_SIZE_REGEX = /56cm/
TARGET_BIKE_NAME = 'Fantom'
def execute
@jrmehle
jrmehle / gist:32458dc124db3407d5a8
Created October 29, 2014 21:05
Rubinius install fails in Yosemite
ruby-install --rubies-dir ~/.rvm/rubies rbx 2.2.10
>>> Installing rbx 2.2.10 into /Users/jared/.rvm/rubies/rbx-2.2.10 ...
>>> Installing dependencies for rbx 2.2.10 ...
Warning: openssl-1.0.1j already installed
Warning: readline-6.3.8 already installed
Warning: libyaml-0.1.6 already installed
Warning: gdbm-1.11 already installed
>>> Downloading http://releases.rubini.us/rubinius-2.2.10.tar.bz2 into /Users/jared/src ...
>>> Verifying rubinius-2.2.10.tar.bz2 ...
>>> Extracting rubinius-2.2.10.tar.bz2 to /Users/jared/src/rubinius-2.2.10 ...
{
"color_scheme": "Packages/User/idleFingers.tmTheme",
"draw_white_space": "selection",
"ensure_newline_at_eof_on_save": true,
"file_exclude_patterns":
[
"*.pyc",
"*.pyo",
"*.exe",
"*.dll",
$('select#user_school_id').select2
minimumInputLength: 3
placeholder: 'Search for Your School'
@jrmehle
jrmehle / yuicompressor.sh
Created March 20, 2009 21:58
Ruby shell script wrapper around YUI compressor.
#!/usr/bin/env ruby
file_to_minify = ARGV.first
system "java -jar /Users/jaredmehle/Documents/workspace/yuicompressor-2.4.2/build/yuicompressor-2.4.2.jar #{file_to_minify} -o #{file_to_minify.split('.').first}-min.js"
# How to setup multiple heroku accounts
# (assuming you already have one setup)
# make sure ~/bin is in your path
create ~/bin/hcred and populate it with the following:
1 #!/usr/bin/env ruby
2
3 `rm ~/.heroku/credentials`
# Run rake db:size to get a print of your database size in bytes.
# Run rake db:tables:size to get the sizes for individual tables
# Works for MySQL and PostgreSQL. Not tested elsewhere.
namespace :db do
desc 'Print data size for entire database'
task :size => :environment do
database_name = ActiveRecord::Base.connection.instance_variable_get("@config")[:database]
adapter = ActiveRecord::Base.connection.adapter_name.downcase
sudo tcpdump -i eth0 -n -s 0 -w - | grep -a -o -E "Host\: .*|GET \/.*"
module Paperclip
module Dimension
def get_size_of(name, thumbnail=nil)
return '0x0' unless get_path_of(name, thumbnail)
Geometry.from_file(get_path_of(name, thumbnail)).to_s
end
# calculates width using processor
def get_width_of(name, thumbnail=nil)
return 0 unless get_path_of(name, thumbnail)
/Users/jared/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/meta_search-15d49d18cde6/lib/meta_search/builder.rb:138:in `method_missing'
/Users/jared/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/meta_search-15d49d18cde6/lib/meta_search/builder.rb:116:in `send'
/Users/jared/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/meta_search-15d49d18cde6/lib/meta_search/builder.rb:116:in `assign_attributes'
/Users/jared/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/meta_search-15d49d18cde6/lib/meta_search/builder.rb:115:in `each_pair'
/Users/jared/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/meta_search-15d49d18cde6/lib/meta_search/builder.rb:115:in `assign_attributes'
/Users/jared/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/meta_search-15d49d18cde6/lib/meta_search/builder.rb:90:in `build'
/Users/jared/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/meta_search-15d49d18cde6/lib/meta_search/searches/active_record.rb:32:in `search'
app/controllers/north_star/properties_controller.rb:22:in `search'
actionpack (3.0.3) lib/action_controller/metal/implicit_rend