Skip to content

Instantly share code, notes, and snippets.

# Install Git needed for Git based gems
packages:
yum:
git: []
@harlow
harlow / recipe.md
Last active August 7, 2019 04:09
Drink Positive

Mezcal Bone Crusher

Here is a variation of a Bone Crusher, a drink originally inspired by acclaimed cocktail writer David Wondrich's Bone cocktail made from rye whiskey, lime juice, sugar and a few dashes of Tabasco.

Here, this spicy, earthy, smoky drink was made from Del Maguey's Single Village Mezcal (Minero), El Tesoro Reposado Tequila, demerara sugar simple syrup, lime and Tabasco.

The Breakdown

3 Fresh Limes
@harlow
harlow / config_for.rb
Last active August 29, 2015 14:12 — forked from dhh/config_for.rb
module YourApp
class Application < Rails::Application
# Convenience for loading config/foo.yml for the current Rails env.
#
# Example:
#
# config/cleversafe.yml:
#
# production:
# url: http://127.0.0.1:8080
@harlow
harlow / case_assignments_controller.rb
Last active August 29, 2015 14:12
Assigning cases to users. A de-factoring of https://gist.github.com/dhh/9348053
class Case::AssignmentsController < ApplicationController
before_action :set_case, :set_new_owner
def create
ActiveRecord::Base.transaction do
# update case owner
@case.update! case_params.merge(owner: @new_owner)
# transfer open tasks to new owner
@case.tasks.open.each { |task| task.update!(owner: @new_owner) }
func (h *RESTHandler) finishReq(op *Operation, req *http.Request, w http.ResponseWriter) {
result, complete := op.StatusOrResult()
obj := result.Object
if complete {
status := http.StatusOK
if result.Created {
status = http.StatusCreated
}
switch stat := obj.(type) {
case *api.Status:
class NotesController < ApplicationController
def create
@note = @project.notes.create params[:note].merge(
creator: current_user, subscribers: extract_subscribers(params[:note]))
@note.subscribers.each { |subscriber| Subscriptions.note(@note, subscriber).deliver }
end
end
class Subscriptions < ActionMailer::Base
# Bulk API design
#
# resources :posts
class PostsController < ActiveController::Base
# GET /posts/1,4,50,90
# post_url([ @post, @post ])
def show_many
@posts = Post.find(params[:ids])
end
# autoload concerns
module YourApp
class Application < Rails::Application
config.autoload_paths += %W(
#{config.root}/app/controllers/concerns
#{config.root}/app/models/concerns
)
end
end
# MODEL
class Case < ActiveRecord::Base
include Eventable
has_many :tasks
concerning :Assignment do
def assign_to(new_owner:, details:)
transaction do
@harlow
harlow / get_set.go
Created August 4, 2014 04:31
Get and set values of a Struct using reflection in Go Lang
type MyStruct struct {
N int
}
n := MyStruct{ 1 }
// get
immutable := reflect.ValueOf(n)
val := immutable.FieldByName("N").Int()
fmt.Printf("N=%d\n", val) // prints 1