Skip to content

Instantly share code, notes, and snippets.

View ylxdzsw's full-sized avatar
🐟
摸鱼

ylxdzsw

🐟
摸鱼
View GitHub Profile
@ylxdzsw
ylxdzsw / package list
Last active June 9, 2020 04:19
Explicitly installed packages on my laptop
adapta-maia-theme
aircrack-ng
android-tools
aria2
bat
chromium-ozone
cmake
code
coffeescript
coreutils
@ylxdzsw
ylxdzsw / prune_zsh_history.jl
Created August 30, 2019 07:14
For me, the shell history is mainly used as a completion dict when I press the up arrow. This script removes the lines that does not help serve this purpose
# For me, the history is mainly used as a completion dict when I press the up arrow.
# This script removes the lines that does not help serve this purpose
entries = readlines("$(homedir())/.zsh_history")
commands = Set(readlines(`zsh -ic 'print -rl -- ${(k)aliases} ${(k)functions} ${(k)builtins} ${(k)commands}'`))
filter_but_keep_multiline(f, iter) = let skip = false
filter(iter) do line
if skip
skip = endswith(line, '\\')
@ylxdzsw
ylxdzsw / backup
Last active March 19, 2020 07:57
#!/usr/bin/pkexec /usr/bin/zsh
set -x
# clean up before backing up
pacman -Sc
journalctl --vacuum-time=7d
rm /var/lib/systemd/coredump/*
# backup based on last previous one to save disk space
TARGET=/run/media/ylxdzsw/DATA
@ylxdzsw
ylxdzsw / box1.jl
Last active May 3, 2019 08:14
关于条件概率的沙雕问题
const box1 = ('红', '红')
const box2 = ('红', '蓝')
const box3 = ('蓝', '蓝')
另一个也是红球的次数 = 0
总试验次数 = 0
while 总试验次数 < 100_000
# 随机抽取一个盒子
box = rand([box1, box2, box3])
@ylxdzsw
ylxdzsw / baoyang_to_tsv.jl
Last active April 10, 2019 12:20
some spiders
using JSON2
using OhMyJulia
using ProgressMeter
f = open("maintain.tsv", "w")
prt(f, "service", "category", "product", "type", "tip", "info", "tags",
"brand", "order_quantity", "sales_quantity", "comments", "price", "marketing_price", "unit", "name", "rate", "remark")
import Base.print
@ylxdzsw
ylxdzsw / soundmeter.jl
Created March 8, 2019 07:09
show noise level
using Statistics
const p = run(pipeline(`arecord -f cd -t raw`, stdout=Pipe()), wait=false)
close(p.out.in)
while true
sleep(0.1)
x = reinterpret(Int16, readavailable(p.out))
x = @. 20log(10, abs(max(x, typemin(Int16) + one(Int16))) / typemax(Int16))
println(mean(x))
uuzero: ⁰₀
uuone: ¹₁
uutwo: ²₂
uuthree: ³₃
uufour: ⁴₄
uufive: ⁵₅
uusix: ⁶₆
uuseven: ⁷₇
uueight: ⁸₈
uunine: ⁹₉
@ylxdzsw
ylxdzsw / main.jl
Created December 9, 2018 13:31
bundle KaTeX fonts into css
using Base64
write("katex.css", replace(read("katex.min.css", String), r"fonts/[^.]+\.woff2.*?}" => s -> "data:font/woff2;base64,$(base64encode(read(s[1:findfirst(x->x==')', s)-1]))))}"))
@ylxdzsw
ylxdzsw / pack_ico.jl
Created November 30, 2018 05:45
pack several .png files into an .ico flie in Julia.
function pack_ico(io::IO, pngs::Bytes...)
# all values are in little endian
# header
write(io, 0x0000) # reserved to be 0
write(io, 0x0001) # 1 for .ico, 2 for .cur
write(io, length(pngs) % UInt16) # number of images
# image directory
c = 6 + 16length(pngs) # offsets of current image, initial value is the header length
@ylxdzsw
ylxdzsw / regen.lua
Created November 28, 2018 15:29
cheat engine regenerate
function regen(t)
local cv1 = readInteger(0x93CCB120)
local cv2 = readInteger(0x93CCB0E4)
if cv1 < 34 then
writeInteger(0x93CCB120, cv1 + 1)
end
if cv2 < 4 then
writeInteger(0x93CCB0E4, cv2 + 1)
end
end