Skip to content

Instantly share code, notes, and snippets.

Avatar

Tuan Nguyen tuan

View GitHub Profile
@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 / 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 / ParallelUploadToBlobStorage.cs
Created Feb 6, 2016
Upload multiple files to azure blob storage in parallel
View ParallelUploadToBlobStorage.cs
class Program
{
static void Main(string[] args)
{
var stopwatch = new Stopwatch();
stopwatch.Start();
UploadToBlobAsync().Wait();
stopwatch.Stop();
Debug.WriteLine("Elapsed time in seconds: " + stopwatch.ElapsedMilliseconds / 1000);
}
@tuan
tuan / openvpn-azure-steps.md
Last active Aug 25, 2021
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 / 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);