Skip to content

Instantly share code, notes, and snippets.

View adriengibrat's full-sized avatar
:octocat:
open sourcing when not too busy

Adrien Gibrat adriengibrat

:octocat:
open sourcing when not too busy
View GitHub Profile
@mrenouf
mrenouf / git_merge_meld.sh
Created September 28, 2011 10:09
Merge helper script for using 'git mergetool' with meld, fixes http://stackoverflow.com/questions/7501666/
#!/bin/bash
# Handles proper use of Meld from Git.
#
# Instead of launching meld with $MERGED as the base revision, this
# script makes a copy of $BASE and handles copying the result back
# to $MERGED if the result was saved.
# As an extra tweak, it also presents branch names (if known) as
# the file name prefix, instead of just "LOCAL" and "REMOTE".
@hubgit
hubgit / xhr-binary.js
Created December 15, 2010 17:09
Binary file XHR getting and sending that works in Chrome 9 and Firefox
// https://developer.mozilla.org/en/using_xmlhttprequest
// http://web.archive.org/web/20071103070418/http://mgran.blogspot.com/2006/08/downloading-binary-streams-with.html
function getBinary(file){
var xhr = new XMLHttpRequest();
xhr.open("GET", file, false);
xhr.overrideMimeType("text/plain; charset=x-user-defined");
xhr.send(null);
return xhr.responseText;
}
@robwormald
robwormald / app.ts
Last active May 29, 2016 01:49
angular2 + rx + ts
import {Component, View, bootstrap, CORE_DIRECTIVES, ON_PUSH, LifecycleEvent, ElementRef} from 'angular2/angular2';
import {NgFormModel, NgControl,FormBuilder, FORM_BINDINGS, FORM_DIRECTIVES} from 'angular2/forms'
import {RxPipe} from './rxPipe'
import {Observable} from 'rx.all'
@Component({
selector: 'hello',
lifecycle: ON_PUSH
})
@adriengibrat
adriengibrat / uuid.js
Created July 5, 2016 23:34
simple uuid generator for evergreen browsers
// see https://tools.ietf.org/html/rfc4122#section-4.4
function uuid () {
var seeds = random(12)
// inspired by https://github.com/broofa/node-uuid/blob/v2.0.0/uuid.js#L362
seeds[5] = (seeds[5] & 0x0fff) | 0x4000 // version bits
seeds[7] = (seeds[7] & 0x3fff) | 0x8000 // clock_seq_hi_and_reserved bits
return 'xx-x-x-x-xxx'.replace(/x/g, function (x, index) { return hex(seeds[index]) })
function random (n) { // get n random 16-bit unsigned integers
@adriengibrat
adriengibrat / messageformat.js
Last active July 20, 2016 07:15
messageformat with format & debug
var mf = (function () {
'use strict';
function warn () {
/* eslint no-console: off, prefer-spread: off */
console.warn.apply(console, arguments)
}
function error (message) {
/* eslint no-var: off */
@adriengibrat
adriengibrat / plural.js
Last active May 30, 2017 08:14
simple CLDR plural rules parser
#!/usr/bin/env node
/**
* plural.js – simple CLDR plural rules parser
* https://gist.github.com/adriengibrat/817140a89cfd4893b4155a2ac913904d
*
* This program is free software. It comes without any warranty.
* Released under the WTFPL license – http://www.wtfpl.net
*
* Usage:
@natchiketa
natchiketa / yo-completion.sh
Last active May 25, 2018 20:47
Bash completion for Yeoman generators
# Bash completion for Yeoman generators - tested in Ubuntu, OS X and Windows (using Git bash)
function _yo_generator_complete_() {
# local node_modules if present
local local_modules=$(if [ -d node_modules ]; then echo "node_modules:"; fi)
# node_modules in /usr/local/lib if present
local usr_local_modules=$(if [ -d /usr/local/lib/node_modules ]; then echo "/usr/local/lib/node_modules:"; fi)
# node_modules in user's Roaming/npm (Windows) if present
local win_roam_modules=$(if [ -d $(which yo)/../node_modules ]; then echo "$(which yo)/../node_modules:"; fi)
# concat and also add $NODE_PATH
local node_dirs="${local_modules}${usr_local_modules}${win_roam_modules}${NODE_PATH}"
@dherman
dherman / loader-api.md
Last active January 31, 2019 03:02
Complete ES6 Loader API

Notational Conventions

This section describes the conventions used here to describe type signatures.

A [T] is an array-like value (only ever used read-only in this API), i.e., one with an integer length and whose indexed properties from 0 to length - 1 are of type T.

A type T? should be read as T | undefined -- that is, an optional value that may be undefined.

Loaders

/**
* User Timing polyfill (http://www.w3.org/TR/user-timing/)
* @author RubaXa <trash@rubaxa.org>
*/
(function (window){
var
startOffset = Date.now ? Date.now() : +(new Date)
, performance = window.performance || {}
, _entries = []
@sergey-shpak
sergey-shpak / lens.js
Last active May 25, 2019 13:02
Hyperapp V2 actions state lens
/*
This is variation of `squirrel` and `namespace` approaches
https://gist.github.com/zaceno/0d7c62be81a845857e755c1378b7dbff
https://gist.github.com/sergey-shpak/5817bf146cb970bc4e259aef71b89ef4
Simplifies Hyperapp#v2 actions work with deeply nested state
(updated to support returned actions, parameterized actions)
Usage examples: