Skip to content

Instantly share code, notes, and snippets.

View bsingr's full-sized avatar

bsingr

  • @coliquio - former Sophos, Git Tower, Inovex, 1&1
  • Lake Constance, Germany
View GitHub Profile
var view = {
foo: null
}
var template = "lalala {{foo}} lalelu";
var html = Mustache.to_html(template, view);
// html is empty now
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);
// 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) {
[...]
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}
//---------------------------------------
tell application "System Events"
set UI elements enabled to true
end tell
# 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
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
@bsingr
bsingr / spec.js
Created February 16, 2011 11:22
bubbleinput spec
describe("event-bindings", function(){
var $sandbox;
beforeEach(function(){
$sandbox = jQuery("body").append("<div id='sandbox'></div>").find("#sandbox");
});
afterEach(function(){
$sandbox.remove();
});
@bsingr
bsingr / hearts.html
Created April 24, 2011 09:44 — forked from threez/hearts.html
BouncingHearts in HTML/CSS/JS
<!DOCTYPE html>
<html>
<head>
<style type="text/css" media="screen">
* {
overflow: hidden;
font-family: "Helvetica Neue";
cursor: pointer;
text-selection: none;
}
@bsingr
bsingr / hearts_css3.html
Created April 24, 2011 10:02
Bouncing Hearts CSS3 in HTML/JS/CSS
<!DOCTYPE html>
<html>
<head>
<style type="text/css" media="screen">
* {
overflow: hidden;
font-family: "Helvetica Neue";
cursor: pointer;
text-selection: none;
}