Skip to content

Instantly share code, notes, and snippets.

View ysc3839's full-sized avatar

Richard Yu ysc3839

View GitHub Profile
#pragma once
template <typename T, typename TExecutor>
[[nodiscard]] inline auto Promise(TExecutor&& executor) noexcept
{
using std::coroutine_handle;
struct _Promise
{
_Promise(TExecutor&& executor) : m_coroHandle(nullptr), m_result(std::nullopt), m_reason()
#!/bin/sh
. /usr/share/libubox/jshn.sh
write_log() {
logger -st natmap-update -p "$1" "$2"
}
RRTYPE=A
ZONE="example.com"
@ysc3839
ysc3839 / README.md
Last active January 3, 2024 14:26
Systemd timer for lego

Systemd timer for lego

Place lego.service and lego.service in /etc/systemd/system. Place config in /var/lib/lego and nginx-example.com.sh in /var/lib/lego/scripts. You should modify config and nginx-example.com.sh. Finally execute sudo systemctl enable lego.timer.

Lego's files are stored in /var/lib/lego. You need to create this directory and use lego ... run to create acme account.

I'm using DNS challenge and didn't test HTTP challenge. Please tell me if it works.

# SPDX-License-Identifier: MIT
from ctypes import c_int, POINTER, c_void_p, byref, c_float
from ctypes.wintypes import DWORD
from comtypes import GUID, IUnknown, STDMETHOD, HRESULT, COMMETHOD, CoCreateInstance
EDataFlow_eRender = 0
ERole_eMultimedia = 1
CLSID_MMDeviceEnumerator = GUID('{BCDE0395-E52F-467C-8E3D-C4579291692E}')
require('luci.util')
local nx_redir = false
function http_date(time)
return os.date('!%a, %d %b %Y %H:%M:%S GMT', time)
end
function handle_request(env)
local send = uhttpd.send
if env.REQUEST_URI == '/' then -- NintendoWiFi
// https://github.com/B-Con/crypto-algorithms/blob/master/sha1.c
const SHA1_BLOCK_SIZE = 20
class sha1_ctx
{
constructor()
{
data = array(64, 0);
datalen = 0;
// https://github.com/B-Con/crypto-algorithms/blob/master/sha256.c
const SHA256_BLOCK_SIZE = 32
class sha256_ctx
{
constructor()
{
data = array(64, 0);
datalen = 0;
#pragma once
// DLGTEMPLATEEX structure
// https://docs.microsoft.com/en-us/windows/desktop/dlgbox/dlgtemplateex
const uint8_t* SkipIDorString(const uint8_t* p)
{
if (*reinterpret_cast<const uint16_t*>(p) == 0xFFFF)
return p + sizeof(uint16_t) * 2;
while (*reinterpret_cast<const uint16_t*>(p))
#!/usr/bin/env python3
# -*- encoding: utf-8 -*-
import json, uuid, os, datetime
from datetime import time as tm
from functools import partial
open_utf8 = partial(open, encoding='utf-8')
ICAL_HEADER = r'''BEGIN:VCALENDAR
PRODID:-//ysc3839//classlist-to-ical.py//