Skip to content

Instantly share code, notes, and snippets.

View instanceofme's full-sized avatar

Adrien Lavoillotte instanceofme

View GitHub Profile
@instanceofme
instanceofme / script.js
Created August 14, 2018 10:20
ES6 proxy for scala-style _.x.y function
class Access {
constructor(path = []) {
this.path = path;
}
// Proxy
get(target, prop) {
console.log("Packing", prop);
return new Proxy(target, new Access([...this.path, o => o[prop]]));
}
@instanceofme
instanceofme / .gitconfig
Created January 3, 2014 17:27
Useful git aliases
[alias]
co = checkout
ci = commit
st = status
br = branch
cp = cherry-pick
rb = rebase
hist = log --pretty=format:\"%C(yellow)%h%Creset %Cgreen%ad%Creset | %s%Cblue%d%Creset %Cgreen[%an]%Creset\" --graph --date=short
type = cat-file -t
dump = cat-file -p
@instanceofme
instanceofme / sync-async.sh
Last active December 20, 2015 04:09
Proof-of-concept script that begins synchronously then goes asynchronous. Meant to be called via SSH, executes some instructions synchronously, launches a long asynchronous task (e.g. download), wait a few seconds to ensure that said taks didn't fail immediately, then ends the SSH connection. See http://serverfault.com/questions/524738/remote-sy…
#! /usr/bin/env bash
function closefd() {
exec 0>&- # close stdin
exec 0<&-
exec 1>&- # close stdout
exec 1<&-
exec 2>&- # close stderr
exec 2<&-
}
@instanceofme
instanceofme / csv2tsv
Last active December 18, 2015 15:49
csv2tsv Translate a CSV file into an unquoted TSV file (for easier handling with bash script). `$ csv2tsv file.csv > my.tsv` Requires [scala]. Supports optional double quote field protection, including `""` representing a single quote inside. Does not support (yet): optional whitespace around separator (will be kept as-is in TSV), output field q…
#!/usr/bin/env scala
//!#
import scala.language.postfixOps
import scala.io.Source
import scala.util.parsing.combinator._
/* The MIT License (MIT)
*
* Copyright (c) 2013 Adrien Lavoillotte
@instanceofme
instanceofme / diacritics.js
Created February 3, 2012 18:31
Remove diacritics
/**
* Remove diacritics (accent and other marks) on characters, and dissociate double characters.
* Based on the character map of http://lehelk.com/2011/05/06/script-to-remove-diacritics/
* but per-character walk (improved performance).
*
* Licensed under WTFPL v2 http://sam.zoy.org/wtfpl/COPYING
*/
var removeDiacritics = (function() {
var diacritics = {"\u24B6":"A","\uFF21":"A","\u00C0":"A","\u00C1":"A","\u00C2":"A","\u1EA6":"A","\u1EA4":"A","\u1EAA":"A","\u1EA8":"A","\u00C3":"A","\u0100":"A","\u0102":"A","\u1EB0":"A","\u1EAE":"A","\u1EB4":"A","\u1EB2":"A","\u0226":"A","\u01E0":"A","\u00C4":"A","\u01DE":"A","\u1EA2":"A","\u00C5":"A","\u01FA":"A","\u01CD":"A","\u0200":"A","\u0202":"A","\u1EA0":"A","\u1EAC":"A","\u1EB6":"A","\u1E00":"A","\u0104":"A","\u023A":"A","\u2C6F":"A","\uA732":"AA","\u00C6":"AE","\u01FC":"AE","\u01E2":"AE","\uA734":"AO","\uA736":"AU","\uA738":"AV","\uA73A":"AV","\uA73C":"AY","\u24B7":"B","\uFF22":"B","\u1E02":"B","\u1E04":"B","\u1E06":"B","\u0243":"B","\u0182":"B","\u0181":"B",