Skip to content

Instantly share code, notes, and snippets.

View ovuruska's full-sized avatar
🏠
Working from home

Oguz Vuruskaner ovuruska

🏠
Working from home
View GitHub Profile
@ovuruska
ovuruska / backward_hook.py
Created May 3, 2021 11:25
replace all nan/inf in gradients to zero
import torch.nn as N
# Taken by https://github.com/Holmeyoung/crnn-pytorch/blob/master/models/crnn.py
class BackwardHook(N.Module):
def backward_hook(self, module, grad_input, grad_output):
for g in grad_input:
g[g != g] = 0
@ovuruska
ovuruska / main.js
Created June 30, 2021 09:22
Run a procedure when it is run by node directly.
const mainFunc = () => {
console.log("Hello World !")
}
if (require.main === module) {
mainFunc()
}
@ovuruska
ovuruska / watchout.sh
Created June 30, 2021 10:17
Redis bash killer tricks.
# Show all redis values
echo 'KEYS *' | redis-cli | sed 's/^/GET /' | redis-cli
# Show all redis dictionaries
echo 'KEYS *' | redis-cli | sed 's/^/HGETALL /' | redis-cli
@ovuruska
ovuruska / nvpmodel_controls.sh
Created July 15, 2021 07:34
Jetson Nano switch from 5W to MAXN
# Switch to 5W mode
sudo /usr/sbin/nvpmodel -m 1
# Switch to MAXN mode
sudo /usr/sbin/nvpmodel -m 0
@ovuruska
ovuruska / run_onnx_tf.py
Created August 9, 2021 08:42
Run imported onnx architecture in Tensorflow backend
import onnx
from onnx_tf.backend import prepare
import numpy as np
if __name__ == "__main__":
model_path = "goat.onnx"
onnx_model = onnx.load(model_path)
onnx.checker.check_model(onnx_model,full_check=True)
tf_model = prepare(onnx_model)
@ovuruska
ovuruska / remove_duplicate_images.py
Created August 11, 2021 16:20
Rename Duplicate Images
import cv2
import os
import numpy as np
from shutil import rmtree
if __name__ == "__main__":
image_dir = "asdf"
images = list(reversed(os.listdir(image_dir)))
@ovuruska
ovuruska / delete_all_cuda_packages.sh
Created August 13, 2021 08:18
Force to delete all cuda packages
sudo dpkg --purge --force-remove-reinstreq $(dpkg --get-selections | grep -v "deinstall" | cut -f1 | grep cuda)
#!/usr/bin/env python
"""
Bundle the site-packages of the current python environment into a zip file
If you have any wheels at `$(pwd)/wheels`, those will be used instead of
of the locally installed packages. For instance, if my pwd looked like
wheels/
|-- numpy-1.11.2-cp27-cp27mu-manylinux1_x86_64.whl
@ovuruska
ovuruska / container_entrypoint.sh
Last active September 7, 2021 12:48
Run container using entrypoint
$IMAGE_NAME="ASDF"
docker run -it --entrypoint /bin/bash $IMAGE_NAME
@ovuruska
ovuruska / docker_env_variables.txt
Created September 12, 2021 08:20
Docker environment
Create a new dockerfile containing:
FROM centos:6
ENV FOO=foofoo
RUN export BAR=barbar
RUN export BAZ=bazbaz && echo "$FOO $BAR $BAZ"
Then build it. The output of the last step is:
Step 4/4 : RUN export BAZ=bazbaz && echo "$FOO $BAR $BAZ"
---> Running in eb66196b238d