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 / carthesian.ts
Last active Nov 16, 2017
carthesian product in TypeScript
View carthesian.ts
function carthesian<T>(columns: T[][], f: (x: T[]) => void, stackOut: T[] = []): void {
if (columns.length === 0) {
} else {
const column = columns.shift()!;
column.forEach(entry => {
carthesian(columns, f, stackOut);
hraban / output.txt
Last active Aug 23, 2017
(bash) Comparing $* and $@
View output.txt
$ /tmp/
$*: []
"$*": ['']
$@: []
"$@": []
$ /tmp/ a b "c d"
$*: ['a', 'b', 'c', 'd']
hraban / .travis.yml
Created May 24, 2017 — forked from hc2p/.travis.yml
This is a prove of concept for leveraging the travis directory caching for speeding up docker builds. It works by configuring the docker deamon to use a folder under current user's (travis) control. That way you have the privileges to use the caching feature of travis ci.
View .travis.yml
sudo: false
- docker
- sudo service docker stop
- if [ "$(ls -A /home/travis/docker)" ]; then echo "/home/travis/docker already set"; else sudo mv /var/lib/docker /home/travis/docker; fi
- sudo bash -c "echo 'DOCKER_OPTS=\"-H tcp:// -H unix:///var/run/docker.sock -g /home/travis/docker\"' > /etc/default/docker"
- sudo service docker start
hraban / potential_json.go
Last active Jan 7, 2017
safe, human readable nested JSON encoding in Go
View potential_json.go
package main
import (
// PotentialJSON acts as a JSON encoding wrapper for []byte. The encoding is
// tentative:
// * if the contents already happen to be valid JSON, then it is represented
hraban / watch.js
Last active Jul 2, 2018
Simple cross-platform change watcher
View watch.js
// Simplistic directory watcher
// example usage:
// $ node watch.js | while read line ; do echo compiling ... ; ( while read -r -t 0; do read -r ; done ) ; rm -rf build ; npm run build ; echo done ; done
var fs = require('fs');
hraban / ensure-subset-type.ts
Last active Mar 24, 2017
Checked subset typing in TypeScript
View ensure-subset-type.ts
// Imagine you want to explicitly define which members of a public API
// interface your implementation actually uses. Example: you implement
// a web extension, but only use a few of the members on the argument
// to the onHeadersReceived handler. Explicitly typing this is useful
// when creating mocks in your unit tests.
// Here's now you could do it:
hraban / vectorized-arrays.js
Last active Nov 10, 2016
Vectorized .all method on arrays to transparently access all members
View vectorized-arrays.js
Object.defineProperty(Array.prototype, 'all', {
get: function () {
return new Proxy(this, {
get: function(target, name, receiver) {
return => x[name]);
set: function (target, name, value) {
target.forEach(x => x[name] = value);
// ... call:, etc.
hraban /
Last active Aug 16, 2016
code snippets for Ravelin blog post
/tmp $ git clone -q
/tmp $ cat sub-repositories.txt scalarelational zero µ
/tmp $ cat sub-repositories.txt | ./tomono/
… crunch crunch crunch
/tmp $ cd core
/tmp/core $ git branch
hraban /
Created Feb 11, 2016
Find the full import chain from one go package to another
#!/usr/bin/env python3
Find the full import chain from one go package to another.
Usage: source_package target_package
This is useful in large codebases to figure out why, for example, the testing package is
included in a resulting binary.
hraban / .bash_aliases
Last active Jun 12, 2018
bash aliases
View .bash_aliases
# gitlog only the specified revision(s), e.g. $ gitlog1 master some-feature-branch
alias gitlog1='git log --color --graph --format="format:%C(normal bold)%h%Creset %s%C(red)%d%Creset (%C(yellow)%aN%Creset, %C(green)%ar%Creset)"'
# Entire git commit history with tree and colors and branch names
alias gitlog='gitlog1 --all --branches=\* --remotes=\*'
You can’t perform that action at this time.