Skip to content

Instantly share code, notes, and snippets.

💭
Life is just a cruel investment in entropy.

Ritiek Malhotra ritiek

💭
Life is just a cruel investment in entropy.
Block or report user

Report or block ritiek

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@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")
@ritiek
ritiek / mpv-socat.sh
Created Jun 3, 2019
Start a track on instances of mpv on different machines at the same time using mpv's IPC server with socat
View mpv-socat.sh
#!/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 / how_to.md
Last active May 7, 2019
Compiling source with static and shared library
View how_to.md
// bin_hello.cpp

#include "lib_hello.h"

int main() {
    hello_world();
}
@ritiek
ritiek / falling_blocks.py
Last active Mar 31, 2019
A simple (py)game with purposely messed code to teach important programming concept to newbies
View falling_blocks.py
import pygame
import random
width, height = (450, 600)
background_color = (10,10,10)
clock = pygame.time.Clock()
screen = pygame.display.set_mode((width, height))
pygame.display.set_caption("Falling Blocks")
pygame.display.flip()
View search_results.html
<!DOCTYPE html><html lang="en" data-cast-api-enabled="true"><head><style name="www-roboto" >@font-face{font-family:'Roboto';font-style:italic;font-weight:400;src:local('Roboto Italic'),local('Roboto-Italic'),url(//fonts.gstatic.com/s/roboto/v18/KFOkCnqEu92Fr1Mu51xIIzc.ttf)format('truetype');}@font-face{font-family:'Roboto';font-style:italic;font-weight:500;src:local('Roboto Medium Italic'),local('Roboto-MediumItalic'),url(//fonts.gstatic.com/s/roboto/v18/KFOjCnqEu92Fr1Mu51S7ACc6CsE.ttf)format('truetype');}@font-face{font-family:'Roboto';font-style:normal;font-weight:400;src:local('Roboto Regular'),local('Roboto-Regular'),url(//fonts.gstatic.com/s/roboto/v18/KFOmCnqEu92Fr1Mu4mxP.ttf)format('truetype');}@font-face{font-family:'Roboto';font-style:normal;font-weight:500;src:local('Roboto Medium'),local('Roboto-Medium'),url(//fonts.gstatic.com/s/roboto/v18/KFOlCnqEu92Fr1MmEU9fBBc9.ttf)format('truetype');}</style><script name="www-roboto" >if (document.fonts && document.fonts.load) {document.fonts.load("400 10pt
@ritiek
ritiek / bot.au3
Created Nov 3, 2018
chrome t-rex game bot
View bot.au3
HotKeySet("{F10}", "Exitter")
While 1
$color = PixelGetColor(545,229)
If $color = 5460819 Then
Send("{DOWN UP}")
Send("{UP DOWN}")
Sleep(150)
Send("{UP UP}")
Sleep(300)
@ritiek
ritiek / GSoC18_FinalReport.md
Created Aug 11, 2018
Google Summer of Code 2018 Final Report
View GSoC18_FinalReport.md

Google Summer of Code 2018 Final Report

My original project - to create a factory based implementation for unifying handling of different types of Plasmas, was completed sooner than expected. Here are the link to related pull requests I made during the summer.

PR Status Description
#501 Merged Raise more fitting NotImplementedError for functions that are yet to be implemented in our Plasma metaclass
#489 Merged Ind
You can’t perform that action at this time.