Skip to content

Instantly share code, notes, and snippets.

@ritiek
ritiek / mpv-socat.sh
Created June 3, 2019 07:56
Start a track on instances of mpv on different machines at the same time using mpv's IPC server with socat
#!/bin/bash
# mpv --idle --no-video --loop --input-ipc-server=/tmp/mpvsocket
# socat /tmp/mpvsocket udp4-listen:5000,reuseaddr,fork
SOCKETS=(#"192.168.1.2:5000"
"192.168.1.3:5000"
"192.168.1.4:5000"
"192.168.1.9:5000"
"192.168.1.8:5000")
@ritiek
ritiek / change-wallpaper.py
Last active June 28, 2019 22:28
A Python cron-job that automatically sets desktop wallpapers from my Box cloud account
#!/usr/bin/python
import random
import os
import subprocess
import sys
from PIL import Image
ROOT_DIR = os.path.expanduser("~/Mount/box")
WALLPAPER_DIR = os.path.join(ROOT_DIR, "Pictures")
@ritiek
ritiek / push_switch.py
Last active July 24, 2019 08:59
Detect 4-pin push switch presses with Raspberry Pi's GPIO pins
# Code stolen shamelessly from
# https://www.raspberrypi.org/forums/viewtopic.php?p=876947&sid=44c21629719b08f74de2b3b465db8d5c#p876947
# I merely modified some bits
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
pin = 4
@ritiek
ritiek / get_language.py
Last active August 13, 2019 14:17
Get official spoken languages in a country
# This data has been compiled from
# https://en.m.wikipedia.org/wiki/List_of_official_languages_by_country_and_territory
country_languages = {
'Abkhazia': ['Abkhaz', 'Russian'],
'Afghanistan': ['Pashto', 'Dari'],
'Albania': ['Albanian'],
'Algeria': ['Arabic', 'Tamazight'],
'Andorra': ['Catalan'],
'Angola': ['Portuguese'],
05943f25fec2ebe063de94d615cdce54646dd31bd9b90b45fecb04f04b34079ff387bf887e64d75d050ec68643b72f2a06432be7d517ad02da050f9aff7e96fb
@ritiek
ritiek / test_led.py
Last active February 3, 2020 09:56
Tests an LED connected via GPIO to Raspberry Pi with software defined PWM
#!/usr/bin/env python
import RPi.GPIO as GPIO
import time
import sys
out_pin = int(sys.argv[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 / 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 -

If you have no idea what this is about. See https://github.com/ritiek/piano-rs.

Dragonborn Comes

FG(FB) (FB)J(BK) (BK)W(GJ)BGF x2

Kataware Doki

(qu) u u (nu) trre(ct)m e

@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"