Skip to content

Instantly share code, notes, and snippets.

@tuan
tuan / openvpn-azure-steps.md
Last active Dec 4, 2020
OpenVPN + Pihole on Azure
View openvpn-azure-steps.md

Create VM

  1. Azure > Marketplace > Ubuntu

Configure VM

  1. Autoshutdown Disabled
  2. Networking: Add inbound rule for port 1194 (TCP and UDP)

Install OpenVPN

wget https://git.io/vpn -O openvpn-install.sh
@tuan
tuan / launch.json
Created Feb 2, 2019
Debug configuration for rxjs
View launch.json
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Mocha All",
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
"args": [
"--opts",
@tuan
tuan / rxjs-bindCallback-test.js
Created May 9, 2017
RxJS bindcallback's stream completes after first emit
View rxjs-bindCallback-test.js
// jsbin https://jsbin.com/xeyugac/edit?js,console
const { Observable } = Rx;
const testFn = (callback) => {
callback(1,2);
};
const testFnAsObservable = Observable.bindCallback(testFn);
const obs = testFnAsObservable();
@tuan
tuan / throttleAsync.ts
Created May 3, 2017
Throttle number of observables
View throttleAsync.ts
import { Observable, Subject, Subscription } from 'rxjs/Rx';
export type FuncAsync<T> = () => Observable<T>;
type QueuedExecution = () => Subscription;
export class ThrottleAsync<T> {
private queue: QueuedExecution[];
@tuan
tuan / 1.procedureal_feeding_time.rb
Last active Nov 12, 2016
Functional Core Imperative Shell
View 1.procedureal_feeding_time.rb
def feeding_time
walruses.each do |walrus| /* we know how to destructure walruses array */
walrus.stomach << Cheese.new /* we know the deep structure of a walrus object */
end
end
@tuan
tuan / host.js
Created Nov 1, 2016
RxJs and window's postMessage for intercommunication
View host.js
import * as Rx from "rxjs/Rx";
import * as uuid from "uuid";
import {IRequest} from "./common";
let button = document.querySelector("button");
let iframe = document.createElement("iframe");
iframe.src = "/proxy.html";
document.body.appendChild(iframe);
View unary.js
function unary(fn) {
return (value) => fn.call(this, value);
}
View mapWith.js
function mapWith (fn) {
return (list) => {
return Array.prototype.map.call(
list,
(value) => fn.call(this, value))
}
}
View once.js
function once(fn) {
let done = false;
return function(...args) {
if (done) {
return void 0;
}
done = true;
return fn.apply(this, args);
View arabicToRoman.js
const RomanNumerals = {
1000: 'M',
500: 'D',
100: 'C',
50: 'L',
10: 'X',
5: 'V',
1: 'I'
};