Skip to content

Instantly share code, notes, and snippets.

@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
setInterval(() => {
if (document.querySelector(".tfny-circleGreen")) {
console.log("click");
document.querySelector(".tfny-circleGreen").dispatchEvent(new Event('mousedown'));
}
}, 10);
@linnil1
linnil1 / pipeline_.py
Last active July 22, 2021 06:37
Python pipeline using docker follow this tutorial https://rnabio.org/module-01-inputs/0001/05/01/RNAseq_Data/
import os
import time
os.makedirs("data/", exist_ok=True)
hg38 = "data/GRCh38_latest_genomic"
image_fastqc = "quay.io/biocontainers/fastqc:0.11.9--0"
image_trimmomatic = "quay.io/biocontainers/trimmomatic:0.39--hdfd78af_2"
image_hisat = "quay.io/biocontainers/hisat2:2.2.1--he1b5a44_2"
image_samtool = "quay.io/biocontainers/samtools:1.10--h9402c20_2"