Skip to content

Instantly share code, notes, and snippets.

View diversario's full-sized avatar
🏳️‍🌈

Ilya Shaisultanov diversario

🏳️‍🌈
View GitHub Profile
@diversario
diversario / app.js
Created September 27, 2011 17:56
connect-formaline example
var connect = require('connect'),
UPLOAD_LIMIT = 1000000,
flconf = {"uploadRootDir": '/tmp/', "requestTimeOut": 600000, "resumeRequestOnError": false, "maxFileSize": UPLOAD_LIMIT, "checkContentLength": true, "holdFilesExtensions": true, "removeIncompleteFiles": true, "logging": 'debug:off,1:on,2:off,3:off,4:off,console:on,file:off,record:off'},
formaline = require('connect-formaline');
connect(
connect.cookieParser(),
connect.session({ secret: 'keyboard cat' }),
formaline(flconf),
function(req, res){
@diversario
diversario / app.js
Created September 28, 2011 14:19
connect-formaline example 2
#!/usr/bin/env node
var express = require('express'),
app = express.createServer(), // actual application
UPLOAD_LIMIT = 20 * 1024 * 1024,
form = require('./connect-formaline'),
formaline_config = ({"uploadRootDir": '/tmp/', "emitProgress": true, "requestTimeOut": 600000, "resumeRequestOnError": false, "maxFileSize": UPLOAD_LIMIT, "checkContentLength": true, "holdFilesExtensions": true, "removeIncompleteFiles": true, "logging": 'debug:on,1:on,2:on,3:off,4:off,console:on,file:off,record:off'});
app
.use(express.cookieParser())
@diversario
diversario / log.js
Created September 29, 2011 10:48
Unfinished upload log
formaline, event "message" --> {"type":"warning","isupload":true,"msg":"unable to retrieve session identifier, configuration parameter me.getSessionID must be a function!"}
formaline, HTTP Request Headers : {
"host": "domain.com",
"user-agent": "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0) Gecko/20100101 Firefox/7.0",
"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",
"referer": "http://domain.com/test.html",
@diversario
diversario / redis.conf
Created December 27, 2011 17:29 — forked from carlzulauf/redis.conf
Redis upstart script (/etc/init/)
description "redis server"
start on runlevel [2345]
stop on shutdown
exec /usr/local/bin/redis-server /etc/redis/redis.conf
respawn
@diversario
diversario / ssdp.node.js
Created October 17, 2012 21:48 — forked from chrishulbert/ssdp.node.js
Service discovery using node.js and ssdp / universal plug n play
var dgram = require('dgram'); // dgram is UDP
// Listen for responses
function listen(port) {
var server = dgram.createSocket("udp4");
server.on("message", function (msg, rinfo) {
console.log("server got: " + msg + " from " + rinfo.address + ":" + rinfo.port);
});
@diversario
diversario / dateStub.js
Created October 20, 2012 22:02
Stub Javascript Date()
var oldDate = Date;
Date = function () {
var args = arguments.length > 0 ? Array.prototype.slice.call(arguments) : [1293861600];
if (typeof args[0] === 'string') {
args = ["'" + args[0] + "'"];
}
return new Function('return new oldDate(' + args.join(',') + ');')();
}
➜ ~ brew --config
HOMEBREW_VERSION: 0.9.4
ORIGIN: https://github.com/mxcl/homebrew
HEAD: bf31154f700a73c5c14b96edf447e75964e9390d
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
CPU: 8-core 64-bit ivybridge
OS X: 10.8.3-x86_64
Xcode: 4.6.1
CLT: 4.6.0.0.1.1362189000
@diversario
diversario / request-i304.js
Created September 11, 2013 19:50
request #304, multiple `error` events on timeout
require('http').Server(function (req, res) {})
.listen(28423, '127.0.0.1', function () {
var request = require('request')
request({
"method": "GET",
"uri": "http://127.0.0.1:28423",
"timeout": 1000
}).on('error', function(e){
console.log('error')
@diversario
diversario / robbyrussell.zsh
Created January 24, 2014 23:08
Display hostname in the prompt
local ret_status="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ %s)"
PROMPT='%{$fg[blue]%}%n@%m ${ret_status}%{$fg_bold[green]%}%p%{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
ZSH_THEME_GIT_PROMPT_PREFIX="git:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})"
@diversario
diversario / app.js
Created June 14, 2014 21:26
cm replset test
var replicaSet = {
"collection" : "express_sessions",
"stringify": false,
"db": {
"name" : "sessions",
"replicaSetOptions": {
rs_name: 'default',
w: 2
},
"servers" : [