Skip to content

Instantly share code, notes, and snippets.

@magnific0
magnific0 / dns_rfc2136.py
Last active June 20, 2019 17:44
ORACLE Dyn.com LetsEncrypts DNS authentication fix
"""DNS Authenticator using RFC 2136 Dynamic Updates."""
import logging
import dns.flags
import dns.message
import dns.name
import dns.query
import dns.rdataclass
import dns.rdatatype
import dns.tsig
@magnific0
magnific0 / trigger_word.py
Created March 27, 2018 19:57
[Guide] Trigger word - Try your own example!
# Set the filename
your_filename = "audio_examples/1040676.wav"
clip = AudioSegment.from_mp3("audio_examples/1040676.mp3")
# Add whitenoise to end of shorter samples
from pydub.generators import WhiteNoise
noise_bg = WhiteNoise().to_audio_segment(duration=clip.duration_seconds*1000.0, volume=-50)
noise_end = WhiteNoise().to_audio_segment(duration=max(10000.0-clip.duration_seconds*1000.0,0), volume=-50)
clip = clip.overlay(noise_bg) + noise_end
@magnific0
magnific0 / traffic-control.sh
Created December 1, 2017 12:37 — forked from ole1986/traffic-control.sh
Traffic control script for incoming and outgoing packages using TC (on a specific ip address)
#!/bin/bash
VERSION="1.0.2"
# Interface connect to out lan
INTERFACE="eth0"
# Interface virtual for incomming traffic
VIRTUAL="ifb0"
# set the direction (1 = outgoing only, 2 = incoming only 3 = both)
DIRECTION=3
# Speed
@magnific0
magnific0 / add_license_to_missing.sh
Last active July 10, 2023 18:36
Add a copyright license header to all CPP and H files
#!/bin/bash
read -r -d '' license <<-"EOF"
/* Copyright (c) 2010-2017, Delft University of Technology
* All rights reserved
*
* This file is part of the Tudat. Redistribution and use in source and
* binary forms, with or without modification, are permitted exclusively
* under the terms of the Modified BSD license. You should have received
* a copy of the license with this file. If not, please or visit:
* http://tudat.tudelft.nl/LICENSE.
@magnific0
magnific0 / license_update.py
Created February 3, 2017 12:19
Tudat update all files to new (short) license
import os
import sys
import re
import fnmatch
import codecs
# Define copyright header for CMakeLists
newlic1 = "".join((" # Copyright (c) 2010-2017, Delft University of Technology\n",
" # All rigths reserved\n",
" #\n",
@magnific0
magnific0 / em
Created November 18, 2015 09:57
#!/bin/sh
# EM --- emacsclient wrapper
# Emacs client wrapper support (sudo) editing of single files and diff mode.
# A POSIX variable
# Reset in case getopts has been used previously in the shell.
OPTIND=1
usage() {
cat << EOF
@magnific0
magnific0 / mailpoet_trackermod.md
Created October 3, 2014 17:59
Appending Arguments to Mailpoet Tracker URL Hook

Appending Arguments to Mailpoet Tracker URL Hook

In this example I append an extra argument to the Mailpoet tracker url called uidhash. This happens to be the confirmation hash used by Mailpoet. The hook should be added to functions.php.

function my_tracker_replaceusertags($email,$user){
  $urls = array();
  $results = array();// collect all links in email
  if(!preg_match_all('#href[ ]*=[ ]*"(?!mailto:|\#|ymsgr:|callto:|file:|ftp:|webcal:|skype:)([^"]+)"#Ui',$email->body,$results)) return;

  foreach($results[1] as $i => $url){

if(isset($urls[$results[0][$i]])|| strpos($url, 'wysija-key')) continue;

@magnific0
magnific0 / wp_usermeta.md
Last active October 9, 2024 00:35
Show and Edit User Meta in Wordpress

Show and Edit User Meta in Wordpress

Description

This simple procedure will allow you to:

  1. Display user meta fields under in the user list as additional columns (Users > All Users).
  2. Display these fields on user profiles.
  3. Edit these fields under user edit.

This method works completely without plugins and involves just some functions and hooks in functions.php. Plugins like "User Meta Display" achieve this to some level, but treat custom meta fields completely different from the regular fields. They are shown and edited in seperate environment and fail to show the meta data is a table list. This method integrates custom user meta along with regular user (meta).

@magnific0
magnific0 / pagmo_issue_44.md
Created February 27, 2014 14:06
Implementing cooperative multi-tasking for multi-threaded C++ Python calls

In response to pagmo issue #44

By default the GIL is not managed which means that multiple threads can access the Python interpreter without acquiring a lock. This default behaviour saves the hassle of the user to work with the GIL. This works perfectly fine as long as only one thread is accessing the Python interpreter, as in the case with most algorithms. However if an algorithm that spawns multiple threads (e.g. PaDe) that try to access the interpreter (because the problem is in Python) at the same time this will eventually cause segfaults.