git fetch upstream && git checkout master && git rebase upstream/master && git push origin master
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var angular = require('angular'); | |
module.exports = angular.module('models.Locale', []) | |
.value('Locale', Locale); | |
/** | |
* @typedef Locale | |
* @property {string} language | |
* @property {string|null} country | |
* @method {boolean} equals |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* server.js | |
* Copyright (c) 2015 marlun78 | |
* MIT License, https://gist.github.com/marlun78/bd0800cf5e8053ba9f83 | |
* Requires Node version >= 4.x | |
*/ | |
'use strict'; | |
const fs = require('fs'); | |
const http = require('http'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var idb = (function () { | |
'use strict'; | |
var IDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB; | |
var IDBTransactionMode = { | |
readOnly: 'readonly', | |
readWrite: 'readwrite', | |
versionChange: 'versionchange' | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* An ObservableValue are like events for values. One important difference from | |
* events is that you are guaranteed to always get the current value when you | |
* subscribe. So there is no chance you subscribe “too late”. It will also | |
* pass you the new value together withthe old value. | |
* ObservableValue are similar to Angular’s `Scope.$watch`. | |
* | |
* http://jsbin.com/hokagosaru/edit?js,console | |
*/ | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// const source = {name: 'Martin', age: 38}; | |
// const target = moveProps(/name/, source); | |
// console.log(source, target); => {age: 38}, {name: 'Martin'} | |
export default function moveProps(pattern, source, target = {}) { | |
return Object.keys(source).reduce((accumulator, key) => { | |
if (pattern.test(key)) { | |
accumulator[key] = source[key]; | |
delete source[key]; | |
} | |
return accumulator; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Just an idea, completely untested! | |
function makeCancelable(promise) { | |
let canceled = false; | |
const proxy = new Promise((resolve, reject) => { | |
promise.then( | |
(value) => canceled === false && resolve(value), | |
(error) => canceled === false && reject(error) | |
); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// interpolate.js | |
// Based on Crockford’s supplant (http://www.crockford.com/javascript/remedial.html) | |
// Example; | |
// interpolate('Hello {name}!', { name: 'Martin' }); // 'Hello Martin!' | |
// interpolate('Hello {0}!', ['Vanja']); // 'Hello Vanja!' | |
function interpolate(template, values) { | |
return template.replace(/\{([^{}]*)\}/g, function(match, key) { | |
const value = values[key]; | |
const type = typeof value; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// sample.js | |
// Samples a given number of characters from a given string. | |
// Example; | |
// sample('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', 4); // Eg. 'uY7m' | |
function sample(characters, length) { | |
var result = ''; | |
for (var i = 0; i < length; i++) { | |
result += getRandomChar(characters); | |
} | |
return result; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
filetype plugin indent on | |
syntax on | |
set number | |
set tabstop=4 | |
set shiftwidth=4 | |
set expandtab |