View npm-publish-fork
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 | |
require "json" | |
require "optparse" | |
$options = {} | |
def system!(*args) | |
puts "> #{args.join(" ")}" | |
system(*args) || raise("Error running #{args.join(" ")}: #{$?} ") |
View tiny_object_model.rb
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
# We'll start by inheriting from a BasicObject, with our two properties: state and behavior. | |
class TinyObject < BasicObject | |
attr_accessor :state | |
attr_accessor :behavior | |
end | |
# `add_method`, for adding a method implementation to a behavior / class's state. | |
behavior_add_method = lambda do |behavior, method_name, method| | |
behavior.state[:methods][method_name] = method |
View gist:ee29cef4aa8a3dfaa742
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
### Keybase proof | |
I hereby claim: | |
* I am justinweiss on github. | |
* I am justinweiss (https://keybase.io/justinweiss) on keybase. | |
* I have a public key whose fingerprint is 6FF0 E872 CACA 2A9A 8942 95E3 08F4 4018 35C2 8D55 | |
To claim this, I am signing this object: |
View settings.rb
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 'yaml' | |
require 'erb' | |
require 'ostruct' | |
class Settings < OpenStruct | |
# Settings.new(:google_analytics) | |
def initialize(config_file_base_name) | |
super(YAML.load(ERB.new(File.read(Rails.root.join("config", "#{config_file_base_name}.yml"))).result)[Rails.env]) | |
end |
View filterable.rb
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
# Call scopes directly from your URL params: | |
# | |
# @products = Product.filter(params.slice(:status, :location, :starts_with)) | |
module Filterable | |
extend ActiveSupport::Concern | |
module ClassMethods | |
# Call the class methods with names based on the keys in <tt>filtering_params</tt> | |
# with their associated values. For example, "{ status: 'delayed' }" would call |
View gist:8046343
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 HashExtensions | |
def string_merge(other, separator = " ") | |
merge(other) {|key, old, new| old.to_s + separator + new.to_s} | |
end | |
end | |
View DefaultKeyBinding.dict
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
/* Picked up from Help search on Key Bindings. Good stuff -shane */ | |
/* ~/Library/KeyBindings/DefaultKeyBinding.dict */ | |
{ | |
"~f"="moveWordForward:"; | |
"~b"="moveWordBackward:"; | |
"~<"="moveToBeginningOfDocument:"; | |
"~>"="moveToEndOfDocument:"; | |
"~v"="pageUp:"; | |
"~d"="deleteWordForward:"; | |
"~^h"="deleteWordBackward:"; |
View book_spec.rb
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
def book_with_endorsements(endorsement_count) | |
book = Factory(:book) | |
endorsement_count.times do |n| | |
Factory(:endorsement, :book_id => book.id) | |
end | |
book | |
end |
View init.el
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
(defun my-git-root () | |
(let* ((current-directory (file-name-directory buffer-file-name)) | |
(git-directory (concat current-directory ".git"))) | |
(while (and | |
current-directory | |
(not (file-exists-p git-directory))) | |
(setq current-directory (file-name-directory (substring current-directory 0 -1))) | |
(setq git-directory (concat current-directory ".git"))) | |
current-directory)) |