This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import openai | |
openai.api_key = os.getenv("OPENAI_API_KEY") | |
response = openai.Completion.create( | |
model="text-davinci-002", | |
prompt="A bot that creates haikus. A haiku is a three or four lines short poem | |
which can be written in various contexts like life, philosophy, politics, current affairs, | |
life lessons, deep thinking, beauty, success, failure and many others. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Node(): | |
""" | |
Basic component of a Tree is a Node | |
""" | |
def __init__(self, value): | |
self.value = value | |
self.left = None | |
self.right = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import string | |
from string import punctuation | |
# Get all the alphabets | |
alphabetsList = list(string.ascii_letters) | |
# Get all the punctuations | |
punctuationList = list(punctuation) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// To start ffserver | |
ffserver -f /etc/ffserver.conf | |
// re stream incoming to ffsever | |
ffmpeg -rtsp_transport tcp -i "rtsp://admin:[email protected]:7314/live/N4NXL/1/2" http://localhost:8090/camera.ffm | |
// configuration file |
NewerOlder