Skip to content

Instantly share code, notes, and snippets.

Aseem Kishore aseemk

Block or report user

Report or block aseemk

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@aseemk
aseemk / shell
Created Apr 8, 2011
Streamline's compiler chokes on valid JS when a function happens to have a keyword name.
View shell
$ node-streamline -c truthy_.js
$ node-streamline -c true_.js
/usr/lib/node/.npm/streamline/0.1.11/package/lib/transform.js:1549
throw new Error(message);
^
Error: error streamlining source: Missing identifier on line 5
at Object.transform (/usr/lib/node/.npm/streamline/0.1.11/package/lib/transform.js:1549:10)
at /usr/lib/node/.npm/streamline/0.1.11/package/lib/compile.js:48:30
at /usr/lib/node/.npm/streamline/0.1.11/package/lib/compile.js:43:206
@aseemk
aseemk / under_.js
Created Apr 10, 2011
Testing support for using Streamline.js with Underscore.js.
View under_.js
// streamline.options = { "callback": "_cb" }
var _ = require('underscore');
var array = [1, 2, 3];
function process(item, _cb) {
// simulate async task
setTimeout(_cb, 1000);
return item;
}
@aseemk
aseemk / closure_error_.js
Created Apr 10, 2011
Throwing an error synchronously within a closure isn't caught -- Streamline bug?
View closure_error_.js
console.log('will throw error in one second...');
try {
// simulate async step here:
setTimeout(_, 1000);
// then *synchronously* throw error here:
(function closure() {
throw new Error();
})();
@aseemk
aseemk / multiple_return_values_.js
Created Apr 10, 2011
Trying to accommodate multiple "return values" in Streamline syntax.
View multiple_return_values_.js
// here's an example third-party, out-of-my-control function.
// it calls the callback with multiple non-error values:
function addAndProfile_original(x, y, callback) {
var start = Date.now();
return setTimeout(function () {
var time = Date.now() - start;
callback(null, x + y, time);
}, 1000);
}
@aseemk
aseemk / streamline.coffee
Created Apr 19, 2011
A wrapper around streamline that supports require()-ing coffee files.
View streamline.coffee
coffee = require 'coffee-script'
streamline = require 'streamline'
fs = require('fs')
if require.extensions
require.extensions['.coffee'] = (module, filename) ->
content = coffee.compile fs.readFileSync filename, 'utf8'
if filename.match /_\.coffee$/
content = streamline.transform.transform content
module._compile content, filename
@aseemk
aseemk / app.js
Created Apr 19, 2011
Express sample app using Eco templating engine.
View app.js
var express = require('express');
var app = express.createServer();
app.configure(function () {
app.use(app.router);
});
app.set('views', __dirname + '/views');
app.set('view engine', 'html');
app.register('.html', require('eco'));
@aseemk
aseemk / app.js
Created Apr 19, 2011 — forked from laurie71/blocks.js
Test app for Express blocks middleware
View app.js
var express = require('express');
var app = express.createServer();
app.configure(function () {
app.use(require('./blocks')(app));
app.use(app.router);
});
app.set('views', __dirname);
app.set('view engine', 'html');
@aseemk
aseemk / app.js
Created Apr 29, 2011
Node or Connect bug: form decoding / body parsing
View app.js
var express = require('express');
var app = express.createServer();
app.set('views', __dirname);
app.set('view engine', 'html');
app.register('.html', require('ejs'));
app.configure(function () {
app.use(express.bodyParser());
app.use(express.errorHandler({
@aseemk
aseemk / app.js
Created May 2, 2011
Less on Node: @import path isn't relative to stylesheet
View app.js
var express = require('express');
var app = express.createServer();
app.configure(function () {
app.use(express.compiler({
src: __dirname,
enable: ['less']
}));
app.use(express.static(__dirname));
app.use(express.errorHandler({
@aseemk
aseemk / animal_.js
Created May 4, 2011
Streamline properly maintains `this` before and after async calls... <3
View animal_.js
function Animal(name) {
this.name = name;
}
Animal.prototype.drink = function (_) {
console.log(this.name + " is about to grab a drink at the watering hole...");
// simulate async step:
setTimeout(_, 1000);
You can’t perform that action at this time.