Skip to content

Instantly share code, notes, and snippets.

;; does the dynamic nature of the unsubscribe require that I send this
;; through the dataflaw and submit the messages with a continue?
[[:transform-enable (vec target-path) :select-list
[{msg/topic msg/app-model msg/type :unsubscribe :paths [[:list-display :bedone :todo-lists <all the other lists>]]}
{msg/topic msg/app-model msg/type :subscribe :paths [[:list-display :bedone :todo-lists list-id]]}]]]
@bhauman
bhauman / tic_tac_toe.rb
Last active December 16, 2015 20:38
My entry for the asheville coders league event: http://www.meetup.com/Asheville-Coders-League/events/113701462/ I added a simple minmax based player as well.
class TicTacToe
attr_accessor :move_pos, :prev_ttt
@@winning_patterns = nil
def initialize(_move_pos = nil, _prev_ttt = nil)
@move_pos, @prev_ttt = _move_pos, _prev_ttt
end
def game_over?
valid_moves.empty?
end
# run with: god -c /path/to/config.god [add -D if you want to not-deamonize god]
# This is the actual config file used to keep the delayed_job running
APPLICATION_ROOT = "/var/www/application"
RAILS_ENV = "production"
God.watch do |w|
w.name = "delayed_job_production"
w.interval = 15.seconds
w.start = "/bin/bash -c 'cd #{APPLICATION_ROOT}/current; /usr/bin/env RAILS_ENV=#{RAILS_ENV} #{APPLICATION_ROOT}/current/script/delayed_job start > /tmp/delay_job.out'"
@bhauman
bhauman / delayed_job_eb_sysvinit
Created March 24, 2013 00:31
Working on getting delayed_job up and running on Elastic Beanstalk using their .ebextentions
!/usr/bin/env bash
# chkconfig: 2345 99 20
# description: Starts and stops delayed job
# hopefully
# processname: delayed_job
. /opt/elasticbeanstalk/support/envvars
function start() {
@bhauman
bhauman / hack.sh
Created March 31, 2012 19:50 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@bhauman
bhauman / jasmine_config.rb
Created May 14, 2011 22:10
Getting Jasmine to load javascript templates Jammit style
#this file is expecting to be in spec/javascripts/support
require "jammit"
module Jasmine
class Config
def src_files
if simple_config['src_files']
match_files(src_dir, simple_config['src_files'] + [package_jammit_templates])
@bhauman
bhauman / functions.rb
Created September 17, 2010 19:49
sass function to test if a color is a dark color
module Sass::Script::Functions
def dark_color(color)
assert_type color, :Color
Sass::Script::Bool.new( (color.rgb.sum / 3.0) < 128 )
end
end
use MockClient do |base|
base.send(:configure) do
set :root, __FILE__
end
end
width = 200
height = 200
mag = MiniMagick::Image.from_file( file_path )
mag.combine_options do |i|
i.resize "#{width}x#{height}^"
i.gravity 'Center'
i.extent "#{width}x#{height}"
end
require 'rubygems'
require 'carrot'
q = Carrot.queue('tasks')
10.times {|x| q.publish('Message number ' + x.to_s) }