Skip to content

Instantly share code, notes, and snippets.

@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.

@nocturnalgeek
nocturnalgeek / MailinatorAliases
Last active June 20, 2024 18:28
A list of alternate domains that point to @mailinator.com
@binkmail.com
@bobmail.info
@chammy.info
@devnullmail.com
@letthemeatspam.com
@mailinater.com
@mailinator.net
@mailinator2.com
@notmailinator.com
@reallymymail.com
@magnific0
magnific0 / wp_usermeta.md
Last active June 16, 2023 05:28
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 / 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 / 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
@ole1986
ole1986 / traffic-control.sh
Last active May 14, 2024 11:08
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 / 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 / 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
@keithws
keithws / 15-ssl-intermediate.conf
Last active November 10, 2023 13:50
Secure Dovecot SSL settings by following Mozilla's Security/Server Side TLS guidelines
##
## Dovecot SSL settings with Intermediate compatibility
## Follows Mozilla's Security/Server Side TLS guidelines
## https://wiki.mozilla.org/Security/Server_Side_TLS
##
##
## Optionial:
## Disable 3DES ciphersuites to prevent CVE-2016-2183
## by appending ":!3DES" to the ssl_cipher_list
@JFWenisch
JFWenisch / seafile-recover-data.md
Last active June 17, 2024 12:47
Recover seafile data from filesystem

First of, you need to download seafile to be able to use the seaf-fsck tool. If you are on a windows computer you can also use ubuntu via wsl.

Download & extract seafile

sudo apt -y install wget
export VER="7.1.3"
wget https://download.seadrive.org/seafile-server_${VER}_x86-64.tar.gz
sudo tar -xvf  seafile-server_${VER}_x86-64.tar.gz -C /srv
sudo mv /srv/seafile-server-${VER} /srv/seafile