Skip to content

Instantly share code, notes, and snippets.

@ritiek
ritiek / example.sh
Created October 2, 2024 00:13
Encryption and decryption using age-plugin-yubikey
echo hello who is there | rage -R <(age-plugin-yubikey -l --slot 1) -o - | rage -d -i <(age-plugin-yubikey -i --slot 1)
@ritiek
ritiek / start.sh
Created June 21, 2024 17:57
PostgreSQL in Docker
# Start server with
sudo docker run -it --rm -e POSTGRES_PASSWORD=mysecretpassword postgres
# Connect to server either with
sudo docker exec -it 938645c5a5d9 psql -U postgres
# or with
sudo docker exec -u postgres -it 938645c5a5d9 psql
@ritiek
ritiek / register_me.py
Created May 24, 2024 14:55
Register on Matrix homeserver using Registration Shared Secret
# Referred from:
# https://element-hq.github.io/synapse/latest/admin_api/register_api.html
import requests
import hmac
import hashlib
import json
# Fill these variables in.
DOMAIN = "example.com"
@ritiek
ritiek / ipscan.sh
Last active June 15, 2024 16:12
Scan for active local IP addresses and resolve their machine names
# Replace "192.168.2.{}" as per your gateway address.
seq 1 254 | xargs -I {} "echo" "192.168.2.{}" | parallel -j 254 "ping -t 1 -c 1 {} > /dev/null && (timeout 1 avahi-resolve -a {} || echo {})" 2> /dev/null | sort -V
@ritiek
ritiek / README.md
Last active February 3, 2024 08:53
Keep Spotify playlists in sync locally using spotdl

Setting up

First run

$ mkdir /media/spotdlsync
$ cd /media/spotdlsync

$ mkdir "Life is Strange"
$ cd "Life is Strange"
@ritiek
ritiek / README.md
Last active July 30, 2023 11:22
Tailscale

Subnet and Exit Nodes

Server:

# First time
$ echo 'net.ipv4.ip_forward = 1' | sudo tee -a /etc/sysctl.d/99-tailscale.conf
$ echo 'net.ipv6.conf.all.forwarding = 1' | sudo tee -a /etc/sysctl.d/99-tailscale.conf
$ sudo sysctl -p /etc/sysctl.d/99-tailscale.conf
@ritiek
ritiek / connect_to_wifi.py
Last active September 27, 2022 22:33
Setting up MicroPython on ESP32
import network
sta_if = network.WLAN(network.STA_IF)
sta_if.active(True)
sta_if.connect("ssid", "pass")
sta_if.isconnected()
sta_if.ifconfig()
import urequests
response = urequests.get("http://ipinfo.io")
ip_info = response.json()
@ritiek
ritiek / change_identity.sh
Last active August 22, 2023 23:12
Change git identity for current repository
# Generate SSH keys for Bob and add them to ssh-agent
# Write it to `~/.ssh/bob.id_rsa`.
ssh-keygen -t ed25519
ssh-add ~/.ssh/bob.id_rsa
git config --local user.name Bob
git config --local user.email "[email protected]"
git config --local credential.username bobxyz
git config --replace-all --local core.sshCommand "ssh -i ~/.ssh/bob.id_rsa"
@ritiek
ritiek / POST.md
Last active October 8, 2022 16:55
GSoC '21 Final Work Submission

Hi Everyone! I am Ritiek Malhotra (ritiek on IRC) and recently completed my undergraduate degree in Computer Science and Engineering. I participated in Google Summer of Code '21 and worked on musicbrainz_rs, a library wrapper on the MusicBrainz Web-API written for the Rust programming language.

Why MetaBrainz?

When the program was announced, I was not familiar with MetaBrainz. I've heard about MetaBrainz quite a few times before this but hadn't used any of their products. I'd been looking for Rust projects through the GSoC organizations page, and that's how I stumbled on MetaBrainz. I learnt about the MusicBrainz project and the entire concept seemed very interesting to me (and it still does!). Initially, I was a little intimidated by all the Rust concepts that musicbrainz_rs made use of - macros, traits, generics and lifetimes. I knew how to write basic Rust but not so much about these intermediate concepts. Nonetheless, I tried to learn more about the librar

@ritiek
ritiek / cmd.sh
Created July 19, 2020 07:28
mpv near lag-less real-time stream
mpv --no-cache --untimed --no-demuxer-thread --vd-lavc-threads=1 -