Skip to content

Instantly share code, notes, and snippets.

@ritiek
ritiek / ipscan.sh
Last active April 25, 2024 18:16
Scan for active local IP addresses and resolve their machine names
# Replace "192.168.2.{}" as per your gateway address.
seq 1 254 | xargs -I {} "echo" "192.168.2.{}" | parallel -j 254 "ping -t 1 -c 1 {} > /dev/null && (timeout 1 avahi-resolve -a {} || echo {})" 2> /dev/null
@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)
@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 / nightcore.sh
Last active January 14, 2024 11:36
Convert a track to nightcore
# Increase tempo (x1.06) and frequency (x1.25 assuming input freq. = 44100 Hz)
ffmpeg -i input.mp3 -filter:a "atempo=1.06,asetrate=44100*1.25" output.mp3
# Without tempo
ffmpeg -i input.mp3 -filter:a "asetrate=44100*1.25" output.mp3
# Create one frame .mp4 from .mp3 + .jpg
ffmpeg -i output.mp3 -i anime.jpg output.mp4
# Do above in single command
ffmpeg -i input.mp3 -i anime.jpg -filter:a "atempo=1.06,asetrate=44100*1.25" -vn output.mp4
@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 / 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 / hosts
Last active July 3, 2023 05:16
hosts file to block all GameRanger advertisements
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
@ritiek
ritiek / falling_blocks.py
Last active February 26, 2023 13:19
A simple (py)game
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()

Keybase proof

I hereby claim:

  • I am ritiek on github.
  • I am ritiek (https://keybase.io/ritiek) on keybase.
  • I have a public key ASA1qFuAESdfigezYxV8q4XPEY6hqSk8UHvogWNRJCsKJwo

To claim this, I am signing this object:

@ritiek
ritiek / scan_vendors.py
Last active January 11, 2023 10:09
Scan devices on LAN to get their IP, MAC and vendor name
#!/usr/bin/env python
import logging
import urllib2 as urllib
import nmap
logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
from scapy.all import *
def scanNetwork(network):