Skip to content

Instantly share code, notes, and snippets.

View taoky's full-sized avatar
🔬
Rebooting...

taoky taoky

🔬
Rebooting...
  • University of Science and Technology of China
  • on USTC campus
  • 18:22 (UTC +08:00)
View GitHub Profile
@taoky
taoky / Cargo.toml
Last active January 4, 2023 09:58
Example of unshare in Rust
[package]
name = "unshare"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
nix = { version = "0.26.1", features = ["sched", "mount"] }
@taoky
taoky / xdp-screen-cast.py
Created October 2, 2022 15:58
Sharing wayland screen/window with portal + pipewire to X programs
#!/usr/bin/python3
# Original script: https://gitlab.gnome.org/-/snippets/19
# Sharing wayland screen/window with portal + pipewire to X programs
# Modifications:
# 1. Add --show-cursor option
# 2. Fix the bug that the script won't exit after the window is closed
# Known bugs:
# 1. Screencasting monitors without top bar may not work smoothly in GNOME
# (Contents of xvimagesink window may not updated when not focused
@taoky
taoky / script.py
Created July 19, 2022 15:54
Sleep timer
#!/usr/bin/env python3
import datetime
# you need python-notify2
import notify2
import time
def main():
now = datetime.datetime.now()
title = "Time Notification"
@taoky
taoky / xfsquota-telegraf.py
Last active April 11, 2022 12:39
xfs_quota telegraf script
#!/usr/bin/env python3
import argparse
import subprocess as sp
def main():
command = ["/sbin/xfs_quota", "-c", "free -N"]
ret = sp.run(command, stdout=sp.PIPE)
if ret.returncode != 0:
@taoky
taoky / qr.c
Last active August 12, 2022 04:12
QR decomposition with Givens method (OpenMP)
#include <math.h>
#include <omp.h>
#include <stdio.h>
#include <stdlib.h>
#define MIN(x, y) ((x) < (y) ? (x) : (y))
int n;
void givens(int from_row, int start_row, int end_row, double (*a)[n], double (*q)[n]) {
@taoky
taoky / qt5.ps1
Last active September 23, 2021 12:30
Minimum static qt build (Windows)
# Modified from https://gist.github.com/mrfaptastic/80e909c9a8237994471bce2d17657779
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
# Tested with QT 5.15.2 on Windows 10
@taoky
taoky / Dockerfile
Created August 14, 2021 13:02
VMware's vibauthor in Docker
FROM centos:6
RUN echo "207.241.237.3 web.archive.org" >> /etc/hosts && \
curl https://web.archive.org/web/20140123032613if_/http://download3.vmware.com/software/vmw-tools/vibauthor/vmware-esx-vib-author-5.0.0-0.0.847598.i386.rpm > /tmp/vibauthor.rpm && \
sed -e "s|^mirrorlist=|#mirrorlist=|g" \
-e "s|^#baseurl=http://mirror.centos.org/centos/\$releasever|baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.10|g" \
-i.bak \
/etc/yum.repos.d/CentOS-*.repo && \
yum makecache && \
yum install -y python-lxml && \
@taoky
taoky / main.py
Created August 4, 2021 08:12
Emergency finding broken repo in gitlab hashed storage
import glob
import sys
configs = glob.iglob("/your/gitlab/path/repositories/@hashed/*/*/*.git/config")
keyword = sys.argv[1]
print("keyword", keyword)
for i in configs:
with open(i) as f:
@taoky
taoky / analyze.py
Last active February 27, 2021 17:04
Analyze rsyncd log with state-machine style python script
from sys import stdin
from collections import defaultdict
def analyze(line):
state = 0
for idx, c in enumerate(line):
if state == 0:
if c == ']':
if line[idx + 2:idx + 6] == "send":
state = 1
@taoky
taoky / 1.sh
Last active December 6, 2020 15:08
run multi jobs and get whether any process failed
#!/bin/bash
rm -f /tmp/failure
~/executor/executor -shell 'sleep 3 && ping' > /tmp/log || touch /tmp/failure &
~/executor/executor ls > /tmp/log2 || touch /tmp/failure &&
wait
test -f /tmp/failure && echo failed! && exit 1
exit 0