Instantly share code, notes, and snippets.

View snoopy.rb
class Snoopy < BasicObject
def initialize(obj)
@obj = obj
end
def method_missing(method, *attributes, &block)
@obj.send(method, *attributes, &block).tap do |val|
@obj.send(:puts, "#{method} #{attributes} -> #{val}")
@obj.send(:puts, "\t#{::Kernel.caller.to_a[0..2].join("\n\t")}\n\n")
end
View example_output
BasicObject
Exception
MonitorMixin::ConditionVariable::Timeout
NoMemoryError
ScriptError
LoadError
Gem::LoadError
NotImplementedError
SyntaxError
SecurityError
View poi_counter.rb
#/usr/bin/env ruby
require 'rexml/document'
total_poi_count = 0
Dir.glob("output/*.xml").each do |file|
# extract event information
doc = REXML::Document.new(File.read(file))
poi_count = doc.elements.to_a('//vendor-pois/entry').length
puts "Count: #{poi_count} for #{file}"
View up_postgres.sh
echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" | sudo tee -a /etc/apt/sources.list.d/pgdg.list
wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install postgresql-9.3 postgresql-9.3-postgis-2.1 postgresql-contrib-9.3 libpq-dev postgresql-9.3-postgis-2.1
cd /tmp
View repository_archiver.rb
#!/usr/bin/env ruby
require 'optparse'
require 'aws-sdk'
options = {}
opt_parser = OptionParser.new do |opt|
opt.banner = "Usage: AWS_ACCESS_KEY_ID=123 AWS_SECRET_ACCESS_KEY=123 repository_archiver.rb --archive unused-fork,some_project,rails"
opt.on("-a","--archive unused-fork,some_project,rails","Name of repositories to clone & archive to S3",Array) do |repositories|
View chef_upgrade_postgis.diff
diff --git a/cookbooks/spp/recipes/postgis.rb b/cookbooks/spp/recipes/postgis.rb
index a893070..26a0edc 100644
--- a/cookbooks/spp/recipes/postgis.rb
+++ b/cookbooks/spp/recipes/postgis.rb
@@ -1,4 +1,45 @@
-package "postgresql-9.1-postgis"
+
+
+#http://linfiniti.com/2012/05/installing-postgis-2-0-on-ubuntu/
+#https://github.com/realityforge/chef-postgis/blob/master/recipes/default.rb
View gist:5359180
$ sudo -E -u dev /opt/boxen/homebrew/bin/brew boxen-install boxen/brews/postgis -v
==> Downloading http://postgis.refractions.net/download/postgis-1.5.3.tar.gz
Already downloaded: /opt/boxen/cache/homebrew/postgis-1.5.3-boxen1.tar.gz
Warning: MD5 support is deprecated and will be removed in a future version.
Please switch this formula to SHA1 or SHA256.
tar xf /opt/boxen/cache/homebrew/postgis-1.5.3-boxen1.tar.gz
==> ./configure --disable-dependency-tracking --prefix=/opt/boxen/homebrew/Cellar/postgis/1.5.3-boxen1 --with-projdir=/opt/boxen/homebrew
./configure --disable-dependency-tracking --prefix=/opt/boxen/homebrew/Cellar/postgis/1.5.3-boxen1 --with-projdir=/opt/boxen/homebrew
configure: WARNING: unrecognized options: --disable-dependency-tracking
checking build system type... x86_64-apple-darwin12.2.0
View gist:5323604
exec { "Fix homebrew installing node issue": # https://github.com/mxcl/homebrew/issues/13337
command => "xcode-select -switch /usr/bin",
user => "root"
}
View gist:5243311
sudo spctl --master-disable # Must be sudo, 'cause it returns successfully but does nothing ><
View sublime_config.pp
class config::sublime {
define addpkg {
$packagedir = "/Library/Application Support/Sublime Text 2/Packages/"
$pkgarray = split($name, '[/]')
$pkgname = $pkgarray[1]
exec { "git clone https://github.com/${name}.git":
cwd => "/Users/${::luser}${packagedir}",
provider => 'shell',