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 / 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
@Keiku
Keiku / read_column_containing_list.py
Created June 28, 2020 06:57
Read a column containing a list as a list
# Reference: python - Reading csv containing a list in Pandas - Stack Overflow https://stackoverflow.com/questions/20799593/reading-csv-containing-a-list-in-pandas
# Copy this text.
"""
HK,"[u'5328.1', u'5329.3', '2013-12-27 13:58:57.973614']"
HK,"[u'5328.1', u'5329.3', '2013-12-27 13:58:59.237387']"
HK,"[u'5328.1', u'5329.3', '2013-12-27 13:59:00.346325']"
"""
import ast
@Keiku
Keiku / concat_strings_in_all_combinations.py
Created June 28, 2020 06:49
Concatenate strings in all combinations
import itertools
['%s%s' % (x, y) for x, y in itertools.product(['a', 'b'], ['1', '2'])]
# ['a1', 'a2', 'b1', 'b2']
@Keiku
Keiku / remove_s3_files_before_specified_last_update_time.sh
Last active June 26, 2020 12:00
Remove S3 files before the specified last update time
# Remove S3 files before the specified last update time
# Reference: amazon s3 - aws cli s3 bucket remove object with date condition - Stack Overflow https://stackoverflow.com/questions/51375531/aws-cli-s3-bucket-remove-object-with-date-condition
aws s3 ls --recursive s3://path/to/ | awk '$1 < "2020-06-25 12:00:00" {print $4}' | xargs -n1 -t -I 'KEY' aws s3 rm s3://path/to/'KEY'