Skip to content

Instantly share code, notes, and snippets.

@TTTPOB
TTTPOB / pam.py
Created April 28, 2024 08:45
mark pam
#!/usr/bin/env python3
import argparse
import re
from pyfaidx import Fasta
mainchr_re = re.compile(r"chr[0-9XY]{1,2}$")
pam_re = re.compile(r"(?=(.GG))")
@TTTPOB
TTTPOB / reveal-nature-journals.user.js
Last active April 17, 2024 02:03
reveal nature journal names in google search results
// ==UserScript==
// @name Nature Article Journal Modifier for Google Search
// @namespace http://tampermonkey.net/
// @version 1.3
// @description Modify Nature article titles in Google Search results to display their journal names, using Fetch API
// @author tttpob
// @match https://www.google.com/search?*
// @grant none
// ==/UserScript==
#!/usr/bin/env python3
import os
import re
def parse_podman_service(service_content):
result = {"name": None, "ip": None}
if not re.search(r'^ExecStart=(/usr/bin/podman|podman)\s', service_content, re.MULTILINE):
return result
ip_match = re.search(r'--ip(\s+|=)(\d+\.\d+\.\d+\.\d+)', service_content)
name_match = re.search(r'(?:--name|-n)(\s+|=)([\w-]+)', service_content)
@TTTPOB
TTTPOB / script.js
Last active March 9, 2024 09:29
render latex equations in claude chat
// ==UserScript==
// @name Claude Equation Renderer
// @namespace http://tampermonkey.net/
// @author tpob
// @downloadURL https://gist.github.com/TTTPOB/84ea9ece3ec640414416649fae09ff04/raw/script.js
// @updateURL https://gist.github.com/TTTPOB/84ea9ece3ec640414416649fae09ff04/raw/script.js
// @version 0.0.2
// @description Renders LaTeX equations in claude
// @match https://claude.ai/chat/*
// @grant none
@TTTPOB
TTTPOB / relpath.py
Last active May 30, 2023 05:03
A Python script that recursively searches for a parent directory containing specific marker files (.git, .here, etc.). The script prints the relative path of the current directory or specified files to this parent directory. Useful for generating relative paths within structured projects or repositories.
#!/usr/bin/env python
import os
import sys
def eprint(*args, **kwargs):
print(*args, file=sys.stderr, **kwargs)
def find_marker_dir(start_path, markers):
@TTTPOB
TTTPOB / MSService.list
Last active March 11, 2023 17:20
https://docs.microsoft.com/en-us/office365/enterprise/urls-and-ip-address-ranges domains(plus some windows related domains) for clash and surge list
DOMAIN-SUFFIX,aadrm.com
DOMAIN-SUFFIX,acompli.com
DOMAIN-SUFFIX,acompli.net
DOMAIN-SUFFIX,aka.ms
DOMAIN-SUFFIX,akadns.net
DOMAIN-SUFFIX,aspnetcdn.com
DOMAIN-SUFFIX,assets-yammer.com
DOMAIN-SUFFIX,azure.com
DOMAIN-SUFFIX,azure.net
DOMAIN-SUFFIX,azureedge.net
@TTTPOB
TTTPOB / extract_gene_id_name_mapping.py
Created February 28, 2023 10:51
extract gencode gtf file gene id and gene name mapping
#!/usr/bin/env python3
import gzip
import sys
from pathlib import Path
def get_gene_lines(path: str):
with gzip.open(path, "rt") as f:
for l in f:
if l.startswith("##"):
@TTTPOB
TTTPOB / edge-scroll.ps1
Created February 3, 2023 08:43
process msedge browser shortcut and registry entry, to enable overlay scrollbar
# scrollbar args
$scrollbar_args = "--enable-features=OverlayScrollbar,OverlayScrollbarWinStyle,OverlayScrollbarWinStyleAnimation"
# ms edge lnk path
$desktop_lnk = "C:\Users\Public\Desktop\Microsoft Edge.lnk"
$start_lnk = "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Edge.lnk"
# registry path
$reg_path = "HKCR\MSEdgeHTM\shell"
# save this script somewhere and invoke it in shell.nix shellHook
# it will read current r and radian path and write it to vscode
# workspace settings
# jq required
settings=.vscode/settings.json
mkdir -p .vscode
echo '{}' > $settings
rpath_exsits=$(cat $settings|jq '."r.rpath.linux"')
rterm_exsits=$(cat $settings|jq '."r.rterm.linux"')
not_exsist="null"
@TTTPOB
TTTPOB / call-this-on-server-with-arg.py
Created April 11, 2021 13:52
telegram bot send message via cloudflare worker (for server notification like job done)
#!/usr/bin/env python3
from urllib import request
import sys
import json
TOKEN="16181xxxxx:xxxxxxxxxxxxxxx"
CHAT="-100118639xxxx"
TEXT=sys.argv[1]
SERVER="what ever name you want"