Skip to content

Instantly share code, notes, and snippets.

View frozzare's full-sized avatar
😎
Focusing

Fredrik Forsmo frozzare

😎
Focusing
View GitHub Profile
/**
* Backbone localStorage Adapter
* https://github.com/jeromegn/Backbone.localStorage
*/
(function(_, Backbone) {
// A simple module to replace `Backbone.sync` with *localStorage*-based
// persistence. Models are given GUIDS, and saved into a JSON object. Simple
// as that.
{
"hello": [1, 2, 3]
}
{
"hello": {
"a": 1
}
}

Unsucking Macports CouchDB with node.js

Why?

The macports couchdb port has problems. The hip thing to do would probably be switching over to homebrew, but I dislike brew for a couple of reasons, which are beyond the scope of this writeup. Also, building from source failed for me with some strange problem in the makefile, that I'll hunt down later.

So, what's wrong with it?

  • couchdb's javascript viewserver couchjs links against libjs.dylib, which is supplied by the spidermonkey port. That port is ancient, but cannot be easily upgraded because of, well... mongodb. That means: no ES5-goodness for the rest of us. :-(
$column-slug: col;
@for $i from 1 through $gridColumns {
.#{$column-slug}#{$i} {
}
}
var f = 0
, b = 1
;
<p>First name: <input data-bind="value: firstName" /></p>
<p>Last name: <input data-bind="value: lastName" /></p>
<h2>Hello, <span data-bind="text: fullName"> </span>!</h2>
<p>First name: <input data-bind="value: firstName" /></p>
<p>Last name: <input data-bind="value: lastName" /></p>
<h2>Hello, <span data-bind="text: fullName"> </span>!</h2>
function ViewModel() {
this.firstName = ko.observable("Fredrik");
this.lastName = ko.observable("Forsmo");
this.fullName = ko.computed(function() {
return this.firstName() + " " + this.lastName();
}, this);
}
ko.applyBindings(new ViewModel());
//Get context with jQuery - using jQuery's .get() method.
var ctx = $("#myChart").get(0).getContext("2d");
//This will get the first returned node in the jQuery collection.
var myNewChart = new Chart(ctx);