Skip to content

Instantly share code, notes, and snippets.

View ChaeOkay's full-sized avatar

Chae O'Keefe ChaeOkay

View GitHub Profile
# @return [Array<String>]
def gem_paths
Gem.path.flat_map { |path| Dir.glob("#{path}/gems/*") }
end
# @param [String] gem_name
# @return [Boolean]
# @raise [LoadError]
def require_gem(gem_name)
if defined?(::Bundler)
@Bartuz
Bartuz / validate_with_matcher.rb
Last active August 17, 2023 14:15 — forked from otaviomedeiros/validate_with_matcher.rb
RSpec matcher for validates_with
# RSpec matcher for validates_with.
# https://gist.github.com/2032846
# Usage:
#
# describe User do
# it { should validate_with CustomValidator }
# end
RSpec::Matchers.define :validate_with do |expected_validator, options|
match do |subject|
@validator = subject.class.validators.find do |validator|
@vanstee
vanstee / better.ex
Last active August 29, 2015 14:25
Chaining Ecto queries using a default query param
defmodule UserQueries do
def in_organization(query \\ User, organization) do
from u in query,
where: u.organization_id == ^organization.id
end
def in_patricks_family(query \\ User) do
from u in query,
where: u.last_name == ^"Van Stee"
end
@thejbsmith
thejbsmith / switch_iterm2_profile_during_ssh_sessions.sh
Created April 16, 2015 13:42
Switch iTerm2 Profile during SSH Sessions
# Add the following to your .bash_profile or .bashrc file in order to switch to a different iTerm profile during an ssh session.
# This same code could be re-purposed for any command, not just ssh
# Set iTerm2 Profile
set_iterm_profile() {
echo -e "\033]50;SetProfile=$1\a"
}
# Switch iTerm2 Profile during SSH Sessions
ssh() {
@zerowidth
zerowidth / sql.md
Last active April 11, 2017 18:31
GitHub::SQL - a helping hand for SQL in a rails app

DEPRECATED

GitHub::SQL has been released as an officially-maintained project and ruby gem: github/github-ds.

@steveclarke
steveclarke / capybara.md
Created April 10, 2012 17:32
RSpec Matchers

Capybara

save_and_open_page

Matchers

have_button(locator)
@yano3
yano3 / gist:1378948
Created November 19, 2011 15:17
git commit --amend --reset-author
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:
git config --global user.name "Your Name"
git config --global user.email you@example.com
After doing this, you may fix the identity used for this commit with:
git commit --amend --reset-author
@lucasfais
lucasfais / gist:1207002
Created September 9, 2011 18:46
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt