Skip to content

Instantly share code, notes, and snippets.

View shiawuen's full-sized avatar

Tan Shiaw Uen shiawuen

View GitHub Profile
app.get('/path/to/html.html', function(req, res, next) {
console.log('oh hai!');
// The request will then pass down to the static file middleware
next();
});
@shiawuen
shiawuen / securing_rails_updates.md
Created March 5, 2012 15:54 — forked from peternixey/securing_rails_updates.md
How Homakov hacked GitHub and how to protect your application

##How Homakov hacked GitHub and the line of code that could have prevented it


Please note: THIS ARTICLE IS NOT WRITTEN BY THE GITHUB TEAM or in any way associated with them. It's simply hosted as a Gist because the markdown formatting is excellent and far clearer than anything I could manage on my personal Tumblr.


@homakov’s explot on GitHub was simple and straightforward. Calling it an attack makes it sound malicious whereas the truth was that GitHub bolted its front door but left the hinges on quick release. Homakov released the hinges, walked in and shouted to anyone who would listen that they had a problem.

@shiawuen
shiawuen / call-method.js
Created March 6, 2012 02:15
Can instance methods not be called from within other instance methods?
var goose = require('mongoose')
, db = goose.connect('mongodb://localhost/testmongo')
, Schema = goose.Schema
, sc = new Schema({
a: String,
b: Date
})
sc.methods.bbb = function() {
return this.b.getFullYear()

finger_server.js

An extremely minimal implementation of the Finger protocol using node.js.

To run (Finger uses port 79 which requires sudo):

sudo node finger_server.js
@shiawuen
shiawuen / hack.sh
Created April 8, 2012 12:59 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@shiawuen
shiawuen / LICENSE
Created May 8, 2012 10:36
jQuery plugin to serialize form fields into JSON
(The MIT License)
Copyright (c) 2011 Tan Shiaw Uen <shiawuen@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CO
@shiawuen
shiawuen / .gitignore
Created July 18, 2012 19:27
multi-select tree structure list
.DS_Store
@shiawuen
shiawuen / gist:3149145
Created July 20, 2012 06:53 — forked from teohm/gist:3149075
Convert any YouTube video into an audio file you can listen to on the go...
# Convert any YouTube video into an audio file you can listen to on the go, using:
# http://rg3.github.com/youtube-dl/
{ ~ } > brew install ffmpeg
{ ~ } > brew install ffprobe
{ ~ } > wget https://raw.github.com/rg3/youtube-dl/2012.02.27/youtube-dl
{ ~ } > chmod u+x youtube-dl
# Pick which video format you want to download.. (use any YT video link)
@shiawuen
shiawuen / deffered.js
Created August 3, 2012 03:49
simple hacky deffered implementation
/**
* Simple Hacky Deffered Implementation
*
* @author Tan Shiaw Uen
* @url https://gist.github.com/3244178
* @License MIT
**/
(function (win, undef) {
@shiawuen
shiawuen / index.html
Created October 4, 2012 17:48
this? this?? this!?
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body style="padding: 100px;background:#ccc;">
<script src="index.js"></script>
</body>