Skip to content

Instantly share code, notes, and snippets.

View rkt2spc's full-sized avatar
🏎️

Tuan rkt2spc

🏎️
View GitHub Profile
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)
#include <iostream>
#include <fstream>
using namespace std;
/* CONSTANTS */
#define MAX_SIZE 65536;
struct Location {
int row, col;
};
@rkt2spc
rkt2spc / tutorial.md
Created July 17, 2018 10:32 — forked from swalkinshaw/tutorial.md
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.

@rkt2spc
rkt2spc / terraform_debug_log_1534130886787
Created August 13, 2018 03:28
Terraform debug logs
$ 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"
@rkt2spc
rkt2spc / README.md
Last active May 30, 2019 18:39
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
pkg: github.com/rocketspacer/lookupbm
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
@rkt2spc
rkt2spc / benchmark_test.go
Last active August 8, 2024 17:20
Benchmark Binary Search and Linear Search on small array
package main
import (
"fmt"
"math/rand"
"testing"
)
func linearSearch(arr []int, value int) int {
for i, v := range arr {