Skip to content

Instantly share code, notes, and snippets.

View sarmadgulzar's full-sized avatar
🤖
AI

Sarmad Gulzar sarmadgulzar

🤖
AI
View GitHub Profile
@sarmadgulzar
sarmadgulzar / mapping.json
Last active June 19, 2024 17:59
Morse Code Encoder and Decoder
{"0":"-----","1":".----","2":"..---","3":"...--","4":"....-","5":".....","6":"-....","7":"--...","8":"---..","9":"----.","A":".-","B":"-...","C":"-.-.","D":"-..","E":".","F":"..-.","G":"--.","H":"....","I":"..","J":".---","K":"-.-","L":".-..","M":"--","N":"-.","O":"---","P":".--.","Q":"--.-","R":".-.","S":"...","T":"-","U":"..-","V":"...-","W":".--","X":"-..-","Y":"-.--","Z":"--..",".":".-.-.-",",":"--..--","?":"..--..","'":".----.","!":"-.-.--","/":"-..-.","(":"-.--.",")":"-.--.-","&":".-...",":":"---...",";":"-.-.-.","=":"-...-","+":".-.-.","-":"-....-","_":"..--.-","\"":".-..-.","$":"...-..-","@":".--.-.","¿":"..-.-","¡":"--...-"}
@sarmadgulzar
sarmadgulzar / add_subtitles.py
Last active February 7, 2024 15:33
Launchpad Presentation
import cv2
from moviepy.video.compositing.CompositeVideoClip import CompositeVideoClip
from moviepy.video.VideoClip import ImageClip, TextClip
img = cv2.imread("input.png")
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
vid = ImageClip(img)
frame_height = img.shape[0]
@sarmadgulzar
sarmadgulzar / substitch.py
Created September 12, 2023 23:06
Stitch YouTube subtitles
import json
data = {}
with open("timedtext.json") as file:
data = json.load(file)
def extract_text(data):
strings = []
@sarmadgulzar
sarmadgulzar / swap.cpp
Created December 8, 2022 08:31
Swap values without using a third variable
#include <iostream>
int main() {
int a = 7;
int b = 5;
std::cout << "Before: a=" << a << ", b=" << b << "\n";
a += b;
b = a - b;
@sarmadgulzar
sarmadgulzar / README.md
Created June 10, 2022 22:49
Some useful scripts to explore the 3x+1 problem explained in: https://www.youtube.com/watch?v=094y1Z2wpJg

Note: You will need to have Python 3 and Rust installed on your computer!

To check how many iterations a number takes to reach 1, run the number_of_iterations.py file as follows:

python3 number_of_iterations.py

Output:

@sarmadgulzar
sarmadgulzar / logic.rs
Created September 14, 2021 00:09
Logic Gates in Rust
#[derive(Debug, Clone, Copy)]
enum Bit {
ZERO,
ONE,
}
impl Bit {
fn nand(self, other: Self) -> Self {
match self {
Self::ONE => match other {
@sarmadgulzar
sarmadgulzar / complex.rs
Created June 6, 2021 04:35
Complex Numbers in Rust
use std::fmt;
use std::ops;
#[derive(Copy, Clone)]
pub struct Complex {
pub real: f64,
pub imag: f64,
}
impl Complex {
@sarmadgulzar
sarmadgulzar / guess_the_number.py
Created August 6, 2019 18:18
A simple program in which user assumes a number between 0 and 100 and computer tries to guess it. When it guesses the number correctly, we display how many tries it took to reach the correct answer.
import random
lower_bound = 0
upper_bound = 100
random_number = int
guess_count = 1
print('Think of a number between 0-100 in your head, and I will try to guess it.')
print('Enter C for correct, L if it is lower and H if it is higher.')