Skip to content

Instantly share code, notes, and snippets.

@Jarry1250
Jarry1250 / monitor.py
Created February 9, 2019 14:39
Monitor input audio and only output when volume is sustained
# Sources:
# https://www.raspberrypi.org/forums/viewtopic.php?t=144374
# https://github.com/ev3dev/ev3dev/issues/198
# https://askubuntu.com/questions/71863/how-to-change-pulseaudio-sink-with-pacmd-set-default-sink-during-playback
# Remember to reboot
# CHANGE THESE
VOLUME_TRIGGER = 45 # Relative Decibels. Bigger number = louder
PROPORTION_TRIGGER = 0.5 # Should be between 0 (any peak, however short) and 1 (only continuous sound)
LENGTH_OF_SAMPLE = 5 # The period to look at in second
@Jarry1250
Jarry1250 / wmukblocks.php
Created March 25, 2014 11:59
Maintenance script for mirror the WMF global block list
<?php
/*
WMUK block copier © 2011 and 2013 Harry Burt <jarry1250@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
var url = 'http://www.foo.com/bar.jsonp?callback=cb';
$.ajax({
url: url,
jsonpCallback: 'cb',
dataType: 'jsonp',
success: function( data ) {
console.log( 'Success A' );
}
});
$.getJSON(url, null, function (data) {
@Jarry1250
Jarry1250 / name.php
Last active December 23, 2015 07:29
Wikipedia bot to swap in address lines for name placeholders
<?php
require_once( '../mw-peachy/Init.php' );
set_time_limit( 0 );
$site = Peachy::newWiki( 'livingbot' );
$template = 'EH listed building row';
$mysqli = new mysqli( "localhost", 'root' );
/* check connection */
if ( mysqli_connect_errno() ) {
printf( "Connect failed: %s\n", mysqli_connect_error() );
@Jarry1250
Jarry1250 / commonscat.php
Last active December 22, 2015 17:49
Code for adding Commons categories to the English Wikipedia listed building pages
<?php
require_once( '../mw-peachy/Init.php' );
set_time_limit( 0 );
$site = Peachy::newWiki( 'livingbot' );
$commons = Peachy::newWiki( null, null, null, 'https://commons.wikimedia.org/w/api.php' );
$http = new HTTP();
$template = '{{EH listed building row';
$lists = array( 'Grade I listed buildings in Suffolk Coastal' /* etc */ );
foreach( $lists as $list ){