Skip to content

Instantly share code, notes, and snippets.

View Half-Shot's full-sized avatar
:fishsticks:
Building bridges

Will Hunt Half-Shot

:fishsticks:
Building bridges
View GitHub Profile
@Half-Shot
Half-Shot / mute_notifs.py
Created April 23, 2024 15:05
Mute notifications whenever a screenshare is detected (assumes you use dunstctl / org.freedesktop.impl.portal.ScreenCast), but can be adapted.
#!/usr/bin/env python3
import dbus
from gi.repository import GLib
from dbus.mainloop.glib import DBusGMainLoop
import threading
import os
def main():
DBusGMainLoop(set_as_default=True)
bus = dbus.SessionBus()
@Half-Shot
Half-Shot / file.js
Last active September 12, 2023 10:26
const TOML = require('@iarna/toml');
// Promises are nicer.
const fs = require('fs/promises');
async function updateInstance(instance) {
// Do not use var, ever.
try {
// Await await await
const wellKnownResponse = await fetch("https://" + instance.domain + "/.well-known/matrix/server");
@Half-Shot
Half-Shot / autopause-notifications.py
Created April 17, 2023 13:57
Autopause notifications when screensharing in Wayland!
#!/usr/bin/env python3
import dbus
from gi.repository import GLib
from dbus.mainloop.glib import DBusGMainLoop
import threading
import os
def main():
DBusGMainLoop(set_as_default=True)
bus = dbus.SessionBus()
@Half-Shot
Half-Shot / room-notifs.md
Created February 7, 2023 17:17
Unread room notifs

How unread notifications work

N.B: This may have changed in sliding sync, I haven't looked into it. This covers the present day CS APIs.

In unencrypted rooms, your unread (that is, highlighting rooms in in your room list) notifications are calculated by the server in a field called unread_notifications that appears down sync in two fields.

There are two types of unread notification:

  • Total (notification_count): The number of unread messages in a room that should increment the counter.
  • Highlight (highlight_count): The number of unread messages that have explicitly highlighted you (makes the room go red).
@Half-Shot
Half-Shot / breaktime.mjs
Created January 2, 2023 00:40
A script for suggesting you should take breaks.
#!/usr/bin/env node
import { readFile, writeFile, stat } from "fs/promises"
import { homedir } from "os"
import path from "path";
const minute = 60000;
const lastBreakPath = path.join(homedir(), ".cache", "last_break");
const configuration = {
breakDuration: 10 * minute,

A new security vulnerability was found in the matrix-appservice-irc bridge, for which we are releasing 0.35.1 as a fix. If you have the provisioning API enabled, this is potentially exploitable, so we advise you to upgrade immediately.

In case you cannot upgrade at the moment, we advise to update your IRC bridge configuration as a mitigation as follows:

You may revert these configuration changes after patching.

unexpected fault address 0x7f03e11a50b0
fatal error: fault
[signal SIGSEGV: segmentation violation code=0x1 addr=0x7f03e11a50b0 pc=0x110d06d]
goroutine 631 [running]:
runtime.throw(0x24f2ae9, 0x5)
/usr/local/go/src/runtime/panic.go:1117 +0x72 fp=0xc002fbfe00 sp=0xc002fbfdd0 pc=0xc7aab2
runtime.sigpanic()
/usr/local/go/src/runtime/signal_unix.go:741 +0x268 fp=0xc002fbfe38 sp=0xc002fbfe00 pc=0xc925a8
github.com/disintegration/imaging.(*scanner).scan(0xc002d71d80, 0x0, 0x0, 0x410, 0x1, 0xc001218600, 0x1040, 0x1040)
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC+dt7ZhlI7tuqWzaM2cErv0cqXT4QyxR7c2uPC/tu+uQnW2Fqbcs4mwvMkmVgqj3Ei420vuefXiFOLKFlfZAFdaoty1uh7syvVvsMfa2sIbviVEJKwMvILYOG19e8y6HnjdpJ3yKKTUwlg+fXr0k5KdYXhw70pa0ZMocjBna+eHsObp+omYbzB7YQVJa4bsiV5Ag0R6PCvG1ydgNayDfGdLx1Wlqn7GS9yrv7OUYAJplNVOMLgy5IT5W02Mu3OGgjlblFwwkmYh18jIVUETMGqlMSXMicxNYW0D5UoL8P2ufsRdWdCHQbCoU7DRucWknAN6G9h8sMbqcK4pZnT8HPg6ryoPkCqOu1mwKqU3zGwM0o+JVrYlpZ4QOvdVFcYetH68zkjLwVV5zeq/PlZ8K1oI3NzjSC7Fd1soZ3jHD2pxwHOxc1vnjmt8ABhUl4ij7DfirMLxULAzCvkIXGScZ+qJN3+9zorypmctlhph5tfi+wIeYdh5sPnOSpm70x7vx0= cardno:000605228237
2019-07-15 20:10:02,336 - synapse.access.http.8053 - 302 - INFO - PUT-1882474- - - 8053 - {matrix.org} Processed request: 618.200sec/-558.657sec (131.344sec, 16.445sec) (5.589sec/1016.393sec/2841) 0B 200! "PUT /_matrix/federation/v1/send/1562344041191/ HTTP/1.0" "Synapse/1.1.0rc1 (b=matrix-org-hotfixes,43e01be15)" [329786 dbevts]
2019-07-15 20:10:02,357 - synapse.access.http.8053 - 302 - INFO - PUT-1882792- - - 8053 - {matrix.org} Processed request: 343.946sec/-301.317sec (0.036sec, 0.005sec) (0.000sec/0.017sec/1) 0B 200! "PUT /_matrix/federation/v1/send/1562344041191/ HTTP/1.0" "Synapse/1.1.0rc1 (b=matrix-org-hotfixes,43e01be15)" [0 dbevts]
2019-07-15 20:10:02,379 - synapse.access.http.8053 - 302 - INFO - PUT-1883097- - - 8053 - {matrix.org} Processed request: 246.346sec/-190.259sec (0.043sec, 0.004sec) (0.000sec/0.016sec/1) 0B 200! "PUT /_matrix/federation/v1/send/1562344041191/ HTTP/1.0" "Synapse/1.1.0rc1 (b=matrix-org-hotfixes,43e01be15)" [0 dbevts]
2019-07-15 20:10:02,401 - synapse.access.http.8053 - 302
@Half-Shot
Half-Shot / motion.html
Last active January 29, 2019 12:42
Motion test
<body>
<h1> Motion! </h1>
<p style="color:red" id="error" hidden> Hmm, your device isn't sending any motion events. Is this really a mobile device? </p>
<p> X: <span id="moX">$</p>
<p> Y: <span id="moY">$</p>
<p> Z: <span id="moZ">$</p>
<script>
setTimeout(() => {
if (window.accelSupported === false) {