Skip to content

Instantly share code, notes, and snippets.

@mk-pmb
mk-pmb / angspa.js
Created October 18, 2017 17:07
Angular SPA webserver
/* -*- coding: UTF-8, tab-width: 2 -*- */
/*jslint indent: 2, maxlen: 80, continue: true, unparam: true, node: true */
'use strict';
/***** Angular Single Page Application Web Server *****
* Example for how to enhance a simple static webserver with route
* exceptions. Simple = without a big framework like express.
* Background is to serve angular single page applications (SPA) for
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: [u'--no-call-home', u'--abort-on-error', u'--no-overwrites', u'--keep-video', u'--restrict-filenames', u'--prefer-ffmpeg', u'--verbose', u'https://egghead.io/lessons/████']
[debug] Encodings: locale UTF-8, fs UTF-8, out None, pref UTF-8
[debug] youtube-dl version 2017.10.07
[debug] Git HEAD: 8f05b37
[debug] Python version 2.7.6 - Linux-3.13.0-133-generic-i686-with-Ubuntu-14.04-trusty
[debug] exe versions: avconv 9.20-6, avprobe 9.20-6, ffmpeg 3.3.3, ffprobe 3.3.3
[debug] Proxy map: {'http': 'http://████/', 'https': 'http://████/'}
@mk-pmb
mk-pmb / stubborn.js
Created September 28, 2017 14:34
Test for Node.js oneshot signal handlers https://github.com/nodejs/node/issues/15654
/*jslint indent: 2, maxlen: 80, node: true */
/* -*- tab-width: 2 -*- */
'use strict';
var EX = module.exports, fork = require('child_process').fork,
equal = require('assert').deepStrictEqual,
busyWait = true;
EX.main = function () {
/*jslint indent: 2, maxlen: 80, node: true */
/* -*- tab-width: 2 -*- */
'use strict';
var input, parseCsv = require('csv-parse/lib/sync'), auto, plus,
sep = ';', eq = require('assert').deepStrictEqual;
input = [ '42.23', '042.23', '042', '0042',
'0x42', '0x42.23', '0o42\n' ].join(sep);
@mk-pmb
mk-pmb / sparse checkout
Created August 20, 2017 18:44 — forked from werty1st/sparse checkout
git sparse checkout
What you are trying to do is called a sparse checkout, and that feature was added in git 1.7.0 (Feb. 2012). The steps to do a sparse clone are as follows:
git init <repo>
cd <repo>
git remote add -f origin <url>
This creates an empty repository with your remote. Then do:
git config core.sparsecheckout true
Now you need to define which files/folders you want to actually check out. This is done by listing them in .git/info/sparse-checkout, eg:
@mk-pmb
mk-pmb / gist:ef2a1bc0e8c50d8bdd4c1566654bdf32
Created August 20, 2017 18:43 — forked from sumardi/gist:5559896
Subdirectory checkouts with Git sparse-checkout
# New repository
mkdir <repo> && cd <repo>
git init
git remote add –f <name> <url>
git config core.sparsecheckout true
echo some/dir/ >> .git/info/sparse-checkout
echo another/sub/tree >> .git/info/sparse-checkout
git pull <remote> <branch>
# Existing repository
@mk-pmb
mk-pmb / README.md
Last active August 5, 2017 23:05 — forked from Thermi/README.md

A quick run down on iptables rules

What is it?

iptables is a cli frontend to netfilter, the Linux kernel firewall/nat implementation for OSI layer 3 and 4.

Okay, give me more details

  • When you run "iptables", the actual file being executed is "xtables-multi". That is, because the file name "iptables" is symlinked to "xtables-multi".
@mk-pmb
mk-pmb / binstr-cmp.js
Last active June 20, 2017 08:41
JS: How to convert an Array-like list of character numbers to a string
/*jslint indent: 2, maxlen: 80, browser: true */
/* -*- tab-width: 2 -*- */
'use strict';
var bytes, s1, s2, arSlc = Array.prototype.slice;
// Let's assume the worst minimalistic buffer API ever imagined:
bytes = { length: 15,
'0': 72, '1': 101, '2': 108, '3': 108, '4': 111, '5': 32,
'6': 119, '7': 111, '8': 114, '9': 108, '10': 100, '11': 33,
@mk-pmb
mk-pmb / 01_mbrs.js
Last active June 19, 2017 21:40
debug nodejs package nosync
'use strict';
var fs = require('fs'), assert = require('assert');
function enforceStdio(fd) {
if (fd !== 0) { throw new Error('Nope, use stdio, stdio rocks!'); }
}
function muchBetterRS(fd) {
if (muchBetterRS.useBackup) {
return muchBetterRS.backup.apply(fs, arguments);
@mk-pmb
mk-pmb / npm@a08189f.log
Last active February 27, 2017 16:21
npm error log when trying to deprecate test-npm-synhl
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/nodejs',
1 verbose cli '/mnt/…/nodejs/modules/npm/cli.js',
1 verbose cli 'deprecate',
1 verbose cli '.',
1 verbose cli 'string highlighting looks ok now' ]
2 info using npm@4.4.0
3 info using node@v6.10.0
4 silly mapToRegistry name null
5 verbose stack AssertionError: 'object' == 'string'