Skip to content

Instantly share code, notes, and snippets.

View nertzy's full-sized avatar
🏠

Grant Hutchins nertzy

🏠
View GitHub Profile
@sstephenson
sstephenson / gist:771090
Created January 8, 2011 19:41
Automatic *.test host resolution in OS X
$ sudo su -
# mkdir /etc/resolver
# cat > /etc/resolver/test
nameserver 127.0.0.1
port 2155
^D
^D
$ brew install dnsmasq
$ dnsmasq --port=2155 --no-resolv --address=/.test/127.0.0.1
$ ping foo.test
@symposion
symposion / README
Created October 15, 2011 15:34 — forked from cyberfox/keychain.rb
Convert OS X Keychain exported entries into logins for 1Password import
These two files should help you to import passwords from mac OS X keychains to 1password.
Assumptions:
1) You have some experience with scripting/are a power-user. These scripts worked for me
but they haven't been extensively tested and if they don't work, you're on your own!
Please read this whole document before starting this process. If any of it seems
incomprehensible/frightening/over your head please do not use these scripts. You will
probably do something Very Bad and I wouldn't want that.
2) You have ruby 1.9.2 installed on your machine. This comes as standard with Lion, previous
versions of OS X may have earlier versions of ruby, which *may* work, but then again, they
@cowboyd
cowboyd / classmethod-inheritance.rb
Created January 19, 2012 21:28
Ruby classes inherit methods on singleton classes
# I never knew that singleton methods defined on a class are callable via subclasses
# Apparently when you create a subclass, that subclass's singleton class has
# its superclass's singleton class as an ancestor.
class Foo
@blip = 'foo'
def self.foo; @blip;end
end
@schubert
schubert / mixlib_log_monkey_patch.rb
Created August 9, 2012 21:43
colorize your chef solo output (put in libraries)
require "mixlib/log/formatter"
module Mixlib
module Log
class Formatter < Logger::Formatter
# Prints a log message as '[time] severity: message' if Chef::Log::Formatter.show_time == true.
# Otherwise, doesn't print the time.
def call(severity, time, progname, msg)
if @@show_time
reset = "\033[0m"
@schubert
schubert / capistrano_colors.rb
Created August 9, 2012 21:46
color hooks for capistrano deployments
namespace :deploy do
reset = "\033[0m"
success = "\033[32m" # Green
failure = "\033[31m" # Bright Red
task :completed do
puts "#{success}"
puts "*" * 40
puts "SUCCESS"
puts "*" * 40
@jugyo
jugyo / to_factory_girl.rb
Created November 7, 2012 05:54
ActiveRecord extension to print FactoryGirl definition!
class ActiveRecord::Base
# Usage:
#
# > puts User.first.to_factory_girl
# FactoryGirl.define do
# factory :user do
# ...
# end
# end
# # Usage: FactoryGirl.create(:user, ...)
class MethodCounter
def initialize
@signature = ENV.fetch("COUNT_CALLS_TO")
@path = @signature.split(/(?:::|#)/)
@scope = @signature.include?("#") ? :instance : :class_or_module
@count = 0
@wrapping = false
@wrapped = false
end
@brittballard
brittballard / blue sky pg search
Last active December 16, 2015 20:10
Why we implemented search the way we did
@brysgo
brysgo / install_command_line_tools_no_prompt
Created February 14, 2014 19:43
Install xcode command line tools without prompt
do shell script "xcode-select --install"
do shell script "sleep 1"
tell application "System Events"
tell process "Install Command Line Developer Tools"
keystroke return
click button "Agree" of window "License Agreement"
end tell
end tell
@nertzy
nertzy / callgrind_profiler.rb
Last active August 29, 2015 14:20
CallgrindProfiler
require 'jruby/profiler'
require 'jruby/profiler/callgrind_printer'
module CallgrindProfiler
def callgrind
unless JRuby.runtime.instance_config.is_profiling?
STDERR.puts 'Profiling not enabled, re-run with `ruby --profile.api`'
return
end