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
# SQL_PHONE_NORMALIZER Example: | |
# Lead.find_by_sql(PhoneFinder::SQL_PHONE_NORMALIZER.call(table: 'leads', column_name: 'phone', phone: '(555) 760-2012')) | |
# User.find_by_sql(PhoneFinder::SQL_PHONE_NORMALIZER.call(table: 'users', column_name: 'phone', phone: '555-223-4027')) | |
# | |
# AREL_PHONE_NORMALIZER Example: | |
# PhoneFinder::AREL_PHONE_NORMALIZER.call(rel: Lead.where(email: 'peter.boling@example.org'), table: 'leads', column_name: 'phone', phone: '(555) 760-2012') | |
# PhoneFinder::AREL_PHONE_NORMALIZER.call(rel: User.where(email: 'peter.boling@example.org'), table: 'users', column_name: 'phone', phone: '555-223-4027') | |
# | |
# See: https://coderbits.com/posts/pCl7og | |
module PhoneFinder |
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 'ext/grape_middleware_logger' | |
module TrumakerAPI | |
module Middleware | |
class ApiLogger < Grape::Middleware::Logger | |
def after | |
logger.info "[api] Requested#{request_log}" if !request_log.blank? | |
if Rails.env.development? | |
response_body = JSON.parse(response.body.first) |
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
module Concern | |
module NestedFilters | |
extend ActiveSupport::Concern | |
CACHE_EXPIRATION = 1.days | |
NULL_SORT = "LAST" | |
NestedFilter = Struct.new(:filter_klass, :filter_param_key, :filter_name, :filter_options) | |
NestedFilterOption = Struct.new(:id, :name) | |
included do |
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
# Download all repos for an organization | |
ORG_NAME=trumaker | |
curl -s https://api.github.com/orgs/$ORG_NAME/repos?per_page=200 | ruby -rubygems -e 'require "json"; JSON.load(STDIN.read).each { |repo| %x[git clone #{repo["ssh_url"]} ]}' | |
# Download all repos for a user | |
USER_NAME=pboling | |
curl -s https://api.github.com/users/$USER_NAME/repos?per_page=200 | ruby -rubygems -e 'require "json"; JSON.load(STDIN.read).each { |repo| %x[git clone #{repo["ssh_url"]} ]}' |
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
module Boolean | |
include Comparable | |
# true > false | |
def <=>(other) | |
raise ArgumentError, "Do not know how to compare #{other.class} with TrueClass and FalseClass" unless [TrueClass, FalseClass].include?(other.class) | |
other ? (self ? 0 : -1) : (self ? 1 : 0) | |
end | |
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
#!/usr/bin/env ruby | |
# vim: set syntax=ruby | |
# branches should be named like: | |
# <story_type>/<story_id>-explosion-in-the-fudge-factory-spec-suite-fix | |
# where story type is one of "hotfix", "bug", "feature", "candy" | |
# | |
branch = `git branch 2> /dev/null | grep -e ^* | awk '{print $2}'` | |
regex = /^(?<story_type>(hotfix)|(bug)|(feature)|(candy))\/(?<story_id>\d{8,})-.+\Z/ | |
match_data = branch.match(regex) |
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
rake_files = "#{list of files copied from console when rake command is run}" | |
autotest_files = "#{list of files copied from console when autotest command is run}" | |
r = rake_files.split(' ').map {|x| ar = x.split('/'); ar[(ar.length-2)..(ar.length-1)].join('/')} | |
a = autotest_files.split(' ').map {|x| ar = x.gsub(/'/,'').split('/'); ar[(ar.length-2)..(ar.length-1)].join('/')} | |
# autotest will generally be lacking some, as its config becomes out of date | |
diff = r - a |
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
# | |
# PostgreSQL writes two optional commands to the database schema | |
# file, called db/structure.sql, that can only be run as a root | |
# database user. These are not needed actually, so comment them | |
# out automatically | |
# | |
# CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; | |
# COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'; | |
# | |
namespace :db do |
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
# Some specs causes a lot of stuff to output to the console during the spec run which interrupts the flow of lovely green dots. | |
# We don't want to ignore stuff that we want to see, like rspec deprecation warnings, but for an otherwise clean spec, | |
# that is puts ing things, we can turn those off by tagging the spec as :noisy. | |
RSpec.configure do |config| | |
original_stderr = $stderr | |
original_stdout = $stdout | |
config.before(:each, :noisy) do | |
# Redirect stderr and stdout | |
$stderr = File.open(File::NULL, "w") # to /dev/null, since Ruby 1.9.3 | |
$stdout = File.open(File::NULL, "w") # to /dev/null, since Ruby 1.9.3 |
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
script/rails generate airbrake --api-key key---derp | |
Configuration: | |
api_key: "key---derp" | |
js_api_key: "key---derp" | |
backtrace_filters: [#<Proc:0x007fa29d75c708@/Users/pboling/.rvm/gems/ruby- | |
development_environments: [] | |
development_lookup: true | |
environment_name: "development" | |
host: "api.airbrake.io" |
OlderNewer