Skip to content

Instantly share code, notes, and snippets.

@acundari
acundari / traefik-auth.conf
Last active December 6, 2022 09:41
Traefik fail2ban
# /etc/fail2ban/filter.d/traefik-auth.conf
[Definition]
failregex = ^<HOST> \- \S+ \[\] \"(GET|POST|HEAD) .+\" 401 .+$
@rasschaert
rasschaert / arch_bootstrap.bash
Last active July 27, 2022 12:43
Shell script that performs the installation of Arch Linux the way I like it.
#!/bin/bash
bootstrapper_dialog() {
DIALOG_RESULT=$(dialog --clear --stdout --backtitle "Arch bootstrapper" --no-shadow "$@" 2>/dev/null)
}
#################
#### Welcome ####
#################
bootstrapper_dialog --title "Welcome" --msgbox "Welcome to Kenny's Arch Linux bootstrapper.\n" 6 60
@methane
methane / gist:2185380
Created March 24, 2012 17:28
Tornado Example: Delegating an blocking task to a worker thread pool from an asynchronous request handler
from time import sleep
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
from tornado.web import Application, asynchronous, RequestHandler
from multiprocessing.pool import ThreadPool
_workers = ThreadPool(10)
def run_background(func, callback, args=(), kwds={}):
def _callback(result):
@boaheck
boaheck / imgfucker.py
Last active May 24, 2022 05:44
ImageGlitcher
#!/usr/bin/env python
import random
import sys
cutLength = 1
pasteDist = 1
frames = 20
imgSequence = False
@offirgolan
offirgolan / unwatch-gh-org.js
Created August 2, 2017 05:57
Unwatch All Org Repos
// Navigate to https://github.com/watching and then run:
// Taken from: https://stackoverflow.com/questions/11043374/how-to-unwatch-multiple-repos-easily-on-github
Array.prototype
.slice.apply(document.querySelectorAll('.js-subscription-row'))
.forEach(el => { const org = el.querySelector('a[href^="/YOUR_ORG"]'); if (org) el.querySelector('button').click()});
@jblachly
jblachly / cloudinit-tips.md
Last active March 9, 2022 07:49
SmartOS (standalone) cloudinit setup for KVM images

The following keys, when placed in the customer_metadata section of the VM definition JSON will effect the specified behaviour:

smartos key corresponds to cloudinit key effect
hostname local-hostname
root_authorized_keys public-keys copies to /root/.ssh and default user ~/.ssh (e.g., ubuntu)
user-script user-script Executed each boot
user-data legacy-user-data
cloud-init:user-data user-data Evaluated by cloud-init once at VM creation only
iptables_disable iptables_disable ?
@bradmontgomery
bradmontgomery / single_dispatch_example.py
Created August 23, 2016 17:08
Example of single dispatch in python. This is seriously cool stuff.
"""
Playing with python's single dispatch.
See: https://hynek.me/articles/serialization/
See also PEP 443: https://www.python.org/dev/peps/pep-0443/
"""
from datetime import datetime
from functools import singledispatch
import asyncio
import threading
from tornado.ioloop import IOLoop
def non_main_thread_task(g_io_loop):
assert IOLoop.current(False) is None, "invalid current thread's ioloop object."
assert IOLoop.current() is g_io_loop, "invalid current thread's ioloop object."
io_loop = IOLoop()