Skip to content

Instantly share code, notes, and snippets.

import matplotlib.pyplot as plt
def rgb(wavelength):
if 645 <= wavelength <= 780:
R, G, B = 1.0, 0.0, 0.0
elif 580 <= wavelength <= 645:
R, G, B = 1.0, -(wavelength - 645) / (645 - 580), 0.0
elif 510 <= wavelength <= 580:
R, G, B = (wavelength - 510) / (580 - 510), 1.0, 0.0
elif 490 <= wavelength <= 510:
var pathqs = 'path[d="M4.75 3.79l4.603 4.3-1.706 1.82L6 8.38v7.37c0 .97.784 1.75 1.75 1.75H13V20H7.75c-2.347 0-4.25-1.9-4.25-4.25V8.38L1.853 9.91.147 8.09l4.603-4.3zm11.5 2.71H11V4h5.25c2.347 0 4.25 1.9 4.25 4.25v7.37l1.647-1.53 1.706 1.82-4.603 4.3-4.603-4.3 1.706-1.82L18 15.62V8.25c0-.97-.784-1.75-1.75-1.75z"]';
var links = [];
setInterval(() => {
document.querySelectorAll(pathqs)
.forEach(e => {
let div = e.parentNode.parentNode.parentNode;
if(div.classList.contains("r-xoduu5")) {
let postlink = div.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.querySelector('a.css-146c3p1.r-bcqeeo.r-1ttztb7.r-qvutc0.r-1qd0xha.r-a023e6.r-rjixqe.r-16dba41.r-xoduu5.r-1q142lx.r-1w6e6rj.r-9aw3ui.r-3s2u2q.r-1loqt21').href;
if (postlink) {
console.log(postlink);
export default {
async fetch(request) {
const corsHeaders = {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET",
"Access-Control-Max-Age": "86400",
"Access-Control-Allow-Headers": "X-Proxy-URL, X-Proxy-Method, X-Proxy-Header",
};
if (request.method === "OPTIONS") {
import os
def plot(data, row=30):
buf = ""
tb, M = [], max(data)
for i in data:
tb.append(int(row*i/M))
rows = [[] for _ in range(max(tb))]
for p, i in enumerate(rows):
for n, j in enumerate(tb):
@morganabc
morganabc / cgiwrap.sh
Last active March 19, 2024 05:38
CGI to HTTP for use with `nc -e`
#!/bin/bash
while IFS=$'\n' read -r line; do
if [[ "$line" == $'\r' ]]; then
raw="${raw}\r"
break;
fi
raw="${raw}${line}\n";
done
IFS=' ' read -r rmethod rpath rver <<< "$raw";
@morganabc
morganabc / Containerfile
Last active March 17, 2024 13:32
Wireguard to SOCKS using container.
FROM debian:12
RUN apt-get update -y && \
apt-get install -y wireguard-tools openssh-server iproute2 openresolv
RUN ssh-keygen -A && \
echo 'root:Passw0rd' | chpasswd && \
sed -i 's/#PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config
# sysctl not working and does not matter
#!/bin/bash
echo $0 $@ $(pwd)
cd "$(dirname "$0")"
mkdir -p rootfs upper squash
./busybox tar xzf utils.tar.gz
./busybox sh -c "utils/squashfuse ./root.sqsh ./squash"
./busybox sh -c "utils/unionfs -o cow upper=RW:squash=RO rootfs"
@morganabc
morganabc / start.sh
Created March 4, 2024 13:55
Gitea Docker
#!/bin/bash
set -e
mkdir -p /tmp/gitea
cat << EOF > /tmp/gitea/Containerfile
FROM debian:12
ENV DEBIAN_FRONTEND noninteractive
AESURL=""
M3U8URL=""
curl "$M3U8URL" --output a.m3u8;
curl "$AESURL" -H "X-AES-KEY: 12ae8af391d" -H "Referer: https://***" -H "Age: 0" -H "X-CACHE-KEY: 14182942013" --output aeskey;
n=0;
for i in $(cat a.m3u8 | sed '/^#/d'); do
nn=$(printf "%04d\n" $n);
echo $nn $i;
curl "$i" --output $nn.ets;
n=$((n+1));
@morganabc
morganabc / entrypoint
Created February 29, 2024 00:02
Multiple instance of user-installed Flatpak.
#!/bin/bash
set -euo pipefail
if [ ! -v FLATPAK_ID ]; then echo "Not in Flatpak."; exit; fi;
DEFAULT_COMMAND=$(cat /app/manifest.json | python3 -c "import sys, json; print(json.load(sys.stdin)['command'])");
NEW_HOME="${HOME}/.altvar"
NEW_APP_DIR="${NEW_HOME}/app/${FLATPAK_ID}"