Skip to content

Instantly share code, notes, and snippets.

View draveness's full-sized avatar
🌟
𝚊𝚋𝚜𝚝𝚛𝚊𝚌𝚝𝚒𝚘𝚗 & 𝚌𝚘𝚖𝚙𝚕𝚎𝚡𝚒𝚝𝚢

Draven draveness

🌟
𝚊𝚋𝚜𝚝𝚛𝚊𝚌𝚝𝚒𝚘𝚗 & 𝚌𝚘𝚖𝚙𝚕𝚎𝚡𝚒𝚝𝚢
View GitHub Profile
@draveness
draveness / reindex-spotlight-db.sh
Created October 12, 2017 03:41
Reindex Spotlight db. Make files discovery for mdfind.
sudo mdutil -E /
@draveness
draveness / zookeeper_cluster_in_docker.yml
Last active November 17, 2017 07:02
zookeeper cluster with docker
version: '3.1'
services:
zoo1:
image: zookeeper
restart: always
hostname: zoo1
volumes:
- ./data/zh1/data:/data
- ./data/zh1/datalog:/datalog
@draveness
draveness / podspec
Created December 8, 2018 03:56
podspec
activeDeadlineSeconds <integer>
affinity <Object>
nodeAffinity <Object>
preferredDuringSchedulingIgnoredDuringExecution <[]Object>
preference <Object>
matchExpressions <[]Object>
key <string>
operator <string>
values <[]string>
weight <integer>
#line 3 "lex.yy.c"
#define YY_INT_ALIGNED short int
/* A lexical scanner generated by flex */
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 5
package main
import (
"context"
"errors"
"fmt"
"math/rand"
"time"
)
errors.New("invalid parameter a")
errors.New("invalid parameter b")
errors.New("Record Not Found")
@draveness
draveness / 1-blogs-serivces-dependency-graph
Last active March 12, 2019 03:04
Mock Interface in Golang
+-------------------------+
| |
| |
+---------------------+ +----->| jekyll |
| | | | |
| | | +-------------------------+
| Service +------+
| |
| +------+ +-------------------------+
+---------------------+ | | |
@draveness
draveness / service.go
Last active January 26, 2021 06:08
Monkey Patch Mock in Golang
package service
import (
pwi "pkg-without-interface"
)
type service struct {}
func (s *service) ListPosts() []Post {
posts := pwi.ListPosts() // ListPosts is a pkg function.
@draveness
draveness / main.go
Last active March 8, 2019 05:39
SQL Mock in Golang
package main
import (
"database/sql"
_ "github.com/go-sql-driver/mysql"
)
func recordStats(db *sql.DB, userID, productID int64) (err error) {
tx, err := db.Begin()
@draveness
draveness / selectgo_loop.go
Created March 29, 2019 13:25
selectgo loop
func selectgo(cas0 *scase, order0 *uint16, ncases int) (int, bool) {
// ...
loop:
// ...
for i := 0; i < ncases; i++ {
casi = int(pollorder[i])
cas = &scases[casi]
c = cas.c
switch cas.kind {