Skip to content

Instantly share code, notes, and snippets.

@m-salman-afzal
m-salman-afzal / handyWaylandPasteFix.md
Created July 3, 2026 15:02
Skip Allow Remote Interaction for Handy

Fix Handy's repeating "Allow remote interaction" prompt on GNOME Wayland

Problem: Handy (Tauri speech-to-text) pops "Allow remote interaction" every time it pastes.

Cause: On GNOME Wayland, Handy's default auto/enigo path injects the paste keystroke through the RemoteDesktop portal. That portal deliberately re-asks for this kind of ephemeral input injection and offers no persistent grant — so it prompts forever.

Fix: Point Handy at a uinput-based typing tool (ydotool), which injects at the kernel level and never touches the portal.

1. Install ydotool + daemon (needs sudo)

@m-salman-afzal
m-salman-afzal / disableShutterSound.md
Created May 1, 2026 19:30
Disable ss shutter sound on gnome

To disable the camera sound when taking screenshots in Ubuntu, you can change the filename of the sound file that Ubuntu uses in these cases:

sudo mv /usr/share/sounds/freedesktop/stereo/camera-shutter.oga /usr/share/sounds/freedesktop/stereo/camera-shutter-disabled.oga
@m-salman-afzal
m-salman-afzal / ipv6ResolutionPostmortem.md
Created March 15, 2026 00:32
Ipv6 was having problems on PTCL, due to which firebase remoteconfig was having tantrums due to how Nodejs handle it. So, it is trace of how it figured it out,

Debugging Firebase Remote Config Failure on PTCL (Pakistan ISP)

The Problem

Running pnpm dev for a Next.js app that fetches Firebase Remote Config on the server side produced:

Error: Credential implementation provided to initializeApp() via the "credential" property
failed to fetch a valid Google OAuth2 access token with the following error:
"request to https://oauth2.googleapis.com/token failed, reason: ".
@m-salman-afzal
m-salman-afzal / upgradeUbuntu.md
Created February 19, 2026 17:16
Use latest of everything in Ubuntu
sudo nano /etc/apt/preferences.d/proposed-updates

paste below:

Package: *
Pin: release a=resolute-proposed
Pin-Priority: 500
@m-salman-afzal
m-salman-afzal / customCursorInSnapAppsSettings.md
Last active January 17, 2026 19:36
Setting custom cursor theme snap apps
  1. Install snap of the required cursor theme. In my case, it was bibata cursor themes, which is available as bibata-all-cursor
  2. Run following command to manually force the theme of all installed snap apps
# Force-connect all snaps to the Bibata icon interface
for plug in $(snap connections | grep gtk-common-themes:icon-themes | awk '{print $2}'); do 
    sudo snap connect ${plug} bibata-all-cursor:icon-themes; 
done
@m-salman-afzal
m-salman-afzal / drawImageToCanvas.js
Created January 6, 2026 20:18
Load image into canvas aynchronously (without blocking the main thread)
function isChromium() {
return Boolean(window.chrome);
}
function fastDrawImage() {
const imageUrl = './url_for_your_image.png';
if (isChromium()) {
fetch(imageUrl)
.then(image => image.blob())
.then(blob => createImageBitmap(blob))
@m-salman-afzal
m-salman-afzal / disableMermiadZoomOnScroll.tsx
Created December 23, 2025 06:04
Disable mermiad js zoom on scroll over the diagram
import { useEffect } from 'react';
export const DisableMermaidZoomOnScroll = () => {
useEffect(() => {
const handleWheel = (e: WheelEvent) => {
const target = e.target as HTMLElement;
const mermaidBlock = target.closest('[data-streamdown="mermaid-block"]');
if (!mermaidBlock) {
return;
@m-salman-afzal
m-salman-afzal / infiniteScroll.ts
Created December 5, 2025 22:16
infiniteScroll
// simple InfiniteScroll behavior without the need for intersectionObserverApi
const InfiniteScroll = () => {
// gap from the very bottom which when reached should trigger some action
const gap = 20 // in px
return (
<div
onScroll={(event) => {
if (event?.target) {
const { scrollTop, scrollHeight, clientHeight } =
event.target as HTMLDivElement;
@m-salman-afzal
m-salman-afzal / DependencyInjectorsComparison.csv
Last active October 23, 2022 19:12
dependency-injector-example >> Packages Info
Container Bundle Size- Minified (kB) Download Time (ms)
TypeDi 9.5 3
Inversify 49.5 13
TSyringe 15.6 5
@m-salman-afzal
m-salman-afzal / RobotController.ts
Last active October 23, 2022 19:10
dependency-injector-example >> for TSyringe >> http/Controllers/RobotController.ts
import e from "express";
import {container} from "tsyringe";
import ChairServiceTsy from "../../src/Application/TSyringeService/ChairServiceTsy";
import RobotServiceTsy from "../../src/Application/TSyringeService/RobotServiceTsy";
// (for TSyringe) When you need to inject another class with different implementation, use ChairServiceNew
import ChairServiceNewTsy from "../../src/Application/Common/ChairServiceNewTsy";
// (for TSyringe) Use ChairServiceNew if you want to replace dependency in regards to DIP
container.register("IChairServiceTsy", {useClass: ChairServiceTsy});