This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'), | |
tls = require('tls'); | |
var host = process.argv[2] || '3.0.0.2'; | |
var port = process.argv[3] || 443; | |
var options = { | |
key: fs.readFileSync('./certs/serverA_512.key'), | |
cert: fs.readFileSync('./certs/serverA_512.crt'), | |
ca: [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Kernel sysctl configuration file for Red Hat Linux | |
# | |
# For binary values, 0 is disabled, 1 is enabled. See sysctl(8) and | |
# sysctl.conf(5) for more details. | |
# Controls source route verification | |
net.ipv4.conf.default.rp_filter = 1 | |
# Do not accept source routing | |
net.ipv4.conf.default.accept_source_route = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http'), | |
cluster = require('cluster'); | |
var numCPUs = require('os').cpus().length; | |
var host = process.argv[2] || '3.0.0.2'; | |
var port = process.argv[3] || 80; | |
if (cluster.isMaster) { | |
// this is the master, so spawn workers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var net = require("net"); | |
process.on("uncaughtException", function(error) { | |
console.error(error); | |
}); | |
if (process.argv.length != 5) { | |
console.log("usage: %s <localport> <remotehost> <remoteport>", process.argv[1]); | |
process.exit(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var dgram = require('dgram'); | |
var host = process.argv[2] || '0.0.0.0'; | |
var port = process.argv[3] || 514; | |
var server = dgram.createSocket('udp4'); | |
server.on('message', function(msg, rinfo) { | |
console.log("received: %s from %s:%s", msg, rinfo.address, rinfo.port); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# to run: | |
# 1. npm install -g coffee-script | |
# 2. npm install http-proxy | |
# 3. coffee kittenproxy.coffee | |
# 4. change browser proxy settings to <thishost>:8080 | |
httpProxy = require("http-proxy") | |
address = process.argv[2] or "0.0.0.0" | |
port = process.argv[3] or 8080 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# forget.sh: remove matching lines from ~/.ssh/known_hosts | |
# usage: forget <hostname|IP|substring> [...] | |
function forget { | |
known_hosts=~/.ssh/known_hosts | |
for host in $* | |
do | |
host=$(echo "${host}" | sed -e 's/^ssh:\/\///' -e 's/^.*@//') | |
line=$(awk '{ print $1 }' ${known_hosts} | grep -n "${host}" | sed 's/:.*$//g' | xargs) | |
while [ -n "${line}" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http'); | |
var host = process.argv[2] || '127.0.0.1'; | |
var port = process.argv[3] || 8080; | |
http.createServer( function (req, res) { | |
var proxy = http.request(req.url, function (proxy_res) { | |
proxy_res.on('data', function (chunk) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# usage: saveimages.rb <url> | |
# locally save all images from a web site | |
require 'nokogiri' | |
require 'open-uri' | |
exit if ARGV[0].nil? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
numbers = [2, 6, 4, 8, 8, 9] | |
sum = ARGV.empty? ? 10 : ARGV.first.to_i | |
def sum_exists(numbers, sum) | |
Array(numbers).combination(2).find_all { |x, y| x + y == sum } || [] | |
end | |
result = sum_exists(numbers, sum) |
OlderNewer