Skip to content

Instantly share code, notes, and snippets.

View zjiekai's full-sized avatar
🐼
Home Sweet Home

zjiekai

🐼
Home Sweet Home
View GitHub Profile
@zjiekai
zjiekai / basic_auth_nodejs_test.js
Created October 18, 2016 07:40 — forked from charlesdaniel/basic_auth_nodejs_test.js
Example of HTTP Basic Auth in NodeJS
var http = require('http');
var server = http.createServer(function(req, res) {
// console.log(req); // debug dump the request
// If they pass in a basic auth credential it'll be in a header called "Authorization" (note NodeJS lowercases the names of headers in its request object)
var auth = req.headers['authorization']; // auth is in base64(username:password) so we need to decode the base64
console.log("Authorization Header is: ", auth);
@zjiekai
zjiekai / sshpass.py
Created August 8, 2016 13:52 — forked from virtuald/sshpass.py
Simple python wrapper to give SSH a password for automation purposes (with output capture)
#!/usr/bin/env python3
import os
import sys
_b = sys.version_info[0] < 3 and (lambda x:x) or (lambda x:x.encode('utf-8'))
def ssh_exec_pass(password, args, capture_output=False):
'''
Wrapper around openssh that allows you to send a password to
s = 'xyabax'
d = dict()
def calc0(s):
global inf
inf = len(s) + 1
return calc(s)
def calc(s):
@zjiekai
zjiekai / punch.py
Created February 16, 2016 03:07 — forked from koenbollen/punch.py
Proof of Concept: UDP Hole Punching
#!/usr/bin/env python
#
# Proof of Concept: UDP Hole Punching
# Two client connect to a server and get redirected to each other.
#
# This is the client.
#
# Koen Bollen <meneer koenbollen nl>
# 2010 GPL
#
@zjiekai
zjiekai / memusg
Last active August 29, 2015 14:18 — forked from netj/memusg
#!/usr/bin/env bash
# memusg -- Measure memory usage of processes
# Usage: memusg COMMAND [ARGS]...
#
# Author: Jaeho Shin <netj@sparcs.org>
# Created: 2010-08-16
set -um
# check input
[ $# -gt 0 ] || { sed -n '2,/^#$/ s/^# //p' <"$0"; exit 1; }