Skip to content

Instantly share code, notes, and snippets.

@TTTPOB
TTTPOB / socat@.service
Created January 24, 2021 13:35
socat systemd unit file for wsl2 to forward a port to windows host
[Unit]
Description=Socat Greeting Service
Documentation=man:socat(1)
[Service]
User=root
Group=root
#ExecStart=/bin/bash -c "/usr/bin/env WSL_HOST=`tail -1 /etc/resolv.conf |cut -d' ' -f2` socat tcp-l:%i,fork,reuseaddr tcp:$WSL_HOST:%i "
ExecStart=/bin/bash -c "socat tcp-l:%i,fork,reuseaddr tcp:`tail -1 /etc/resolv.conf |cut -d' ' -f2`:%i"
Restart=on-success
@TTTPOB
TTTPOB / zfsMonitor.service
Created February 16, 2021 15:44
oversimplified script to monitor zpool status and send it to telegram via a bot
[Unit]
Description=Monitoring the zpool on my machine
[Service]
ExecStart=/usr/local/bin/zfsMonitor
Type=oneshot
StandardOutput=journal
User=root
@TTTPOB
TTTPOB / SRR2fqgz.py
Last active April 15, 2021 12:50
NCBI SRR to fastq.gz, save your time by skipping the `fasterq-dump`
#!/usr/bin/env python
# coding: utf-8
# see https://blog.tpob.xyz/2021/03/24/%E6%9B%B4%E5%BF%AB%E4%B8%8B%E8%BD%BDsra%E6%95%B0%E6%8D%AE%E5%BA%93%E4%B8%AD%E7%9A%84fastq.gz%E6%96%87%E4%BB%B6/ for more
import requests
import json
import sys
accesion=sys.argv[1]
@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"
@TTTPOB
TTTPOB / 全局字体替换.css
Created April 28, 2021 04:25
全局字体替换
@namespace url(http://www.w3.org/1999/xhtml);
/*!
* custom-yahei-family.css
* https://n2o.io/go?page=custom.css
*
* Copyright 2018 Francis Zhao <francis@n2o.io>
* https://n2o.io/license
*
* Date: 2018-03-11T15:00+06:00
@TTTPOB
TTTPOB / send.py
Created May 13, 2021 11:04
send message to wecom (企业微信) by phone number
#!/bin/env python3
## the reason why i use urllib is to minimize dependency requiremnts
## the reason i dont user serverchan (https://sc.ftqq.com/) is that i want a multiuser support
from urllib import request
import sys
import json
## Please Change xxxxxx to the value you have
CORPID="xxxxxx"
MSGSECRET="xxxxxx"
@TTTPOB
TTTPOB / read_compute_matrix_result.r
Created September 24, 2021 07:15
read matrix file generated by deeptools computeMatrix into R
readComputeMatrixResult<-function(dfPath,offset=6){
library(rjson)
library(tidyverse)
df<-read_tsv(file=dfPath,col_names=F,col_types=cols(),skip=1)
metadata<-readLines(gzfile(dfPath),1)%>%str_remove("^@")%>%fromJSON(json_str=.)
dfSplited<-list()
for(i in 1:length(metadata$sample_labels)){
dfSplited<-c(
dfSplited,
@TTTPOB
TTTPOB / getsrr.py
Last active October 15, 2021 12:49
simple script to get srr from gsm or srx accesion, useful when you need to download many srr data
#!/usr/bin/env python3
import httpx
from bs4 import BeautifulSoup as bs
from xml.etree import ElementTree as ET
import click
import re
# see https://blog.tpob.xyz/2021/10/14/%E6%9B%B4%E5%BF%AB%E8%8E%B7%E5%BE%97srr-accession/
# for more information
@TTTPOB
TTTPOB / bedcolumnname.r
Created October 15, 2021 13:50
bed file column name
bedcolname<- c(
"seqnames",
"start",
"end",
"name",
"score",
"strand"
)
@TTTPOB
TTTPOB / shiftandmove_reference_for_computeMatrix.r
Created October 15, 2021 13:53
when using deeptools computeMatrix, you wont be able to get the central point "central", you need to shift the point half the binsize, and add a new bin
#!/usr/bin/env Rscript
suppressPackageStartupMessages({
library(tidyverse)
})
args <- commandArgs(trailingOnly = TRUE)
bed <- args[1]
distshift <- args[2] %>% as.numeric()
chromsize <- args[3]
# debug only