Skip to content

Instantly share code, notes, and snippets.

View codatory's full-sized avatar

Alex Conner codatory

View GitHub Profile
for pid in `ps aux | grep '[p]ool www' | awk '{print $2}'`; do
head /proc/$pid/smaps | grep 'Rss' | awk '{print $2 $3}'
done
require 'open-uri'
require 'json'
tweeter = 'JasonFalls'
keep_going = true
page = 1
yes = 0
no = 0
while keep_going do
@codatory
codatory / Gemfile
Created October 22, 2012 20:28
AWS Status Checker
source :rubygems
gem 'libusb'
gem 'nokogiri'
@codatory
codatory / csv_builder.rb
Created September 26, 2012 16:12
Plain Ruby 1.9 CSV Builder
# c = CSVBuilder.new ['column 1 name', 'column 2 name', 'column 3 name']
# rowdata.each do |r|
# special_column = r.boolean ? 'YES' : 'NO'
# c.add_row [special_column, r.name, r.date]
# end
# c.export('optional_filename.csv')
require 'csv'
require 'tempfile'
#!/bin/sh
FILENAME='check_update.sh'
URL='https://raw.github.com/gist/1950778'
if [[ -f $FILENAME ]]; then
echo 'Updating file in place...'
curl --retry 3 --progress-bar --location --time-cond $FILENAME --remote-time --output $FILENAME $URL
else
echo 'File does not exist, downloading...'
source :rubygems
gem 'mysql2'
gem 'sqlite3'
gem 'tiny_tds'
gem 'sequel'
gem 'progressbar'
<img src="foo.jpg" class="lowres" /><img src="foo2x.jpg" class="hires" />
@codatory
codatory / pinboard_check.rb
Created July 14, 2012 14:34
Quick and Dirty tool for finding stale bookmarks on Pinboard
require 'pinboard_api'
require 'peach'
require 'typhoeus'
hydra = Typhoeus::Hydra.new
PinboardApi.username = ''
PinboardApi.password = ''
pins = PinboardApi::Post.all
require 'set'
my_data = %w(cat cat dog dog foo bar bin baz baz bin)
my_set = Set.new
my_data.each do |i|
if my_set.add?(i)
puts "#{i} is the first of its kind"
else
@codatory
codatory / fuzzy_match.rb
Created June 22, 2012 21:14
Fuzzy Matching Library
class FuzzyMatch
class Matcher
require 'singleton'
require 'fuzzystringmatch'
include Singleton
JW = FuzzyStringMatch::JaroWinkler.create
def self.get_score(str1,str2)
JW.getDistance(str1,str2)
end