# Wrapper around jQuery ajax methods that exposes
# returned data by publishing an event
class Ajax
@getJSON: (url, event)->
$.getJSON url, (data)->
Event.trigger(event, data)
window.Ajax = Ajax
class Event
@on: (event, fn)->
$('body').bind event, (_, data) -> fn(data)
@trigger: (event, data)->
$('body').trigger(event, [data])
class Ajax
@getJSON: (url, event)->
$.getJSON url, (data)->
#= require dashboard/map_utils
# helper functions
asJson = (url, event)->
$.getJSON url, (data)->
$('body').trigger(event, [data])
onEvent = (event, fn)->
$('body').bind event, (_, data) -> fn(data)
View gist:3852929
function manifest_to_hash() {
$path = APP_ROOT . "shared/assets/manifest.yml";
$hash = array();
$fp = fopen($path, "r");
while (($line = fgets($fp)) != NULL) {
$line = rtrim($line);
if ($line === "---") continue;
list($key, $value) = explode(":", $line);
$hash[trim($key)] = trim($value);
View gist:3852695
namespace :deploy do
namespace :assets do
task :precompile, :roles => :web, :except => { :no_release => true } do
from = source.next_revision(current_revision)
if capture("cd #{latest_release} && #{source.local.log(from)} vendor/assets/ app/assets/ | wc -l").to_i > 0
run %Q{cd #{latest_release} && #{rake} RAILS_ENV=#{rails_env} #{asset_env} assets:precompile}
else "Skipping asset pre-compilation because there were no asset changes"
View project-web-reload.conf
# /etc/init/project-web-reload.conf
pre-start script
initctl restart project-web
sleep 15
end script
exec /usr/local/rvm/bin/default_bluepill restart
View clojure.clj
; a quick attempt at doing the same thing in clojure could for example something like
(defpartial input [name]
[:input {:name name}]]])
(defpartial edit-task-form [& inputs]
View gist:3167612
- content_for :bottom do
$(function() {
chart: { renderTo: 'chart',
type: "column" },
title: { text: "Errors per Site" },
xAxis: {
title: { text: null },
View gist:3146336
fill = (what, {with, of}) ->
container = what ?= "mug"
quantity = with ?= "500 mL"
liquid = of ?= "coffee"
alert("#{quantity} of #{liquid} on my #{container} plz")
fill "cup", with: "400ml", of: "cachaça"
View gist:2898729
# So .. if I really need to have different behavior
# based on gender ...
class Male < Person
class Female < Person
FactoryGirl.define do