Skip to content

Instantly share code, notes, and snippets.

View perplexes's full-sized avatar

Colin Curtin perplexes

View GitHub Profile
@perplexes
perplexes / Procfile
Created March 5, 2015 19:25
Flowdock groups for hubot
web: bin/hubot -a flowdock -n <<<bot name>>> --enable-slash
### Keybase proof
I hereby claim:
* I am perplexes on github.
* I am perplexes (https://keybase.io/perplexes) on keybase.
* I have a public key whose fingerprint is E27F 1732 FE53 88CC F03B 3C84 3B74 C3C6 9C50 474E
To claim this, I am signing this object:
@perplexes
perplexes / sidekiq_middleware.rb
Created February 27, 2014 20:52
Sidekiq Middleware inspector
# Script to dump your current Sidekiq server middleware like `rake middleware`
# Drop this in script/sidekiq_middleware.rb and run:
# RAILS_ENV=production bundle exec sidekiq -r ./script/sidekiq_middleware.rb
puts "Eager loding Rails..."
require 'rails'
require 'sidekiq/rails'
require File.expand_path('./config/environment.rb')
::Rails.application.eager_load!
puts Sidekiq.server_middleware.entries.map(&:klass).join("\n")
@perplexes
perplexes / node.rb
Created June 5, 2013 22:14
Hash/Array Tree searcher
# > n = Node.find_where(terms2){|v| !v["Section"].empty?}
# => #<Node key="Sections" value=Hash children=1>
# > puts n.path
# => [0]["Departments"]["Department"][3]["Courses"]["Course"][1]["Sections"]
class Node
attr_reader :parent, :key, :value, :children
def initialize(parent, key, value)
@parent = parent
@key = key
@value = value
@perplexes
perplexes / buildpacks.md
Last active November 25, 2021 02:29
Heroku custom compiled library .bundle/config

Buildpacks

Heroku uses buildpacks to compile your application into a slug that is used across dynos for scaling horizontally quickly. A slug is a tar.gz archive of your app’s repository with certain pre-deploy features baked into the filesystem. Since everything to run your application is included in the archive, scaling becomes a simple matter of transferring it to a dyno, unpacking, and running the appropriate process. This is how Heroku achieves scaling-by-moving-a-slider.

For example, the Ruby buildpack will:

  • install ruby locally
  • install the jvm/jruby (if you’re using it)
  • install/run bundler and install your gems to Rails.root/vendor
  • create your database.yml (which ends up reading from your app’s environment variables)
@perplexes
perplexes / gist:5118700
Created March 8, 2013 18:34
Post csv to gist with net/http
require 'csv'
csv_string = CSV.generate do |csv|
csv << titles
data.sample(1000).each do |row|
csv << row
end
end; csv_string.size
require 'net/http'
require 'uri'
@perplexes
perplexes / tumblr2wordpress.rb
Last active December 14, 2015 02:49
A small script for moving from tumblr to wordpress
require 'xmlrpc/client'
wordpress = XMLRPC::Client.new('academiaedu.wordpress.com', '/xmlrpc.php')
require 'tumblr_client'
# To get these:
# Go to http://tumblr-rb.herokuapp.com/ (a service for the below)
# --OR--
# `gem install tumblr-rb` somewhere with a public ip address
@perplexes
perplexes / gist:4343520
Created December 20, 2012 07:20
brew install go fails (HB 0.9.3, go 1.0.3)
Colins-MacBook-Pro:local colin$ ls -lah /usr/local/opt/go
ls: /usr/local/opt/go: No such file or directory
Colins-MacBook-Pro:local colin$ brew -v install go
Homebrew 0.9.3
==> Downloading http://go.googlecode.com/files/go1.0.3.src.tar.gz
Already downloaded: /Users/colin/Library/Caches/Homebrew/go-1.0.3.tar.gz
/usr/bin/tar xf /Users/colin/Library/Caches/Homebrew/go-1.0.3.tar.gz
==> ./make.bash --no-clean
./make.bash --no-clean
# Building C bootstrap tool.
commit f65a43c9027d8fc82de44f82737a744dcac0556f
Author: Colin Curtin <colin.t.curtin@gmail.com>
Date: Wed Nov 7 12:21:46 2012 -0800
Fix documentation for .initial backend parameter to match the source.
diff --git a/doc/sphinx/reference/vcl.rst b/doc/sphinx/reference/vcl.rst
index 60daaa3..31c79a5 100644
--- a/doc/sphinx/reference/vcl.rst
+++ b/doc/sphinx/reference/vcl.rst
@perplexes
perplexes / readme.txt
Created June 13, 2012 10:18
Bandwidth monitor with tcpdump and ruby
EDIT: What you're looking for is iptraf (linux) or iftop (osx/brew) :P Yay @stormbrew
Here's a thing. The display is crap, but it mimics something that Windows 7 does pretty awesomely (??? did I just say that??).
> tcpdump -i en2 | ruby stream.rb
10.0.1.15.49257: 59.0617085357773 B/S
10.0.1.15.49302: 79.8090170222657 B/S
10.0.1.15.50671: 43.88880366791089 B/S
10.0.1.15.50684: 0.0 B/S
10.0.1.15.50685: 0.0 B/S