Skip to content

Instantly share code, notes, and snippets.

View rocka's full-sized avatar

rocka

View GitHub Profile
@rocka
rocka / tango.minttyrc
Created December 14, 2018 13:47
mintty "Tango" color scheme
Black=0,0,0
BoldBlack=64,64,64
Red=204,0,0
BoldRed=239,41,41
Green=78,154,6
BoldGreen=138,226,52
Yellow=196,160,0
BoldYellow=252,233,79
Blue=52,101,164
BoldBlue=114,159,207
@rocka
rocka / time-sync.service
Created January 30, 2024 17:43
A janky script to sync system time from various public APIs in case NTP is unusable
[Unit]
Description=Sync system time from various network APIs
[Service]
User=root
Type=oneshot
ExecStart=/usr/local/lib/time-sync.sh
@rocka
rocka / arch_init.sh
Last active October 4, 2022 08:06
Arch Linux VPS initialize script
#!/bin/bash
USERNAME='rocka'
HOSTNAME='arch'
SS_PORTNO='1234'
SS_METHOD='aes-256-gcm'
SS_PASSWD='all-your-base-are-belong-to-us'
# pacman related config
sed -i 's/#Color/Color/g' /etc/pacman.conf
@rocka
rocka / filter.mjs
Created July 6, 2022 10:31
Split fcitx5-chinese-addons `sc.dict`
import { open } from 'node:fs/promises';
import readline from 'node:readline';
const segmenter = new Intl.Segmenter('zh-CN', { granularity: 'grapheme' });
const file = await open('./dict_sc.txt');
const rl = readline.createInterface({
input: file.createReadStream(),
crlfDelay: Infinity // \r followed by \n will always be considered a single newline
@rocka
rocka / dumpReferenceTables.kt
Created December 15, 2021 17:00
dump JNI local reference table in Kotlin
// ref: https://stackoverflow.com/questions/13283649/android-jni-local-reference-table-dump-current-state
fun dumpReferenceTables() {
try {
Class.forName("dalvik/system/VMDebug").run {
val dumpReferenceTables = getDeclaredMethod("dumpReferenceTables")
val constructor = getDeclaredConstructor()
constructor.isAccessible = true
dumpReferenceTables.invoke(constructor.newInstance())
}
} catch (e: Exception) {
@rocka
rocka / fcitx5-chinese-addons CMakeLists.txt.diff
Last active June 20, 2021 18:04
fcitx5-android-poc CMakeLists.txt changes
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 38090ea..2301442 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -8,10 +8,10 @@ include(GNUInstallDirs)
include(ECMSetupVersion)
include(ECMUninstallTarget)
-find_package(Fcitx5Core 5.0.4 REQUIRED)
-find_package(Fcitx5Module REQUIRED COMPONENTS Notifications QuickPhrase Spell Clipboard TestFrontend TestIM)
@rocka
rocka / twitter_remove_t_co.js
Last active June 2, 2021 12:08
replace t.co with original links
// ==UserScript==
// @name Twitter remove t.co
// @description replace t.co with original links
// @match https://twitter.com/*
// @version 0.1
// ==/UserScript==
const PRIMARY_COLUMN = '[data-testid="primaryColumn"]';
const SIDEBAR_COLUMN = '[data-testid="sidebarColumn"]';
const A_HREF_T_CO = 'a[href^="https://t.co"]';
@rocka
rocka / gist:847df66cca3481c4072d6c65011801d6
Last active March 11, 2021 15:13 — forked from tylerchesley/gist:6198074
Function to recursively copy files from an Android asset directory
private fun copyFileOrDir(path: String) {
val assetManager = this.assets
try {
val assets = assetManager.list(path)
if (assets!!.isEmpty()) {
copyFile(path)
} else {
val dir = File("${applicationInfo.dataDir}/${path}")
if (!dir.exists()) dir.mkdir()
for (i in assets.indices) {
@rocka
rocka / docker-update.sh
Last active August 4, 2019 15:42
Update all docker-compose projects to latest image
#!/bin/bash
msg() {
# green
echo -e "\e[32m==>\e[0m" "\e[1m$@\e[0m"
}
msg2() {
# blue
echo -e "\e[34m ->\e[0m" "\e[1m$@\e[0m"
@rocka
rocka / docker_helper.fish
Last active June 30, 2019 04:04
docker helper functions for fish shell
# Docker helper functions for fish shell
function docker-update --description 'pull all :latest images'
docker images --format '{{.Repository}}:{{.Tag}}' | egrep ':(latest|alpine)' | xargs -L1 docker pull
end
function docker-clean --description 'remove all none-taged images'
docker rmi (docker images | grep '<none>' | awk '{print $3}')
end