Skip to content

Instantly share code, notes, and snippets.

Avatar
🌴
On vacation

Ritiek Malhotra ritiek

🌴
On vacation
View GitHub Profile
@ritiek
ritiek / cmd.sh
Created Jul 19, 2020
mpv near lag-less real-time stream
View cmd.sh
mpv --no-cache --untimed --no-demuxer-thread --vd-lavc-threads=1 -
@ritiek
ritiek / README.md
Last active Jul 10, 2020
Adding a 3rd party apt repository
View README.md

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 Apr 10, 2020 — forked from kefir-/capture.sh
Screen capture with audio and webcam overlay with microphone using ffmpeg
View capture.sh
# $ 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 Mar 28, 2020
Using FFmpeg to read input via stdin in Python
View ffmpeg_stdin.py
# 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)
View gist:2c21aff65b16dba5cc3ec444a5a8390e
05943f25fec2ebe063de94d615cdce54646dd31bd9b90b45fecb04f04b34079ff387bf887e64d75d050ec68643b72f2a06432be7d517ad02da050f9aff7e96fb
@ritiek
ritiek / test_led.py
Last active Feb 3, 2020
Tests an LED connected via GPIO to Raspberry Pi with software defined PWM
View test_led.py
#!/usr/bin/env python
import RPi.GPIO as GPIO
import time
import sys
out_pin = int(sys.argv[1])
@ritiek
ritiek / get_language.py
Last active Aug 13, 2019
Get official spoken languages in a country
View get_language.py
# 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'],
@ritiek
ritiek / README.md
Last active Aug 1, 2019
Controlling mpris supported players (like mpsyt) on a headless Raspberry Pi with playerctl
View README.md
sudo apt install -y dbus 
wget http://raspbian.raspberrypi.org/raspbian/pool/main/p/playerctl/libplayerctl-dev_2.0.1-1_armhf.deb
wget http://raspbian.raspberrypi.org/raspbian/pool/main/p/playerctl/gir1.2-playerctl-2.0_2.0.1-1_armhf.deb
wget http://raspbian.raspberrypi.org/raspbian/pool/main/p/playerctl/libplayerctl2_2.0.1-1_armhf.deb
wget http://raspbian.raspberrypi.org/raspbian/pool/main/p/playerctl/playerctl_2.0.1-1_armhf.deb
sudo dpkg -i libplayerctl-dev_2.0.1-1_armhf.deb
sudo dpkg -i gir1.2-playerctl-2.0_2.0.1-1_armhf.deb
sudo dpkg -i libplayerctl2_2.0.1-1_armhf.deb
sudo dpkg -i playerctl_2.0.1-1_armhf.deb
@ritiek
ritiek / push_switch.py
Last active Jul 24, 2019
Detect 4-pin push switch presses with Raspberry Pi's GPIO pins
View push_switch.py
# 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 / change-wallpaper.py
Last active Jun 28, 2019
A Python cron-job that automatically sets desktop wallpapers from my Box cloud account
View change-wallpaper.py
#!/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")
You can’t perform that action at this time.