Skip to content

Instantly share code, notes, and snippets.

@huytd
huytd / co-in-15-lines.js
Last active May 25, 2016 10:10
Re-implement tj/co in 15 lines
function run(fn) {
var pointer = fn();
var next = function(result) {
if (result.value.then && typeof result.value.then === 'function') {
result.value.then(function(data) {
var out = pointer.next(data);
if (!out.done) next(out);
});
} else {
var out = pointer.next(result.value);
@huytd
huytd / workWithJson.go
Created June 22, 2016 20:19
Working with JSON in Golang
package main
import (
"fmt"
"encoding/json"
)
type (
Map map[string]interface{}
)
@huytd
huytd / goASTParsing.go
Created June 26, 2016 20:07
Parse code using AST
package main
import (
"fmt"
"go/ast"
"go/parser"
"go/token"
)
func main() {
@huytd
huytd / lldb_cheat_sheet.md
Created July 14, 2016 17:48 — forked from ryanchang/lldb_cheat_sheet.md
LLDB Cheat Sheet

LLDB Cheat Sheet

A complete gdb to lldb command map.

Print out

  • Print object
(lldb) po responseObject
(lldb) po [responseObject objectForKey@"state"]
  • p - Print primitive type
@huytd
huytd / FizzBuzz.rb
Created July 24, 2016 20:32
FizzBuzz TDD implementation
module FizzBuzz
extend self
def run(n)
if n % 3 == 0 && n % 5 == 0
return "FizzBuzz"
elsif n % 3 == 0
return "Fizz"
elsif n % 5 == 0
return "Buzz"
@huytd
huytd / .gitconfig
Created August 4, 2016 16:26
Use neovim as diff tool
[merge]
tool = vimdiff
[mergetool]
prompt = true
[mergetool "vimdiff"]
cmd = nvim -d $LOCAL $REMOTE $MERGED -c '$wincmd w' -c 'wincmd J'
[difftool]
prompt = false
[diff]
tool = vimdiff
@huytd
huytd / expect.js
Last active August 16, 2016 23:35
DIY assertion library
let ___expect_finish_timer = null;
const expect = function(input) {
if (___expect_finish_timer) {
clearTimeout(___expect_finish_timer);
}
___expect_finish_timer = setTimeout(() => {
console.log('\n\x1b[32m✓ All tests passed!\x1b[0m\n');
}, 200);
@huytd
huytd / colors.go
Created August 18, 2016 18:16
Color output for Go app
package colors
import (
"fmt"
"regexp"
)
var (
TERM_STYLE = []string{
// LIGHT

Keybase proof

I hereby claim:

  • I am huytd on github.
  • I am huytd (https://keybase.io/huytd) on keybase.
  • I have a public key whose fingerprint is 54E3 5C6D AD03 A654 3302 A05F 8294 9437 AB11 7366

To claim this, I am signing this object:

Secret Management with Vault

Problems

  • Cloud deployment problem: Where do we store our secrets (read: database username and password) and how to give them to the server when we deploy?
  • Secret sharing and auditing problem: If everybody in our team uses the same token, how can we audit when something wrong happend? Who is the last person logged in using the shared key?
  • Revocation problem: our ex-sysadmin have quitted, how we managed to remove his