Skip to content

Instantly share code, notes, and snippets.

SAPikachu / 1.
Last active May 25, 2023 08:14
Idea: Verifiably non-riggable shuffle algorithm for online mahjong games

Idea: Verifiably non-riggable shuffle algorithm for online mahjong games

  1. Server should save a random bytestring PS (regenerated after each full match) for each player. PS should be visible on game UI.
  2. Server should publish a global 1024-bit (128 bytes) random bytestring GS (changed every X minutes). Current and next GS should be visible on game UI.
  3. When a match starts, save timestamp T1.
  4. When a round starts, save timestamp T2, and generate a random bytestring R. Then, generate random seed for this round by calculating SHA512 hash of concatenation of following elements (|| denotes concatenation):
  • T1
  • T2
  • R
  • HMAC-SHA512(GS, T1 || T2 || R)
SAPikachu / ZFS + couchdb + zstd compression
Last active August 1, 2021 03:22
ZFS / couchdb / zstd compression test


  • Ubuntu 20.04
  • Kernel 5.4.0-67
  • OpenZFS 2.0.4-0york2~20.04
  • ashift: 12
  • Compression: zstd, default level


Keybase proof

I hereby claim:

  • I am sapikachu on github.
  • I am sapikachu ( on keybase.
  • I have a public key ASCDs5kwFA8KZaR-ExqujHIKUUlxW1-IptukK3hxoOIM9Ao

To claim this, I am signing this object:

This file has been truncated, but you can view the full file.
"use strict";
(function() {
Error.stackTraceLimit = Infinity;
var $global, $module;
if (typeof window !== "undefined") { /* web page */
$global = window;
} else if (typeof self !== "undefined") { /* web worker */
$global = self;
SAPikachu / openwrt-tcpoptstrip.patch
Last active May 6, 2022 09:04
diff --git a/include/ b/include/
index 5d532ce..474a48b 100644
--- a/include/
+++ b/include/
@@ -262,6 +262,9 @@ $(eval $(call nf_add,IPT_TPROXY,CONFIG_NETFILTER_XT_TARGET_TPROXY, $(P_XT)xt_TPR
# led
$(eval $(call nf_add,IPT_LED,CONFIG_NETFILTER_XT_TARGET_LED, $(P_XT)xt_LED))
+# tcpoptstrip
#!/usr/bin/env python3
import os
import time
import math
from queue import Queue, Empty
from threading import Thread
import logging
from influxdb import InfluxDBClient
SAPikachu /
Last active May 24, 2022 12:09
Custom guest wireless network on ASUS RT-AC68U (Merlin firmware)
# /jffs/scripts/firewall-start
# A VM in VLAN 1111 (tagged) is plugged to port 1, it will act as router of guest network, offer DHCP, and do other filtering as necessary
# Port 5 (internal CPU port) has to be included to make it works
robocfg vlan 1111 ports "1t 5t"
# Bring up VLAN interface
ip link add link eth0 name vlan1111 type vlan id 1111
SAPikachu / gist:caa7da4925d1872d95db
Created July 20, 2015 13:58
Test code for sending mail to change event in Google Calendar
#!/usr/bin/env python3
import requests
# is the organizer, is controlled by our app and wants to update the event
# Message body is modified from the mail sent by Google Calendar
body = """Date: Fri, 17 Jul 2015 13:23:53 +0000
Subject: Updated: RFC2446 Test @ Tue Jul 21, 2015 5pm - 6pm (
SAPikachu / gist:c276860e466c36070904
Created June 8, 2015 03:52
scp performance benchmark
sapikachu@sapikachu-netbox:/tmp/memtest$ ./
Bytes per second: sent 42984714.6, received 7850.0
Bytes per second: sent 42957622.1, received 7874.5
Bytes per second: sent 43907095.0, received 8061.9
Bytes per second: sent 57376736.6, received 10429.3
Bytes per second: sent 57130993.1, received 10765.5
Bytes per second: sent 60852877.9, received 11334.7
# User authentication method. Could be set multiple times and in that case
# all should succeed.
# Options: certificate, pam.
auth = "certificate"
#auth = "plain[passwd]"
#auth = "pam"
# The plain option requires specifying a password file which contains
# entries of the following format.
# "username:groupname:encoded-password"