Skip to content

Instantly share code, notes, and snippets.

Avatar
🏃‍♂️
Sprinting

Sleeba Paul sleebapaul

🏃‍♂️
Sprinting
View GitHub Profile
@sleebapaul
sleebapaul / adventuresWithTries.py
Created Feb 9, 2020
Adventures with Trie data structure
View adventuresWithTries.py
class Node():
def __init__(self, character):
self.letter = character
self.isEndOfWord = False
self.children = {}
class Trie:
def __init__(self):
"""
Initialize an empty Node as root.
@sleebapaul
sleebapaul / binarySearchTree.py
Last active Jun 30, 2020
Arsenal for Binary Search Tree Adventures
View binarySearchTree.py
class Node():
"""
Basic component of a Tree is a Node
"""
def __init__(self, value):
self.value = value
self.left = None
self.right = None
@sleebapaul
sleebapaul / bitwise_operations.py
Last active Dec 25, 2019
Bitwise operations using Python
View bitwise_operations.py
def set_bit(x, pos):
"""
First create a mask which has 1 in the required position and everywhere else is 0
Then do bitwise OR that will the set 1 in the position
"""
mask = 1 << pos
return x | mask
def clear_bit(x, pos):
"""
@sleebapaul
sleebapaul / binary_search.py
Last active Jan 11, 2020
Binary Search using Python
View binary_search.py
def binary_search(a_list, search_item):
"""
Binary search using loop on a sorted list
Based on the value we look for, bifurcate the list into two look up windows.
The value we look for is the middle value of current window.
If search value < middle value of the window, put the upper bound to middle value
If search value > middle value of the window, put the lower bound to middle value
@sleebapaul
sleebapaul / queue_using_linked_list.py
Created Dec 20, 2019
Implementation of Queue using Linked List
View queue_using_linked_list.py
class Node(object):
"""
Fundamental building block of a linked list
A node consists of a value and the next node location pointer
"""
def __init__(self, value):
self.val = value
self.next = None
@sleebapaul
sleebapaul / stack_using_linked_list.py
Last active Dec 20, 2019
Implementation of Stack using Linked List
View stack_using_linked_list.py
class Node(object):
"""
Fundamental building block of a linked list
A node consists of a value and the next node location pointer
"""
def __init__(self, value):
self.val = value
self.next = None
@sleebapaul
sleebapaul / single_linked_list_ops.py
Last active Feb 19, 2020
(Almost) everything you need for your Single Linked List adventures
View single_linked_list_ops.py
class Node():
"""
Basic component for single linked list - A node
A node consist of a value and a pointer to another node
"""
def __init__(self, data):
self.val = data
self.next = None
@sleebapaul
sleebapaul / simple_language_model.py
Created Jun 1, 2018
The simplest character level language model using random picking of characters from a dictionary
View simple_language_model.py
import random
import string
from string import punctuation
# Get all the alphabets
alphabetsList = list(string.ascii_letters)
# Get all the punctuations
punctuationList = list(punctuation)
@sleebapaul
sleebapaul / commands
Last active Apr 2, 2021
FFMPEG commandline tool for video streaming and format conversion
View commands
// To start ffserver
ffserver -f /etc/ffserver.conf
// re stream incoming to ffsever
ffmpeg -rtsp_transport tcp -i "rtsp://admin:admin@65.254.18.55:7314/live/N4NXL/1/2" http://localhost:8090/camera.ffm
// configuration file
@sleebapaul
sleebapaul / matlab_snippet.m
Last active Nov 25, 2017
Why all should learn how to code?
View matlab_snippet.m
student = [‘A’, ’B’, ’C’, ’D’, ’E’];
marks = [21, 35, 13, 26, 49];
n = length(marks);
count = 0;
count1 = 0;
for i = 1:n
if marks(i) >= 25
fprintf(‘ %s has passed\n’,student(i));
count = count + 1;
else