Skip to content

Instantly share code, notes, and snippets.

Avatar

jairajsahgal jairajsahgal

View GitHub Profile
@jairajsahgal
jairajsahgal / animated_sin_wave.py
Created November 9, 2021 19:55
Animation of sin wave in python
View animated_sin_wave.py
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
# References
# https://towardsdatascience.com/animations-with-matplotlib-d96375c5442c
# https://riptutorial.com/matplotlib/example/23558/basic-animation-with-funcanimation
def func(t, line):
@jairajsahgal
jairajsahgal / word_auto_complete.py
Created November 9, 2021 17:59
This python program gives you auto complete suggestions of words just like command line.
View word_auto_complete.py
import readline
import requests
class MyCompleter(object): # Custom completer
def __init__(self, options):
self.options = sorted(options)
@jairajsahgal
jairajsahgal / reverse_video_save.py
Created September 30, 2021 19:56
This program reverses your video using opencv, and saves it with mp4 content.
View reverse_video_save.py
# make sure you have opencv installed, "pip install opencv-python"
# make sure your video is .avi or .mp4 encoded, else change the encoder accordingly
import cv2
output_file = "output.mp4"
cap = cv2.VideoCapture("Video File Location")
width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
fps = cap.get(cv2.CAP_PROP_FPS)
check , vid = cap.read()
counter = 0
@jairajsahgal
jairajsahgal / password_generator.sh
Created March 18, 2021 07:58
Password Generator in Bash
View password_generator.sh
#!/bin/bash
# Simple password generator
echo "This is a simple password generator"
echo "Please enter the length of the password"
read PASS_LENGTH
echo "Please enter number of passwords to be generated"
read NO_OF_PASS
echo "Enter website for which password is to be generated"
read COMPANY
View toss_a_coin.py
from random import *
l=["Head","Tail"]
shuffle(l)
print(l[0])
@jairajsahgal
jairajsahgal / toss_a_coin.py
Created February 27, 2021 10:39
A funny gist
View toss_a_coin.py
from random import *
l=["Head","Tail"]
shuffle(l)
print(l[0])