Skip to content

Instantly share code, notes, and snippets.

Hi ;)

Tuan Anh Tran tuananh

Hi ;)
View GitHub Profile
bcnzer / worker.js
Created Oct 15, 2018
Cloudflare Worker that uses Workers KV to get Authorization data. All authentication and authorization is done on the edge
View worker.js
addEventListener('fetch', event => {
* Entry point of the worker
async function handleRequest(event) {
try {
// Get the JWT
View k8s-filters.yaml
# These filters are based on email that Tim Hockin sent to kubernetes-dev a
# while ago on how to bring some sanity to github notifications with Kubernetes.
# This file can be processed with
# Mark all k8s email
- match:
View incognito-page.js
const Page = require('puppeteer/lib/Page');
// the following 2 methods are originally from:, with some modification to fit puppeteerv1.0.0
async function newPageWithNewContext(browser) {
const { browserContextId } = await browser._connection.send('Target.createBrowserContext');
const { targetId } = await browser._connection.send('Target.createTarget', { url: 'about:blank', browserContextId });
const target = await browser._targets.get(targetId);
const client = await browser._connection.createSession(targetId);
const page = await Page.create(client, target, browser._ignoreHTTPSErrors, browser._appMode, browser._screenshotTaskQueue);
page.browserContextId = browserContextId;
enricofoltran / main.go
Last active Apr 12, 2021
A simple golang web server with basic logging, tracing, health check, graceful shutdown and zero dependencies
View main.go
package main
import (
danielhavir /
Last active Jul 30, 2018
JavaScript Must Die!
### Removes Node and NPM from mac OS ###
# Uninstall using NPM
npm uninstall npm -g || echo "NPM uninstall didn't work"
# Try if Node's installed with Brew
(brew uninstall node&&brew prune)||echo "Node was not installed with Brew"
# Remove all files and folders including Node or NPM
rm -rf /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/{npm*,node*,man1/node*}
rm -rf /usr/local/bin/npm /usr/local/share/man/man1/node* /usr/local/lib/dtrace/node.d ~/.npm ~/.node-gyp /opt/local/bin/node opt/local/include/node /opt/local/lib/node_modules
rm -rf /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/npm*
rm -rf /usr/local/include/node*
vidia / nginx-unificontroller.conf
Last active Apr 1, 2021
Example, working, NGINX config for proxying to Unifi Controller software and using letsencrypt. Includes websocket fix.
View nginx-unificontroller.conf
# I had a bit of trouble getting my unifi controller (hosted offsite) to use a proxy/letsencrypt. So here are the fruits of my labor.
# The unifi default port is 8443 running on localhost.
# License: CC0 (Public Domain)
server {
# SSL configuration
listen 443 ssl default_server;
listen [::]:443 ssl default_server;
View streams.txt
# Let's add a few entries in our stream "mystream". Every entry in a stream is like
# an hash, composed of fields and values, but every entry can have different fields.
# XADD appends a new entry in a stream, and returns an unique ID which is guaranteed
# be incrementing.
# The first part of the ID is the millisecond unixtime during the
# addition (or the time of the last entry in the stream, if greater than the current time).
# The second part of an entry is a 64 bit counter for entries added in the same ms.> XADD mystream name pamela nicknake kill-9
balupton /
Last active Jun 5, 2019
Summary of the Node.js Board controversy from what I can gather
View bench.js
if (!process.browser) var sodium = require('sodium-native')
var blake2b = require('blake2b')
var blake2bw = require('blake2b-wasm')
var BLAKE2s = require('blake2s-js')
var crypto = require('crypto')
var DATA_64KB = Buffer.alloc(65536)
var DATA_4KB = Buffer.alloc(4096)
var DATA_128B = Buffer.alloc(128)
antirez / lmdb.tcl
Created Apr 28, 2017
LMDB -- First version of Redis written in Tcl
View lmdb.tcl
# Copyriht (C) 2009 Salvatore Sanfilippo <>
# All Rights Reserved
# - cron with cleanup of timedout clients, automatic dump
# - the dump should use array startsearch to write it line by line
# and may just use gets to read element by element and load the whole state.
# - 'help','stopserver','saveandstopserver','save','load','reset','keys' commands.
# - ttl with milliseconds resolution 'ttl a 1000'. Check ttl in dump!