Skip to content

Instantly share code, notes, and snippets.

View roundedrectangle's full-sized avatar

roundedrectangle

View GitHub Profile
@roundedrectangle
roundedrectangle / 1.py
Created June 4, 2025 21:09
Demo for safe exiting discord.py-self Client while it's being ran inside a thread (without raising anything, including KeyboardInterrupt or any other similar or not similar exception)
import discord
from threading import Thread
import asyncio
class MyClient(discord.Client):
disconnect_task: asyncio.Task | None = None
def create_disconnect_task(self):
# Could'be been done easier (and better, task in a task is not the best thing) if _close() was not inside close()
self.disconnect_task = self.loop.create_task(self.close())
@roundedrectangle
roundedrectangle / mastodon-vs-pixelfed-api.md
Created May 26, 2025 17:38
Mastodon and pixelfed API differences
  1. Pixelfed requires redirect_uris parameter for OAuth2, while Mastodon uses redirect_uri. I am not exactly sure if Mastodon would work with Pixelfed's parameter, but when using redirect_uri parameter for Pixelfed, even with redirect_uris assigned, it results in error.
  2. GET /api/v1/accounts/relationships HTTP/1.1 endpoint on Mastodon uses id parameter (in docs it is reffered as id[] because you can assign it multiple times), but in Pixelfed it is named literally as id[].

In general, Mastodon API is ~comptaible with Pixelfed API.

You can check massive API differences (endpoints which are unsupported) on official website here.

@roundedrectangle
roundedrectangle / qml.yaml
Created February 13, 2025 19:18
QML language formatting for Micro (uncomplete and might be out of date with what I have locally)
filetype: qml
detect:
filename: "\\.qml"
rules:
# JS-specific
- constant.number: "\\b[-+]?([1-9][0-9]*|0[0-7]*|0x[0-9a-fA-F]+)([uU][lL]?|[lL][uU]?)?\\b"
- constant.number: "\\b[-+]?([0-9]+\\.[0-9]*|[0-9]*\\.[0-9]+)([EePp][+-]?[0-9]+)?[fFlL]?"
- constant.number: "\\b[-+]?([0-9]+[EePp][+-]?[0-9]+)[fFlL]?"
@roundedrectangle
roundedrectangle / Translating my (and maybe even other's) SailfishOS apps.md
Last active December 15, 2024 14:33
Translating my (and maybe even other's) SailfishOS apps

Translating my (and maybe even other's) SailfishOS apps

Read this before translating my apps. Even if you translated other apps, there are some pitfalls here, and a lot of people wasted their time translating what is not needed, so please at least read step 5.

The most important aspect is to translate Opal modules here, and keep the translations unfinished in the .ts file.

When following this instruction, make sure that you should replace appname with actual app name. For example, for Sailcord it is harbour-saildiscord.

  1. Fork the repo from GitHub UI. When creating the fork, select the "Copy the main branch only" checkmark. Only needed once
  2. If required, click on "Sync fork" on your fork.
@roundedrectangle
roundedrectangle / README.md
Last active November 13, 2024 13:18
discord.py-self sorted servers and folders

Sorted servers and folders without folder stubs or broken early environments

A function to paste in the Client subclass

from typing import Sequence, Union
import discord

class MyClient(discord.Client):
 @property
@roundedrectangle
roundedrectangle / bookworm_usbethernet_dnsmasq.md
Last active July 9, 2024 15:06
Setup dnsmasq for setting automatic IP on raspberry pi bookworm for usb ethernet gadget

First, follow a tutorial on enabling the usb ethernet gadget on bookworm. I recommend this

Check that you have an IP assigned to your computer, iphone or whatever you use. If not, proceed.

Raspberry Pi uses Network Manager now, and dhcpd has been replaced with dnsmasq. Many old instruction no longer work.

Next, edit /etc/dnsmasq.conf with your favourite text editor. I use nano:

sudo nano /etc/dnsmasq.conf