Skip to content

Instantly share code, notes, and snippets.

View Stfort52's full-sized avatar

Jaehoon Baek Stfort52

  • POSTECH, Lab of Computational Biology
  • South Korea
  • 03:50 (UTC +09:00)
View GitHub Profile
@Stfort52
Stfort52 / conda_here.sh
Created October 16, 2025 09:01
Adds a function here to activate conda env matching your working directory and its parents. Useful if you make conda env names from project directory name.
function init_conda_envs() {
local env_dir="$HOME/path/to/your/conda/dir/envs"
if [[ -d "$env_dir" ]]; then
export CONDA_ENVS=$(ls -1 "$env_dir" | xargs)
else
export CONDA_ENVS=""
fi
}
function here() {
@Stfort52
Stfort52 / mulsupcon.py
Created October 15, 2025 08:13
Rewrite of "Multi-Label Supervised Contrastive Learning" for more causal use
# From the paper "Multi-Label Supervised Contrastive Learning"
# https://doi.org/10.1609/aaai.v38i15.29619
# https://github.com/williamzhangsjtu/MulSupCon
from typing import Callable, Literal, overload
import torch
import torch.nn.functional as F
from torch import Tensor, nn
OUTPUT_FUNC_T = Callable[[Tensor, Tensor, Tensor], tuple[Tensor, ...]]
@Stfort52
Stfort52 / lisi.md
Last active August 6, 2025 08:01
Port of lisi from harmony

Lisipy

This is a port of the LISI algorithm from harmony in python, directly from Rcpp.

It should yield identical results as the python version while showing similar performance as the Rcpp version, thanks to the power of numba JIT.

@Stfort52
Stfort52 / candlestick.py
Last active December 26, 2024 08:49
Candlestick figure maker for fun
import pandas as pd
import matplotlib.pyplot as plt
def draw_candlestick(data, time_axis, window_size, **kwargs) -> plt.Figure:
"""
Draws a candlestick chart.
Parameters:
data (list or np.ndarray): Continuous data points.
time_axis (list or np.ndarray): Corresponding time points (timestamps or discrete steps).
from typing import Literal
import pandas as pd
def get_ensembl_mappings(
genes: list[str],
organism: str = "hsa",
server: Literal["www", "eu", "uswest", "asia", "gprofiler"] = "asia",
) -> pd.DataFrame:

Plot pytorch module parameters

A simple implementation.

plot

@Stfort52
Stfort52 / ens2seq.py
Created May 10, 2024 07:25
Simple uniprot interface, not suitable for real querying
def ens2seq(ensembl_id: str) -> str:
"""Converts ensembl gene id to protein sequence
@ensembl_id: str, ensembl gene id
"""
uri = f"https://rest.uniprot.org/uniprotkb/stream?"
query = f"({ensembl_id}) AND (reviewed:true)"
params = {
"compressed": "false",
@Stfort52
Stfort52 / celltypist-cv.ipynb
Created August 17, 2023 07:57
Train Celltypist with your data and perform 5-fold Cross-Validation
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Stfort52
Stfort52 / _vm.md
Last active December 17, 2022 05:41
Write-up for CODEGATE 2022 Finals Reversing challenge VM

CODEGATE 2022 Finals VM

Analysis

We are given a virtual machine binary called run, and a custom binary for it called VM. It has 16 registers and a flat memory. Below is the opcodes of this VM.

image

Then, we should disassemble the given program to see what's going on. disasm.py disassembles the custom binary VM into disassembly.S. Take a look at it.

@Stfort52
Stfort52 / verylog.md
Last active October 24, 2023 08:15
Write-up for CODEGATE 2022 Finals reversing challenge verylog

CODEGATE 2022 Finals verylog

TL;DR

Analysis

These modules,

  1. generate six permutation states from fixed seed (T_0)
  2. opens key.txt(T_2)
  3. reads each numbers from key.txt(T_3)
  4. generates answer by permutation (T_1)
  5. compares answer with input (T_3)