Skip to content

Instantly share code, notes, and snippets.

View jeremyf's full-sized avatar

Jeremy Friesen jeremyf

View GitHub Profile
[user]
name = Jeremy Friesen
email = jeremy.n.friesen@gmail.com
[color]
branch = auto
diff = auto
status = auto
[color "branch"]
current = red reverse
local = red bold
# Two spiffy github commands. One is to go to the appropriate branch
# The other is to open up the issues, allowing for passing a param and opening
# the specific issue
[alias]
# Open the current branch on github
hub = "! br=$(git branch --contains HEAD | sed -En \"s/^\\* //p\"); if ! git ls-remote . | grep -q -e \"refs/remotes/.*/${br}\"; then br=\"master\"; fi; open $(git config -l | sed -En \"s%remote.origin.url=git(@|://)(github.com)(:|/)(.+/.+).git%https://\\2/\\4/tree/${br}%p\")"
# Go to the github project's issues
# $ git hub-issue
# => open browser and go to project's issues
class Foo
class << self
def bar; 'class bar'; end
protected :bar
end
def bar; 'instance bar'; end
end
if $0 == __FILE__
begin
@jeremyf
jeremyf / snippet.rb
Created February 12, 2010 22:30
Compare two files
require 'pathname'
# Compares two files for "similar" look, ignoring
# where elements are in the document.
def collect_unique_lines(*args)
dir = Pathname.new(Rails.root.join('tmp'))
contents = File.read(dir.join(args.join('.'))).split("\n")
lines = []
# proposed_lines = []
contents.inject(lines) {|mem,string|
#!bash
#
# bash completion support for core Git.
#
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
# Distributed under the GNU General Public License, version 2.0.
#
# The contained completion routines provide support for completing:
#
# ~/.gitconfig
[alias]
# Open the current branch on github
hub = "! br=$(git branch --contains HEAD | sed -En \"s/^\\* //p\"); if ! git ls-remote . | grep -q -e \"refs/remotes/.*/${br}\"; then br=\"master\"; fi; open $(git config -l | sed -En \"s%remote.origin.url=git(@|://)(github.com)(:|/)(.+/.+).git%https://\\2/\\4/tree/${br}%p\")"
# Go to the lighthouse project, your config will need to have set the subdomain and project
# If branch begins with a number (0-9), then open that ticket # in Lighthouse
# Otherwise, go to milestones/current
lighthouse = "! ref=\"milestones/current\"; ticket=$(git branch --contains HEAD | sed -En \"s/^\\* //p\" | grep -e \"^[0-9]\" | awk '{print \"tickets/\"$1}'); if [[ -n \"${ticket}\" ]]; then ref=\"${ticket}\"; fi; open https://$(git config lighthouse.subdomain).lighthouseapp.com/projects/$(git config lighthouse.project)/${ref}"
#!/usr/bin/perl
# Thank you Gavin Brock (http://brock-family.org/gavin/perl) - June 2007
#==============================================================================#
use strict;
use warnings;
use Foundation;
#==============================================================================#
# I need class C to call the foo method for each module included
# that has the method foo. Order does not matter as much as each
# method getting called. alias method chain?
module ChainMethod
def chain_method(method_name)
base_method = instance_method(method_name.to_sym)
chained_method = included_modules.inject([base_method]) do |mem, mod|
if method = (mod.instance_methods.include?(method_name.to_s) ? mod.instance_method(method_name.to_sym) : nil)
mem << method
end
@jeremyf
jeremyf / wp2bgg.rb
Created January 12, 2012 17:56
A simple script to do some of the heavy lifting for moving Wordpress reviews to BoardGameGeek
#!/usr/bin/env ruby
require 'rubygems'
require 'nokogiri'
require 'highline/import'
require 'open-uri'
conversions = [
["<blockquote>", '[q]' ],
["</blockquote>", '[/q]' ],
@jeremyf
jeremyf / .rvmrc
Created March 21, 2012 14:50
.rvmrc file that is a shell script; From Object on Rails
#!/usr/bin/env bash
# This is an RVM Project .rvmrc file, used to automatically load the ruby
# development environment upon cd'ing into the directory
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional.
environment_id="ruby-1.9.2-p290@ootw"
#
# Uncomment following line if you want options to be set only for given project.