Skip to content

Instantly share code, notes, and snippets.

View trobrock's full-sized avatar

Trae Robrock trobrock

View GitHub Profile
numbers = [1,2,3,4,5,6,7,8,9]
target = 50
k = 5
def calculate_sum(inputs, k)
inputs.each_index do |i|
pairing = [inputs[i]]
inputs.each_index do |j|
next if i == j
set -g default-terminal "screen-256color"
# Use the system pasteboard
set-option -g default-command "reattach-to-user-namespace -l zsh"
# Bind Control key to match Screen
set -g prefix C-a
# Use vi key bindings
set -g status-keys vi
@trobrock
trobrock / snapshots.rake
Created November 17, 2011 23:18
Clean up EC2 snapshots
namespace :snapshots do
desc "cull all snapshots except for 1st of each month and last 60 days."
task :cull do
ec2 = Configuration.instance.connection
snaps = ec2.describe_snapshots
snaps = snaps.select {|s| DateTime.parse(s[:aws_started_at]) < 60.days.ago }
snaps.inject({}) { |newhash, h| newhash[Time.parse(h[:aws_started_at])] = h; newhash }
saved = newhash.keys.group_by { |date| date.month }.map { |k, v| v.first }
saved.each do |key|
snaps.delete key
#!/bin/bash
/usr/bin/ruby -e "$(curl -fsSL https://raw.git.com/gist/323731)"
brew install tomcat
brew install wget
brew install jenkins
brew install node
#!/bin/bash
curl -s https://rvm.beginrescueend.com/install/rvm | bash
'[[ -s "/Users/release/.rvm/scripts/rvm" ]] && source "/Users/release/.rvm/scripts/rvm"\nexport JAVA_HOME=/Library/Java/Home\nexport JRE_HOME=/Library/Java/Home\nexport JAVA_OPTS="-Djava.awt.headless=true -Xmx2048M"' > /Users/release/.profile
source /Users/release/.profile
rvm install --force ruby-1.8.7-p352
rvm install --force ree
function gbd() {
if [[ -n $1 ]]; then
if [[ -n $2 ]]; then
git push $1 :$2
git branch -d $2
else
git push origin :$1
git branch -d $1
fi
fi
@trobrock
trobrock / power.sh
Created April 11, 2012 18:16
Used for showing, and coloring the battery percentage in my tmux status line
#!/bin/zsh
power=$(/usr/sbin/ioreg -l | awk 'BEGIN{a=0;b=0}
$0 ~ "MaxCapacity" {a=$5;next}
$0 ~ "CurrentCapacity" {b=$5;nextfile}
END{printf("%.2f%%", b/a * 100)}')
charging=$(/usr/sbin/ioreg -l | awk '/IsCharging/{ print $5 }')
power_int=$(echo $power | sed 's/\..*//')
-> % bundle
....
Installing unf (0.0.5)
Bundler::GemNotFound: Could not find unf-0.0.5-jruby.gem for installation
An error occured while installing unf (0.0.5), and Bundler cannot continue.
Make sure that `gem install unf -v '0.0.5'` succeeds before bundling.
@trobrock
trobrock / queue.rb
Created May 23, 2012 15:16
Linked List Queue
class Queue
def initialize
@first = nil
@last = nil
@length = 0
end
def push(element)
node = Node.new
node.value = element
@trobrock
trobrock / queue.rb
Created May 23, 2012 15:19
Queue with an expanding buffer
class Queue
attr_reader :elements
def initialize
@elements = Buffer.new
end
def push(element)
@elements << element
end