This file contains 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
Topic | |
- NoSQLite | |
- Consider 3 useful things: | |
- SQLite - SQLite is itself a great datastore because it is a | |
fast and powerful SQL database in one file and is widely | |
deployed and supported. | |
- JSON - JSON is a simple and cruft free way to describe and | |
transport objects. That is why programmers love it. There is | |
good support for it in virtually every language. | |
- HTTP - HTTP allows things to connect and talk to each other. |
This file contains 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
git checkout -- lib | |
bin/cake build | |
TypeError: In src/helpers.coffee, Cannot call method 'compile' of undefined | |
at WhileNode.compile_node (/Users/johnw/js/coffee-script/lib/nodes.js:1551:29) | |
at WhileNode.compile (/Users/johnw/js/coffee-script/lib/nodes.js:82:21) | |
at Expressions.compile_expression (/Users/johnw/js/coffee-script/lib/nodes.js:367:28) | |
at Expressions.compile_node (/Users/johnw/js/coffee-script/lib/nodes.js:306:30) | |
at Expressions.compile_with_declarations (/Users/johnw/js/coffee-script/lib/nodes.js:352:19) | |
at CodeNode.compile_node (/Users/johnw/js/coffee-script/lib/nodes.js:1371:64) | |
at CodeNode.compile (/Users/johnw/js/coffee-script/lib/nodes.js:82:21) |
This file contains 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
# Migrations | |
# ------------------------------------- | |
# A handy utility for doing a SQLite table data or schema migration. | |
# | |
# If something goes wrong here at the wrong time, | |
# not that it will, I know you have a backup. :) | |
# | |
# First creates a temporary table and dumps all the rows from the old table. | |
# The old table is then dropped. | |
# |
This file contains 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
# this doesn't compile | |
# Error: In stdio, Parse error on line 1: Unexpected ',' | |
foo: bar "x", 1 | |
# this does | |
bar "x", 1 | |
# so does this | |
foo: bar "x", "1" |
This file contains 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
sqlite = require("sqlite") | |
db = new sqlite.Database() | |
db.open(":memory", function (err) { | |
db.execute("create table t1(x,y);", function (err) { | |
db.execute("insert into t1 values(?, ?)", ["hi", "hi"], function (err){ | |
if (err) throw err; | |
}); | |
}); | |
}); |
This file contains 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
foo (a) -> | |
if x? then y | |
# generates | |
# foo(function(a) { | |
# return (typeof x !== "undefined" && x !== null) ? y : undefined; | |
# }); | |
# However, if you are checking for the existence of a param to the function, then no undefined check | |
foo (x) -> | |
if x? then y |
This file contains 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
methodMap = { | |
'create': 'POST', | |
'update': 'PUT', | |
'delete': 'DELETE', | |
'read': 'GET' | |
}; | |
getUrl = function(object) { | |
if (!(object && object.url)) { | |
throw new Error("A 'url' property or function must be specified"); | |
} else { |
This file contains 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
# | |
# Override Backbone.sync | |
# | |
methodMap = { | |
'create': 'POST' | |
'update': 'PUT' | |
'delete': 'DELETE' | |
'read' : 'GET' | |
} |
This file contains 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
7/7] cxx_link: build/default/bson_1.o build/default/long_1.o build/default/objectid_1.o build/default/binary_1.o build/default/code_1.o build/default/dbref_1.o -> build/default/bson.node | |
Waf: Leaving directory `/Users/johnw/.node_modules/.npm/mongodb/0.8.1/package/external-libs/bson/build' | |
'build' finished successfully (0.799s) | |
The 'sys' module is now called 'util'. It should have a similar interface. | |
=== EXCEUTING TEST_BSON === | |
Assertion failed: (handle->InternalFieldCount() > 0), function Unwrap, file src/node_object_wrap.h, line 30. | |
make[1]: *** [all] Abort trap | |
make: *** [build_native] Error 2 | |
npm info mongodb@0.8.1 Failed to exec install script | |
npm ERR! install failed Error: mongodb@0.8.1 install: `make total` |
This file contains 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
# Uses the openssl too to generate sha1 hashes for files, returns them in a dictionary by relative path from root passed in | |
child_process = require "child_process" | |
path = require "path" | |
util = require "util" | |
PATH_TO_OPEN_SSL = "openssl" | |
CMD = "#{PATH_TO_OPEN_SSL} dgst -sha1" | |
generate = (dir, pattern, callback) -> | |
cmd = "#{CMD} #{pattern}" |