Skip to content

Instantly share code, notes, and snippets.

View htfy96's full-sized avatar
🐢
WFH

Zheng Luo htfy96

🐢
WFH
View GitHub Profile
@htfy96
htfy96 / cpp-build-profile-2024.md
Last active April 2, 2024 16:48
C++ Build profiles for 2024 projects

C++ Build profiles for 2024 projects

Standard development profile

This profile achieves 50% - 80% release profile performance, while also provides a reasonable amount of safety checks and debugging support. This should also be the profile for your CI build.

Compilation flags

-Og -Wall -Wextra -D_FORTIFY_SOURCE=2 -fstack-protector-strong -g -D_GLIBCXX_ASSERTIONS
@htfy96
htfy96 / how-to-delete-easy.md
Last active June 21, 2020 23:26
How to delete a bunch of files on server without interrupting other workload in 2020

What doesn't work

ionice

Two reasons:

  • Common answer: Many modern OS doesn't use BFQ scheduler, and deadline-related schedulers ignore ionice: check this with cat /sys/block/sda/queue/scheduler
  • In kernel, the IO on writeback pages isn't accounted to the actual process until cgroup v2 OR blkio scheduler. So, if you deleted some files which updates the dentry page cache of parent directory, the writeback page cache won't be accounted to the user and thus stay unlimited

What does work

tl;dr:

@htfy96
htfy96 / install_dep_and_build
Created December 5, 2019 18:32
Install conan packages and build with cmake_multi generator
#!/bin/bash
# Usage:
# Assuming you are in ROOT/build
# and ROOT contains conanfile.txt and CMakeLists.txt
# ./install_dep_and_build [Debug|Release|RelWithDebInfo]
# Prerequisite:
# Make sure you have
# [generators]
@htfy96
htfy96 / build.sh
Created October 12, 2019 01:57
libwasmfoo
_deps/wasiclang-src/opt/wasi-sdk/bin/clang --sysroot _deps/wasiclang-src/opt/wasi-sdk/share/wasi-sysroot stb_vorbis.c -c -o stb_vorbis.
_deps/wasiclang-src/opt/wasi-sdk/bin/clang -Wl,--export-all --sysroot _deps/wasiclang-src/opt/wasi-sdk/share/wasi-sysroot *.o -o lib.wasm
cargo/release/lucetc --bindings _deps/mod_lucet-src/lucet-wasi/bindings.json --reserved-size 256MiB lib.wasm -o libwasmfoo.so --opt-level 2
@htfy96
htfy96 / childexit-pipe.c
Created September 23, 2019 23:30
Detecting child exit with pipe
#include <stdio.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <assert.h>
#include <sys/select.h>
#include <stdbool.h>
@htfy96
htfy96 / cdq.cpp
Last active March 3, 2024 20:03
Solution to CF Educational Round 56 Problem E, with CDQ divide-and-conquer (CDQ分治)
#include <bits/stdc++.h>
/*
https://codeforces.com/contest/1093/problem/E
Convert all modification and query into single-point events (t, x, y). Initially sort by t,
for each interval, recursively handle independent two parts. Then calc the interference
between part one and two: only mod in part 1 can affect result in part 2. Therefore, we can
sort part1 and 2 respectively by x, then process all mod event in part 1 and all query events in
part 2 in a sort-merge-like way. The Y-dimension is maintained with a fenwick tree.
In the end all elements will be sorted by x.
@htfy96
htfy96 / discrete.cpp
Created October 4, 2018 14:47
discrete
#include <bits/stdc++.h>
using namespace std;
int main()
{
vector<int> a {1, 3, 3, 2, 5};
vector<int> b;
for (int i=0; i<a.size(); ++i)
b.push_back(i);
@htfy96
htfy96 / proof.md
Created September 19, 2018 05:08
Proof of identication

I hereby claim:

  • I am the person who sends Wechat messages and moments at Sept 18 22:07 - 22:17 PDT from account @VicLuo96

To claim this, I sign this message with my pubkey 0x98809CA08BF5662A:

I hereby claim:

- I am the person who sends Wechat messages and moments at Sept 18 22:07 - 22:17 PDT from account @VicLuo96
@htfy96
htfy96 / A-small-attempt-3.out
Created July 29, 2018 12:50
GCJ Kickstart Round D Problem A: Solution and sample data
Case #1: 13
Case #2: IMPOSSIBLE
Case #3: 2
Case #4: 386239
Case #5: IMPOSSIBLE
Case #6: IMPOSSIBLE
Case #7: IMPOSSIBLE
Case #8: 84609596512776
Case #9: 0
Case #10: 1155268877829
@htfy96
htfy96 / feeds.opml
Created June 27, 2018 05:16
My feedly feeds collection
<?xml version="1.0" encoding="UTF-8"?>
<opml version="1.0">
<head>
<title>Vic subscriptions in feedly Cloud</title>
</head>
<body>
<outline text="news" title="news">
<outline type="rss" text="路透: 时事要闻" title="路透: 时事要闻" xmlUrl="http://cn.reuters.com/rssFeed/CNTopGenNews/" htmlUrl="http://cn.reuters.com"/>
<outline type="rss" text="Washington Post: Breaking News, World, US, DC News &amp; Analysis" title="Washington Post: Breaking News, World, US, DC News &amp; Analysis" xmlUrl="http://www.washingtonpost.com/rss/homepage" htmlUrl="http://www.washingtonpost.com/pb/homepage/"/>