This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var view = { | |
foo: null | |
} | |
var template = "lalala {{foo}} lalelu"; | |
var html = Mustache.to_html(template, view); | |
// html is empty now |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var view = { | |
foo: {id: 1}, | |
bar: [{id: 2}] | |
} | |
var template = "lalala {{#foo}}{{id}}{{/foo}} lalelu {{#bar}}{{id}}{{/bar}}"; | |
var html = Mustache.to_html(template, view); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Works just like <tt>jQuery.fn.bind()</tt> with a couple noteable differences. | |
// | |
// * It binds all events to the application element | |
// * All events are bound within the <tt>eventNamespace()</tt> | |
// * Events are not actually bound until the application is started with <tt>run()</tt> | |
// * callbacks are evaluated within the context of a Sammy.EventContext | |
// | |
// See http://code.quirkey.com/sammy/docs/events.html for more info. | |
// | |
bind: function(name, data, callback) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[...] | |
wrapped_callback = function(response) { | |
var new_content = response, | |
all_content = ""; | |
$.each(data_array, function(i, idata) { | |
// extend the data object with the context | |
//--------------------------------------- | |
// dpree: | |
// the following line eats some of my data, e.g.: {"items": myItems} | |
//--------------------------------------- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tell application "System Events" | |
set UI elements enabled to true | |
end tell |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# the actual used upload called from zeus | |
post '/upload/:filename' do | |
deployed = false | |
begin | |
filename = File.join(YFILES_GRAPH_DIR, params[:filename]) | |
File.open(filename, "wb") do |f| | |
while line = request.body.gets | |
f.write(line) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
arr = [{:email => 1, :name => "foo"}, {:email => 1, :name => "bar"}, {:email => 2, :name => "foo"}] | |
uniqueness_by = :email | |
result = arr.inject({:collected => [], :indicators => []}) do |helper,item| | |
indicator = item[uniqueness_by] # indicates uniqueness | |
unless helper[:indicators].include?(indicator) # new indicator? then collect it! | |
helper[:indicators] << indicator # for later decisions | |
helper[:collected] << item # the actuall result to the user | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe("event-bindings", function(){ | |
var $sandbox; | |
beforeEach(function(){ | |
$sandbox = jQuery("body").append("<div id='sandbox'></div>").find("#sandbox"); | |
}); | |
afterEach(function(){ | |
$sandbox.remove(); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<style type="text/css" media="screen"> | |
* { | |
overflow: hidden; | |
font-family: "Helvetica Neue"; | |
cursor: pointer; | |
text-selection: none; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<style type="text/css" media="screen"> | |
* { | |
overflow: hidden; | |
font-family: "Helvetica Neue"; | |
cursor: pointer; | |
text-selection: none; | |
} |
OlderNewer