This file contains hidden or 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
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 |
This file contains hidden or 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
Why did we monkey patch PgSearch::Document? | |
After reseraching potential solutions it was obvious our best course of action was to use Postgresql's built in full text search indexing to accomodate BlueSky's search needs. After coming to this decision we had to make the decision would we rather build our own custom solution, or use one of several gems available. While I'm typically a fan of custom builds when possible, after reviewing some of the source of two gems (pg_search and textacular) it was easy to do a cost benefit analysis and decide that using a gem in this case was the best course of action. | |
Once the decision had been made to use a gem the question of which gem was the next in line. After doing some research pg_search was the winner because of the internationalization and more complex requirements we like the additional flexability and features pg_search provides (many of which are outlined here https://github.com/Casecommons/pg_search#searching-using-different-search-features.) | |
Using pg_search |
This file contains hidden or 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 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 |
This file contains hidden or 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 ActiveRecord::Base | |
# Usage: | |
# | |
# > puts User.first.to_factory_girl | |
# FactoryGirl.define do | |
# factory :user do | |
# ... | |
# end | |
# end | |
# # Usage: FactoryGirl.create(:user, ...) |
This file contains hidden or 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
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 |
This file contains hidden or 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 "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" |
This file contains hidden or 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 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 |
This file contains hidden or 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
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 |
This file contains hidden or 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
$ 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 |
NewerOlder