Skip to content

Instantly share code, notes, and snippets.

@mk-pmb
mk-pmb / proxy-config-test.sh
Last active August 29, 2015 14:07
Bower proxy config test
#!/bin/bash
# -*- coding: utf-8, tab-width: 2 -*-
# Ubuntu style, as npm and wget use it:
export http_proxy='http://pub-inet.proxy.lan:3128'
export https_proxy="$http_proxy"
# Windows wget style:
export HTTP_PROXY="$http_proxy"
export HTTPS_PROXY="$http_proxy"
@mk-pmb
mk-pmb / create-umlaut-file.pl
Created March 13, 2015 16:44
Node.js tests for ISO umlauts in filenames
#!/usr/bin/perl
use strict;
open(GROSZ, ">>", "test-uml\xE4\xFCt\xDF-file.txt");
close(GROSZ);
@mk-pmb
mk-pmb / _frag-upd.sed
Last active August 29, 2015 14:24
Replace parts of HTML pages with sed
#!/bin/sed -rf
# -*- coding: UTF-8, tab-width: 2 -*-
#
# Command to update the fragments in the HTML files:
# sed -rf _frag-upd.sed -i *.html
/<nav id="menu"/{
r nav-menu.frag
b skip
}
{
{I have|I've} been {surfing|browsing} online more than {three|3|2|4} hours today, yet I never found any interesting article like yours. {It's|It
is} pretty worth enough for me. {In my opinion|Personally|In my view}, if all {webmasters|site owners|website owners|web owners} and bloggers made good content as
you did, the {internet|net|web} will be {much more|a lot more}
useful than ever before.|
I {couldn't|could not} {resist|refrain from} commenting. {Very well|Perfectly|Well|Exceptionally well} written!|
{I will|I'll} {right away|immediately} {take hold of|grab|clutch|grasp|seize|snatch}
your {rss|rss feed} as I {can not|can't} {in finding|find|to find} your {email|e-mail} subscription {link|hyperlink} or {newsletter|e-newsletter} service. Do {you have|you've} any?
{Please|Kindly} {allow|permit|let} me {realize|recognize|understand|recognise|know} {so that|in order that} I {may just|may|could} subscribe.
Thanks.|
ohai.
@mk-pmb
mk-pmb / netsh-cmds-headlines.js
Last active February 8, 2016 15:41
Bookmarklet: Netsh commands for Interface IP … identified as headlines.
/*jslint indent: 2, maxlen: 80, browser: true *//*
Netsh commands for Interface IP
===============================
… identified as headlines:
1. visit https://technet.microsoft.com/en-us/library/bb490943.aspx
2. apply bookmarklet
*/
(function () {
@mk-pmb
mk-pmb / promisefs.js
Created August 21, 2016 11:11
Promisify with control over selection, names and target.
/*jslint indent: 2, maxlen: 80, node: true */
/* -*- tab-width: 2 -*- */
'use strict';
var EX = module.exports, Promise = require('bluebird'), origFs = require('fs');
Object.keys(origFs).forEach(function customPromisify(key) {
var slot = origFs[key];
if (slot instanceof Function) {
if (key.match(/Sync$/)) { return; }
@mk-pmb
mk-pmb / collect-stream.diff
Last active September 23, 2016 10:20
meese's LED request
var express = require('express');
var jquery = require('jquery');
-var bodyParser = require('body-parser');
+var collectStream = require('collect-stream');
var app = express();
-app.use(bodyParser.json()); // for parsing application/json
-app.use(bodyParser.urlencoded({ extended: true })); // for parsing application/x-www-form-urlencoded
+
+function receiveLedMatrix(req, res, err, body) {
/*jslint indent: 2, maxlen: 80, node: true */
'use strict';
var xmldefuse = require("xmldefuse"),
rawXY = "X &amp& <lt< >gt> 'apos' \"quot\" Y",
rawCD = "Have <![CDATA[ marks ]]> in ]]> text",
eq = require("assert").strictEqual;
eq(xmldefuse.cdata(rawXY),
"<![CDATA[X &amp& <lt< >gt> 'apos' \"quot\" Y]]>");
doctype html
html
head
meta( http-equiv="Content-Type" content="text/html; charset=UTF-8" )
- var pageTitle = 'Complicated ways to write numbers'
title= pageTitle
meta( http-equiv="Content-Script-Type" content="text/javascript" )
body.page.screen
h2= pageTitle