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
#!/usr/bin/env ruby | |
require_relative '../config/environment' | |
Bundler.require :bot | |
name = ARGV[1] | |
csv = "#{name}.csv" | |
bot = Bink.new csv | |
command = ARGV[0] |
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 ApplicationController < ActionController::Base | |
rescue_from StandardError, with: :handle_exception | |
def squeak(*args) | |
SqueakyMailer.notification(*args).deliver | |
end | |
def handle_exception(e) | |
squeak( | |
message: "Error: #{e.message}", |
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
# Merging Scopes | |
# ============== | |
# The goal is to join two tables to get all the records where a scope on both | |
# side of the join is used. I used to do this with a `where()` in which I | |
# added some sql on the joined table. But, I wanted to use the existing scopes | |
# from the joining table. Turns out there's a `merge` method on a scope where | |
# you can merge with another scope without having to chain! | |
class Car < ActiveRecord::Base | |
has_and_belongs_to_many :people |
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
tea $("#person"), | |
name: "Nick", | |
bio: "Coderguy" |
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
package athena | |
import ( | |
accountant "codeship-accountant", | |
janus "codeship-janus", | |
ares "ares-api" | |
) | |
func main() { | |
// codeship accountant implements accountant interface |
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 'active_support' | |
require 'active_support/core_ext/object/json' | |
class Person | |
def initialize(name, age, car) | |
@name = name | |
@age = age | |
@car = car | |
@birthyear = compute_birth_year | |
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
#!/usr/bin/env bash | |
# Makes a docker container for a static golang application. | |
# For a small app, this container is usually about 7mb. | |
# | |
# Usage: | |
# build-container myapp myuser/myapp cmd/myapp/main.go | |
set -e | |
# Version is the git sha for HEAD | |
version=$(git log -1 --format=format:%H) |
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
build: | |
# get all the deps | |
go get -d -v -t ./... | |
# check out the library to the right ref | |
checkit github.com/myaccount/mylib abc123 | |
# build stuff! | |
go build ./... |
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
# Add to the bottom of the rake file: | |
require 'hydra' | |
require 'hydra/tasks' | |
Hydra::TestTask.new('hydra:spec') do |t| | |
t.add_files 'spec/**/*_spec.rb' | |
end | |
Hydra::TestTask.new('hydra:features') do |t| | |
t.add_files 'features/**/*.feature' | |
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
module Search | |
VECTORS = [ | |
{:klass => Company, :columns => ['ticker', 'name']}, | |
{:klass => Executive, :columns => ['name']} | |
] | |
class << self | |
def find(query) | |
query = query.split(' ').join(' & ') | |
return Search::VECTORS.collect{|tuple| | |
Array(tuple[:columns]).collect{|column| |
OlderNewer