Skip to content

Instantly share code, notes, and snippets.

View ferstar's full-sized avatar
🎯
Focusing

J. F. Zhang ferstar

🎯
Focusing
View GitHub Profile
@ferstar
ferstar / delete_action_runs.py
Created January 7, 2022 01:25
Delete all workflow runs&artifacts of a github repo
import asyncio
import sys
from aiohttp import ClientSession, ClientTimeout
def seq_iter(seq, step=10):
if not seq:
return seq
from_idx, to_idx, seq_len = 0, step, len(seq)
@ferstar
ferstar / rm duplicate items.py
Last active February 26, 2020 15:04
code board
a_list = [
{"型号": 12, "重量": 16, "产地": 19, "审核人": 33},
{"型号": 22, "重量": 92, "产地": 87, "审核人": 34},
{"型号": 15, "重量": 27, "产地": 86, "审核人": 35},
{"型号": 71, "重量": 55, "产地": 21, "审核人": 36},
]
b_list = [
{"产地": 87, "型号": 22, "重量": 92, "审核人": 34},
{"产地": 86, "型号": 15, "重量": 27, "审核人": 35},
@ferstar
ferstar / upload_file_to_tmp_link.py
Last active July 12, 2022 04:17
Temporarily upload files to TMPLINK
@ferstar
ferstar / SimpleHTTPServerWithUpload.py
Last active June 12, 2019 08:48 — forked from touilleMan/SimpleHTTPServerWithUpload.py
Simple Python Http Server with Upload - Python3 version
#!/usr/bin/env python3
"""Simple HTTP Server With Upload.
This module builds on BaseHTTPServer by implementing the standard GET
and HEAD requests in a fairly straightforward manner.
see: https://gist.github.com/UniIsland/3346170
"""
@ferstar
ferstar / deseq2-analysis-template.R
Created March 9, 2018 09:53 — forked from stephenturner/deseq2-analysis-template.R
Template for analysis with DESeq2
## RNA-seq analysis with DESeq2
## Stephen Turner, @genetics_blog
# RNA-seq data from GSE52202
# http://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=gse52202. All patients with
# ALS, 4 with C9 expansion ("exp"), 4 controls without expansion ("ctl")
# Import & pre-process ----------------------------------------------------
# Import data from featureCounts
@ferstar
ferstar / ip_mask.py
Created October 11, 2017 09:10
初学 Python ,求大佬指导个 Python 思路 https://www.v2ex.com/t/396718
import sys
def main(fp):
print('ip\tmask')
with open(fp, 'r') as fh:
for line in fh:
line_trim = line.strip()
if line_trim.startswith('ip address'):
lst = line_trim.split()
@ferstar
ferstar / code_highlight_addon.py
Last active April 8, 2018 15:09
fix an anki plugin bugs which was called "Syntax Highlighting for Code"
# -*- coding: utf-8 -*-
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import codecs
import os
import sys
from aqt import editor, addons, mw
@ferstar
ferstar / kk_change_ip.sh
Created June 20, 2017 03:08
change switch ip when it changes
#!/bin/sh
PATH=/usr/bin:/sbin:/bin
SW_FILE=/www/switches.json
NOW_IP=$(ifconfig wlan0 | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | head -n 1)
OLD_IP=$(jq -r '.switches[0].ip' ${SW_FILE})
if [ ${NOW_IP} != ${OLD_IP} ]; then
echo "ip changes detected, I'll update the ${SW_FILE}"
jq --arg v ${NOW_IP} '.switches[0].ip=$v' ${SW_FILE} > /tmp/tmp.json
@ferstar
ferstar / color_msg.sh
Last active June 26, 2017 03:31
color bash prompt with timestamp ahead
#!/bin/bash
color_msg() {
if [ $# -gt 2 ]; then
echo -e "\033[1;31mUsage: ${0} [error|-e|info|-i|warn|-w] "your message".\033[0m"
fi
now_time=$(date '+[%Y/%m/%d %H:%M:%S]')
case ${1} in
# red
error|-e )
echo -e "${now_time}\t\033[1;31m${2}\033[0m"
@ferstar
ferstar / gist:71179b2e90e48d2a022da5dbef5e1199
Last active June 14, 2017 05:40 — forked from mjg59/gist:ab1e9a6e60ef96ca9565ae09690a396b
Running fine on Windows 10 x64 & Python 3.5.2 but nothing happened.
#!/usr/bin/python
import subprocess
import socket
import sys
def encode_packet(data):
output = bytearray()
for i in range(0, len(data)):