Skip to content

Instantly share code, notes, and snippets.

View bioinformatist's full-sized avatar
🎯
Focusing

Yu Sun bioinformatist

🎯
Focusing
View GitHub Profile
@mtolk
mtolk / mermaid.html
Created September 16, 2020 12:59
This gist was created to anwser a question about using mermaidjs in the zola static site generator: https://zola.discourse.group/t/mermaid-integration/573?u=marco
<!-- should be in templates/ -->
<html>
<head>
<style>
div.mermaid {
width:25%;
}
</style>
</head>
<body>
@okld
okld / multipage_settings_app.py
Last active July 6, 2025 21:46
Streamlit - Settings page with session state
import streamlit as st
from persist import persist, load_widget_state
def main():
if "page" not in st.session_state:
# Initialize session state.
st.session_state.update({
# Default page.
"page": "home",
@Alvtron
Alvtron / pytorch_stratified_split.md
Last active July 22, 2024 08:12
Split a PyTorch Dataset into two subsets using stratified random sampling.

Stratified dataset split in PyTorch

When working with imbalanced data for machine learning tasks in PyTorch, and simple random split might not be able to partly divide classes that are not well represented. Resulting sample splits might not portray the real-world population, leading to poor predictive peformance in the resulting model.

Therefore, I have created a simple function for conducting a stratified split with random shuffling, similar to that of StratifiedShuffleSplit from scikit-learn (https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.StratifiedShuffleSplit.html)

import random
import math
import torch.utils.data
@takidog
takidog / main.py
Created October 19, 2019 18:21
push RTSP stream with ffmpeg by python
import cv2
import subprocess as sp
if __name__ == "__main__":
rtsp_server = 'rtsp://example.org:554/...' # push server (output server)
#pull rtsp data, or your cv cap. (input server)
cap = cv2.VideoCapture(
'rtsp://example.org:554/pull from me ')
@y0ngb1n
y0ngb1n / docker-registry-mirrors.md
Last active November 5, 2025 09:59
国内的 Docker Hub 镜像加速器,由国内教育机构与各大云服务商提供的镜像加速服务 | Dockerized 实践 https://github.com/y0ngb1n/dockerized

bcache

bcache 实测对于小文件随机写场景下效果好,而且减少了小写的延迟。

目前 bcache 这类方案主要的问题是过于复杂,难以实现和维护。

Intro

引入块层的缓存对于优化磁盘的读写性能来说效果显著。块级别的缓存有多种实

@mdonkers
mdonkers / server.py
Last active October 23, 2025 16:32
Simple Python 3 HTTP server for logging all GET and POST requests
#!/usr/bin/env python3
"""
License: MIT License
Copyright (c) 2023 Miel Donkers
Very simple HTTP server in python for logging requests
Usage::
./server.py [<port>]
"""
from http.server import BaseHTTPRequestHandler, HTTPServer
@afzafri
afzafri / ImagePixelCoordinate.html
Last active July 29, 2024 02:25
Image Pixel Coordinate Generator. A simple Javascript web application for my Smartwatch Watch Face website, use to find the pixel coordinate in a photo, for watch face making purpose.
<p>Choose your clock_bg Photo</p>
<!-- choose image file, on choose, automatically set to the canvas -->
<input type="file" id="imageLoader" name="imageLoader"/>
<!-- hide the tool, only show once file is choosen -->
<div id="toolArea" style="display: none;">
<p>Click on the image to place a marker<br> The markers on the image will show the coordinates value in decimal, while the table below will show the coordinates in Hex value.</p>
<!-- draw image and markers on the canvas here -->
<canvas id="Canvas" width="240" height="240"></canvas>