Skip to content

Instantly share code, notes, and snippets.

View sgqy's full-sized avatar

sgqy

  • Japan
  • 20:29 (UTC +09:00)
  • X @sgqy_
View GitHub Profile
@sgqy
sgqy / command.txt
Last active November 7, 2024 00:10
print 2 pages of book to one b5 paper
docker compose run --entrypoint bash tex
pdfjam --no-tidy --nup 2x1 --b4paper --landscape --frame true --trim '6.5mm 25mm 6.5mm 10mm' --outfile o.pdf nst.pdf '6-'
@sgqy
sgqy / Dockerfile
Last active August 18, 2024 13:24
code-server with golang and cuda
FROM codercom/code-server:bookworm
# Use root to install tools
USER 0
# Install C++
RUN --mount=type=tmpfs,target=/dev/shm bash <<EOF
set -euxo pipefail
cd /dev/shm
$('li.search_result_img_box_inner').each((i, e) => {
$(e).css('background', '')
$(e).css('opacity', '')
v = $(e).find('span.strike').text().replace(/[,円]/g, '')
p = Number(v)
cx = Math.min(Math.max(0, Math.floor(p / 500)), 16).toString(16)
$(e).css('background', `#f${cx}4`)
b = $(e).find('ul[data-is_bought=true]')
if (b.length > 0) {
$(e).css('opacity', '0')
@sgqy
sgqy / valloc.c
Created September 26, 2021 14:06
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <sys/mman.h>
int main()
{
#if 0
const size_t addr = 0x00000100f0000000;
#!/usr/bin/env python3
from captcha.image import ImageCaptcha
cap = ImageCaptcha(width=400, height=100, fonts=['/usr/share/fonts/opentype/source-code-pro/SourceCodePro-Regular.otf'])
img = cap.generate_image('13800138000')
img.show()
@sgqy
sgqy / awake.c
Last active September 22, 2021 14:00
Keep Windows screen on, no mater what weird-and-hidden power configs it uses.
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#ifdef MB_DEBUG
#define INTERVAL (500)
#else
#define INTERVAL (30 * 1000)
#endif
#ifdef MB_DEBUG
@sgqy
sgqy / one_line_ja.py
Last active September 22, 2021 17:56
OmegaT
fn = '/dev/shm/one-line.ogg'
import speech_bot
bot = speech_bot.speech('google-conf.json')
import sys
t = ''.join(sys.argv[1:])
bot.save('ja', t, fn)
#import os
#!/usr/bin/env python3
# Auto remove fans in bilibili.com
# 全天候移除 B 站粉丝, 彻底变成小透明
# 操作不可逆, 后果自负
# 用法: 把 B 站的 cookies 保存为 Netscape 格式的 cookie.txt 后, 再执行此脚本
# 另外, 稍作修改就可以变成自动关注或自动拉黑新增粉丝的奇怪脚本
# 已知的 act 代码:
#!/bin/bash
find -L -iname '*.mkv' -print0 | sort -z | \
xargs -0 -i sh -c ' /usr/bin/echo -ne "\e[1;33m" && echo "$1" | tee -a /dev/shm/conv-log && /usr/bin/echo -ne "\e[0m" && \
~/lab/ffmpeg-cuda/ffmpeg/ffmpeg -y -hide_banner -loglevel level+warning -stats \
-i "$1" -map 0 -c copy \
-c:a libopus -b:a 128k -c:v hevc_nvenc -cq:v 35 o.mkv \
&& mv o.mkv "$1" ' -- {}
find -L -iname '*.mp4' -print0 | sort -z | sed -z 's/\.mp4$//g' | \