This file contains 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
app.get('/logs/server', function (req, res) { | |
var readStream; | |
readStream = fs.createReadStream(basepath + "/logs/server.log"); | |
readStream.setEncoding('utf8'); | |
readStream.on('data', function(data) { | |
data = data.replace('\n', ','); | |
// res.header('Content-Type', 'text/plain'); | |
res.send(data); | |
}); | |
readStream.on('end', function(){}); |
This file contains 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
var request = require('request'), default_headers, site_root = 'http://localhost:3000';; | |
default_headers = { | |
'User-Agent': 'Mozilla/5.0 (X11; Linux i686; rv:7.0.1) Gecko/20100101 Firefox/7.0.1', | |
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', | |
'Accept-Language': 'en-us,en;q=0.5', | |
'Accept-Encoding': 'gzip, deflate', | |
'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7', | |
// 'Connection': 'keep-alive', | |
'Cache-Control': 'max-age=0' |
This file contains 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
// I have this code in my controller and it keeps repeating (but I wanna be DRY) | |
// so I thought of moving it in my model.... buuut | |
// the thing is it checks for errors and if so it displays them | |
// and as far as I know rendering content to the user from a model is considered a bad practice | |
Model.find_by_id(req.body.id, options, function(err, record) { | |
if (err) { render_json_internal_error(res, err); } | |
else { Model.check_something(api, req.session.user, callback); } | |
}); |
This file contains 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
(function(){ | |
var DomReady = window.DomReady = {}; | |
// Everything that has to do with properly supporting our document ready event. Brought over from the most awesome jQuery. | |
var userAgent = navigator.userAgent.toLowerCase(); | |
// Figure out what browser is being used | |
var browser = { |
This file contains 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
/* Open the standard input stream and set the encoding to UTF-8 */ | |
var stdin = process.openStdin(); | |
stdin.setEncoding('utf8'); | |
/* This is the callback for handing data events from standard input. */ | |
inputHandler = function (response) { | |
/* Now that we're listening we either handle a prompt or handle a task | |
until the work queue is empty. */ | |
if (response != 'exit') { | |
process.stdout.write(">> " + response); |
This file contains 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
frontend flashpolicy 0.0.0.0:843 | |
mode tcp | |
maxconn 20000 | |
timeout client 86400000 | |
default_backend flashpolicy_servers | |
backend flashpolicy_servers | |
mode tcp | |
balance roundrobin | |
timeout server 86400000 |
This file contains 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
#!/usr/bin/env python | |
# Monitor for new questions on StackOverflow | |
# Author: Xueqiao Xu <xueqiaoxu@gmail.com> | |
import time | |
import json | |
import gzip | |
import pprint | |
import urllib | |
import urllib2 |
This file contains 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
var assert = require('assert'); | |
var net = require('net'); | |
var open = process.binding('fs').open; | |
var sendfile = process.binding('fs').sendfile; | |
if (process.argv.length < 4) { | |
console.error('usage: sendfile <port> <path>'); | |
process.exit(1); | |
} |
This file contains 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
config.json | |
reading-image.png |
This file contains 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
//author: Sun, Junyi (weibo.com/treapdb) | |
//usage: node --nouse-idle-notification --expose-gc --max-old-space-size=8192 memcached.js | |
var config ={ | |
port: 11211, | |
max_memory: 100 // default 100M bytes | |
} | |
var net = require('net'); | |
var LRU = function (max) { // this LRU implementaion is based on https://github.com/chriso/lru |