Skip to content

Instantly share code, notes, and snippets.

@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==
@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
#!/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 / 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 / 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"
@TTTPOB
TTTPOB / get_sequence_location_on_genome.py
Created February 3, 2022 15:49
get sequence location on genome, advantage of this script is that it will recognize GGGG as 2 NGG sites.
#!/usr/bin/env python3
import re
from multiprocessing import Pool
from Bio import SeqIO
from Bio.Seq import Seq
import click
from pathlib import Path
import pandas as pd
import numpy as np
@TTTPOB
TTTPOB / gtf_to_bed12.py
Created January 18, 2022 02:48
convert gtf provided by gencode to bed12 file that suits pyGenomeTracks(well, it can handle gtf files but absurdly slow)
#!/usr/bin/env python3
from typing import Dict, List
import pandas as pd
import click
import numpy as np
from pathlib import Path
from tqdm import tqdm
import subprocess
@TTTPOB
TTTPOB / get_promoter_by_extend.r
Created January 14, 2022 02:22
get promoter by extend from gencode gtf file
#!/usr/bin/env Rscript
docstring <- "Usage: ./get_promoter_by_extend.r <encode_gtf> <extend> <output>"
args <- docopt::docopt(docstring)
args$extend <- as.numeric(args$extend)
print(args)
suppressPackageStartupMessages({
library(tidyverse)
library(magrittr)
library(rtracklayer)
})
@TTTPOB
TTTPOB / shift_extend.py
Last active December 30, 2021 03:27
shift and extend paired end bam into a bed file
#!/usr/bin/env python3
import pysam
from collections import defaultdict
import subprocess
import click
from pathlib import Path
import pandas as pd
import numpy as np
from sys import stderr