Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
require 'git'
require 'logger'
g = Git.open(Dir.pwd)
if ARGV.include?("-h") || ARGV.include?("--help")
puts <<-EOF
USAGE: git bump [options]
@dpmcnevin
dpmcnevin / gist:48c0cf022fa0ca610e12
Created October 12, 2014 01:57
Set iTerm2 Background Color per Git Repo (zsh)
set_color() {
local HEX_FG=$1
local HEX_BG=$2
local OPACITY=$3
local FG_R=`echo $HEX_FG | sed 's/../0x&,/g' | awk -F "," '{printf("%d",$1 * 257)}'`
local FG_G=`echo $HEX_FG | sed 's/../0x&,/g' | awk -F "," '{printf("%d",$2 * 257)}'`
local FG_B=`echo $HEX_FG | sed 's/../0x&,/g' | awk -F "," '{printf("%d",$3 * 257)}'`
local BG_R=`echo $HEX_BG | sed 's/../0x&,/g' | awk -F "," '{printf("%d",$1 * 257)}'`
local BG_G=`echo $HEX_BG | sed 's/../0x&,/g' | awk -F "," '{printf("%d",$2 * 257)}'`
@dpmcnevin
dpmcnevin / _.md
Created November 26, 2012 15:54
Another Inlet
@dpmcnevin
dpmcnevin / pivotal.rb
Created March 30, 2011 23:28
Git post-receive hook to modify stories in Pivotal Tracker
require 'rubygems'
require 'mail'
require 'pivotal_tracker'
require 'git'
class Pivotal
attr_reader :story, :project
SQL (0.1ms) BEGIN
Issue Load (0.1ms) SELECT `issues`.* FROM `issues` WHERE (`issues`.`resolution` IS NULL) AND (`issues`.`description` = '') AND (`issues`.`name` = 'something') ORDER BY start_at DESC LIMIT 1
SQL (0.2ms) SELECT COUNT(*) AS count_id FROM `comments`
SQL (18.6ms) INSERT INTO `comments` (`body`, `commentable_id`, `commentable_type`, `created_at`, `updated_at`, `user_id`) VALUES ('Duplicate attempted to open', 3370, 'Issue', '2010-11-03 14:36:12', '2010-11-03 14:36:12', 1)
SQL (47.5ms) ROLLBACK
class OperatingSystem < ActiveRecord::Base
belongs_to :host
def self.search(term)
t = OperatingSystem.arel_table
match_on = [:name,:version,:service_pack]
matches = match_on.map {|m| "IF(#{t[m].matches("%#{term}%").to_sql},operating_systems.#{m.to_s},NULL)" }
matching_string = "CONCAT_WS(' ', #{matches.join(",")}) as matched_on"
class Host < ActiveRecord::Base
has_one :operating_system
attr_accessor :matched_on
end
Rails.application.config.session_store :cookie_store, {
:domain => '.rails.local',
:key => '_sso_session'
}
Rails.application.config.secret_token = 'the same really long hex string'
Rails.application.config.session_store :cookie_store, {
:domain => '.rails.local',
:key => '_sso_session',
:secret => 'the same really long hex string'
}
config.action_controller.session = {
:domain => ".rails.local"
}