Skip to content

Instantly share code, notes, and snippets.

View matteoferla's full-sized avatar

Matteo Ferla matteoferla

View GitHub Profile
@bzamecnik
bzamecnik / floyd_steinberg_dithering.py
Created August 6, 2019 16:05
Floyd-Steinberg dithering in Python (quite fast via Numba JIT)
# https://en.wikipedia.org/wiki/Floyd–Steinberg_dithering
from numba import jit
import numpy as np
@jit(nopython=True)
def floyd_steinberg(image):
# image: np.array of shape (height, width), dtype=float, 0.0-1.0
# works in-place!
h, w = image.shape
for y in range(h):
@rmoriz
rmoriz / script.sh
Last active September 19, 2023 02:04
build rtl8812au driver running Raspbian on Raspberry Pi 3 and Zero (both tested, should work on all)
#!/bin/sh
mkdir -p /tmp/rtl8812au
cd /tmp/rtl8812au
apt-get install -y \
git \
dkms \
raspberrypi-kernel-headers \
raspberrypi-kernel
@bannanc
bannanc / OE_toandfrom_RDK.ipynb
Last active September 7, 2023 16:54
This is a jupyter notebook explaining how to convert molecules in OpenEye toolkits to the equivalent molecule in RDKit going both directions between toolkits.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@abingham
abingham / capture_help.py
Last active May 22, 2023 20:55
How to capture the output of Python's help() function.
import io
import sys
# Temporarily redirect stdout to a StringIO.
stdout = sys.stdout
s = io.StringIO()
sys.stdout = s
help(sys.intern)
@joecampo
joecampo / fail2ban.md
Last active March 26, 2024 15:36
fail2ban – stop HTTP(S) route abuse/brute forcing

If you're not familiar: What is fail2ban? fail2ban is an awesome linux service/monitor that scans log files (e.g. auth.log for SSH) for potentially malicious behavior. Once fail2ban is tripped it will ban users for a specified duration by adding rules to Iptables. If you're unfamiliar with fail2ban Chris Fidao has a wonderful (& free!) series about security including setting up fail2ban here.

Recently Laravel released a new feature in 5.1 to throttle authentication attempts by simply adding a trait to your authentication controller. The Laravel throttle trait uses the inputted username, and IP address to throttle attempts. I love seeing this added to a framework out of the box, but what about some of our other apps not built on Laravel? Like a WordPress login? Or even an open API etc.? Ultimately,