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 / 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 January 23, 2024 12:42
[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('##')]
@dceoy
dceoy / pypi_upload.sh
Created May 15, 2017 15:55
[Linux] Upload a Python package to PyPI
python setup.py bdist_wheel
twine upload dist/*.whl
@dceoy
dceoy / install_vbox_guest_additions.sh
Last active June 3, 2018 17:48
[Linux] Install the latest version of VirtualBox Guest Additions
#!/usr/bin/env bash
#
# # Mount vboxsf
# $ sudo mount -t vboxsf vbox ~/synced
set -uex
v=$(curl http://download.virtualbox.org/virtualbox/LATEST.TXT)
curl http://download.virtualbox.org/virtualbox/${v}/VBoxGuestAdditions_${v}.iso -o /tmp/vbga.iso
sudo mount -t iso9660 /tmp/vbga.iso /mnt/
@dceoy
dceoy / install_rundeck.sh
Last active February 3, 2017 06:11
[Ubuntu] Install Rundeck
#!/usr/bin/env bash
wget -q -O - https://bintray.com/user/downloadSubjectPublicKey?username=bintray | sudo apt-key add -
echo 'deb http://dl.bintray.com/rundeck/rundeck-deb /' | sudo tee -a /etc/apt/sources.list.d/rundeck.list
echo 'deb-src http://dl.bintray.com/rundeck/rundeck-deb /' | sudo tee -a /etc/apt/sources.list.d/rundeck.list
sudo apt-get -y update
sudo apt-get -y install rundeck
@dceoy
dceoy / bayes_factor.cpp
Created December 28, 2015 16:44
[R] Bayes Factor from 2 x 2 contingency table
// [[Rcpp::plugins("cpp11")]]
#include <Rcpp.h>
using namespace Rcpp;
double bf(NumericVector v, int n) {
int h = sum(rbeta(n, 1 + v[0], 1 + v[1]) > rbeta(n, 1 + v[2], 1 + v[3]));
if (h == n) {
return R_PosInf;
} else {
@dceoy
dceoy / mcmc_logit.R
Created June 4, 2015 00:28
[R] Logistic Regression using MCMCpack
#!/usr/bin/env Rscript
sapply(c('dplyr', 'data.table', 'MASS', 'MCMCpack'), function(p) require(p, character.only = TRUE))
# Biopsy Data on Breast Cancer Patients
#
# variables:
# 'V1' clump thickness.
# 'V4' marginal adhesion.
# 'class' "benign" or "malignant".
#!/usr/bin/env Rscript
# Diabetes survey on Pima Indians
#
# variables:
# 'glucose' Plasma glucose concentration at 2 hours in an oral glucose tolerance test
# 'diabetes' Diabetes pedigree function
# 'test' test whether the patient shows signs of diabetes (coded 0 if negative, 1 if positive)
data(pima, package = 'faraway')