Skip to content

Instantly share code, notes, and snippets.

PATH := node_modules/.bin:$(PATH)
SHELL := /bin/bash
browser_files := $(shell find src/browser -type f -name '*.js')
browser_specs := $(shell find test/browser -type f -name '*_spec.js')
browser_bundle := build/browser.js
karma_config := test/browser/karma.conf.js
browser_test := build/browser.spec.done
client_files := $(shell find src/client -type f -name '*.js')
client_specs := $(shell find test/client -type f -name '*_spec.js')
#!/bin/bash
set -uf -o pipefail
ENVIRONMENT=$1
SESSION_NAME=${2:-kay-${ENVIRONMENT}}
SERVER_SOCKET=/tmp/tmux-${SESSION_NAME}
SCRIPTS_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
case ${ENVIRONMENT} in
### Keybase proof
I hereby claim:
* I am pitluga on github.
* I am tonypitluga (https://keybase.io/tonypitluga) on keybase.
* I have a public key whose fingerprint is 3EB6 6263 A018 F003 36C3 66AB C75F 6C31 C878 A4E7
To claim this, I am signing this object:
@pitluga
pitluga / ezcrypto.rb
Created December 4, 2012 14:47
Monkey Patch for JRuby EzCrypto to be compatible with MRI EzCrypto
EzCrypto::CipherWrapper.class_eval do
def initialize(key,target,mode,algorithm)
@cipher = OpenSSL::Cipher::Cipher.new(algorithm)
if mode
@cipher.encrypt
else
@cipher.decrypt
end
@cipher.key=key.raw
@pitluga
pitluga / core.clj
Created October 29, 2012 18:58
Braintree Clojure Example
(ns braintree-clj.core
(:import [com.braintreegateway BraintreeGateway Environment TransactionRequest Transaction$Type])
(:require [clojure.string :as s]
[hiccup.core :as hiccup]
[hiccup.page-helpers :as page-helper]
[noir.core :as noir]
[noir.request :as noir-req]
@pitluga
pitluga / gist:1164228
Created August 23, 2011 02:56
simple validation
def validate(params_hash)
errors = {}
errors[:model] = "is required" if params_hash[:model].nil?
errors[:pk] = "is required" if params_hash[:pk].nil?
errors
end
@pitluga
pitluga / monitor.sh
Created October 21, 2010 16:01
monitors memory usage of passenger rails processes and stuff monitored by monit. useful with watch
#!/bin/sh
passenger-status 10614 | grep global
echo
passenger-memory-stats 10614 | grep Rails
echo
/usr/local/bin/monit -c /srv/apps/ruby-app/current/config/monitrc -p /srv/apps/ruby-app/shared/pids/monit.pid -s /srv/apps/ruby-app/shared/system/monit.state status | awk '/Process/ { process=$2} /memory kilobytes tot/ { printf "%50s %7s\n", process, $4} ' | sed -e '$!N;s/\n//'
BOTS = %w(Bully Dual Prospector Rage Random)
MAPS = 1..100
def parse_results(output)
output = output.split("\n")
loss = (output[-1] =~ /Player 1 Wins/).nil?
turns = output[-2].split[1]
[!loss, turns.to_i]
end
BOTS = %w(Bully Dual Prospector Rage Random)
MAPS = 1..100
def play_game(map, challenger)
cmd = %Q{java -jar tools/PlayGame.jar maps/map#{map}.txt 1000 1000 log.txt "ruby mybot.rb" "java -jar example_bots/#{challenger}Bot.jar"}
`#{cmd} 2> commentary.txt`
output = File.read('commentary.txt').split("\n")
victory = output[-1] =~ /Player 1 Wins/