Skip to content

Instantly share code, notes, and snippets.

View Merwanski's full-sized avatar
:electron:
Focusing

Merwanski

:electron:
Focusing
  • Belgium
  • Belgium
View GitHub Profile
@Merwanski
Merwanski / photo2video.py
Last active January 22, 2022 21:30
photo2video.py
import cv2
import numpy as np
import glob
video_file_name = 'project.wmv'
path_to_images = 'path_2_video/*.bmp'
cmpt = 0
for filename in glob.glob(path_to_images):
@Merwanski
Merwanski / readYaml.py
Created January 17, 2022 11:42
read yaml file content
# YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe.
# Please read https://msg.pyyaml.org/load for full details.
import yaml
f = open(filaname_path, 'r')
yaml.load(f, Loader=yaml.FullLoader)
f.close()
@Merwanski
Merwanski / replace_cv_bridge.py
Last active February 17, 2022 00:45
replace cv bridge
# You could use numpy directly, instead of cv_bridge
import numpy as np
im = np.frombuffer(image_data.data, dtype=np.uint8).reshape(image_data.height, image_data.width, -1)
pi
# Another solution // Still not yet tested
# Beautiful solution is to use ros_numpy (https://github.com/eric-wieser/ros_numpy).
# It is similar to the function of cv_bridge, but without the dependency on cv2:
@Merwanski
Merwanski / new_machine_ubuntu_2004.sh
Created December 20, 2021 12:08
new_machine_ubuntu_2004
!bash
# install docker
# Step 1 — Installing Docker
# First, update your existing list of packages:
sudo apt update
# Next, install a few prerequisite packages which let apt use packages over HTTPS:
sudo apt install -y apt-transport-https ca-certificates curl software-properties-common
@Merwanski
Merwanski / clear_docker
Created December 13, 2021 13:23
clear pc from docker images / containers
# REMOVE the containers no longer running
docker rm $(docker ps -a -q)
# REMOVE the images without any attached container to them
docker rmi $(docker images -q -f dangling=true)
@Merwanski
Merwanski / gist:7c4c7872e0dfaa6c7e96f7b3e9bf4e06
Created December 8, 2021 09:45
keep the container running and not exit directly
# add this at the end of your entrypoint file
# to keep the container running and not exit directly
set -x
while $1
do
echo "Press [CTRL+C] to stop.."
sleep 5
echo "My second and third argument is $2 & $3"
done
# reset last git commit
git reset --soft HEAD~1
@Merwanski
Merwanski / get_gpu_name.py
Created November 25, 2021 15:25
get gpu name tensorflow and pytorch
# tensorflow
from tensorflow.python.client import device_lib
devices_tf = device_lib.list_local_devices()
devices_tf = print(devices)
# pytorch
import torch
devices_torch = torch.cuda.get_device_name()
print(devices_torch)
@Merwanski
Merwanski / command tensorflow container
Created November 25, 2021 15:13
tensorflow/tensorflow:latest-gpu-py3 docker container to start with dev machine
Create a new container from the TensorFlow image
"""
$ docker run -it --rm tensorflow/tensorflow:latest-gpu-py3
"""
You should be logged-in in the new container. You can explore it using ls, cd, etc…
You can exit using
$ exit.
Create a directory to exchange files between your machine and the container:
@Merwanski
Merwanski / git_branch_in_prompt
Created November 24, 2021 13:56
git branch in terminal prompt
# TODO Add the code below to your barshrc file
# Git branch in prompt.
force_color_prompt=yes
color_prompt=yes
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;31m\]$(parse_git_branch)\[\033[00m\]\$ '