Skip to content

Instantly share code, notes, and snippets.

var jsDump = require('jsDump'),
settings = require('settings/root');
var logger = exports.logger = {
levels: {silent:0, error:1, info:2, debug:2},
log: function(obj) {
if (typeof log !== 'undefined')
log(jsDump.parse(obj));
if (typeof console !== 'undefined')
console.log(obj);
@mandric
mandric / gist:1782893
Created February 9, 2012 20:35
http request that does a callback request
// http request that does a callback request
var req = function(options) {
var r = http.request(options, function(res) {
var resBody = '';
res.setEncoding('utf8');
res.on('data', function (chunk) {
resBody += chunk;
});
res.on('end', function() {
var resJSON = JSON.parse(resBody);
$ kanso push
loading .
loading packages/modules
Error: Error: Cannot find module 'kanso/modules'
at Function._resolveFilename (module.js:334:11)
at Function._load (module.js:279:25)
at Module.require (module.js:357:17)
at require (module.js:368:17)
at Object.<anonymous> (/Users/mandric/dev/kujua-export/packages/modules/build/add.js:1:77)
at Module._compile (module.js:432:26)
$ npm install -g kanso
npm ERR! error installing kanso@0.1.2 Error: Unsupported
npm ERR! error installing kanso@0.1.2 at checkEngine (/Users/mandric/local/node/lib/node_modules/npm/lib/install.js:570:14)
npm ERR! error installing kanso@0.1.2 at Array.0 (/Users/mandric/local/node/lib/node_modules/npm/node_modules/slide/lib/bind-actor.js:15:8)
npm ERR! error installing kanso@0.1.2 at LOOP (/Users/mandric/local/node/lib/node_modules/npm/node_modules/slide/lib/chain.js:15:13)
npm ERR! error installing kanso@0.1.2 at chain (/Users/mandric/local/node/lib/node_modules/npm/node_modules/slide/lib/chain.js:20:4)
npm ERR! error installing kanso@0.1.2 at installOne_ (/Users/mandric/local/node/lib/node_modules/npm/lib/install.js:548:3)
npm ERR! error installing kanso@0.1.2 at installOne (/Users/mandric/local/node/lib/node_modules/npm/lib/install.js:488:3)
npm ERR! error installing kanso@0.1.2 at /Users/mandric/local/node/lib/node_modules/npm/lib/install.js:425:9
npm ERR! error installing kanso@
// passes in couchbase single server, you can test in Futon by pasting into Custom Test
couchTests.custom_test = function(debug) {
var db = new CouchDB("test_suite_db", {"X-Couch-Full-Commit":"false"});
db.deleteDb();
db.createDb();
if (debug) debugger;
var testregexDoc = {
_id: "_design/testregex",
@mandric
mandric / gist:1488631
Created December 17, 2011 00:13
Chicago Aldermen
"Person Name","Ward","Ward Phone","E-mail","Web Site","Ward Office","City","State","Zip","City HallPhone","Web Site 2"
"Arena, John","45","(773) 286-4545","ward45@cityofchicago.org","http://ward45.org","4754 N. Milwaukee Ave.","Chicago","IL","60630","(312) 744-6841"
"Austin, Carrie M.","34","(773) 928-6961","caustin@cityofchicago.org","507 W. 111th St. ", "Chicago","IL","60628","(312)744-6820","Budget Committee: http://committeeonthebudget.cityofchicago.org/index.html"
"Balcer, James","11","(773) 254-6677","jbalcer@cityofchicago.org","http://www.11thward.com/","3659 S. Halsted St. ","Chicago","IL","60609","(312) 744-6663"
"Beale, Anthony","09","(773) 785-1100","ward09@cityofchicago.org","http://www.ward09.cityofchicago.org/","34 East 112th Place ","Chicago","IL","60628","(312) 744-6838"
"Brookins, Jr."," Howard","21","(773) 881-9300","ward21@cityofchicago.org","9011 S. Ashland Ave."," Unit B ","Chicago","IL","60620","(312) 744-4810"
"Burke, Edward M.","14","(773) 471-1414","eburke@cityofchicago.org","2650 W.
@mandric
mandric / gist:1424480
Created December 2, 2011 19:20
couchdb regex test
// fails in couchbase single server, you can test in Futon by pasting into Custom Test
couchTests.custom_test = function(debug) {
var db = new CouchDB("test_suite_db", {"X-Couch-Full-Commit":"false"});
db.deleteDb();
db.createDb();
if (debug) debugger;
var testregexDoc = {
_id: "_design/testregex",
{
"payload": {
"task": "send",
"secret": "secret_key",
"messages": [
{
"to": "+000-000-0000",
"message": "the message goes here",
"callback": "POST http://server/url?id=123&param=true"
},
/**
* Update functions to be exported from the design doc.
*/
var _ = require('underscore')._
exports.add_sms = function (doc, req) {
// add validation
var new_doc = _.extend(req.form, {_id: req.uuid});
// support Ushahidi response protocol
<receiver android:name="StartupReceiver">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_REPLACED"/>
<action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
<action android:name="android.intent.action.PACKAGE_ADDED"/>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<category android:name="android.intent.category.HOME"/>
</intent-filter>
</receiver>