Skip to content

Instantly share code, notes, and snippets.

@Susensio
Susensio / rotation_spacing.py
Last active September 17, 2018 10:41 — forked from jsfenfen/output.png
Detecting rotation and line spacing of image of page of text using Radon transform
# -*- coding: utf-8 -*-
"""
Inspired in https://gist.github.com/jsfenfen/4c615775007b802117b7
Automatically detect rotation and line spacing of an image of text using
Fourier transforms
If image is rotated by the inverse of the output, the lines will be
horizontal (though they may be upside-down depending on the original image)
@Susensio
Susensio / HumbleBundle books.md
Last active August 29, 2018 10:32 — forked from santiagobasulto/README.md
Download HumbleBundle books in batch with a simple Python script.

Download HumbleBundle books

This is a quick Python script I wrote to download HumbleBundle books in batch. I bought the amazing Machine Learning by O'Reilly bundle. There were 15 books to download, with 3 different file formats per book. So I scratched a quick script to download all of them in batch.

(Final Result: books downloaded)

@Susensio
Susensio / open_terminal_shortcut.sh
Last active September 17, 2018 08:48
Add open terminal here shortcut in Debian 9.5 Gnome
# Source: https://askubuntu.com/questions/68078/keyboard-shortcut-for-open-a-terminal-here
echo "#! /bin/sh
gnome-terminal" > ~/.local/share/nautilus/scripts/Terminal
chmod +x ~/.local/share/nautilus/scripts/Terminal
# F12 or whatever
echo "F12 Terminal" > ~/.config/nautilus/scripts-accels
@Susensio
Susensio / __init__.py
Last active August 2, 2018 07:54
Python logging boilerplate for packages
from .module import foo
import logging
from logging.handlers import RotatingFileHandler
import os
import os.path
# Logging directory
LOGGING_FOLDER = 'logs/'
LOG_PATH_TEMPLATE = LOGGING_FOLDER + "{}.log"
@Susensio
Susensio / sync_backlight.sh
Created July 28, 2018 09:15
Syncs laptop backligh to LG HDMI monitor
#!/usr/bin/env bash
# Listen for changes in backlight and applies to external screen
MAX_BACKLIGHT=$(</sys/class/backlight/intel_backlight/max_brightness)
last_backlight=$(</sys/class/backlight/intel_backlight/brightness)
acpi_listen | while IFS='/' read -ra line; do
if [ "$line" = "video" ]; then
# Read laptop backlight
sleep 0.2
@Susensio
Susensio / profiling_qcachegrind.sh
Last active February 10, 2024 07:53
Python profiling with QCacheGrind
# Profile with cProfile python module and save to output
python -m cProfile -o output.cprof script.py
# Transform into tree format for QCacheGrind
pyprof2calltree -i output.cprof -o callgrind.cprof
# Open QCacheGrind and load callgrind.cprof file
@Susensio
Susensio / git_push_active_branch.md
Last active January 11, 2019 09:18
First git push to remote

Disclaimer

This gist allows full control from the client, discarding all possible changes made in the server!

NOT USEFULL for colaborative work without further modifications. Coworkers commits could be deleted.


Server

Init server repository and configure