Skip to content

Instantly share code, notes, and snippets.

@guitsaru
guitsaru / dotenv
Last active September 20, 2016 23:12 — forked from doughsay/dotenv
Dotenv bash helpers
#!/bin/bash
export DOTENV_ENV=${DOTENV_ENV:-dev}
GIT_DIR=$(git rev-parse --show-toplevel 2>/dev/null || pwd)
DOTENV_FILE=$GIT_DIR/.env.$DOTENV_ENV
if [ -e $DOTENV_FILE ]; then source $DOTENV_FILE; fi
$@

Keybase proof

I hereby claim:

  • I am guitsaru on github.
  • I am guitsaru (https://keybase.io/guitsaru) on keybase.
  • I have a public key whose fingerprint is F939 6BCA DB3D 1249 B84C BE50 D780 2993 7E96 C6EE

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am guitsaru on github.
  • I am mattpeek (https://keybase.io/mattpeek) on keybase.
  • I have a public key whose fingerprint is 8D78 276B 7049 8C30 9AA9 F4B1 AA36 973C 9B4E 981E

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am guitsaru on github.
  • I am guitsaru (https://keybase.io/guitsaru) on keybase.
  • I have a public key whose fingerprint is EECB AC2F 576B 72CA 16D5 A43A 0D5A 0FE1 58D6 3A61

To claim this, I am signing this object:

@guitsaru
guitsaru / forego.rb
Created November 7, 2013 18:19
forego homebrew formula
require 'formula'
class Forego < ScriptFileFormula
homepage 'https://github.com/ddollar/forego'
url 'https://godist.herokuapp.com/projects/ddollar/forego/releases/0.8.2/darwin-amd64/forego'
sha1 '62f4c0cb7e48647ca7c9ef4a801f49576b577d4a'
version '0.8.2'
test do
system "#{bin}/forego", "version"
class Tournament < ActiveRecord::Base
include Bracket::Swiss # (OR Bracket::KOTH OR Bracket::SingleElimination etc)
end
module Bracket
module KOTH
def self.included(base)
base.workflow do
# state and events for a king of the hill tournament
end
stateString :: Int -> Bool -> String
stateString i False = "Case #" ++ show i ++ ": OFF"
stateString i True = "Case #" ++ show i ++ ": ON"
isOn :: Int -> Int -> Bool
isOn snappers snaps = isInt ((fromIntegral (snaps + 1) :: Double) / (fromIntegral (2^snappers) :: Double))
where isInt :: Double -> Bool
isInt d = (d - fromIntegral (floor d) :: Double) == 0
readInput :: String -> [(Int, Int)]
$('.action.new[data-content][data-association]').click(function () {
var new_id = new Date().getTime();
var regexp = new RegExp("new_" + $(this).attr('data-association'), "g");
$(this).before($(this).attr('data-content').replace(regexp, new_id));
return false;
});
class Array
def pick(number)
result = []
original = self.clone
if number < original.size
number.times { result << original.delete_at(Kernel.rand(original.size)) }
else
result = original
end
define_index do
set_property :enable_star => true
set_property :min_prefix_len => 3
set_property :delta => true
indexes number, city, state, zip, status
indexes message.transcription, :as => :message
indexes assignee.display_name, :as => :assignee
indexes tags.name, :as => :tag
indexes comments.body, :as => :comments