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 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 |
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
#!/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) |
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
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' |
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
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 => [ |
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
[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 |
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
name "application" | |
run_list "application" |
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
[release@thrift1 20120911215203]$ jruby -v | |
jruby 1.5.6 (ruby 1.8.7 patchlevel 249) (2010-12-03 9cf97c3) (OpenJDK 64-Bit Server VM 1.6.0_24) [amd64-java] | |
[release@thrift1 20120911215203]$ jruby -Sgem env | |
RubyGems Environment: | |
- RUBYGEMS VERSION: 1.3.6 | |
- RUBY VERSION: 1.8.7 (2010-12-03 patchlevel 249) [java] | |
- INSTALLATION DIRECTORY: /opt/jruby-1.5.6/lib/ruby/gems/1.8 | |
- RUBY EXECUTABLE: /opt/jruby-1.5.6/bin/jruby | |
- EXECUTABLE DIRECTORY: /opt/jruby-1.5.6/bin | |
- RUBYGEMS PLATFORMS: |
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/sh | |
git checkout master | |
remote=$1 | |
branches=$(git branch --remote --merged master | grep $remote/ | grep -v /master) | |
for branch in $branches | |
do | |
branch=$(echo $branch | cut -d'/' -f2) | |
git push $remote :$branch |
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
#!/usr/bin/env ruby | |
wanting = ARGV[0] | |
role = wanting.scan(/[a-z]+/).first.to_sym | |
number = wanting.scan(/\d+/).first.to_i | |
ROLES = {} | |
def role(role, *hosts) | |
hosts.pop if hosts.last.is_a?(Hash) | |
ROLES[role] = hosts |
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
#!/usr/bin/env ruby | |
require 'stringex' | |
title = ARGV.first | |
date = "#{Time.now.year}-#{Time.now.month}-#{Time.now.day}" | |
file_name = "#{date}-#{title.to_url}.md" | |
File.open(File.join("_posts", file_name), 'w') do |f| | |
f.puts "---" | |
f.puts "layout: post" |