Skip to content

Instantly share code, notes, and snippets.

@katanacrimson
katanacrimson / gist:3982194
Created October 30, 2012 18:46
madness; brought to you by connect, express, passport, and socket.io.
io.configure(function () {
io.set('authorization', function (data, accept) {
if (data.headers.cookie) {
cookieParser(data.headers.cookie, function(err, c) {
if(err) accept('cookie parse failure: ' + err, false)
data.cookie = c.cookies || {}
data.signedCookie = c.signedCookies || {}
data.sessionID = data.cookie[cookieKey] || data.signedCookie[cookieKey] || null
if(!data.sessionID) accept('no sid cookie', false) // bad cookie! bad!
sessionStore.get(data.sessionID, function (err, session) {
@katanacrimson
katanacrimson / netstat.js
Created October 24, 2012 22:29
Quickie node.js to grab & parse current local TCP connections [netstat, Windows]
var child = require('child_process'),
util = require('util'),
netstat = child.spawn('netstat', ['-nb']),
out = ''
netstat.stdout.on('data', function(data) {
out += data
})
netstat.stderr.on('data', function(data) {
console.log('err: ' + data)
<KyleXY> staticsafe: what?
<staticsafe> ubuntu 5.10
<staticsafe> wat
<KyleXY> That's the truth, nenolod just blabbed about it
<KyleXY> <spam>
<KyleXY> 07:52 <@nenolod> Lucifer7: honestly cia.vc being down is probably good for the internet
<KyleXY> 07:52 <@nenolod> Lucifer7: and ultimately good for open source in general
<KyleXY> 07:53 <@nenolod> Lucifer7: now the community is forced to actually do something about the fact that the CIA.vc server was filled with security holes
<KyleXY> 07:53 < Lucifer7> but now i have to actually look at websites to see commits instead of just idle on irc ugh
<KyleXY> 07:53 <@nenolod> Lucifer7: such as running ubuntu 5.10
@katanacrimson
katanacrimson / pass.js
Created August 22, 2012 02:33
Football season is here
$ node pass.js
99.3
@katanacrimson
katanacrimson / ohgodwhy.js
Created July 30, 2012 14:27
Minor script for horrific compaction of some ANSI art of mine...
var fs = require('fs'),
start = new Date()
fs.readFile('flame.htm', 'utf8', function(err, data){
if(err) throw err
console.log('pre-parsing: extracting css color codes')
var re, hex, res = data.match(/h([0-9a-f]{3,6})/g).sort().unique(),
post = ['fff', 'fefefe', 'ffffff', 'fffefe', 'fffffe', 'fefeff'],
css = '/' + "*!\n * <3\n" + '*' + "/\n" + 'pre{font: 8px monospace;line-height: 3px;color: #ffffff;}'
@katanacrimson
katanacrimson / gist:3073744
Created July 9, 2012 01:39
node bcrypt implementation test
$ cat bcrypt.js && node bcrypt.js
var bcrypt = require('bcrypt'), current = '', last = '', salt = bcrypt.genSaltSync(2)
for(var i = 51;i <= 100;i++) {
current = bcrypt.hashSync(Array(i).join('a'), salt)
console.log("length: " + (i-1) + ' salt: ' + current)
if(current == last) break
last = current
}
length: 50 salt: $2a$04$NARA6XWraiNNu/gmbbZUQOg2RtlSFed9itNdWbDv2uMyZA.L/o8Yq
@katanacrimson
katanacrimson / push.sh
Created April 24, 2012 16:25
Quick and dirty shell script for getting screenshots quickly taken and uploaded.
#!/bin/bash
#
# Local push to own server
#
# Requires:
# - remote webserver (best used w/userdirs)
# - local package "scrot"
# - local package "xclip"
# - local package "pngcrush"
# - iq > 20
@katanacrimson
katanacrimson / Session.php
Created February 29, 2012 20:52
Session hijack detection with IP "chunk" validation...
<?php
namespace codebite\tsundere\Session;
use \R;
use \sigmabb\sigmabb\WebKernel as Sigma;
// licensed: MIT license
class Session
{
private $app, $_sid_entry, $sid, $session, $ipv4_validation_level, $ipv6_validation_level;
@katanacrimson
katanacrimson / gist:1699771
Created January 29, 2012 17:38
gitlab ruby crash
Started GET "/csharp/master/tree/chap3_28_hw/chap3_28_hw" for [redacted] at 2012-01-29 11:31:46 -0600 [350/1886]
Processing by RefsController#tree as JS
Parameters: {"project_id"=>"csharp", "id"=>"master", "path"=>"chap3_28_hw/chap3_28_hw"}
Rendered refs/_tree_item.html.haml (11.7ms)
Rendered refs/_tree_item.html.haml (10.5ms)
Rendered refs/_tree_item.html.haml (10.2ms)
Rendered refs/_tree_item.html.haml (10.2ms)
Rendered refs/_tree_item.html.haml (6.8ms)
Rendered refs/_tree.html.haml (149.5ms)
Rendered refs/tree.js.haml (150.8ms)
@katanacrimson
katanacrimson / .tmux.conf
Created January 10, 2012 22:31
tmux config file
set -g set-titles off
set -g prefix C-a
unbind C-b
bind C-a send-prefix
bind-key C-a last-window
unbind % # Remove default binding since we’re replacing
bind | split-window -h
bind - split-window -v
set -g lock-command 'tput civis && read -s -n1'