Skip to content

Instantly share code, notes, and snippets.

Ben Ng ben-ng

Block or report user

Report or block ben-ng

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
View package.json
{
"author": "Ben Ng <me@benng.me> (http://benng.me)",
"name": "tdk",
"description": "Theme Developer Kit from http://toolkitt.com",
"keywords": [
"toolkitt",
"theme",
"browserify"
],
"version": "0.0.1",
@ben-ng
ben-ng / gist:6017181
Created Jul 17, 2013
CORS before action
View gist:6017181
exports.allow = function(resp, req) {
if(!resp.headersSent) {
resp.setHeader('Access-Control-Allow-Origin', req.headers.origin)
resp.setHeader('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS');
resp.setHeader('Access-Control-Allow-Credentials', 'true');
resp.setHeader('Access-Control-Allow-Headers', 'Content-Type');
}
};
@ben-ng
ben-ng / parser.js
Created Jul 19, 2013
Heroku DB URL parser
View parser.js
function parse_url(str, component) {
// http://kevin.vanzonneveld.net
// + original by: Steven Levithan (http://blog.stevenlevithan.com)
// + reimplemented by: Brett Zamir (http://brett-zamir.me)
// + input by: Lorenzo Pisani
// + input by: Tony
// + improved by: Brett Zamir (http://brett-zamir.me)
// + improved by: Ben Ng (http://benng.me)
// % note: Based on http://stevenlevithan.com/demo/parseuri/js/assets/parseuri.js
// % note: blog post at http://blog.stevenlevithan.com/archives/parseuri
View application.js
var Application = function () {
this.before(function () {
this.session.set('pineapple', 'turkey');
console.log(this.session.get('pineapple'));
});
};
exports.Application = Application;
View gist:6114955
var config = {
/* Blah blah blah */
, sessions: {
store: 'cookie'
, key: 'did'
, expiry: 14 * 24 * 60 * 60
}
};
View gist:6115034
var config = {
something: 'something'
};
module.exports = config;
// geddy.config.something == 'something'
View package.json
{
"name": "geddy",
"description": "Web framework for Node.js",
"keywords": [
"Web",
"framework",
"REST",
"MVC",
"realtime"
],
View respondwith_error.json
{
message: "crap",
stack: "Error: crapped out etc etc"
}
@ben-ng
ben-ng / stacktrace.txt
Created Oct 20, 2013
Stack Trace for Cordova 3.1.0 camera plugin on android device without SD card
View stacktrace.txt
10-20 02:09:32.287: W/CursorWrapperInner(2913): Cursor finalized without prior close()
10-20 02:09:32.297: E/System(2913): Uncaught exception thrown by finalizer
10-20 02:09:32.297: D/WebView(2913): loadUrlImpl: called
10-20 02:09:32.297: E/System(2913): java.io.IOException: close failed: EIO (I/O error)
10-20 02:09:32.297: E/System(2913): at libcore.io.IoUtils.close(IoUtils.java:41)
10-20 02:09:32.297: E/System(2913): at java.io.FileInputStream.close(FileInputStream.java:121)
10-20 02:09:32.297: E/System(2913): at java.io.FileInputStream.finalize(FileInputStream.java:142)
10-20 02:09:32.297: E/System(2913): at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:186)
10-20 02:09:32.297: E/System(2913): at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:169)
10-20 02:09:32.297: E/System(2913): at java.lang.Thread.run(Thread.java:856)
@ben-ng
ben-ng / index.js
Created Oct 23, 2013
requirebin sketch
View index.js
var Ribcage = require('ribcage-view')
, OuterView
, InnerView
, myView;
InnerView = Ribcage.extend({
events: {
'click a': 'handleClick'
}
, template: function () {
You can’t perform that action at this time.