Skip to content

Instantly share code, notes, and snippets.

View rkt2spc's full-sized avatar
🏎️

Tuan rkt2spc

🏎️
View GitHub Profile
@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 {
@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 / 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 / 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.

#include <iostream>
#include <fstream>
using namespace std;
/* CONSTANTS */
#define MAX_SIZE 65536;
struct Location {
int row, col;
};
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)
@rkt2spc
rkt2spc / basic-firewall.sh
Created January 15, 2017 17:35
Linux op works
ufw allow OpenSSH
ufw allow http
ufw allow https
ufw enable
ufw status
@rkt2spc
rkt2spc / client-app.js
Created December 28, 2016 08:55
Handle oauth token redirect front-end angular
var app = angular.module('app', ['ui.router']);
app.config(['$stateProvider',
function ($stateProvider) {
// UI-Router
// Application states
var applicationStates = [
// Pre-authenticated
{
@rkt2spc
rkt2spc / markdown.md
Created December 13, 2016 13:50 — forked from rikukissa/POST.md
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

Keypoints

  • 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)
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