Skip to content

Instantly share code, notes, and snippets.

View dceoy's full-sized avatar
Lazy

Daichi Narushima dceoy

Lazy
View GitHub Profile
@dceoy
dceoy / install_pyenv.sh
Last active May 7, 2019 10:12
[Shell] Install the latest version of Python with pyenv
#!/usr/bin/env bash
#
# https://github.com/dceoy/ansible-dev/blob/master/roles/python/files/install_pyenv.sh
set -uex
PYENV_DIR="${HOME}/.pyenv"
PYENV="${PYENV_DIR}/bin/pyenv"
[[ ${#} -ge 1 ]] && PY_MAJOR_VER="${1}" || PY_MAJOR_VER=3
@dceoy
dceoy / install_bio_stack.sh
Last active March 13, 2019 22:00
[Shell] Install BWA, Samtools, Bcftools, and Bedtools
#!/usr/bin/env bash
#
# Usage: ./install_bio_stack.sh <dest dir path>
set -uex
PREFIX_DIR=$(realpath "${1}")
BIN_DIR="${PREFIX_DIR}/bin"
SRC_DIR="${PREFIX_DIR}/src"
mkdir -p "${SRC_DIR}" "${BIN_DIR}"
@dceoy
dceoy / subprocess_line_generator.py
Last active December 4, 2018 14:25
[Python] Generate STDOUT lines from subprocess
#!/usr/bin/env python
import subprocess
def run_and_parse_subprocess(**popen_args):
with subprocess.Popen(**popen_args) as p:
for line in p.stdout:
yield line.decode('utf-8')
if p.poll() == 0:
@dceoy
dceoy / install_cudnn.sh
Created October 12, 2018 06:52
[CUDA] Configure CUDA
#!/usr/bin/env bash
#
# Usage: ./install_cudnn.sh <tar file>
set -ex
[[ -n "${1}" ]] \
&& tar -xzvf ${1} -C /tmp \
&& cp /tmp/cuda/include/cudnn.h /usr/local/cuda/include \
&& cp /tmp/cuda/lib64/libcudnn* /usr/local/cuda/lib64 \
@dceoy
dceoy / HotelligT2.py
Last active October 12, 2018 06:54
[Python] Hotelling's T-squared anomaly detection
#!/usr/bin/env python
import numpy as np
from scipy import stats
class HotellingsT2(object):
def __init__(self, alpha):
self.anomaly_score_threshold = stats.chi2.ppf(q=(1 - alpha), df=1)
@dceoy
dceoy / install_packages.R
Last active June 17, 2018 18:04
[R] Install R packages
#!/usr/bin/env Rscript
if(length(argv <- commandArgs(trailingOnly = TRUE)) > 0) {
install.packages(pkgs = argv,
repos = c(CRAN = 'https://cran.rstudio.com/'),
dependencies = TRUE)
} else {
message('Nothig to do.')
}
@dceoy
dceoy / disable_DS_Store.sh
Created May 9, 2018 13:01
[Shell] Disable .DS_Store in macOS
defaults write com.apple.desktopservices DSDontWriteNetworkStores True
@dceoy
dceoy / docker-compose.yml
Last active August 30, 2018 09:09
[Docker Compose] Run a Hugo server
---
version: '3'
services:
hugo:
container_name: hugo
image: dceoy/hugo:latest
user: ${UID}:${GID}
ports:
- 1313:1313
@dceoy
dceoy / download_pkg.sh
Created February 15, 2018 20:23
[Shell] Download Python and R packages
#!/usr/bin/env bash
#
# Usage:
# ./download_pkg.sh \
# --py-pkg ./py_requirements.txt \
# --r-pkg ./r_requirements.txt \
# --py-dir ./src/py \
# --r-dir ./src/r
#
# Options:
@dceoy
dceoy / read_vcf.py
Last active July 31, 2025 05:38
[Python] Read VCF (variant call format) as pandas.DataFrame
#!/usr/bin/env python
import io
import os
import pandas as pd
def read_vcf(path):
with open(path, 'r') as f:
lines = [l for l in f if not l.startswith('##')]