Skip to content

Instantly share code, notes, and snippets.

View SeanSyue's full-sized avatar
🏔️
Nature Lover

Yuchen Xue SeanSyue

🏔️
Nature Lover
View GitHub Profile
@SeanSyue
SeanSyue / Dockerfile
Last active February 2, 2024 06:48
Dockerfile for building pytorch, pyplot & cv2
View Dockerfile
##############################################################################
# Dockerfile for building an image with non-root privilege as default
# In addition, it's capable of displaying images created by
# `cv2.imshow()` and `plt.show()`
# In order to use the full functionality, one should
#
# 1. Run the command `xhost +local:docker`
#
# 2. build an image by including
@SeanSyue
SeanSyue / Dockerfile
Created February 1, 2024 12:52
Build opencv inside a docker image
View Dockerfile
# ref:
# https://github.com/Valian/docker-python-opencv-ffmpeg/blob/master/Dockerfile-py3-cuda
ARG CUDA_VERSION="10.0"
ARG FLAVOR="runtime"
FROM nvidia/cuda:${CUDA_VERSION}-cudnn7-${FLAVOR}-ubuntu16.04
ARG OPENCV_VERSION="4.1.0"
# Install all dependencies for OpenCV
RUN apt-get -y update && \
@SeanSyue
SeanSyue / main.py
Created February 1, 2024 12:50
ImportDocstring
View main.py
import mymodule
print(mymodule.__doc__)
print(mymodule.f.__doc__)
@SeanSyue
SeanSyue / nested_mapping_serializer.py
Created December 9, 2023 09:55
A generator function that flattens a nested `Mapping` object.
View nested_mapping_serializer.py
from typing import Any, TypeAlias, TypeVar, Union
from collections.abc import MutableSequence, Iterable, Mapping, Iterator
import copy
MS = TypeVar("MS", bound=MutableSequence)
Nested: TypeAlias = Mapping[Any, Union[Iterable, "Nested"]]
def nested_mapping_serializer(
@SeanSyue
SeanSyue / IndexableNamespace.py
Last active January 31, 2024 18:25
An extension of the SimpleNamespace type, where the members of whose IndexableNamespace instance can also be accessed and modified by indexing.
View IndexableNamespace.py
from types import SimpleNamespace
from typing import Any
from collections.abc import MutableSequence
class IndexableNamespace(SimpleNamespace, MutableSequence):
"""
An extension of the SimpleNamespace type.
The members of an IndexableNamespace instance can also be
accessed and modified by indexing.
@SeanSyue
SeanSyue / Julia-learning.ipynb
Created November 27, 2023 09:06
Get started with Julia using Jupyter Notebook
View Julia-learning.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@SeanSyue
SeanSyue / Dockerfile
Created June 17, 2020 15:49
Yumdownloader Dockerfile
View Dockerfile
# docker image to download yum rpms via dependencies
# these are the centos tags you can use below if you want to use a different version of centos
#latest, centos7, 7 (docker/Dockerfile)
#centos6, 6 (docker/Dockerfile)
#centos5, 5 (docker/Dockerfile)
#centos7.1.1503, 7.1.1503 (docker/Dockerfile)
#centos7.0.1406, 7.0.1406 (docker/Dockerfile)
#centos6.7, 6.7 (docker/Dockerfile)
#centos6.6, 6.6 (docker/Dockerfile)
#centos5.11, 5.11 (docker/Dockerfile)
View bootstrap_docker_ip.sh
###### Get docker machine ip ######
# able to resolve docker ip for both Docker Toolbox and Docker Desktop
if [[ -z "${DOCKER_HOST_IP-}" ]]; then
docker_host_ip=$(docker run --rm --net host alpine ip address show eth0 | awk '$1=="inet" {print $2}' | cut -f1 -d'/')
# Work around Docker for Mac 1.12.0-rc2-beta16 (build: 9493)
if [[ $docker_host_ip = '192.168.65.2' ]]; then
docker_host_ip=$(/sbin/ifconfig | grep -v '127.0.0.1' | awk '$1=="inet" {print $2}' | cut -f1 -d'/' | head -n 1)
fi
export DOCKER_HOST_IP=$docker_host_ip
@SeanSyue
SeanSyue / remove_android_studio.sh
Created July 12, 2019 04:07
Remove Android Studio on MacOS
View remove_android_studio.sh
# https://stackoverflow.com/questions/17625622/how-to-completely-uninstall-android-studio/18458893#18458893
# with small modification
rm -Rf /Applications/Android\ Studio.app
rm -Rf ~/Library/Preferences/AndroidStudio*
rm -Rf ~/Library/Preferences/com.google.android.*
rm -Rf ~/Library/Preferences/com.android.*
rm -Rf ~/Library/Application\ Support/AndroidStudio*
rm -Rf ~/Library/Android/*
rm -Rf ~/Library/Logs/AndroidStudio*
rm -Rf ~/Library/Caches/AndroidStudio*
@SeanSyue
SeanSyue / remove_python_macos.sh
Created July 12, 2019 04:07
Remove python 3.6 on MacOS
View remove_python_macos.sh
sudo rm '/usr/local/bin/2to3'
sudo rm '/usr/local/bin/2to3-3.6'
sudo rm '/usr/local/bin/idle3'
sudo rm '/usr/local/bin/idle3.6'
sudo rm '/usr/local/bin/pydoc3'
sudo rm '/usr/local/bin/pydoc3.6'
sudo rm '/usr/local/bin/python3'
sudo rm '/usr/local/bin/python3-32'
sudo rm '/usr/local/bin/python3-config'
sudo rm '/usr/local/bin/python3.6'