Skip to content

Instantly share code, notes, and snippets.

View aseemk's full-sized avatar

Aseem Kishore aseemk

View GitHub Profile
@aseemk
aseemk / app.js
Created April 29, 2011 05:33
Node or Connect bug: form decoding / body parsing
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 18:37
Less on Node: @import path isn't relative to stylesheet
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 22:46
Streamline properly maintains `this` before and after async calls... <3
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);
@aseemk
aseemk / loop_.js
Created May 5, 2011 06:12
Example of Streamline's compiler failing silently.
function process(user) {
var model = new User(user);
model.save(_);
}
for (var i = 0; i < users.length; i++) {
process(users[i]);
}
@aseemk
aseemk / loop_broken_.js
Created May 5, 2011 21:26
Streamline v0.1.21 chokes on variables assigned inside a for-in loop that are defined outside.
var obj, key, val;
obj = {
foo: 'bar',
hello: 'world'
};
for (key in obj) {
val = obj[key];
setTimeout(_, 1000);
@aseemk
aseemk / doesnt_work.coffee
Created May 11, 2011 00:31
CoffeeScript rejects multi-line comments that begin at a different indentation level
for i in foo
print 'hello'
###
hello?
###
print 'world'
@aseemk
aseemk / error.html
Created May 11, 2011 09:29
Eco error messages contain meaningless line numbers
<h2>Error reporting</h2>
<p>
Does the error message for this page report the correct line number?
</p>
<% para = (phrase) -> %>
<p><%= phrase %></p>
<% end %>
@aseemk
aseemk / multiline.html
Created May 11, 2011 09:43
Eco multi-line blocks and comments.
<h1>Multi-Line Blocks</h1>
<p>
It would be great to support multi-line blocks.
Here are some use cases:
</p>
<%
# Documentation via multiple lines of single-line comments.
# Like so.
@aseemk
aseemk / foreach.html
Created May 11, 2011 09:51
Eco forEach iteration
<h2>For-Each</h2>
<p>
This should print a list of names, no?
(It does in EJS.)
</p>
<% names = ['Alice', 'Bob', 'Carol'] %>
<ul>
@aseemk
aseemk / colon.html
Created May 11, 2011 10:15
Eco comments ending in colons
<h1>Comments ending in colons</h1>
<% # This comment ends in a colon: %>
<p>
That shouldn't be a problem for Eco! But it is. ;)
</p>