Skip to content

Instantly share code, notes, and snippets.

@JustinTulloss
JustinTulloss / boolean-objects.js
Created November 30, 2010 09:34
How Boolean Objects behave in JS
!!(new Boolean(false)) => true
(new Boolean(false)) ? true : false => true
(new Boolean(false)) == false => true
(new Boolean(false)) === false => false
@JustinTulloss
JustinTulloss / importjson.py
Created November 12, 2010 20:25
importing json
try:
import json
except ImportError:
import simplejson as json
# in setuptools
dependencies = []
try:
@JustinTulloss
JustinTulloss / nav_bar.html
Created October 19, 2010 07:09
Example of syntax
{= render_generic_tab_bar(tab_bar_class, options)
<div class="{{ tab_bar_class }} clearfix">
{% _.each(options.tabs, function(tab) {
if (tab.visible === undefined || tab.visible ) { %}
<span class="tab{% if (tab.name == options.selected_tab) emit(' selected'); %}"><a href="{{ tab.url }}">{{ tab.text }}</a></span>
{% } %}
{% }); %}
</div>
=}
@JustinTulloss
JustinTulloss / load.js
Created October 19, 2010 06:33
Injecting template versions
// By just injecting a script tag, we can version the template and exploit the cache
function loadTemplate(template, version) {
var src = '/media/bujagali/' + this.name + '.' + this.version + '.js';
var headEl = document.getElementByTag('head')[0];
var script;
script = document.createElement('script');
script.type = 'text/javascript';
script.src = src;
headEl.appendChild(script);
//These vows
var vows = require('vows'),
assert = require('assert'),
sys = require('sys'),
zeromq = require('zeromq');
vows.describe('ZeroMQ')
.addBatch({
'A context': {
topic: function() { this.callback(new zeromq.Context()) },
var Animal = new Cobra.Class({
__init__: function(self) {
self.breathes = true;
}
});
var Feline = new Cobra.Class({
__extends__: Animal,
__init__: function(self) {
Cobra.Class.ancestor(Feline, '__init__', self);
this.neilYoungModel = { items : [
{data:"On The Beach", year:"1974"},
{data:"Tonight's The Night", year:"1975"},
{data:"Harvest", year:"1972"},
{data:"Greendale", year:"2003"},
{data:"Broken Arrow", year:"1996"},
{data:"Everybody Knows...", year:"1969"},
{data:"Zuma", year:"1975"},
{data:"Unplugged", year:"1993"},
{data:"Harvest Moon", year:"1992"}
/* Copyright (C) 1991,1993,1995,1997,1998,2003,2004
Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Torbjorn Granlund (tege@sics.se).
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
(let [channel-agents [
; For every item in (:1 channels) (a list of channels), create
; an agent. Then do this for (:2 channels), which is a list of
; channels that belong in the second column.
(map
(fn [channel]
(send-off
(agent "")
(fn [_]
(flockr.channels/render-channel
(tokyo-cabinet/use "trial.hdb"
(tokyo-cabinet/put "Hello World" "Saying Hi! to the big old world out there")
(println (tokyo-cabinet/get "Hello World")))