Skip to content

Instantly share code, notes, and snippets.

@black-silence
black-silence / toggle-mic-mute.py
Created February 6, 2023 15:59
Simple script to toggle pulseaudio microphone mute, to be used with a global hotkey.
#!/usr/bin/env python3
# Script to toggle microphone mute
# Toggles the preferred (usb) mic if present, or the fallback mic
# device.description from `pacmd list-sources`
preferred_mic = "USB PnP Audio Device Mono"
fallback_mic = "HD Audio Controller Stereo Microphone"
@black-silence
black-silence / create-php-ini.php
Created March 4, 2021 14:23
Create copy of php.ini without xdebug. When using phan, I don't want to have xdebug in the php.ini but I don't want to maintain a separate config file for phan. So I use php to create a custom php.ini without xdebug, then call php with the custom config to run phan.
<?php
declare(strict_types=1);
/**
* This reads the php.ini the current CLI process is using and creates a copy
* so we can kick out xdebug and use the created config for phan without having to remove xdebug globally.
*/
function cleanIniFile(string $content): string {
$noComments = preg_replace("/^;.*\n/m", '', $content);
@black-silence
black-silence / sonarphp-xml-patcher.py
Created April 10, 2019 13:49
quick-dirty phpunit xml result patcher so sonarphp doesn't choke
#!/usr/bin/env python3
import xml.etree.ElementTree as ET
et = ET.parse('logfile.xml')
root = et.getroot()
for mastersuites in root:
for suite in mastersuites:
if not "file" in suite.attrib:
continue
@black-silence
black-silence / Aragami-workshop-workaround.py
Created March 11, 2017 23:22
workaround for Aragami editor version 1
#!/usr/bin/env python3
import os
import glob
workshop = os.path.join(os.getcwd(), "workshop", "content", "280160")
os.chdir(workshop)
c = d = 0
# Remove existing symlinks
scan = os.scandir(workshop)