Skip to content

Instantly share code, notes, and snippets.

select
/* Image Filetypes */
when match(1,'FFD8FFE00010'x'JFIF') then ftype = 'JPEG'
when match(1,'GIF8') then ftype = 'GIF'
when match(2,'PNG') then ftype = 'PNG'
when match(1,'0a0501'x) then ftype = 'PCX'
when match(9,'ILBM') & form then ftype = 'ILBM'
@stagas
stagas / identd.js
Created December 22, 2010 15:24
Lame Ident Daemon for IRC
#!/usr/bin/env node
//
// Lame Ident Daemon for IRC
//
// (c) 2010 George Stagakis
//
// MIT Licenced
//
@stagas
stagas / sendmail.js
Created December 21, 2010 18:53
simple sendmail for node.js
//
var net = require('net')
, config = {
type: 'text/plain'
}
exports.send = function(options, cb) {
var stream = net.createConnection(options.port, options.host)
@stagas
stagas / bitcompressors.js
Created December 18, 2010 23:16
bit compressors for everyone
// bit compressors for everyone
// by stagas
// public domain
var bitEncodeUTF8 = function(bits) {
var arr = []
while (bits.length) {
arr.push(String.fromCharCode(parseInt('1' + bits.substr(0, 15), 2)))
bits = bits.substr(15)
}
@stagas
stagas / anotherbitcompressor.js
Created December 18, 2010 20:08
another bit compressor in pure javascript
// another bit compressor
// by stagas
// public domain
var bitEncode = function(bits) {
var arr = []
while (bits.length) {
arr.push(String.fromCharCode(parseInt('1' + bits.substr(0, 15), 2)))
bits = bits.substr(15)
}
@stagas
stagas / bitcompressor.js
Created December 18, 2010 19:29
bit compressor in pure javascript
// bit compressor
// by stagas
// public domain
var bitEncode = function(bits) {
var arr = []
while (bits.length) {
arr.push(parseInt('1' + bits.substr(0, 52), 2).toString(32))
bits = bits.substr(52)
}
if (secured || !store.cookie.secure) {
// Send an updated cookie to the browser
store.cookie.expires = typeof store.cookie.persistent === 'undefined' || store.cookie.persistent ? new Date(Date.now() + store.maxAge) : null;
// Multiple Set-Cookie headers
headers = headers || {};
var cookie = utils.serializeCookie(key, req.sessionID, store.cookie);
if (headers['Set-Cookie']) {
headers['Set-Cookie'] += '\r\nSet-Cookie: ' + cookie;
} else {
@stagas
stagas / flooder.js
Created December 8, 2010 13:03
flooder middleware (simple one)
, function(req, res, next) {
var ip = req.headers.ip
if (typeof banned[ip] !== 'undefined') {
if (Date.now() - banned[ip] > 3 * 60 * 60 * 1000) {
try {
delete banned[ip]
} catch(e) {}
log('UNBANNED:'.cyan, ip)
} else {
@stagas
stagas / sillymemtest.js
Created December 7, 2010 13:24
silly mem test - try both with commented and not commented the JSON.stringify
//
var sys = require('sys')
var o = {}
, bo = []
for (var i=1000000; i--; ) {
bo.push('123456789012345678901234567890')
}
{ message: 'Parse Error',
stack: [Getter/Setter],
bytesParsed: 21260 } [ ' at Client.onData [as ondata] (http.js:889:27)',
' at Client._onReadable (net.js:762:27)',
' at IOWatcher.onReadable [as callback] (net.js:276:10)' ]