Skip to content

Instantly share code, notes, and snippets.

View codatory's full-sized avatar

Alex Conner codatory

View GitHub Profile
#!/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...'
@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'
@codatory
codatory / Gemfile
Created October 22, 2012 20:28
AWS Status Checker
source :rubygems
gem 'libusb'
gem 'nokogiri'
require 'open-uri'
require 'json'
tweeter = 'JasonFalls'
keep_going = true
page = 1
yes = 0
no = 0
while keep_going do
for pid in `ps aux | grep '[p]ool www' | awk '{print $2}'`; do
head /proc/$pid/smaps | grep 'Rss' | awk '{print $2 $3}'
done
#!/bin/bash
SERVERS=( 8.8.8.8 8.8.4.4 209.244.0.3 209.244.0.4 )
for server in ${SERVERS[@]}; do
date -u "+%Y-%m-%d %H:%M UTC : Testing $server"
mtr -lrwc 20 -o 'LDRS NBAW V JMXI' $server
done
@codatory
codatory / stlib_loader.rb
Created January 9, 2013 15:35
require most of Ruby 1.9's standard library
libs = Dir.glob("#{ENV['MY_RUBY_HOME']}/lib/ruby/1.9.1/*.rb").map{|i| i.split('/').last.split('.').first}
libs.reject!{|i| i == 'debug'}
libs.reject!{|i| i =~ /tk/}
libs.reject!{|i| i =~ /^[A-Z]/}
libs.each do |lib|
puts "Loading #{lib}"
require lib
end
FOr b3 w1ll pR0dUc+, c@ch3d 3n4b|3d, 83 w1t. WI5h 34513r (4(h3d 0R +HE, 15 m1t3 pr3f3|23nc35 n0w, 1T 8@d \/\/3b.
@codatory
codatory / chicagovps.txt
Last active December 13, 2015 23:19
Cheap VPS Benchmarks
ChicagoVPS 2048 MB VPS
$40 /year (special)
Cachefly 100 MB Download: 3.36M/s in 30s
========================================================================
BYTE UNIX Benchmarks (Version 5.1.3)
System: rails: GNU/Linux
OS: GNU/Linux -- 2.6.32-042stab062.2 -- #1 SMP Wed Oct 10 18:28:35 MSK 2012
namespace :import do
desc 'Imports ZipCodes from geonames.org'
task :zip_codes do
require 'zip/zip'
require Rails.root.join('config/environment.rb')
ZIPFILE = Rails.root.join('tmp/zipcodes.zip')
CSV_OPTS = {col_sep: "\t", headers: [:country_code, :postal_code, :place_name, :state_name, :state_code, :county_name, :county_code, :community_name, :community_code, :lattitude, :longitude, :accuracy]}
if !File.exist?(ZIPFILE)