Skip to content

Instantly share code, notes, and snippets.

View acoshift's full-sized avatar
🔥
ლ(*꒪ヮ꒪*)ლ

Thanatat Tamtan acoshift

🔥
ლ(*꒪ヮ꒪*)ლ
View GitHub Profile
@acoshift
acoshift / index.html
Created December 22, 2016 05:35
Vuejs Global State + Mixin
<!doctype>
<html>
<div id="app"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.1.6/vue.js"></script>
<script>
// create single state instance
const state = {
value: 0
}
@acoshift
acoshift / auth-service-rxjs.js
Created December 31, 2016 13:27
Auth Service using RxJS for store global state
import { Observable, BehaviorSubject } from 'rxjs'
import axios from 'axios'
const API_URL = 'http://localhost:8080'
const API = {
get (url) {
return Observable.fromPromise(axios.get(API_URL + url))
}
}
@acoshift
acoshift / Checkbox.vue
Created January 3, 2017 11:20
vuejs-semantic-checkbox
<template lang="pug">
.ui.checkbox
input(ref='input', type='checkbox')
label
slot
</template>
<script>
export default {
props: ['value'],
@acoshift
acoshift / nginx.tmpl
Created July 15, 2017 19:40
nginx ingress controller template for gce tcp lb
{{ $cfg := .Cfg }}
{{ $IsIPV6Enabled := .IsIPV6Enabled }}
{{ $healthzURI := .HealthzURI }}
{{ $backends := .Backends }}
{{ $proxyHeaders := .ProxySetHeaders }}
daemon off;
worker_processes {{ $cfg.WorkerProcesses }};
pid /run/nginx.pid;
{{ if ne .MaxOpenFiles 0 }}
@acoshift
acoshift / App.vue
Created August 9, 2017 14:47
Vue + Vue-Rx
<template>
<div id="app">
<input ref="q">
<button v-stream:click="q$">Search</button>
<div>
<h1>{{ topic }} ({{ page }} / {{ totalPage }})</h1>
<select v-stream:change="perPage$">
<option :value="10">10</option>
<option :value="15">15</option>
<option :value="20">20</option>
@acoshift
acoshift / main.go
Created October 15, 2017 06:24
remove duplicate: loop
func removeDuplicateLoop(arr []int) []int {
p := append([]int{}, arr...)
for i := range p {
for j := i + 1; j < len(p); j++ {
if p[i] == p[j] {
p = append(p[:j], p[j+1:]...)
j--
}
}
}
@acoshift
acoshift / main.go
Created October 15, 2017 06:33
remove duplicate: hash map
func removeDuplicateMap(arr []int) []int {
p := make(map[int]struct{})
for _, v := range arr {
p[v] = struct{}{}
}
r := make([]int, 0, len(p))
for v := range p {
r = append(r, v)
}
return r
@acoshift
acoshift / main.go
Last active October 15, 2017 13:05
remove duplicate: loop 2
func removeDuplicateLoop2(arr []int) []int {
r := make([]int, 0)
for i := range arr {
for j := range r {
if arr[i] == r[j] {
goto duplicated
}
}
r = append(r, arr[i])
@acoshift
acoshift / main.go
Created April 7, 2018 11:50
main.go for k8s app
package main
import (
"context"
"log"
"net/http"
"os"
"os/signal"
"sync"
"syscall"
@acoshift
acoshift / main.go
Created April 7, 2018 12:06
main.go for k8s app w/ hime
package main
import (
"log"
"net/http"
"time"
"github.com/acoshift/hime"
"github.com/acoshift/probehandler"
)