Skip to content

Instantly share code, notes, and snippets.

View mrjjwright's full-sized avatar

John Wright mrjjwright

View GitHub Profile
#when executing this line with erroneous "]"
queue.push([sql_statement + ";\n"], handle_callback])
#compiler returns
#node.js:1055:9
#should the following with an erroneous single ":" instead of "::"
SampleClass:sample_function: (string) ->
#compile to
SampleClass = (sample_function = function sample_function(string) {
# as it does now or throw a warning or error?
foo(param, ->
foo1()
, ->
foo2()
# Executes each part of the iPhone sync serially one after another.
# Makes use of the flow-js lib by Will Conant (http://github.com/willconant/flow-js)
iphone_sync_flow: ->
self: this
flow.exec(
->
new IPhoneVoicemail(self.username).sync(this)
->
new IPhoneCallHistory(self.username).sync(this)
->
@mrjjwright
mrjjwright / node-jhead.coffee
Created March 25, 2010 21:19
requires Date.js, parses jhead output to array of objects
# This is a simple little wrapper around the jhead exif reader.
# See http://www.sentex.net/~mwandel/jhead/
# Date.js (http://datejs.org). Remove and the below lines if you don't need js dates
require "./date"
sys: require "sys"
path: require "path"
PATH_TO_JHEAD: "./external/jhead"
jhead_parse: (image_file_or_dir, callback) ->
//
// YAJLTopLevelParser.h
//
// Created by John Wright on 03/29/10.
// Copyright 2010. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
@mrjjwright
mrjjwright / save.coffee
Created April 2, 2010 15:19
From NoSQLite, nice example of the power of flow.js for doing something like saving one or multiple objects to the db
save: (table, obj, tx_flag, callback) ->
#augment object with guid unless options say not to
if @options.no_guid is false
if not _.isArray(obj)
obj.guid: Math.uuidFast()
else for o in obj
o.guid: Math.uuidFast()
inserts: []
foo: (cb) ->
arr: [1, 2, 3]
do_foo: (i) ->
async_call ->
if i-- then do_foo(i)
else cb()
foo(arr.length-1)
@mrjjwright
mrjjwright / remove_null_guids.coffee
Created April 11, 2010 23:45
An example of a data migration in NoSQLite
require "nosqlite"
require "Math.uuid"
convert_callback: (row) ->
if not row.guid?
row.guid: Math.uuidFast();
return row;
db_file: "my_db.sqlite"
@mrjjwright
mrjjwright / nosqlite_blueprint.txt
Created April 29, 2010 20:35
The blueprint for a radically new version of my project NoSQLite
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.