Skip to content

Instantly share code, notes, and snippets.

@skyone-wzw
skyone-wzw / kde-color-scheme-toggle.sh
Created June 25, 2024 15:07
KDE 6 Light/Dark mode toggle
#!/bin/bash
current_scheme=$(LANG=C.UTF-8 plasma-apply-colorscheme --list-schemes | awk -F' \\(|\\)' '/current color scheme/ {gsub(/^[ \*]+/, "", $1); print $1}')
# if no awk, use grep
# current_scheme=$(LANG=C.UTF-8 plasma-apply-colorscheme --list-schemes | grep "current color scheme" | sed 's/^[ \*]*\([^ ]*\) .*/\1/')
if [ "$current_scheme" == "BreezeDark" ]; then
target_scheme="BreezeLight"
elif [ "$current_scheme" == "BreezeLight" ]; then
target_scheme="BreezeDark"
@skyone-wzw
skyone-wzw / sudoku.py
Created May 18, 2024 20:18
使用 PuLP 线性规划求解器求解数独问题。Solve Sudoku problems using the PuLP linear programming solver.
import pulp
import re
input_string = """
+-------+-------+-------+
| x x x | 6 5 x | x x x |
| x x 8 | 4 x x | 9 1 x |
| x x x | x x x | x 8 3 |
+-------+-------+-------+
| x 6 x | x x x | x x x |
@skyone-wzw
skyone-wzw / docker-compose.yml
Created April 27, 2024 13:37
GitLab 低配
services:
gitlab:
container_name: gitlab
image: gitlab/gitlab-ce:16.8.1-ce.0
ports:
- "80:80"
- "22:22"
volumes:
- "./config:/etc/gitlab"
- "./logs:/var/log/gitlab"
@skyone-wzw
skyone-wzw / gitlab.yml
Created February 4, 2024 06:54
GitLab configure with low hardware requirements
version: "3.8"
# 基于 Arch Linux x86_64 的测试环境
# 单用户, 内存占用 2.5G 左右, CPU 需要 2 核, 日常占用 1%.
# 树莓派 4B 基于 ARM Cortex-A72, 理论上可以运行
services:
gitlab:
container_name: gitlab
image: gitlab/gitlab-ce:16.8.1-ce.0 # for arm64v8: yrzr/gitlab-ce-arm64v8:16.5.8-ce.0
@skyone-wzw
skyone-wzw / bird.conf
Created November 12, 2023 05:13
DN42 Bird2 Configure
################################################
# Variable header #
################################################
define OWNAS = <OWNAS>;
define OWNIP = <OWNIP>;
define OWNIPv6 = <OWNIPv6>;
define OWNNET = <OWNNET>;
define OWNNETv6 = <OWNNETv6>;
define OWNNETSET = [<OWNNET>+];
@skyone-wzw
skyone-wzw / prisma.ts
Created October 8, 2023 09:52
Store PrismaClient as a global variable in development environments only
import {PrismaClient} from "@prisma/client"
const globalForPrisma = globalThis as unknown as {prisma: PrismaClient}
export const prisma =
globalForPrisma.prisma || new PrismaClient()
if (process.env.NODE_ENV !== "production") globalForPrisma.prisma = prisma
@skyone-wzw
skyone-wzw / KotlinNativeReadFile.kt
Created January 15, 2023 10:58
Read a file in kotlin/native use c interop.
package host.skyone.native
import kotlinx.cinterop.*
import platform.posix.*
fun main() {
val file = "test.txt"
val contentSize = nativeHeap.alloc<stat>().apply { stat(file, this.ptr) }.st_size
val buffer = ByteArray(contentSize)
val fp = open(file, O_RDONLY)
@skyone-wzw
skyone-wzw / JsonPolymorphism.kt
Created November 10, 2022 05:38
Kotlin Json 序列化的多态
import kotlinx.coroutines.runBlocking
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.decodeFromString
import kotlinx.serialization.json.Json
private val json = Json {
classDiscriminator = "myType"
}
@skyone-wzw
skyone-wzw / dcgan.ipynb
Created July 23, 2022 04:21
对抗神经网络
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#define offset_of(type, member) ((size_t) &((type *)0)->member)
#define container_of(ptr, type, member) ({ \
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (char *)__mptr - offset_of(type, member) );})