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.
Init server repository and configure
# 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 |
#!/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 |
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" |
# 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 |
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)
# -*- 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) |
"Dynamic plotting in matplotlib. Copy and paste into a Jupyter notebook." | |
# written October 2016 by Sam Greydanus | |
%matplotlib notebook | |
import matplotlib.pyplot as plt | |
import numpy as np | |
import time | |
def plt_dynamic(x, y, ax, colors=['b']): | |
for color in colors: | |
ax.plot(x, y, color) |
Given a Parent
class with value
property, Child
can inherit and overload the property while accessing Parent
property getter and setter.
Although we could just reimplement the Child.value
property logic completely without using Parent.value
whatsover, this would violate the DRY principle and, more important, it wouldn't allow for proper multiple inheritance (as show in the example property_inheritance.py
bellow).
Two options:
Child
redefines value
property completely, both getter and setter.