Skip to content

Instantly share code, notes, and snippets.

@adamghill
adamghill / apps.py
Last active May 5, 2022
Watch .env file for changes in a Django app
View apps.py
from django.apps import AppConfig
from django.conf import settings
from django.utils.autoreload import autoreload_started
class Config(AppConfig):
name = "random_app_name"
def ready(self):
autoreload_started.connect(watch_env)
View restic-backup.service
MOVED TO ⮕ https://github.com/erikw/restic-automatic-backup-scheduler
@lukecav
lukecav / functions.php
Created Sep 15, 2017
Bypass logout confirmation in WooCommerce
View functions.php
function wc_bypass_logout_confirmation() {
global $wp;
if ( isset( $wp->query_vars['customer-logout'] ) ) {
wp_redirect( str_replace( '&', '&', wp_logout_url( wc_get_page_permalink( 'myaccount' ) ) ) );
exit;
}
}
add_action( 'template_redirect', 'wc_bypass_logout_confirmation' );
@biinari
biinari / extract-123-reg-zonefile.js
Last active Aug 16, 2022
Script to extract the DNS entries from 123-reg advanced dns page
View extract-123-reg-zonefile.js
// Moved to a new home at https://github.com/biinari/zonefile-extract/tree/master/123-reg
@bender-the-greatest
bender-the-greatest / time-function.ps1
Last active Jun 14, 2018
Alternative implementation of Measure-Command, works similarly to Linux `time` command
View time-function.ps1
# Alternative (improved?) implementation of Measure-Command
# Works similarly to the Linux/Unix `time` command
#
# Function which times how long a command takes to completion
# Note that this function outputs to Write-Host so as to
# protect the proper return value. Note that a time will be
# returned even if the command fails.
#
# Unless `-quiet` is specified, command output is sent directly
# to `Write-Host` to allow for the simultaneous return of the
@dropwhile
dropwhile / results.txt
Last active Mar 10, 2020
python compression comparison
View results.txt
Data Size:
Input: 2074
LZ4: 758 (0.37)
Snappy: 676 (0.33)
LZF: 697 (0.34)
ZLIB: 510 (0.25)
LZ4 / Snappy: 1.121302
LZ4 / LZF: 1.087518
LZ4 / ZLIB: 1.486275
Benchmark: 50000 calls