Skip to content

Instantly share code, notes, and snippets.

View benjaminoakes's full-sized avatar

Ben Oakes benjaminoakes

View GitHub Profile
puts "hello world!"
# autocompletion for ruby_test
# # works with tu/tf aliases
# # see also ~/bin/ruby_test.rb
_ruby_tests() {
if [[ -n $words[2] ]]; then
compadd `ruby_test -l ${words[2]}`
fi
}
compdef _ruby_tests ruby_test
alias tu="ruby_test unit"
@benjaminoakes
benjaminoakes / gist:1201052
Created September 7, 2011 16:36
Padrino console on Heroku
$ heroku console
Ruby console for myapp.heroku.com
>> var_that_does_not_exist
! Internal server error
>>
$ heroku run bundle exec padrino console -e production
Running bundle exec padrino console -e production attached to terminal... up, run.9
=> Loading production console (Padrino v.0.10.1)
=> Loading Application MyApp
=> Loading Application Admin
@benjaminoakes
benjaminoakes / gist:1259589
Created October 3, 2011 16:56
EMScripten performance
def fib(i)
if i == 0 || i == 1
1
else
fib(i - 2) + fib(i - 1)
end
end
start = Time.now
puts fib(20)
@benjaminoakes
benjaminoakes / example.rb
Created April 19, 2012 16:01
`dry_run` gives HTTParty::Parser has not implemented a parsing method for the :json format.
# I'm not sure what's causing this yet. If you'd like, message me via GitHub if you've run into the same issue.
@benjaminoakes
benjaminoakes / LICENSE
Created October 11, 2012 02:45
Playing around with Ubuntu's beta web API
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
@benjaminoakes
benjaminoakes / mixed_mode_rvm.txt
Last active December 12, 2015 01:39
rvm mixed mode (rvm user all) passenger install error
$ \curl -L https://get.rvm.io | sudo bash -s stable
$ rvm user all
$ rvm install ruby-1.9.3-p327
$ rvm use ruby-1.9.3-p327 --default
$ gem install passenger
$ passenger-install-apache2-module
Welcome to the Phusion Passenger Apache 2 module installer, v3.0.19.
This installer will guide you through the entire installation process. It
shouldn't take more than 3 minutes in total.
{
"$schema": "http://json-schema.org/draft-04/hyper-schema",
"id": "schemata/program",
"title": "Program",
"description": "An applicant applies to a **program** at an organization.",
"definitions": {
"href": {
"type": "string",
"description": "Hypertext reference to this resource.",
@benjaminoakes
benjaminoakes / table_size.psql
Created April 21, 2016 20:38
Calculate size of PostgreSQL tables
dbname=# SELECT
dbname-#    relname as "Table",
dbname-#    pg_size_pretty(pg_total_relation_size(relid)) As "Size",
dbname-#    pg_size_pretty(pg_total_relation_size(relid) - pg_relation_size(relid)) as "External Size"
dbname-#    FROM pg_catalog.pg_statio_user_tables ORDER BY pg_total_relation_size(relid) DESC;
                      Table                       |    Size    | External Size
--------------------------------------------------+------------+---------------
table1                           | 19 GB      | 1665 MB
table2                           | 12 GB      | 9720 MB
table3                           | 10 GB      | 5903 MB
@benjaminoakes
benjaminoakes / travisci_notifier.js
Last active April 27, 2017 18:52
Travis CI Notifier - run from console on a build page and you'll see a notification when it's done
// Straight from MDN
function notifyMe(s) {
// Let's check if the browser supports notifications
if (!("Notification" in window)) {
alert("This browser does not support desktop notification");
}
// Let's check whether notification permissions have already been granted
else if (Notification.permission === "granted") {
// If it's okay let's create a notification