Skip to content

Instantly share code, notes, and snippets.

Avatar
🌴
On vacation

Ritiek Malhotra ritiek

🌴
On vacation
View GitHub Profile
@ritiek
ritiek / folder_predict.py
Last active Nov 1, 2020
Keras predicting on all images in a directory
View folder_predict.py
from keras.models import load_model
from keras.preprocessing import image
import numpy as np
import os
# image folder
folder_path = '/path/to/folder/'
# path to model
model_path = '/path/to/saved/model.h5'
# dimensions of images
@ritiek
ritiek / nightcore.sh
Last active Sep 12, 2020
Convert a track to nightcore
View nightcore.sh
# 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 / scan_vendors.py
Last active Sep 8, 2020
Scan devices on LAN to get their IP, MAC and vendor name
View scan_vendors.py
#!/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):
@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)
@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])
View gist:2c21aff65b16dba5cc3ec444a5a8390e
05943f25fec2ebe063de94d615cdce54646dd31bd9b90b45fecb04f04b34079ff387bf887e64d75d050ec68643b72f2a06432be7d517ad02da050f9aff7e96fb
You can’t perform that action at this time.