This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ctypes | |
import mmap | |
def replace_space_to_underscore(input_: str): | |
assert input_.isascii() | |
buf = ctypes.create_string_buffer(input_.encode()) | |
shellcode = ( | |
b"\x48\xbf" | |
+ ctypes.addressof(buf).to_bytes(8, "little") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CronTabParsingError extends Error { | |
static assert(condition: unknown, message: string): asserts condition { | |
if (!condition) { | |
throw new CronTabParsingError(message); | |
} | |
} | |
} | |
const ordinal = (n: number): string => { | |
if (n % 100 >= 11 && n % 100 <= 13) return `${n}th`; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { cn } from "@/utils"; | |
export const ProgressiveBlurBackground: React.FC< | |
React.ComponentProps<"div"> & { | |
orientation?: "top" | "bottom"; | |
steps?: number; | |
blurTargetPx?: number; | |
} | |
> = ({ | |
className, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import final | |
import parsy as p | |
whitespace = p.regex(r"\s*") | |
comment = p.regex(r"//.*") | |
def lexeme(parser: p.Parser): | |
return parser << (whitespace | comment) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# udpchk.py - simple tool to test UDP support of SOCKS5 proxy. | |
# Copyright (C) 2016-2017 Zhuofei Wang <[email protected]> | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); you may not | |
# use this file except in compliance with the License. You may obtain a copy | |
# of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""A module for serving static files with URL rewriting support. | |
Module Overview: | |
This module provides the RewrittenStaticFiles class, an extension of Starlette's StaticFiles that supports URL rewriting. | |
The class is designed to serve static files from a specified directory or packages and to apply rewrite rules in case a requested | |
file is not found (HTTP 404). Rewrite rules are defined as a dictionary where keys are patterns (either wildcard strings or compiled | |
regular expressions) and values are target paths. If a request initially results in a 404 error, the class will attempt to match | |
the path against the rewrite rules and serve the corresponding rewritten file if found. | |
Examples: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hashlib | |
import zipfile | |
import zlib | |
from base64 import b64decode | |
from dataclasses import dataclass | |
from io import BytesIO | |
from pathlib import Path | |
from typing import IO, Literal, Optional | |
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# stage for building scrcpy | |
FROM ubuntu:latest AS builder | |
RUN apt-get update && \ | |
apt-get install -y --no-install-recommends \ | |
curl gcc git pkg-config meson ninja-build libsdl2-dev ca-certificates \ | |
libavcodec-dev libavdevice-dev libavformat-dev libavutil-dev \ | |
libswresample-dev libusb-1.0-0-dev libswscale-dev libvncserver-dev && \ | |
apt-get clean && \ | |
rm -rf /var/lib/apt/lists/* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Generate iCalendar file for BUPT class schedule. | |
Usage: | |
python this_file.py <username> <password> | |
Note: | |
1. You need to install the following packages: | |
- httpx | |
- ics |
NewerOlder