Skip to content

Instantly share code, notes, and snippets.

View danott's full-sized avatar
📈
Chart with upward trend

Dan Ott danott

📈
Chart with upward trend
View GitHub Profile
@danott
danott / null_object.rb
Last active August 29, 2015 14:01
The Null Object Pattern as an ActiveSupport Concern.
module NullObject
extend ActiveSupport::Concern
included do
const_set("Null#{name}", Class.new)
end
module ClassMethods
def null
const_get("Null#{name}").new
@danott
danott / idea.go
Created April 24, 2014 16:05
This is how I think go versioning could work...
package main
import (
// mypackage "github.com/danott/mypackage"
mypackage "some-clever-service-name-for-versioning-go-programs.com/danott/mypackage/0.0.1"
)
func main() {
mypackage.ExportedFun()
}
@danott
danott / ballard_walking_brewery_tour.md
Last active August 29, 2015 13:57
A listing of Ballard breweries, for friends coming to Seattle.
@danott
danott / deploy.rb
Created March 11, 2014 15:14
Make deploys better by adding this to the top of your Ruby based deploy scripts.
if ARGV.join.match("--push-it-to-the-limit") || ENV['ALWAYS_BE_PUSHING_IT_TO_THE_LIMIT']
puts "Pushing it to the limit."
system(%[osascript -e 'tell app "Rdio" to play source "t13182620"'])
end
func doSomethingWithIntish(i int) {
// whatever
}
doSomethingWithInt(1)
// type time.Month int
doSomethingWithInt(time.January)
@danott
danott / messin_around_in_industry_inc.py
Created February 4, 2014 01:48
Script for Industry Inc in DrawBot
textToRender = "Neato!"
fontSizeToRender = 1062
fontSize(fontSizeToRender)
width, height = textSize(textToRender)
width = width * 1.4
size(width, height)
# Centering. Needs to be fine tuned
@danott
danott / test_serial_comma.rb
Last active January 4, 2016 07:09
Make these tests pass and the computer will do serial commas for you!
require "minitest/autorun"
class TestSerialComma < MiniTest::Unit::TestCase
def possessives
%w[hers his yours mine ours]
end
def test_possessives_1
assert_equal "hers", serial_comma(places.slice(0, 1))
@danott
danott / til_20140101.coffee
Created January 15, 2014 00:04
TIL: Always include length when using @batmanjs accessors. Fixes some random bugs.
# BAD
@get('accessorToManyObjects').length
# GOOD
@get('accessorToManyObjects.length')
<!--
#####################################
TITLE: Daily Events Detailed Report
#####################################
DESCRIPTION: This reports all the events happening on a day (or span of days) and contains more detailed information (such as answers to questions attached to rooms). The visual style is more appropriate for displaying as a web page.
-->
<!DOCTYPE html>
<html>
<head>
@danott
danott / pre-commit
Created November 13, 2013 00:03
Gate frivolous commits to master and staging.
#!/bin/bash
exec < /dev/tty
current_branch() {
git rev-parse --abbrev-ref HEAD
}
if current_branch | grep -E "^(staging|master)$" > /dev/null
then