Skip to content

Instantly share code, notes, and snippets.


Tuan Nguyen rocketspacer

Block or report user

Report or block rocketspacer

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
rocketspacer /
Last active May 30, 2019
Which lookup method is faster on small dataset? switch or if or map?

Lookup Benchmark Results

$ go test -bench=. -benchtime=5s 
goos: darwin
goarch: amd64
BenchmarkLookUp/ValueExists@Head/Switch-8       1000000000               6.39 ns/op
BenchmarkLookUp/ValueExists@Head/IfElse-8       10000000000              1.86 ns/op
BenchmarkLookUp/ValueExists@Head/Map-8          1000000000               9.86 ns/op
View terraform_debug_log_1534130886787
$ TF_LOG=trace terraform apply
2018/08/13 11:26:22 [INFO] Terraform version: 0.11.7
2018/08/13 11:26:22 [INFO] Go runtime version: go1.10.1
2018/08/13 11:26:22 [INFO] CLI args: []string{"/usr/local/Cellar/terraform/0.11.7/bin/terraform", "apply"}
2018/08/13 11:26:22 [DEBUG] Attempting to open CLI config file: /Users/tuan.nguyenm/.terraformrc
2018/08/13 11:26:22 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2018/08/13 11:26:22 [INFO] CLI command args: []string{"apply"}
2018/08/13 11:26:22 [INFO] command: empty terraform config, returning nil
2018/08/13 11:26:22 [DEBUG] command: no data state file found for backend config
2018/08/13 11:26:22 [DEBUG] New state was assigned lineage "3e382eed-2144-5b18-36d9-9afd685f34b5"
rocketspacer /
Created Jul 17, 2018 — forked from swalkinshaw/
Designing a GraphQL API

Tutorial: Designing a GraphQL API

This tutorial was created by Shopify for internal purposes. We've created a public version of it since we think it's useful to anyone creating a GraphQL API.

It's based on lessons learned from creating and evolving production schemas at Shopify over almost 3 years. The tutorial has evolved and will continue to change in the future so nothing is set in stone.

rocketspacer / type_racer_cheat.js
Last active Mar 21, 2018
Cheat code for
View type_racer_cheat.js
async function cheat(wpm = 90) {
const elem = document.querySelector('[id^="gwt-uid-"] > table > tbody > tr:nth-child(2) > td > table > tbody > tr:nth-child(1) > td > table > tbody > tr:nth-child(1) > td > div > div');
if (!elem) return new Error(`Goal element not found`);
const goal = Array.from(elem.children)
.filter((v) => v.tagName === 'SPAN')
.map((v) => v.innerHTML)
View gist:f0d755263c5aa0a169a9ff8aba7a29cf
#include <iostream>
#include <fstream>
using namespace std;
#define MAX_SIZE 65536;
struct Location {
int row, col;
View mongodb_errors_code
error_code("OK", 0)
error_code("InternalError", 1)
error_code("BadValue", 2)
error_code("OBSOLETE_DuplicateKey", 3)
error_code("NoSuchKey", 4)
error_code("GraphContainsCycle", 5)
error_code("HostUnreachable", 6)
error_code("HostNotFound", 7)
error_code("UnknownError", 8)
error_code("FailedToParse", 9)
ufw allow OpenSSH
ufw allow http
ufw allow https
ufw enable
ufw status
rocketspacer / client-app.js
Created Dec 28, 2016
Handle oauth token redirect front-end angular
View client-app.js
var app = angular.module('app', ['ui.router']);
function ($stateProvider) {
// UI-Router
// Application states
var applicationStates = [
// Pre-authenticated
rocketspacer /
Created Dec 13, 2016 — forked from rikukissa/
Unit testing Angular.js app with node.js, mocha, angular-mocks and jsdom

Testing Angular.js app headlessly with node.js + mocha

Lean unit tests with minimal setup

Code examples


  • Fake DOM (Everything works without a real browser)
  • Uses ngMocks to inject and mock Angular.js dependencies
  • I'm assuming you are already using browserify (but everything works fine without it)
View Example SPA
Project Structure
- index.js //Your NodeJs code
- /public // What in here is your tradition Angular App (like the one on Angular Tutorial)
- /css
- /js
- app.js // Your Angular code
- index.html
================= Server Side =============================
//Node index.js
You can’t perform that action at this time.