Skip to content

Instantly share code, notes, and snippets.

View arpanetus's full-sized avatar
🐃

Omar Änwar arpanetus

🐃
View GitHub Profile

I wanted to be able to detect when Dark mode was turned on or off in my Go program so I can swap icons in my tray app on Windows so I wrote this.
When Dark Mode is turned on or off, it writes to a pair of registry keys, both of which Windows allows you to set independently in Settings > Personalization > Colors.

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize  

SystemUsesLightTheme  DWORD 0 or 1 // Changes the taskbar and system tray color  
AppsUseLightTheme     DWORD 0 or 1 // Changes app colors  

Mine is a tray app, so I am monitoring the first one. I did not want to just periodically poll the registry key and I wanted to be able to react immediately when the registry key is changed, so I am using the win32 function RegNotifyChangeKeyValue in advapi32.dll to tell the OS to notify my app so I can swap out the icon for a color-appropriate one.
I start the monitor function in main, which loads the RegNotifyChangeKeyValue function from advapi32 and starts a gorouti

@arpanetus
arpanetus / install.sh
Last active September 23, 2023 11:57
docker install oneliner
sudo apt-get update
sudo apt-get install -y \
ca-certificates \
curl \
gnupg \
lsb-release
sudo rm -rf /usr/share/keyrings/docker-archive-keyring.gpg
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
@arpanetus
arpanetus / halıq.md
Last active February 8, 2023 21:00
Халық банк туралы бір ауыз сөз

Бірде Халық банктың Онлайн-Банк қызметіне хабарласқан едім.

Онлайн-банк, Гөгіл сұрамасы

Лендиңі түгел дерлік орыс тілінде. Қазақша бір түйір сөз таппайсың.

Онлайн-банк, Лендиң

Соны айтсам, көмекші қызметтегі қыз "Ондағының бәрін қазақша аударып болмайды, одан бөлек орысша нұсқасы бірінші жасалады" дегені бар.

package main
import (
"context"
"fmt"
"os/exec"
"time"
)
type App struct {
@arpanetus
arpanetus / nca.sh
Last active June 21, 2022 11:29
nca.sh
#!/bin/bash
cd ~/Downloads
if [ -f "ncalayer.zip" ]; then
while true; do
read -p "file exists, you want to download it again? (y/n): " yn
case $yn in
[yY] ) echo "downloading it";
mv ncalayer.zip ncalayer.old.zip

NCALayer proper installation guide [Linux]

NCALayer is a tool for signing documents and authorizing into Kazakhstani govt. services such as egov.kz. It's an application written in Java, and thus has to be installed into your machine. We won't discuss the inner mechanism of the app that much, yet I highly dislike the fact that it exists exactly like that.

One thing that we certainly have to mention is ✨safety✨ during the usage of it:

package main
import (
"fmt"
"io/ioutil"
"os"
"time"
"encoding/json"

Keybase proof

I hereby claim:

  • I am arpanetus on github.
  • I am arpanetus (https://keybase.io/arpanetus) on keybase.
  • I have a public key ASCXCxMyfqZj0xOKrO-cftAWWUFkXjRZGh9F5NfABXDmWAo

To claim this, I am signing this object:

#!/usr/bin/env bash
set -e
dev=sda
efi=true
boot_fs=vfat
state_version="19.09"
profile="<nixpkgs/nixos/modules/installer/scan/not-detected.nix>"
prompt() {