Skip to content

Instantly share code, notes, and snippets.

View jiacai2050's full-sized avatar
:atom:
Focusing

Jiacai Liu jiacai2050

:atom:
Focusing
View GitHub Profile
(def dataset (interleave (range 10000000) (range)))
(defn workflow [ds]
(->> ds
(dedupe)
(map #(* % %))
(filter #(= 0 (rem % 111)))
(take 10)))
@jiacai2050
jiacai2050 / trrprefs.md
Created March 9, 2018 06:27 — forked from bagder/trrprefs.md
trr prefs

Preferences

All preferences for the DNS-over-HTTPS functionality in Firefox are located under the "network.trr" prefix (TRR == Trusted Recursive Resolver).

network.trr.mode

set which resolver mode you want.

0 - Off (default). use standard native resolving only (don't use TRR at all)

1 - Race native against TRR. Do them both in parallel and go with the one that returns a result first.

(ns demo.specter-benchmark
(:use [com.rpl.specter]
[criterium.core]))
;; one big app state, look like
;; {app-id1 {peer-id1 #{ch-di1}}}
(def clients (atom {}))
(def num-app 10)
(def num-peer 20)
package hystrix;
import com.netflix.hystrix.*;
import rx.Observable;
import java.io.IOException;
import java.util.Random;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
@jiacai2050
jiacai2050 / ss.txt
Last active December 1, 2024 14:59
socks proxy rules
#BEGIN
[wildcard]
*://*.pyimagesearch.com/*
*://*go.dev/*
*://*quora.com/*
*://*quoracdn.net/*
*://*yandex.com/*
*://*ahhhhfs.com/*
*://*yandex.ru/*

I write a buggy server to leak socket fd, which listen on 5000, and as expected there were CLOSE-WAIT left when client is closed

$ ss -ntpa | grep 5000
LISTEN     0      50                       :::5000                    :::*      users:(("java",14586,92))
CLOSE-WAIT 79     0          ::ffff:127.0.0.1:5000      ::ffff:127.0.0.1:55804  users:(("java",14586,96))
CLOSE-WAIT 79     0          ::ffff:127.0.0.1:5000      ::ffff:127.0.0.1:59235  users:(("java",14586,93))
CLOSE-WAIT 5      0          ::ffff:127.0.0.1:5000      ::ffff:127.0.0.1:55803  users:(("java",14586,95))
CLOSE-WAIT 150    0          ::ffff:127.0.0.1:5000      ::ffff:127.0.0.1:59236  users:(("java",14586,94))
@jiacai2050
jiacai2050 / defer_benchmank.go
Last active September 10, 2019 02:20
go defer benchmark 1.12 vs 1.13
package defer_demo
import (
"testing"
)
func doDefer() int {
acc := 0
for i := 0; i < 100; i++ {
defer func(i int) {
import (
"encoding/binary"
"github.com/spaolacci/murmur3"
)
func UnsafeToBytes(s string) []byte {
return *(*[]byte)(unsafe.Pointer(&s))
}
// bulk_load_prometheus fills prometheus tsdb with data (opentsdb-style) from stdin.
//
// The caller is responsible for assuring that the database is empty before
// bulk load.
package main
import (
"bufio"
"encoding/json"
"flag"