Skip to content

Instantly share code, notes, and snippets.

View xissy's full-sized avatar

Taeho Kim xissy

View GitHub Profile
# Uncomment the next line to define a global platform for your project
#platform :ios, '11.0'
target 'Family' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for Family
pod 'Alamofire', '~> 4.5'
pod 'SwiftyJSON', '~> 4.0'
@xissy
xissy / json_formatter.go
Created March 30, 2018 10:15
Logrus JSON formatter for Apex Up
package main
import (
"encoding/json"
"fmt"
"time"
"github.com/sirupsen/logrus"
)
@xissy
xissy / binarysearch.go
Last active October 15, 2017 07:42
Binary search in Go
package binarysearch
import (
"errors"
)
func BinarySearch(a []int, target int) (int, error) {
startPos := 0
endPos := len(a)
@xissy
xissy / cache.go
Last active October 15, 2017 16:15
LRU Cache in Go
package cache
type Cache interface {
Get(key string) interface{}
Set(key string, value interface{})
}
type CacheNode struct {
Key string
Value interface{}
@xissy
xissy / etcd-1.sh
Created August 20, 2017 04:34
Bootstrap etcd v3 cluster
# For each machine
ETCD_VERSION=v3.2.5
TOKEN=taipei101-etcd-token
CLUSTER_STATE=new
NAME_1=core-1
NAME_2=core-2
NAME_3=core-3
HOST_1=10.0.1.1
HOST_2=10.0.1.2
HOST_3=10.0.1.3
@xissy
xissy / gogs.sh
Last active August 20, 2017 05:31
Traefik with Docker Swarm and TLS
docker service create \
--network traefik-net \
--name gogs \
--mount src=gogs,dst=/data \
--constraint node.hostname=="hostname-1" \
--label traefik.port=3000 \
--label traefik.frontend.rule=Host:git.xxx.com \
gogs/gogs
@xissy
xissy / cockroach-1.sh
Created August 16, 2017 06:45
Bootstrap a cockroachdb cluster
./cockroach start --background --certs-dir=certs --advertise-host=10.140.1.1
@xissy
xissy / consul-agent-1.sh
Created August 16, 2017 05:03
Bootstrap a consul cluster
docker run -d --restart always --net host --name consul \
consul agent -server -bootstrap-expect=3 -retry-join=10.140.1.2 -retry-join=10.140.1.3 -bind=10.140.1.1 -ui -client=10.140.1.1
@xissy
xissy / docker.sh
Last active September 13, 2017 21:18
Install docker-ce on ubuntu
sudo apt-get update
sudo apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
@xissy
xissy / .bashrc
Created May 25, 2017 23:00
AWS EMR .bashrc for Spark
# set the default region for the AWS CLI
export AWS_DEFAULT_REGION=$(curl --retry 5 --silent --connect-timeout 2 http://169.254.169.254/latest/dynamic/instance-identity/document | grep region | awk -F\" '{print $4}')
export JAVA_HOME=/etc/alternatives/jre
export HADOOP_CONF_DIR=/etc/hadoop/conf
export SPARK_HOME=/usr/lib/spark
export SPARK_WORKER_DIR=/var/run/spark/work
export EXTRA_CLASSPATH=/usr/lib/hadoop-lzo/lib/hadoop-lzo.jar:/etc/hive/conf
export SPARK_LOCAL_IP=$(ec2-metadata -o | cut -d ' ' -f2)
export SPARK_LOCAL_HOSTNAME=$(ec2-metadata -h | cut -d ' ' -f2)