Skip to content

Instantly share code, notes, and snippets.

View qiwihui's full-sized avatar
🦉
Focusing

qiwihui qiwihui

🦉
Focusing
View GitHub Profile
@Treeki
Treeki / TurnipPrices.cpp
Last active July 26, 2025 06:27
AC:NH turnip price calculator
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
// munged from https://github.com/simontime/Resead
namespace sead
{
class Random
{
// ==UserScript==
// @name Shuffle iSay
// @namespace https://www.douban.com/people/MoNoMilky/
// @version 0.2
// @description Your brain is strange and strong, interesting.
// @author Bambooom
// @match https://*.douban.com/*
// @grant none
// ==/UserScript==
@daopk
daopk / git-config-http-version.md
Last active February 22, 2025 09:40
Fix error : RPC failed; curl 92 HTTP/2 stream 0 was not closed cleanly: PROTOCOL_ERROR (err 1)
git config --global http.version HTTP/1.1
git config --global http.postBuffer 157286400
@shakna-israel
shakna-israel / Prose.md
Last active January 6, 2025 17:00
Obfuscating Python

Obfuscating Python

Obfuscation isn't difficult in most programming languages. It's why we have "good practices" because it is so easy to hide what you mean in badly written code.

Obfuscation tends to be even easier in dynamic languages because of how forgiving they tend to be - and because they tend to give you direct access to the environment so that you can manipulate it.

Today, for fun, I'm going to obfuscate this code:

def _(n):

if n <= 0:

@c-bata
c-bata / release-sphinx-to-gcs.yml
Last active September 19, 2021 02:22
Github Actions Workflow to build your sphinx documentation and upload it to Google Cloud Storage.
name: release
on:
push:
branches:
- master
jobs:
release:
name: Build
runs-on: ubuntu-latest
@HarryR
HarryR / poseidon.py
Last active May 22, 2022 08:32
Starkad and Poseidon: New Hash Functions for Zero Knowledge Proof Systems
#!/usr/bin/env python
"""
Implements the Poseidon permutation:
Starkad and Poseidon: New Hash Functions for Zero Knowledge Proof Systems
- Lorenzo Grassi, Daniel Kales, Dmitry Khovratovich, Arnab Roy, Christian Rechberger, and Markus Schofnegger
- https://eprint.iacr.org/2019/458.pdf
Other implementations:
@dimfeld
dimfeld / slog-logging-middleware.rs
Last active August 27, 2021 04:50
Simple actix-web middleware for custom KV logging with slog
use actix_service::{Service, Transform};
use actix_web::{dev::ServiceRequest, dev::ServiceResponse, Error};
use futures::future::{ok, FutureResult};
use futures::{Future, Poll};
use slog::info;
// There are two step in middleware processing.
// 1. Middleware initialization, middleware factory get called with
// next service in chain as parameter.
// 2. Middleware's call method get called with normal request.
@kekru
kekru / 01nginx-tls-sni.md
Last active August 17, 2025 18:13
nginx TLS SNI routing, based on subdomain pattern

Nginx TLS SNI routing, based on subdomain pattern

Nginx can be configured to route to a backend, based on the server's domain name, which is included in the SSL/TLS handshake (Server Name Indication, SNI).
This works for http upstream servers, but also for other protocols, that can be secured with TLS.

prerequisites

  • at least nginx 1.15.9 to use variables in ssl_certificate and ssl_certificate_key.
  • check nginx -V for the following:
    ...
    TLS SNI support enabled
@ginokent
ginokent / mysql-5.6.sh
Last active April 29, 2021 05:50
MySQL 5.6 on Ubuntu 16.04
#!/bin/bash
# MySQL 5.6 client libraries
# https://launchpad.net/ubuntu/xenial/amd64/libmysqlclient-dev/5.6.28-1ubuntu3
# https://launchpad.net/ubuntu/xenial/amd64/mysql-client-5.6/5.6.28-1ubuntu3
# https://launchpad.net/ubuntu/xenial/amd64/mysql-client-core-5.6/5.6.28-1ubuntu3
# https://launchpad.net/ubuntu/xenial/amd64/mysql-common/5.6.28-1ubuntu3
# https://launchpad.net/ubuntu/xenial/amd64/libmysqlclient18/5.6.28-1ubuntu3
# DEPRECATED https://launchpad.net/ubuntu/xenial/amd64/libdbd-mysql-perl/4.033-1
@0age
0age / MetamorphicContractInitCode.txt
Last active October 5, 2024 17:18
Metamorphic Contract Initialization Code
* @title Metamorphic Contract
* @author 0age, derived from cloner contract by @mhswende
* @notice This contract will create a metamorphic contract, or an upgradeable
* contract that does not rely on a transparent proxy, when deployed using
* CREATE2. It expects the deployer to provide a getImplementation() function
* that will return an implementation address, which it will then clone and
* deploy. Unlike with upgradeable transparent proxies, the state of a
* metamorphic contract will be wiped clean with each upgrade. With great power
* comes great responsibility - implement appropriate controls and educate the
* users of your contract if it will be interacted with!