Skip to content

Instantly share code, notes, and snippets.

@bro1
bro1 / split.sh
Created October 24, 2024 09:00
Split a set of mp3 files each into a set of 10 minute segments
function splitfile() {
TRACK_NAME=$(basename -s .mp3 "$1")
ffmpeg -i "${TRACK_NAME}.mp3" -f segment -segment_time 600 -c copy "out/${TRACK_NAME}-%02d.mp3"
}
mkdir out
export -f splitfile
find *.mp3 -exec bash -c "splitfile \"{}\"" \;
@bro1
bro1 / extract.js
Last active July 27, 2024 02:16
Extract the content from tables in NZ Skeptics newsletter so that it can be converted to epub
a = document.querySelectorAll(".mcnTextContent, .mcnImageContent, .mcnCaptionBottomImageContent, .mcnImageGroupContent");
db = document.getElementById("archivebody");
db.innerHTML = "";
for (i = 0; i< a.length; i++) {db.innerHTML += a[i].innerHTML + "<br>";}
b = document.querySelectorAll("h1, h2, h3");
for (i = 0; i< b.length; i++) {b[i].removeAttribute("style");}
function generateWeeklyPlan() {
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var sh = spreadsheet.getSheetByName("Plan")
// Get the count of entries in the recipe list
var max = sh.getRange(1,1).getValue()
var used = []
for (var i = 0; i < 7; i = i + 1) {
@bro1
bro1 / uninstall-lo64.sh
Created September 5, 2020 02:29
Uninstall Libre Office 6.4 debian
# verify what's going to be removed
apt list "libreoffice6.4*" "libobasis6.4*"
# actually remove it
sudo apt-get remove "libreoffice6.4*" "libobasis6.4*"
@bro1
bro1 / visio-create-box.vbs
Created September 4, 2020 07:15
A basic macro for Visio
Sub Macro2()
'Enable diagram services
Dim DiagramServices As Integer
DiagramServices = ActiveDocument.DiagramServicesEnabled
ActiveDocument.DiagramServicesEnabled = visServiceVersion140 + visServiceVersion150
Application.Windows.ItemEx("Drawing3").Activate
Dim s As Shape
@bro1
bro1 / gist:c0b9e718e6437d4a8d5e5afa1834599d
Created April 19, 2020 04:01
Add 2 utilities to sudoers config so that they can be executed without password
username ALL=NOPASSWD : /usr/sbin/rtcwake * , /bin/date *
@bro1
bro1 / remove.sh
Last active July 24, 2019 09:42
get rid of TouchPal keyboard on Android
adb devices (and check if the phone is connected)
adb shell
pm uninstall -k --user 0 com.emoji.keyboard.touchpal
@bro1
bro1 / pom.xml
Created March 4, 2017 09:13
javafx-maven-plugin example
<plugin>
<groupId>com.zenjava</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>8.8.3</version>
<configuration>
<mainClass>com.bro1.podcastvideo.PodcastVideoApp</mainClass>
</configuration>
</plugin>
@bro1
bro1 / .htaccess
Created July 16, 2016 01:40
WordPress .htaccess modification to include the PHP Authorisation variables when PHP is running in CGI/FastCGI mode
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /mysite/
RewriteRule ^index\.php$ - [L]
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /mysite/index.php [L]
</IfModule>
@bro1
bro1 / log.regex
Created October 28, 2015 05:39
Regex - introduce a log statement for every assertion
^(\s+)(.*assert.*)$
$1kLogger.info\("$2"\);\n$0