Skip to content

Instantly share code, notes, and snippets.

@YaYaB
YaYaB / rewrite_commit_info.sh
Created April 30, 2020 11:58
Correct email and name commits
git filter-branch --env-filter '
WRONG_EMAIL=""
NEW_NAME=""
NEW_EMAIL=""
if [ "$GIT_COMMITTER_EMAIL" = "$WRONG_EMAIL" ]
then
export GIT_COMMITTER_NAME="$NEW_NAME"
export GIT_COMMITTER_EMAIL="$NEW_EMAIL"
fi
@YaYaB
YaYaB / install_deepdetect.sh
Last active March 3, 2020 09:25
This script allows to automate installation of DeepDetect (https://www.deepdetect.com/)
# This is for Ubuntu 18.04, 16.04, 14.04
# Make sure Nvidia Drivers, cuda and cudnn are well installed in the machine on which you want to install DeepDetect
# Prefer cuda 10.1 instead of cuda 10.2 (cuda 10.2 is not well supported).
# https://www.deepdetect.com/
# Install dependencies based on version of ubuntu
unbuntu_version=$(echo "$(lsb_release -r)" | cut -f2 | cut -d '.' -f1)
if [ $unbuntu_version = 18 ]
then
# Prepare temp folder
@YaYaB
YaYaB / .zshrc
Last active August 14, 2020 20:44
Personal zshrc
# If you come from bash you might have to change your $PATH.
# Path to your oh-my-zsh installation.
MYUSER=`whoami`
export ZSH="/home/${MYUSER}/.oh-my-zsh"
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
ZSH_THEME="refined"
@YaYaB
YaYaB / json_to_ljson.py
Last active January 10, 2020 11:37
Transform a json document to a ljson document (one json per line)
import json
import os
from glob import glob
input_doc = "TODO" # can be a json doc or a folder containing only jsons
output_ljson = "{}_output.ljson".format('.'.join(input_doc.split('.')[:-1]))
def transform_input_to_dumpable(input_doc):
@YaYaB
YaYaB / sort_alphanumerical.py
Created December 2, 2019 16:06
Sort a list of string in an alphanumerical way
import re
def atoi(text):
return int(text) if text.isdigit() else text
def natural_keys(text):
'''
alist.sort(key=natural_keys) sorts in human order
http://nedbatchelder.com/blog/200712/human_sorting.html
(See Toothy's implementation in the comments)
@YaYaB
YaYaB / download_image_web.py
Created October 30, 2019 10:30
Download an image from url
import urllib.request
import shutil
def downloader(image_url, basename, index=None):
req = urllib.request.Request(image_url, headers={'User-Agent': 'Mozilla/5.0'})
if index:
full_file_name = basename + '-' + str(index) + '.jpg'
else:
full_file_name = basename + '.jpg'
with urllib.request.urlopen(req) as response, open(full_file_name, 'wb') as out_file:
@YaYaB
YaYaB / detect_identical_files.py
Last active October 22, 2019 15:42
Detect identical files
import hashlib
from glob import glob
from pathlib import Path
import argparse
import os
def get_args():
parser = argparse.ArgumentParser(
"Detect identical files."
@YaYaB
YaYaB / merge_bboxes.py
Last active April 17, 2024 08:43
Merge bounding boxes together.
import copy
import cv2
import os
def merge_bboxes(bboxes, delta_x=0.1, delta_y=0.1):
"""
Arguments:
bboxes {list} -- list of bounding boxes with each bounding box is a list [xmin, ymin, xmax, ymax]
delta_x {float} -- margin taken in width to merge
@YaYaB
YaYaB / untrack_file
Created August 30, 2019 07:46
Untrack file in git (when add file to gitignore and file already tracked)
file_path=""
git update-index --assume-unchanged ${file_path}
@YaYaB
YaYaB / dl_website.sh
Created August 28, 2019 07:27
Download website
NAME_WEBSITE=""
COOKIES=""
wget --mirror \
--convert-links \
--adjust-extension \
--page-requisites \
--no-parent \
--random-wait \
-r -p -e robots=off -U mozilla \