Skip to content

Instantly share code, notes, and snippets.

View buschtoens's full-sized avatar
🏳️‍🌈
Open Source

Jan Buschtöns buschtoens

🏳️‍🌈
Open Source
View GitHub Profile
@buschtoens
buschtoens / fixed-http-proxy.js
Created May 29, 2012 13:49
This is a fix for the unix socket problem of node-http-proxy
// https://github.com/nodejitsu/node-http-proxy/issues/104
var http = require("http"),
https = require("https");
module.exports = exports = require("http-proxy");
var maxSockets = exports.getMaxSockets();
exports.HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
@buschtoens
buschtoens / example.js
Created September 8, 2012 17:06
Argument sanitization
// Module dependencies
var sanitize = require("./sanitize.js");
// function createConnection(String host, Number port, Object credentials, Array data)
function createConnection(host, port, credentials, data) {
sanitize(arguments, [String, Number, Object, Array]);
console.log(host, port, credentials, data);
}
var sanitize = require("./index.js")
, typeOf = sanitize.typeOf
, nameOf = sanitize.nameOf
, argsOf = sanitize.argsOf;
function stopwatch() {
var start = new Date();
return function stop() {
var end = new Date();
return end.getTime() - start.getTime();
@buschtoens
buschtoens / example.js
Created November 11, 2012 19:25
Simple Timer
// create a new Timer
var reloader = new Timer(30000);
// reload the page
reloader.register(window.location.reload.bind(window.location, true));
// reschedule on mouse movement
document.addEventListener("mousemove", reloader.restart.bind(reloader));
// reschedule on keyboard acitivity
@buschtoens
buschtoens / master.js
Created December 1, 2012 11:10
Node.js domain distribution
var http = require("http")
, net = require("net")
, fs = require("fs");
try { fs.mkdirSync("/tmp/http", 0777); } catch(e) {}
fs.chmodSync("/tmp/http", 0777);
http.createServer(function(req, res) {
var options = {
method: req.method
@buschtoens
buschtoens / annularSector.js
Created December 2, 2012 19:14
Generate the path for an annular sector svg
function deg2rad(deg) {
return deg * Math.PI / 180;
}
function annularSector(centerX, centerY, startAngle, endAngle, innerRadius, outerRadius) {
startAngle = deg2rad(startAngle + 180);
endAngle = deg2rad(endAngle + 180);
var p = [
[centerX + innerRadius * Math.cos(startAngle), centerY + innerRadius * Math.sin(startAngle)]
@buschtoens
buschtoens / exec.vbs
Last active October 14, 2015 00:48
Simple power utility for starting processes
Set objShell = CreateObject("Shell.Application")
intOffset = 0
' get action
strAction = "open"
If (WScript.Arguments.Named.Exists("action")) Then
intOffset = intOffset + 1
Select Case WScript.Arguments.Named.Item("action")
Case "elevate" strAction = "runas"
@buschtoens
buschtoens / The Legend of Veggie.md
Last active December 14, 2015 19:18
How to cook The Legend of Veggie, also known as spinach triangles.

The Legend of Veggie

...or as the Germans say "Spinatecken" (5 min preparation + 15 min baking time)

Ingredients

  • 450g cream spinach
  • 150g flour
  • 120g shredded cheese
  • 4 tablespoonful of milk
  • 2 teaspoons of baking powder
@buschtoens
buschtoens / .htaccess
Created May 6, 2013 00:13
Dynamic VHost with mod_rewrite
# Mod Rewrite
RewriteEngine on
RewriteBase /
# Top Level Domains
RewriteCond %{HTTP_HOST} ^(?:.*?)([^.]+\.[^.]+)(?::80)?$ [NC]
RewriteCond %{REQUEST_URI} !^/domains
RewriteCond %{DOCUMENT_ROOT}/domains/%1 -d
RewriteRule ^(.*) /domains/%1/$1 [L]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.