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
DEFAULT_POWER = 10 | |
def exponent(integer, power: DEFAULT_POWER, **keywords) | |
integer ** power | |
end | |
puts exponent(10, power: 2) | |
puts exponent(10) | |
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
[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 |
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
# 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 |
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 Foo | |
class << self | |
def bar; 'class bar'; end | |
protected :bar | |
end | |
def bar; 'instance bar'; end | |
end | |
if $0 == __FILE__ | |
begin |
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
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| |
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
#!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: | |
# |
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
# ~/.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}" |
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
# 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 |
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
# Sample gitconfig | |
# | |
[hub] | |
protocol = https | |
[user] | |
name = Jeremy Friesen | |
email = jeremy.n.friesen@gmail.com | |
[credential] | |
helper = osxkeychain | |
[github] |
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
# @api public | |
# | |
# An ActiveRecord::Relation scope that meets the following criteria: | |
# | |
# * Users that are directly associated with the given entity through on or | |
# more of the given roles | |
# * Users that are indirectly associated with the given entity by group | |
# and role. | |
# | |
# @param roles [Sipity::Models::Role] |