Skip to content

Instantly share code, notes, and snippets.

View chaosmatrix's full-sized avatar
🌴
On vacation

chaos matrix chaosmatrix

🌴
On vacation
View GitHub Profile

ariac

show torrent file list

# show bt file list
aria2c -S file.torrent

# download select files
aria2c --select-file=1,2-5,6 file.torrent

generate pdf from *.tex and *.bib

requires:

  1. apt-get install texlive texlive-latex-extra texlive-science
  2. Notes: when error with missing '*.sty', use command apt-file search '\*.sty' find and install package (should be named with texlive-*)

steps:

  1. pdflatex filename.tex
  2. bibtex filename
  3. pdflatex filename.tex

python tips

@chaosmatrix
chaosmatrix / golang_random_performance_benchmark.md
Created May 6, 2022 18:05
golang random performance benchmark

result

BenchmarkRandomFloat32-8        295268905                4.006 ns/op
BenchmarkRandomFloat64-8        428253756                2.712 ns/op
BenchmarkRandomInt31-8          477604716                2.370 ns/op
BenchmarkRandomInt63-8          486116708                2.304 ns/op
BenchmarkRandomInt31n-8         281318878                4.269 ns/op
BenchmarkRandomInt63n-8         231014283                5.088 ns/op
BenchmarkRandomUint32-8         484158534                2.358 ns/op
BenchmarkRandomUint64-8         389739458                2.974 ns/op
@chaosmatrix
chaosmatrix / rust_tips.md
Created December 27, 2021 22:33
rust-lang tips

rust tips

ipset

ipset swap vs ipset add

ipset swap: RCU
ipset add: RWLock
@chaosmatrix
chaosmatrix / bit_hacking_performance_benchmark.md
Last active September 11, 2021 17:18
bit hacking perfomance benchmark

result

BenchmarkBitHackNextPower10thousand-8                   1000000000               0.2313 ns/op
BenchmarkBitHackNextPower_BadCode10thousand-8           528308299                2.251 ns/op
BenchmarkPower2NextPower10thousand-8                    415830385                2.898 ns/op
BenchmarkBitHackNextPower100thousand-8                  1000000000               0.2270 ns/op
BenchmarkBitHackNextPower_BadCode100thousand-8          556960591                2.261 ns/op
BenchmarkPower2NextPower100thousand-8                   283740397                4.276 ns/op
BenchmarkBitHackNextPower1million-8                     1000000000               0.2300 ns/op
BenchmarkBitHackNextPower_BadCode1million-8             546635028                2.228 ns/op
@chaosmatrix
chaosmatrix / golang_tips.md
Last active August 12, 2023 14:16
golang tips

check file permission bits

// executable
if stat, err := os.Stat(filename); err != nil {
  panic(err)
}
if stat.Mode().Perm() & 0111 == 0000 {
  fmt.Printf("%s not executable\n", filename)
}
@chaosmatrix
chaosmatrix / music continue.music
Last active February 12, 2020 11:22
music continue
潮鳴り
fragile
@chaosmatrix
chaosmatrix / make_python_slower.md
Last active May 29, 2022 00:43
a collection of slower python code

format

1. python version
2. what to do
3. slower: how to code in bad way
4. faster: how to code in good way
5. why: why performance difference

example