Skip to content

Instantly share code, notes, and snippets.

View taoky's full-sized avatar
⌨️
Back to work

taoky taoky

⌨️
Back to work
View GitHub Profile
@taoky
taoky / interactive.py
Created August 25, 2023 09:52
Playing interactive ChatGLM2 with bigdl.llm (CPU)
# Deps:
# pip install bigdl-llm[all]
import torch
import time
import argparse
# import numpy as np
import readline
from bigdl.llm.transformers import AutoModel
from transformers import AutoTokenizer
@taoky
taoky / main.rs
Last active February 14, 2023 19:20
Debugging glib2 context sources
use std::{time::Duration, thread::sleep};
use zbus::blocking::Connection;
mod mutter;
fn main() {
let connection = Connection::session().unwrap();
let proxy = mutter::IdleMonitorProxyBlocking::new(&connection).unwrap();
for _ in 0..10000 {
@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: