Skip to content

Instantly share code, notes, and snippets.

@djburdick
djburdick / rotate matrix
Created November 17, 2010 05:18
playing with gists
def rotate_matrix(matrix)
output = Array.new(matrix.count) { Array.new(matrix.count) }
matrix.each_with_index do |mat, i|
j = matrix.count - 1
matrix[i].each do |n|
output[j][i] = n
j -= 1
end
app/models/kabam_payment.rb:284:in `create_from_postback'
app/models/kabam_payment.rb:15:in `handle_postback'
app/controllers/kabam_payments_controller.rb:20:in `perform_postback'
app/controllers/kabam_payments_controller.rb:8:in `create'
[GEM_ROOT]/gems/actionpack-3.0.9/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
[GEM_ROOT]/gems/actionpack-3.0.9/lib/abstract_controller/base.rb:150:in `process_action'
[GEM_ROOT]/gems/actionpack-3.0.9/lib/action_controller/metal/rendering.rb:11:in `process_action'
[GEM_ROOT]/gems/actionpack-3.0.9/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
[GEM_ROOT]/gems/activesupport-3.0.9/lib/active_support/callbacks.rb:436:in `_run__2339183601854325624__process_action__3247919654770010835__callbacks'
[GEM_ROOT]/gems/activesupport-3.0.9/lib/active_support/callbacks.rb:410:in `_run_process_action_callbacks'
MUL = 100 # normalize to whole number
def random_item
items = items.merge!('' => (100 - items.values.sum.to_f)).sort_by { |k,v| v }
percentile = 0
items.each do |loot,prob|
percentile += prob
return loot if rand(100*MUL) < (percentile*MUL)
end
@djburdick
djburdick / heroku.rake
Created December 30, 2012 01:27
Heroku rake tasks for deploy and system commands. #heroku, #deploy
# Usage: rake name:task app_name
task PROD = "appname" # "task" here stubs to prevent rake errors with commandline
task STAGING = "appname-staging"
APP = ARGV[1] || PROD # default app
puts "=== APP #{APP} ==="
namespace :deploy do
@djburdick
djburdick / deploy.rake
Last active December 10, 2015 08:48 — forked from njvitto/deploy.rake
heroku deploy and system command rake tasks. #heroku, #deploy
# Usage: rake name:task app_name
task PROD = "appname" # "task" here stubs to prevent rake errors with commandline
task STAGING = "appname-staging"
APP = ARGV[1] || PROD # default app
puts "=== APP #{APP} ==="
namespace :deploy do
@djburdick
djburdick / mysql_install
Last active December 11, 2015 18:49
mac brew install mysql. #mysql
1. brew install mysql
2. mysql_install_db --verbose --user=`whoami` --basedir="$(brew
-prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
3. mysql.server start
To launch on startup:
* if this is your first install:
mkdir -p ~/Library/LaunchAgents
@djburdick
djburdick / git_remove_untracked
Created January 26, 2013 21:27
git removing untracked files from working dir. #git
git clean -f -d
@djburdick
djburdick / mac_copy_commandline
Created January 26, 2013 21:32
mac clipboard copy from command line. #mac
pbcopy < id_dsa.pub
@djburdick
djburdick / rubymine_commands
Created January 26, 2013 21:35
rubymine commands. #rubymine
F4 # jumps to the method you have the cursor on
Command + T # find file by name
Command+Shit+T # find method by name
Command + Option <- # go back
Control + Tab # switch between last two used tabs
Shit + F5 # clone file
@djburdick
djburdick / files_being_written_to_deleted
Created January 26, 2013 21:38
files being written to that no longer exist. #linux
1. /usr/sbin/lsof +L1 # lists all open files
2. ls -l /proc/*/fd/ | grep deleted_file_name # processes writing to a deleted file