Skip to content

Instantly share code, notes, and snippets.

View dougc84's full-sized avatar

Doug Clark dougc84

View GitHub Profile
@dougc84
dougc84 / awesome_print.rb
Created May 9, 2012 20:35
AwesomePrint initializer aliasing
# The following snippet handles any calls to ap or awesome_print hanging out in your code,
# which can be particularly troublesome in a production environment where awesome_print isn't
# included in your Gemfile.
# If you have any inline "ap" or "awesome_print" calls, they will be aliased to
# puts (not using the alias method, that wasn't optimal). The output will also be logged at
# info level (feel free to change this depending on your needs) with the calling file and
# line number so you can find the offending calls.
# You can grep through your log files for "[ AP called from " to find any calls to ap.
@dougc84
dougc84 / .bash_profile
Created October 9, 2012 15:21
Command Prompt Fun
# terminal colors
export CLICOLOR=1
# vars
# ... omitted ...
# aliases
alias l='ls -lashF' # ' --color=always'
alias be='bundle exec'
@dougc84
dougc84 / useful regexes.txt
Last active October 12, 2015 01:27
Useful RegExs
Find HTML Entities
&[^\s]*;
@dougc84
dougc84 / benchmark_array_functions.rb
Created November 27, 2012 06:50
Array Benchmarking Tests
#!/usr/bin/env ruby
require 'benchmark'
require 'active_support/core_ext/array' # required for Array.wrap.
# by the way, did you know there is a "my_array.fourty_two()" method?
Benchmark.bm do |b|
language = []
100.times do
language << "8foanin"
@dougc84
dougc84 / flush_dns.sh
Created December 10, 2012 19:10
Flush DNS on Mac
#!/bin/bash
sudo killall -HUP mDNSResponder
@dougc84
dougc84 / home_controller.rb
Created December 13, 2012 23:13
before filter example
class HomeController < ApplicationController
layout 'login'
before_filter :actions_if_signed_in
def index
end
def blocked
end
@dougc84
dougc84 / audited.rb
Last active December 10, 2015 06:08
Audited initializer to globally disable audits except when needed.
# Audited initializer to globally disable audits except when needed.
# https://gist.github.com/4392334
#
# Hacked from idea originally provided in issue:
# https://github.com/collectiveidea/audited/issues/18
# by Frost (github.com/Frost)
#
# Modified by Doug Clark (github.com/dougc84)
#
# Add this in an initializer (audited.rb)
@dougc84
dougc84 / test_unit.rb
Created June 15, 2013 20:49
shoulda-matchers fix for Rails 4 RC 2
# :enddoc:
require 'test/unit/testcase'
if defined?(ActionController)
require 'shoulda/matchers/action_controller'
class ActionController::TestCase
include Shoulda::Matchers::ActionController
extend Shoulda::Matchers::ActionController
@dougc84
dougc84 / 2.0.0-p247-mirror
Created July 11, 2013 04:48
ruby-build package to install Ruby 2.0.0-p247 from mirror
install_package "openssl-1.0.1e" "https://www.openssl.org/source/openssl-1.0.1e.tar.gz#66bf6f10f060d561929de96f9dfe5b8c" mac_openssl --if has_broken_mac_openssl
install_package "ruby-2.0.0-p247" "http://www.mirrorservice.org/sites/ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p247.tar.gz" standard verify_openssl
@dougc84
dougc84 / .pryrc
Last active December 28, 2015 11:09
.pryrc
# try requiring and including awesome_print
# if gem is not installed, will simply pass over this.
require "awesome_print"
AwesomePrint.pry! if defined?(AwesomePrint)
#
# output becomes:
#
# [1] app_folder_name development(main)> def something
# 1 > "hello"