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
function current_git_branch { | |
git branch 2> /dev/null | grep '\*' | awk '{print $2}' | |
} | |
hack() | |
{ | |
CURRENT=$(current_git_branch) | |
git checkout master | |
git pull origin master | |
git checkout ${CURRENT} |
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
BR=$(git symbolif-ref HEAD 2> /dev/null || git name-rev HEAD 2> /dev/null || echo 'no branch') | |
BR=${BR#HEAD\ } | |
BR=${BR#refs/heads/} |
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
reinhenrichs(master):rubinius$ cd kernel | |
reinhenrichs(master):rubinius/kernel$ cd common | |
reinhenrichs(master):rubinius/kernel/common$ cd .. | |
reinhenrichs(master):rubinius/kernel$ git checkout HEAD^ | |
reinhenrichs(master~1):rubinius/kernel$ | |
reinhenrichs(master~1):rubinius/kernel$ git checkout master | |
reinhenrichs(master):rubinius/kernel$ cd .. | |
reinhenrichs(master):rubinius$ cd .. | |
reinhenrichs:/Users/reinhenrichs/code/opensource$ |
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
module Readers | |
# Maps key/value pairs from the data structure used to initialize a | |
# Endeca object. Allows attribute renaming. Use a block to perform data | |
# injunction on the value as it is set. Depends on an +attributes+ accessor | |
# for the attributes hash. | |
# | |
# ==== Examples | |
# | |
# # Specify basic attributes | |
# reader :title |
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
# Thanks to Josh Susser | |
class Object | |
alias_method :try, :send | |
end | |
class NilClass | |
def try | |
nil | |
end | |
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
class Endeca::Document < SomeAwesomeName::Abstract | |
def properties | |
@properties ||= @raw['Properties'] || {} | |
end | |
alias_method :attributes, :properties | |
# Returns the collection of Endeca::Dimension for the given Document | |
def dimensions | |
return @dimensions if @dimensions | |
@dimensions = {} |
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
class Hash | |
def to_query_string | |
map { |k, v| | |
"#{URI.esacape(k)}=#{URI.escape(v)}" | |
}.join('&') | |
end | |
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
module Enumerable | |
def comprehend(&block) | |
map(&block).compact | |
end | |
def comprehend2(&block) | |
inject([]){|arr, x| result = block[x]; arr << result if result; arr} | |
end | |
def comprehend3(&block) |
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
#!/bin/env ruby -wdK | |
# Given an array, print it as a bar graph | |
# Use FOR SPEED!!! | |
class VertiBar | |
WIDTH = 72 | |
STEPS = WIDTH/6 | |
def self.draw(sample) | |
new(sample).draw | |
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
def self.next_available_arv_id | |
return self.get_next_patient_identifier(identifier_type = "Arv national id") | |
end |