This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# An example of enabling WIFI and connecting to WEP/WPA/WPA2 wireless network. | |
# Here setup your network information. | |
ESSID= | |
KEY= | |
# Enable WLAN. | |
ifconfig wlan0 up |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// An example of recovering the old taste of req.files under Express 4. | |
var app = require('express')(); | |
app.use(require('body-parser')()); | |
// As body-parser won't parse multipart/form-data, we use connect-multiparty to do this. | |
// There are some other alternatives, for example, formidable, busboy, and multiparty, etc. | |
app.use(require('connect-multiparty')()); | |
app.post('/', function(req, res) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// An example of using yield to simplify the callback hell. | |
// The limitation is, this only apply to whose callbacks take the normal form of function(err, result), more arguments are ignored. | |
// Maybe there are many workarounds, but keep it simple, the ECMAScript 6 is around the corner. | |
// Issues: | |
// 1. If you yield your syncTask(callback), it will complain that "Generator is already running." | |
// An solution is yield setTimeout(callback, 0) in your syncTask(callback). | |
function Async(task) { | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// An example of decrypting AES/ECB/PKCS5Padding-encrypted buffer in node.js. | |
// Hope this gist will help you. Feel free to discuss with me. | |
var crypto = require('crypto'); | |
// Change this to fit your needs. | |
// The buffer of your raw password. | |
var keyBuffer = new Buffer('12345678'); | |
// The buffer of your data to be decrypted. | |
var encryptedBuffer = new Buffer('12345678'); |