Skip to content

Instantly share code, notes, and snippets.

View lyaunzbe's full-sized avatar
🎯
Focusing

Ben L. lyaunzbe

🎯
Focusing
  • art blocks
  • :)
  • 09:18 (UTC -12:00)
View GitHub Profile
@lyaunzbe
lyaunzbe / hoganexpress.js
Created July 12, 2012 03:57
Getting hogan.js working with Express 3.x
var express = require('express'),
hogan = require('hogan.js'),
app = express.createServer();
app.set('view engine', 'hogan');
app.register('hogan', {
compile: function() {
var t = hogan.compile.apply(hogan, arguments);
return function() {
return t.render.apply(t, arguments);
@lyaunzbe
lyaunzbe / gist:3695519
Created September 11, 2012 02:35
Nodejitsu debugging
/**
* Entry point
*/
var express = require('express')
, fs = require('fs')
, db = require('./db-connect');
//load config stuff
var fs = require('fs');
#JITSU
error: { dev: 65609,
error: ino: 62195,
error: mode: 33279,
error: nlink: 1,
error: uid: 113,
error: gid: 65534,
error: rdev: -1,
error: size: 61,
error: blksize: 512,
info: Welcome to Nodejitsu lyaunzbe
info: jitsu v0.9.8
info: It worked if it ends with Nodejitsu ok
info: Executing command databases create mongo bangalter
info: A new mongo has been created
info: Database name: undefined
error: Unknown database type: undefined
info: Nodejitsu ok
/usr/local/lib/node_modules/jitsu/lib/jitsu/commands/databases.js:184
results.forEach(function (database) {
^
TypeError: Object #<Object> has no method 'forEach'
at databases.list (/usr/local/lib/node_modules/jitsu/lib/jitsu/commands/databases.js:184:15)
at Databases.list (/usr/local/lib/node_modules/jitsu/node_modules/nodejitsu-api/lib/client/databases.js:56:5)
at Request.Client.request [as _callback] (/usr/local/lib/node_modules/jitsu/node_modules/nodejitsu-api/lib/client/client.js:109:5)
at Request.request.self.callback (/usr/local/lib/node_modules/jitsu/node_modules/nodejitsu-api/node_modules/request/main.js:104:22)
at Request.<anonymous> (/usr/local/lib/node_modules/jitsu/node_modules/nodejitsu-api/node_modules/request/main.js:458:18)
at Request.EventEmitter.emit (events.js:88:17)
FileInputStream FIS = null;
try {
FIS = new FileInputStream("src/dataset.dat");
} catch (FileNotFoundException e) {
e.printStackTrace();
}
BufferedInputStream BIS = new BufferedInputStream(FIS, 1000);
DataInputStream DIS = new DataInputStream(BIS);
@lyaunzbe
lyaunzbe / promises.md
Created October 20, 2012 16:59 — forked from domenic/promises.md
You're Missing the Point of Promises

You're Missing the Point of Promises

Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:

getTweetsFor("domenic", function (err, results) {
    // the rest of your code goes here.
});
var static = require('node-static');
//
// Create a node-static server instance to serve the './public' folder
//
var file = new(static.Server)('./public');
require('http').createServer(function (request, response) {
request.addListener('end', function () {
//
test('Module definition', function(t){
t.plan(2);
t.type(lute, 'function', 'Lute should be a funciton.');
t.type(task,'object', 'Task should be an object.');
t.end();
});
test('Processesing an example task', function(t){
t.plan(1);
lute(['rick.ogg'],task, function(err){
$('a').on('click', function(e){
$('body').fadeOut(500);
var href = $(this).attr('href');
setTimeout(function() {window.location = href;}, 500);
return false;
});