alias ~~~=":<<'~~~sh'";:<<'~~~sh'
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 fastPow = (x, n) => { | |
if (x <= 0) return 0; | |
if (n === 0) return 1; | |
if (n === 1) return x; | |
const result = fastPow(x, n >> 1); | |
return (n & 1) ? result * x : 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
// doubly linked list | |
const removeNode = node => { | |
node.prev.next = node.next; | |
node.next.prev = node.prev; | |
node.prev = node.next = node; | |
return node; | |
}; | |
class DLL { |
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
import {up, down} from './min-heap.js'; | |
// more efficient operations based on up() and down() | |
// WARNING: untested (if I wrote comprehensive tests it wouldn't be a gist, would it?) | |
const replaceTop = (heapArray, value, less) => { | |
const top = heapArray[0]; | |
heapArray[0] = value; | |
down(heapArray, 0, less); | |
return top; |
alternatively use: http://geoff.greer.fm/lscolors/
The value of this variable describes what color to use for which attribute when colors are enabled with CLICOLOR. This string is a concatenation of pairs of the format fb, where f is the foreground color and b is the background color.
The color designators are as follows:
a black
This is the table from man 5 terminfo
.
Do NOT hardcode terminal escape sequences. Use tput with the cap-names from the table below to get the right code for your terminal.
(P) | indicates that padding may be specified |
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
# The approach is to mark packets from a specific user, | |
# create a dedicated routing table with a default route | |
# through the VPN, and force all marked packets to be | |
# routed using that table. | |
# | |
# Sources: | |
# https://www.niftiestsoftware.com/2011/08/28/making-all-network-traffic-for-a-linux-user-use-a-specific-network-interface/ | |
# http://freeaqingme.tweakblogs.net/blog/9340/netflix-using-a-vpn-for-just-one-application.html | |
# In this guide |
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
// Copied from https://github.com/heya/dom under BSD-3 and slightly modified. | |
// create.js | |
// Dojo-inspired set of DOM utilities | |
export const namespaces = { | |
svg: 'http://www.w3.org/2000/svg', | |
xlink: 'http://www.w3.org/1999/xlink', | |
ev: 'http://www.w3.org/2001/xml-events', | |
xml: 'http://www.w3.org/XML/1998/namespace' |
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
// a facelift of the venerable on.js: slightly modified for ES6, removed dead browsers | |
// copied from https://github.com/clubajax/on, used under the MIT license | |
// internal utilities | |
const getNodeById = id => { | |
const node = document.getElementById(id); | |
if (!node) { | |
console.error('`on` Could not find:', id); | |
} |
NewerOlder