/**
* Creates nested groups by object properties.
* `properties` array nest from highest(index = 0) to lowest level.
*
* @param {String[]} properties
* @returns {Object}
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
class LruCache<T> { | |
private values: Map<string, T> = new Map<string, T>(); | |
private maxEntries: number = 20; | |
public get(key: string): T { | |
const hasKey = this.values.has(key); | |
let entry: T; | |
if (hasKey) { | |
// peek the entry, re-insert for LRU strategy |
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
// This is just a short reminder of this great explanation: | |
// http://www.2ality.com/2015/06/tail-call-optimization.html | |
// not TCO | |
function factorial(n) { | |
if (n <= 0) return 1; | |
return n * factorial(n-1); // here, the main recursive call not in a tail position because of the `n` context. | |
} |
I have two Github accounts: oanhnn (personal) and superman (for work). I want to use both accounts on same computer (without typing password everytime, when doing git push or pull).
Use ssh keys and define host aliases in ssh config file (each alias for an account).
This will set up a passthrough between the eth0
interface and the wan0
interface, with a VPN connection in-between.
You can then connect a machine to the ethernet port of the raspberrypi, and that machines network traffic will pass through the vpn tunnel on the raspberrypi.
The device connected to the ethernet plug of the PI should be set up with:
IP: 192.168.0.2
Mask: 255.255.255.0
Gateway: 192.168.0.1