Skip to content

Instantly share code, notes, and snippets.

View ylxdzsw's full-sized avatar
🐟
摸鱼

ylxdzsw

🐟
摸鱼
View GitHub Profile
@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))
@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 / 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 / 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 / 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 / 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 / local.conf
Created February 15, 2020 17:30
My /etc/fonts/local.conf
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<alias>
<family>monospace</family>
<prefer>
<family>Droid Sans Mono</family>
<family>Noto Sans Mono CJK SC</family>
</prefer>
</alias>
@ylxdzsw
ylxdzsw / ffplay.desktop
Created February 15, 2020 18:35
Desktop file for using ffplay as the video/audio player
#!/usr/bin/env xdg-open
[Desktop Entry]
Version=1.0
Terminal=false
Type=Application
Name=FFPlay
Exec=ffplay %U
NoDisplay=true
Categories=AudioVideo;Audio;Video;Player;
MimeType=application/mxf;application/ogg;application/ram;application/sdp;application/smil;application/smil+xml;application/vnd.apple.mpegurl;application/vnd.ms-asf;application/vnd.ms-wpl;application/vnd.rn-realmedia;application/vnd.rn-realmedia-vbr;application/x-extension-m4a;application/x-extension-mp4;application/x-flac;application/x-flash-video;application/x-matroska;application/x-netshow-channel;application/x-ogg;application/x-quicktime-media-link;application/x-quicktimeplayer;application/x-shorten;application/x-smil;application/xspf+xml;audio/3gpp;audio/3gpp2;audio/aac;audio/ac3;audio/AMR;audio/AMR-WB;audio/basic;audio/dv;audio/eac3;audio/flac;audio/m4a;audio/midi;audio/mp1;audio/mp2;audio/mp3;audio/mp4;audio/mpeg;audio/mpegurl;audio/mpg;audio/ogg;audio/opus;audio/prs.sid;audio/scpls;audio/vnd.rn-realaudio;audio/wav;audio/webm;audio/x-aac;
@ylxdzsw
ylxdzsw / cfmonitor.coffee
Created May 1, 2020 16:45
A failed attempt to abuse cloudflare workers as a web monitor.
serverchan_token = ''
telegram_token = ''
telegram_chatid = ''
secret = '' # it also acts as instance ID. Change this everytime you restart the script.
host1 = ''
host2 = '' # we need two hosts because of https://community.cloudflare.com/t/issue-with-worker-to-worker-https-request/94472
addEventListener 'fetch', (e) ->
e.respondWith main e
@ylxdzsw
ylxdzsw / revolve4times.html
Created June 10, 2020 08:37
For a stupid question
<style>
html, body, div {
padding: 0;
margin: 0;
}
#big {
border-radius: 50%;
width: 300px;
height: 300px;