Skip to content

Instantly share code, notes, and snippets.

View amphineko's full-sized avatar
🍊
Have a job but do open-source when not busy

amphineko amphineko

🍊
Have a job but do open-source when not busy
  • 08:58 (UTC)
View GitHub Profile
.editor-group-watermark > .letterpress{
background-image: url("https://raw.githubusercontent.com/Aikoyori/ProgrammingVTuberLogos/main/VSCode/VSCode.png") !important;
opacity: .75;
}
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
using UnityEngine.Bindings;
using UnityEngine.Internal;
using UnityEngine.SceneManagement;
@amphineko
amphineko / khala-block-scan.js
Last active August 20, 2021 15:55
Khala: something is wrong at #58602
const start = 58600
const end = 58700
for (let i = start; i < end; i++) {
if (i % 100 === 0) {
console.log(`fetch block [${i}, ${i + 99}]`)
}
const blockHash = await api.rpc.chain.getBlockHash(i)
try {
print('Knot Resolver ' .. package_version())
modules = {
'bogus_log',
'hints',
'predict',
'prefill',
'workarounds < iterate',
}
@amphineko
amphineko / io-ts-playground.ts
Created July 10, 2020 19:58
io-ts decoding and custom types example
import { either, isLeft, isRight } from 'fp-ts/lib/Either'
import * as it from 'io-ts'
import { Int, Type, TypeOf } from 'io-ts'
import { PathReporter } from 'io-ts/lib/PathReporter'
// custom type: integer string
const IntegerString = new Type<number, string, unknown>(
'IntegerString',
Int.is,
#include <condition_variable>
#include <cstdio>
#include <mutex>
#include <queue>
#include <thread>
extern "C"
{
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
@amphineko
amphineko / CreateLinkedTokenSource.cs
Last active November 26, 2019 22:41
CancellationTokenSource.CreateLinkedTokenSource won't cancel peer tokens.
using System.Diagnostics;
var timeout = new CancellationTokenSource(TimeSpan.FromSeconds(1));
var observer = new CancellationTokenSource();
var linked = CancellationTokenSource.CreateLinkedTokenSource(timeout.Token, observer.Token);
await Task.Run(async () => {
try
{
@amphineko
amphineko / webpack.config.js
Created September 22, 2019 23:12
cursed webpack
const path = require('path')
const { CleanWebpackPlugin: CleanPlugin } = require('clean-webpack-plugin')
const HtmlPlugin = require('html-webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
module.exports = (env, argv) => {
const isProduction = argv.mode === 'production'
return {
@amphineko
amphineko / !v2ray-docker-compose-README.md
Last active May 24, 2023 14:27
V2Ray with outbound address (cursed way)

There're some Docker-ized configuration files to setup a weird proxy.
Since V2Ray doesn't support specifiy outbound address yet,
placing a Shadowsocks instance with -b option behind the V2Ray server is less complex than policy routing in the kernel.

The whole proxy chain for this VMess over WebSocket:
Reverse Proxy (NGINX, etc.) -> V2Ray (WebSocket -> VMess) -> Shadowsocks

@amphineko
amphineko / lock-and-sleep.ps1
Created July 22, 2019 19:34
PowerShell script to lock workstation and turn off monitor
<#
This PowerShell script locks your current session, then immediately turns off your monitor.
You don't have to wait for or alter your screen timeout,
or use a sleep button set to turning off monitor that doesn't exist on your computer.
#>
$LockWorkStation = Add-Type -Name "Win32LockWorkStation" -PassThru -MemberDefinition @"