Skip to content

Instantly share code, notes, and snippets.

View trobrock's full-sized avatar

Trae Robrock trobrock

View GitHub Profile
name "application"
run_list "application"
[2012-08-30T15:02:18-07:00] INFO: Processing directory[/var/apps/outight_app/current/log] action delete (outright-application::default line 60)
[2012-08-30T15:02:18-07:00] INFO: Processing directory[/var/apps/outight_app/current/public/system] action delete (outright-application::default line 60)
[2012-08-30T15:02:18-07:00] INFO: Processing directory[/var/apps/outight_app/current/tmp/pids] action delete (outright-application::default line 60)
[2012-08-30T15:02:18-07:00] INFO: Processing execute[test ! -d /var/apps/outright_app/current/log] action run (outright-application::default line 66)
[2012-08-30T15:02:18-07:00] ERROR: execute[test ! -d /var/apps/outright_app/current/log] (outright-application::default line 66) has had an error
[2012-08-30T15:02:18-07:00] ERROR: execute[test ! -d /var/apps/outright_app/current/log] (/var/chef/cache/cookbooks/outright-application/recipes/default.rb:66:in `from_file') had an
error:
execute[test ! -d /var/apps/outright_app/current/log] (outright-application::default line 6
require 'rest-client'
req = RestClient::Request.new(
:method => :post,
:url => "https://snapi.sincerely.com/shiplib/create",
:payload => {
:appkey => ENV["SINCERELY_APP_KEY"],
:debugMode => true,
:frontPhotoId => image["id"],
:recipients => [
@trobrock
trobrock / trobrock.zsh
Created August 3, 2012 20:51
Custom additions to oh my zsh
alias gd='git diff'
alias gdc='git diff --cached'
alias gpq='git pull-request'
alias gld="gl | grep Updating | cut -d ' ' -f2 | xargs git diff"
alias grm="git status | awk '/deleted/{print \$3}' | xargs git rm"
alias gm='git merge --no-ff'
alias gmff='git merge'
alias gf='git fetch -p'
alias clean='find ./**/*.orig | xargs rm'
alias migrate='rake db:migrate db:test:prepare parallel:prepare'
@trobrock
trobrock / git_clean_remote.sh
Created July 31, 2012 18:40
Clean unneeded branches from a git remote
#!/usr/bin/env bash
git_clean_remote()
{
remote=$1
[[ -z "$remote" ]] && echo "Must provide a remote" && return 1
for branch in $(git branch -r | grep $remote | grep -v master)
do
diff=$(git cherry -v master $branch | wc -l)
class Calculator
def exec(expression)
while op = expression.match(/\([^()]+\)/)
offsets = op.offset(0)
out = exec op[0].gsub(/[()]/,'')
expression[offsets.first...offsets.last] = out.to_s
end
while op = expression.match(/\d+ ?[\*\/] ?\d+/)
run_expression op, expression
@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
@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
-> % 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 / 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/\..*//')