This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Returns an array which index [0] represents the least significant bit. | |
# to_negativebase(9) # => [1, 0, 0, 1, 1] | |
# to_negativebase(-9) # => [1, 1, 0, 1] | |
def to_negativebase(value, base = -2) | |
raise ArgumentError if base > -2 | |
digits = [] | |
while value != 0 | |
value, mod = value.divmod(base) | |
if mod < 0 | |
mod += -base |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
git branch -r --merged | grep origin | sed 's/origin\///' | xargs -n 1 git push --delete origin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Great presentation on vim | |
" http://slidedeck.io/inside/vim-presentation | |
autocmd filetype crontab setlocal nobackup nowritebackup | |
set nocompatible | |
filetype off | |
" Python3 | |
let g:python3_host_prog = '/usr/local/bin/python3' | |
" PLUG BEGIN |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
database: &default | |
host: 127.0.0.1 | |
adapter: proxy_mysql2 | |
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "csv" | |
require "bugsnag/api" | |
token = ENV["TOKEN"] | |
Bugsnag::Api.configure do |config| | |
config.auth_token = token | |
end | |
def organization |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run rake db:size to get a print of your database size in bytes. | |
# Run rake db:tables:size to get the sizes for individual tables | |
# Works for MySQL and PostgreSQL. Not tested elsewhere. | |
namespace :db do | |
desc 'Print data size for entire database' | |
task :size => :environment do | |
database_name = ActiveRecord::Base.connection.instance_variable_get("@config")[:database] | |
adapter = ActiveRecord::Base.connection.adapter_name.downcase |