Skip to content

Instantly share code, notes, and snippets.

View jhsu's full-sized avatar
💀
compliant with future standards

Joe Hsu jhsu

💀
compliant with future standards
  • MineHub
  • New York, NY
  • X @jhsu
View GitHub Profile
def name_like(names)
names = names.gsub(/,/, ' ').split
results = self.search
names.map do |name|
results = results.search(:first_name_like_or_last_name_like_or_middle_name_like => name)
end
results
end
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
}
export PS1='# \u@\h \[\033[1;33m\]\w\[\033[0m\]$(parse_git_branch) $\n# '
[color]
branch = auto
diff = auto
status = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
def run(command=:all)
query = {}
options = {:include => self.tables, :conditions => self.to_condition}
options.merge!({:select => :id}) if command == :count
query[:id_in] = ids if ids && !ids.empty?
query[:id_not_in] = exclude_ids if exclude_ids && !exclude_ids.empty?
results = Applicant.search
if !query.keys.empty?
query.each { |scope, ids| results = results.send(scope, ids) }
results = results.all
@jhsu
jhsu / workflow.markdown
Created January 22, 2010 15:48
Git Workflow Blueprint
namespace :do do
desc 'update changelog'
task :changelog do
# Pass in git opts by opts="-5" # -5 is number of commits
File.open('CHANGELOG', 'w+') do |changelog|
`git log -z --tags --abbrev-commit --no-color --format=fuller #{ENV['opts']}`.split("\0").each do |commit|
next if commit =~ /^Merge: \d*/
ref, author, author_time, commiter, commiter_time, _, title, message = commit.split("\n", 8)
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
}
function git_branch_name {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/"
}
startup_message off
term screen-256color-bce
# term xterm-256color
escape ^Bb
# terminfo and termcap for nice 256 color terminal
# allow bold colors - necessary for some reason
attrcolor b ".I"
# tell screen how to set colors. AB = background, AF=foreground
require 'benchmark'
class Rake::Task
def execute_with_benchmark(*args)
bench = Benchmark.measure do
execute_without_benchmark(*args)
end
puts "\n #{name} --> #{bench}"
end
alias_method_chain :execute, :benchmark
end
# ams git hotfix save_workflow
/Users/jhsu/.ams/extensions/git/bin/hotfix:shift:9: shift count must be <= $#
/Users/jhsu/.ams/extensions/git/bin/hotfix:45: no such file or directory: /Users/jhsu/.ams/extensions/git/scripts/update
Creating new branch for hotfix save_workflow
Switched to branch 'production'
Your branch is ahead of 'origin/production' by 7 commits.
Switched to a new branch 'hotfix-save_workflow'
You are now ready to start hacking on hotfix-save_workflow, Thank you, Come again.