This file contains 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
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 |
This file contains 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
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' |
This file contains 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
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 |
This file contains 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
# 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 |
This file contains 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
# 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 |
This file contains 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
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 |
This file contains 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
git clean -f -d |
This file contains 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
pbcopy < id_dsa.pub |
This file contains 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
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 |
This file contains 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
1. /usr/sbin/lsof +L1 # lists all open files | |
2. ls -l /proc/*/fd/ | grep deleted_file_name # processes writing to a deleted file |
OlderNewer