Skip to content

Instantly share code, notes, and snippets.

View meaku's full-sized avatar

Michael Jaser meaku

View GitHub Profile
@meaku
meaku / DEUTSCHskript.js
Created January 28, 2013 12:33
Das node.js HTTP-Server Beispiel umgesetzt in "DEUTSCHskript"
//knoten.js Netzdiener-Beispiel in DEUTSCHskript
var Http = FordereAn('http');
Http.ErstelleDiener(Funktion (Anf, Ant) {
Ant.SchreibeKopf(200, { "Inhalts-Art" : "text/blank"});
Ant.Beenden("Hallo Welt \n");
}).höre(1337, "LokalerGastgeber");
@meaku
meaku / .htaccess
Created March 18, 2013 13:14
.htaccess for SSL via SNI to prevent the certificate-error for unsupported browsers. Always share http links and https will be used if supported. Otherwise the connection will be http. SNI is not supported on IE on Windows XP (5 - 8) and Android < 4.x __Important Note__ Don't use this .htaccess if you need HTTPS for all your clients. It is just …
# HTTP(S) Stuff
# Redirect all users except IE 5-8 & Android < 4 to HTTPS
RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{HTTP_USER_AGENT} !MSIE\ [5-8]
RewriteCond %{HTTP_USER_AGENT} !Android.*(Mobile)?\ [0-3]
RewriteRule (.*) https://%{HTTP_HOST}/$1 [L]
@meaku
meaku / .htaccess
Created August 20, 2013 08:44
Conditional BasicAuth
# enable basic auth for dev systems
SetEnvIfNoCase Host dev\.host\.com passreq
AuthType Basic
AuthName "Testing"
AuthUserFile htuser
Require valid-user
Order deny,allow
Deny from env=passreq
@meaku
meaku / ssh_debugging.md
Last active August 29, 2015 13:58
SSH debugging

Try certain keys

ssh-add -R #deletes all loaded keys

add-add ~/.ssh/myKey #add the desired key

git clone ...  #see what happens
@meaku
meaku / autoresponder.js
Last active August 29, 2015 14:06
autoresponder.js
#!/usr/bin/env node
"use strict";
console.log("checking for auto responses");
var fs = require("fs"),
exec = require("child_process").exec;
var input = "";
@meaku
meaku / gist:ad1e76df00d8ad8daa5c
Last active December 7, 2022 01:58
iojs / node.js flamegraphs using perf

Prerequisites

Record perf data

perf record -i -g -e cycles:u -- node --perf-basic-prof app.js

  • generate some load!
@meaku
meaku / fetchSSHKeys.js
Last active August 29, 2015 14:21
fetch ssh keys
"use strict";
var request = require("request");
function fetchKeys(userName) {
return new Promise(function (resolve, reject) {
request(`https://github.com/${userName}.keys`, function (err, res, body) {
if (err) {
reject(err);
@meaku
meaku / BunyanDynamo.js
Created August 4, 2015 10:06
A simple dynamodb stream for bunyan logging each line
"use strict";
var util = require("util");
var Writable = require("stream").Writable;
var model = require("../db/dynamodb");
/**
* Log Stream
*

Passing values

Problem: Promises resolve only with a single value. If you want to pass on the result of PromiseCall1 to PromiseCall2, you have different options:

Nesting

You can nest a .then() for Promise Call 2 and return both value from the scope.

  • Nesting makes it harder to read and should be avoided