Skip to content

Instantly share code, notes, and snippets.

Hraban Luyat hraban

Block or report user

Report or block hraban

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@hraban
hraban / bash log
Last active Aug 9, 2019
Nice new Git feature: detect folder moves
View bash log
$ cd /tmp
$ mkdir test
$ cd test
$ git init
Initialized empty Git repository in /private/tmp/test/.git/
$ git commit --allow-empty -m root
[master (root-commit) 6814cc9] root
$ mkdir foo
$ echo a > foo/a
$ git add foo
@hraban
hraban / interleave.js
Last active Jun 10, 2019
Interleaving two arrays in Javascript (using iterators & generators)
View interleave.js
/**
* interleave([1,2], [8,7,6,5], [], 'abc')
* => [ 1, 8, 'a', 2, 7, 'b', 6, 'c', 5 ]
*/
function* interleave() {
const its = Array.from(arguments).map(x => x[Symbol.iterator]());
let done;
do {
done = true;
for (const it of its) {
@hraban
hraban / leanxml.js
Last active Oct 7, 2019
Lean XML DOM builder compatible with TypeScript's jsxFactory for Reactless .tsx files
View leanxml.js
/**
* Leanxml Runtime: lean TS jsxFactory runner for creating XML doms.
*
* N.B.: Doesn’t work on tagnames with uppercase first letter!
*/
const xmldom = require('xmldom');
function leanxml(tagname, attrs, ...children) {
return function leanxmlBuilder(doc) {
@hraban
hraban / workspace.sh
Created Jan 6, 2019 — forked from dixson3/workspace.sh
Create and manage a case-sensitive disk-image on OSX. This is great when you have a need to work with case-sensitive repos on a mac.
View workspace.sh
#!/bin/bash
set -eu -o pipefail
${DEBUGSH+set -x}
# where to store the sparse-image
NAME=civol
SPARSELOC=~/Documents/$NAME.dmg
FSTYPE="APFS"
@hraban
hraban / main.js
Created Nov 22, 2018
child process interruption and signal control
View main.js
const child_process = require('child_process');
const process = require('process');
process.on('SIGINT', () => console.log("ooh this is sigint"));
process.on('SIGUSR1', () => console.log("oh this is sigusr1!!"));
function block4ever() {
setTimeout(() => {} , 1000000);
}
@hraban
hraban / .nvmrc
Last active Sep 24, 2018
exploring signal handling in bash scripts, subshells and pipelines
View celtx-usletter-normal.css
/* Open the .celtx file in an editor, look for the bit between <html> and </html>, put it in a new file (filename ending in .html), add this bit between one of the <style> and </style> tags. Open in a webbrowser, click print. */
body {
font-family: monospace;
font-size: 13pt;
line-height: 1.4em;
width: 190mm;
margin: 0;
padding: 1em;
@hraban
hraban / rinker.sh
Last active Jun 1, 2018
Fork of Easydns dyndns update script
View rinker.sh
#!/bin/bash
set -eu -o pipefail
#################################################################
## ChangeIP.com bash update script ##
#################################################################
## Written 3/18/09 by Tom Rinker, released to the Public Domain##
#################################################################
## This is a simple bash script to preform a dDNS update with ##
@hraban
hraban / get.ts
Last active Feb 28, 2018
Autonomous http(s) request lib for node, inspired by Tomas Dvorak
View get.ts
// copied from:
// https://www.tomas-dvorak.cz/posts/nodejs-request-without-dependencies/
// Licensed under: Attribution 4.0 International (CC BY 4.0)
// https://creativecommons.org/licenses/by/4.0/
// (note: there's some funky url parsing business which I didn't fully test; caveat emptor)
import * as http from "http";
import * as https from "https";
import * as url from "url";
@hraban
hraban / runtime-mixin.ts
Last active Feb 6, 2018
Typescript runtime mixins
View runtime-mixin.ts
// Inspired by:
// https://github.com/tc39/proposal-pipeline-operator/blob/37119110d40226476f7af302a778bc981f606cee/README.md#object-decorators
//
// Once pipe operator is implemented in TS, use this example to check if it
// survives type checking.
// Describe mixed in functionality
You can’t perform that action at this time.