Skip to content

Instantly share code, notes, and snippets.

@linnil1
linnil1 / calculator.py
Created February 14, 2023 07:37
Calculator made by python
from typing import Any, Iterable
from operator import add, sub, mul, truediv, neg
op_func: dict[str, Any] = {"+": add, "-": sub, "*": mul, "/": truediv, "**": pow, "--": neg}
op_param: dict[str, int] = {"+": 2, "-": 2, "*": 2, "/": 2, "**": 2, "--": 1}
priority: dict[str, int] = {"+": 0, "-": 0, "*": 2, "/": 2, "**": 5, "--": 4}
op_set = ["**", "*", "+", "-", "/", "(", ")"]
num_set = "0123456789."
@linnil1
linnil1 / Dockerfile
Created December 5, 2022 09:37
Dockerfile for hla-la version 1.0.3 built in alpine for fun. Inspired by https://github.com/zlskidmore/docker-hla-la
FROM alpine
WORKDIR /usr/local/bin
# samtools
ENV samtools_version 1.16.1
RUN apk add g++ make ncurses-dev zlib-dev xz-dev bzip2-dev curl-dev
RUN wget https://github.com/samtools/samtools/releases/download/${samtools_version}/samtools-${samtools_version}.tar.bz2 && \
tar -xjf samtools-${samtools_version}.tar.bz2 && \
cd samtools-${samtools_version}/ && \
./configure && \
@linnil1
linnil1 / Dockerfile
Last active November 29, 2022 13:42
Example code for fashion-MNIST by tensorflow and pytorch with docker to test server's enviornment.
FROM docker.io/nvidia/cuda:11.8.0-cudnn8-devel-ubuntu22.04
RUN apt update -y && apt install -y python3-pip
RUN pip install tensorflow torch torchvision tqdm pillow
@linnil1
linnil1 / show_current_time.py
Created October 24, 2022 08:00
Show the current time per 10 seconds to trick idle detecting
import time
while True:
print(f"{time.ctime():30s}", end="")
print("\b" * 30, end="", flush=True)
time.sleep(10)
@linnil1
linnil1 / server_api_form.ts
Created May 5, 2022 11:06
Handle form data (file) in Nuxt3 h3 server
import {File} from 'fetch-blob/file.js'
import {Blob} from 'buffer'
import {default: Busboy} from 'busboy'
async function readForm(req) {
// My implementation is similar to
// https://github.com/cloudflare/miniflare/blob/master/packages/core/src/standards/http.ts#L302
const data = {}
await new Promise( (resolve) => {
"""
Airflow Example: Build a dynamic read-mapping DAG for multiple samples
Author: linnil1
Run bowtie2(read-maper) on two samples to a reference fasta
1. Prepare data like this
```
$ ls /home/linnil1/airflow/data/
@linnil1
linnil1 / replace_uidgid.py
Last active December 15, 2021 02:29
Change all UID and GID from old system to new system
# Replacing all UID, GID in directorary
# Requirement: python3.6
# Usage: python3 replace_uidgid.py old_etc_passwd old_etc_group new_etc_passwd new_etc_group /home --dry-run -vv
# Author: linnil1
import os
import argparse
from collections import defaultdict
import pathlib
@linnil1
linnil1 / aiohttp_with_cronjob.py
Last active December 3, 2021 08:53
aiohttp + aiocron
# Example of running aiohttp and aiocron together
#
# Packages: aiohttp==3.8.1 aiocron==1.8
# Tested python version: python:3.10.0
# Issue: aircron not working once aiohttp start
# Solution Concept: Both share the same event loop
import logging
import asyncio
import aiocron
from aiohttp import web
import csv
import os
import shutil
def hash_id(id):
# input 12
# output 000/dataset_12.dat
s = str(id)
l = len(s)
@linnil1
linnil1 / webhook.py
Created October 5, 2021 16:31
Github webhook by aiohttp
import asyncio
import hmac
import json
from aiohttp import web
# custom import
from datetime import datetime
from pprint import pprint