Skip to content

Instantly share code, notes, and snippets.

View jeffrydegrande's full-sized avatar

Jeffry Degrande jeffrydegrande

View GitHub Profile
class Router
@people_path: -> "/people"
@person_path: (id)-> "/person/#{id}/"
# 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)
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);
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
logger.info "Skipping asset pre-compilation because there were no asset changes"
end
end
@jeffrydegrande
jeffrydegrande / project-web-reload.conf
Created September 28, 2012 01:58 — forked from potatosalad/project-web-reload.conf
Upstart + Bluepill + Unicorn with hot restart
# /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
; a quick attempt at doing the same thing in clojure could for example something like
(defpartial input [name]
[:tr
[:td
[:input {:name name}]]])
(defpartial edit-task-form [& inputs]
[:div.generic.lightbox
[:table
#chart
- content_for :bottom do
:javascript
$(function() {
chart: { renderTo: 'chart',
type: "column" },
title: { text: "Errors per Site" },
xAxis: {
title: { text: null },
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"