Skip to content

Instantly share code, notes, and snippets.

View Ronmi's full-sized avatar

Ronmi Ren Ronmi

View GitHub Profile
@Ronmi
Ronmi / readme.md
Created September 6, 2025 01:36
A shell script to select pinentry implementation according to envvar

Only useful if you

  • use pinentry (like gpg signing, manage credentials with pass)
  • ssh to your desktop sometimes

TL; DR

  • Install pinentry-qt or pinentry-gnome.
  • Install pinentry-curses or pinentry-tty.
  • Create the installer script and run it with root:
@Ronmi
Ronmi / desc.md
Created August 17, 2025 18:07
家庭內<del>催眠</del>開發環境

前言

利用 dnsmasqwireguard 搞一組簡單的內部開發環境。目標是不論在家開桌機、咖啡廳開筆電或是家裡開筆電,都能得到幾乎一樣的體驗。

硬體需求

  • 連外網路
  • 從外面連回家用的外網 IP (固 I 佳,動態的要另外想辦法處理 DDNS)
  • NAT
    • 最簡單的方式是買台速度和訊號不錯的分享器,只會用它的路由、撥號和防火牆功能
@Ronmi
Ronmi / cache.md
Created January 13, 2025 09:20
Enable local cache for Forgejo action runner

By default, cache location when running CI tasks is /opt/hostedtoolcache. It's okay to change it by setting 3 envvars in config.yaml

runner:
  envs:
    RUNNER_TOOL_CACHE: /path/to/cache
    AGENT_TOOLSDIRECTORY: /path/to/cache
    RUN_TOOL_CACHE: /path/to/cache
@Ronmi
Ronmi / tw covid sms.md
Created May 23, 2021 21:45
Android 一鍵實聯制

使用 Automate 啟動 Binary Eye 掃碼後,自動傳送簡訊到 1922

  1. 安裝 Binary Eye
  2. 安裝 Automate
  3. 下載 Automate Flow 並匯入
  4. 把 flow 加到桌面 (新增桌面小工具 -> automate -> flow shortcut -> TW COVID SMS)

Automate 預設簡訊每小時只能發 10 封,若經常需要出入實聯制場所,請自行更改設定 (在主選單的 Settings -> SMS sent limit)

((前 轉 前) 反轉)
@Ronmi
Ronmi / ioc.php
Created October 31, 2017 03:37
poorman IoC
<?php
class SomeClass {
public function process($c) {
if ($c instanceof ClassA) {
$this->processA($c);
} elseif ($c instanceof ClassB) {
$this->processB($c);
} else {
// error process

Worst-case matching

This benchmark matches the last route and unknown route. It generates a randomly prefixed and suffixed route in an attempt to thwart any optimization. 1,000 routes each with 9 arguments.

This benchmark consists of 16 tests. Each test is executed 1,000 times, the results pruned, and then averaged. Values that fall outside of 3 standard deviations of the mean are discarded.

Test Name Results Time + Interval Change
r3 - unknown route (1000 routes) 995 0.0000081977 +0.0000000000 baseline
r3 - last route (1000 routes) 997 0.0000102492 +0.0000020514 25% slower
@Ronmi
Ronmi / compiled.php
Last active October 20, 2015 01:58
PoC of router - compiled php
<?php
class FruitRouteKitGeneratedMux implements Fruit\RouteKit\Router
{
public function __construct()
{
}
private function dispatchGET($uri)
{
@Ronmi
Ronmi / mux.php
Created October 19, 2015 10:21
PoC of router - creating routing table
<?php
require('vendor/autoload.php');
$mux = new Fruit\RouteKit\Mux;
$mux
->get('/', ['\A\B\C', 'methodA'])
->get('/obj/methodA', ['Obj', 'methodA'])
->get('/obj/methodB', ['Obj', 'methodB'])
@Ronmi
Ronmi / DNSQuery.php
Created December 3, 2014 01:30
Pure php code to query DNS record
<?php
/**
* Usage:
* $obj = new DNSQuery('www.google.com', '8.8.8.8', 1, 'A', 'IN');
* if ($obj->isSuccess()) var_dump(DNSQuery::parse($obj->response));
*/
class DNSQuery
{
private $name;