Skip to content

Instantly share code, notes, and snippets.

@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'],
@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 / 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 / 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 / how_to.md
Last active May 7, 2019 12:12
Compiling source with static and shared library
// bin_hello.cpp

#include "lib_hello.h"

int main() {
    hello_world();
}
@ritiek
ritiek / wolfpedia.py
Last active April 28, 2019 09:01
Fetch information from wolfram and wikipedia using Flask API
import wolframalpha
import wikipedia
from wikipedia.exceptions import DisambiguationError
from flask import Flask
app = Flask(__name__)
client = wolframalpha.Client('T27H46-H3TH6GL545')
def wolframit(query):
@ritiek
ritiek / PlasmaPy.md
Last active March 25, 2019 13:19
My OpenAstronomy GSoC 2018 Application
@ritiek
ritiek / README.md
Last active February 20, 2019 13:46
Aww yiss! Rick n' Roll Android Apps
@ritiek
ritiek / count.sh
Last active December 19, 2018 13:37
Count number of lines of code in a project
find . -name "*.py" -type f -exec grep . {} \; | wc -l
@ritiek
ritiek / bot.au3
Created November 3, 2018 05:35
chrome t-rex game bot
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)