Skip to content

Instantly share code, notes, and snippets.

@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 "bobisthebest@example.com"
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 -
@ritiek
ritiek / README.md
Last active July 10, 2020 18:49
Adding a 3rd party apt repository

I wanted to specifically install libpython3.7-dev but it wasn't available in my default apt repositories. My apt repositories had libpython3.8-dev which wouldn't work for my specific use-case.

I am on PopOS 20.04. So the corresponding debian codename would be "buster".

I noticed that it was available in https://debian.pkgs.org/10/debian-main-amd64/libpython3.7-dev_3.7.3-2+deb10u1_amd64.deb.html. But it's really hard to keep resolving dependencies.

I needed apt to fix it for me.

@ritiek
ritiek / capture.sh
Last active April 25, 2021 11:40 — forked from kefir-/capture.sh
Screen capture with audio and webcam overlay with microphone using ffmpeg
# $ pacmd list-sources|awk '/index:/ {print $0}; /name:/ {print $0}; /device\.description/ {print $0}'
# index: 0
# name: <alsa_output.pci-0000_00_02.0-platform-hdmi-lpe-audio.stereo-fallback.monitor>
# device.description = "Monitor of Atom Processor Z36xxx/Z37xxx Series Graphics & Display Stereo"
# index: 1
# name: <alsa_output.platform-bytcr_rt5640.HiFi__hw_bytcrrt5640__sink.monitor>
# device.description = "Monitor of Built-in Audio MonoSpeaker playback + Speaker playback + Headphones playback"
# * index: 2
# name: <alsa_input.platform-bytcr_rt5640.HiFi__hw_bytcrrt5640__source>
# device.description = "Built-in Audio Internal IN3 analog Mic capture + Internal IN1 analog Mic capture + Headset Mic capture + DigitalMics capture"
@ritiek
ritiek / ffmpeg_stdin.py
Last active April 9, 2024 19:06
Using FFmpeg to read input via stdin in Python
# pip install pytube3
import pytube
import urllib.request
import subprocess
content = pytube.YouTube("https://www.youtube.com/watch?v=YQHsXMglC9A")
streams = content.streams.filter(only_audio=True).order_by("abr").desc()
response = urllib.request.urlopen(streams[0].url)
05943f25fec2ebe063de94d615cdce54646dd31bd9b90b45fecb04f04b34079ff387bf887e64d75d050ec68643b72f2a06432be7d517ad02da050f9aff7e96fb