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
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 |
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
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 |
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
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 |
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 | |
/usr/bin/ruby -e "$(curl -fsSL https://raw.git.com/gist/323731)" | |
brew install tomcat | |
brew install wget | |
brew install jenkins | |
brew install node |
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 | |
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 |
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
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 |
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/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/\..*//') |
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
-> % 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. |
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
class Queue | |
def initialize | |
@first = nil | |
@last = nil | |
@length = 0 | |
end | |
def push(element) | |
node = Node.new | |
node.value = element |
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
class Queue | |
attr_reader :elements | |
def initialize | |
@elements = Buffer.new | |
end | |
def push(element) | |
@elements << element | |
end |