Skip to content

Instantly share code, notes, and snippets.

View Keiku's full-sized avatar
🐢
Slowly but surely.

Keiichi Kuroyanagi Keiku

🐢
Slowly but surely.
View GitHub Profile
@Keiku
Keiku / command.sh
Last active March 13, 2023 10:40
A list of linux commands.
# compress/decompress zip file.
zip file.csv.zip file.csv
unzip file.csv.zip
# compress/decompress gz file.
gzip file.csv
gzip -d file.csv.gz
# compress/decompress bz2 file.
bzip2 file.csv
@Keiku
Keiku / convert_number_strings_to_numbers.py
Last active January 8, 2023 20:45
Convert number strings with commas in pandas DataFrame to float.
import pandas as pd
import locale
from locale import atof
df = pd.DataFrame([['1,200', '4,200'], ['7,000', '-0.03'], ['5', '0']],
columns=['col1', 'col2'])
# col1 col2
# 0 1,200 4,200
# 1 7,000 -0.03
# 2 5 0
@Keiku
Keiku / roc_auc.py
Last active October 5, 2022 01:52
Plot ROC curve.
import matplotlib.pyplot as plt
from sklearn.metrics import roc_curve, auc
import seaborn as sns
sns.set('talk', 'whitegrid', 'dark', font_scale=1.5, font='Ricty',
rc={"lines.linewidth": 2, 'grid.linestyle': '--'})
fpr, tpr, _ = roc_curve([1, 0, 1, 0, 1, 0, 0], [0.9, 0.8, 0.7, 0.7, 0.6, 0.5, 0.4])
roc_auc = auc(fpr, tpr)
@Keiku
Keiku / pip_install_unreleased_main_repository.sh
Created April 19, 2022 09:20
pip install the unreleased main repository
# pip install the unreleased main repository
git clone https://github.com/pypa/pipenv.git
python setup.py develop --user
# or below command
pip install git+https://github.com/pypa/pipenv.git --user
# add PATH for fish shell
set -U fish_user_paths /home/anasys/.local/bin $fish_user_paths
@Keiku
Keiku / use_cuda11.3_on_ubuntu16.04_cuda10.2.md
Created March 28, 2022 07:42
Use CUDA 11.3 in Ubuntu 16.04 and CUDA 10.2 environment
> ~/c/docker-compose cat docker-compose.yaml                                                                                                                      16:33:48
services:
  test:
    image: nvidia/cuda:11.3.1-cudnn8-devel-ubuntu20.04
    command: nvidia-smi
    environment:
     - NVIDIA_DISABLE_REQUIRE=1
    deploy:
      resources:
@Keiku
Keiku / update_pipfile.sh
Created November 23, 2021 04:58
Update for pillow alerts on pipenv on Github
# delete pillow package
emacs Pipfile
# delete below package
# [packages]
# pillow
pipenv clean
# install pillow package
emacs Pipfile
# add below package
@Keiku
Keiku / update_mirror_repository.sh
Last active September 9, 2021 06:52
Reflect changes in the original repository in the mirror repository.
# I refer to "git --How do I update my bare repo? --Stack Overflow https://stackoverflow.com/questions/3382679/how-do-i-update-my-bare-repo"
# Create mirror repository
git clone --bare https://github.com/Keiku/test1.git
cd test1.git
git push --mirror https://github.com/Keiku/test2.git
# Promote development with mirror repository
cd ../
git clone https://github.com/Keiku/test2.git
@Keiku
Keiku / get_indices_in_conditions_from_2d_array.py
Created August 5, 2021 05:17
Get the index that meets the conditions from the 2d array
import numpy as np
# sample array
array = np.array([[1, 1, 1, 0, 0, 0],
[1, 1, 1, 0, 0, 0]])
# get row index and col index
rows, cols = np.where(array == 1)
# Convert row index and column index to 2d array
np.transpose((rows, cols))
# array([[0, 0],
@Keiku
Keiku / get_filename_including_parent_dir.py
Created July 10, 2020 06:29
Get file name including parent folder.
import pathlib
path = pathlib.Path('home/path/to/file.txt')
root = path.parent.parent
# PosixPath('home/path')
path.relative_to(root)
# PosixPath('to/file.txt')
@Keiku
Keiku / insightface_demo.py
Created July 2, 2020 13:10
InsightFace demo for face detection
# Reference: 1. Getting Started with Pre-trained Model from RetinaFace — insightface 0.1.5 documentation http://insightface.ai/build/examples_face_detection/demo_retinaface.html
# How to install insightface
# pip install insightface
# pip install mxnet-cu100
import insightface
import urllib
import urllib.request
import cv2
import numpy as np