This file contains hidden or 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 nrOfOptions = 10 | |
const samples = 1000 | |
const iterations = 100_000_000; | |
let seenAll = 0; | |
let missing = 0; | |
for (let i = 0; i <iterations; i++) { | |
let seen = Array(nrOfOptions).fill(false) |
This file contains hidden or 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
Suppose you've branched from master like this: | |
``` | |
master: a --- b --- c | |
\ | |
feature: d - e | |
\ | |
feature-patch: f - g | |
````` |
This file contains hidden or 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
import angular from 'angular'; | |
/** | |
* Angular doesn't yet have build in support to detect rejected promises without rejection handlers. | |
* This module monkey patches $q in order to implement such handling. The code below will contain | |
* many anti-patterns, unfortunately this is the only way to get this detection to work. | |
* | |
* Usage: depend on this module, the rest will be done for you | |
* | |
* Note that this is specifically written for angular 1.4.x and it is likely to break in later versions. |
This file contains hidden or 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
//getWatchers function from: https://medium.com/@kentcdodds/counting-angularjs-watchers-11c5134dc2ef#.uh88feqpr | |
function getWatchers(root) { | |
root = angular.element(root || document.documentElement); | |
var watcherCount = 0; | |
function getElemWatchers(element) { | |
var isolateWatchers = getWatchersFromScope(element.data().$isolateScope); | |
var scopeWatchers = getWatchersFromScope(element.data().$scope); | |
var watchers = scopeWatchers.concat(isolateWatchers); | |
angular.forEach(element.children(), function (childElement) { |
This file contains hidden or 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
import glob from 'glob'; | |
import fs from 'fs'; | |
import path from 'path'; | |
//We don't want ng-class, so we need to make sure to have the \s stuff | |
const CLASS_REGEXP = /\sclass="(.*?)"/g; | |
const ICON_PREFIX_REGEXP = /^icon-/; | |
const replacements = { | |
"ban-circle": "ban", |
This file contains hidden or 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
//Simple, without $await | |
//In the simple variant $async/yield works like async/await. That is, yield "awaits" a promise, | |
//and an $async function still returns a promise | |
const init = $async(function*() { | |
const user = yield $http.get('/users/me'); | |
$scope.user = user; | |
const messages = yield messageService.getMessagesFor(user); | |
$scope.messages = messages; | |
}); |
This file contains hidden or 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
#!/bin/bash | |
# See https://gist.github.com/TiddoLangerak/c61e1e48df91192f9554 for the getCurrentWindowCWD | |
CWD=$(getCurrentWindowCWD) | |
if [ -z "$CWD" ] | |
then | |
CWD=$HOME | |
fi | |
urxvt256c-ml -cd $CWD |
This file contains hidden or 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
#!/bin/bash | |
# i3 thread: https://faq.i3wm.org/question/150/how-to-launch-a-terminal-from-here/?answer=152#post-id-152 | |
# Inspired by https://gist.github.com/viking/5851049 but with support for tmux | |
CWD='' | |
# Get window ID | |
ID=$(xdpyinfo | grep focus | cut -f4 -d " ") | |
# Get PID of process whose window this is |