Skip to content

Instantly share code, notes, and snippets.

View luqs1's full-sized avatar

Luqmaan luqs1

View GitHub Profile
@luqs1
luqs1 / Files.py
Created January 2, 2020 23:23
Host files in the directory on your IP accessible to others on the network
import socket
import os
port = input('port: ')
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(("8.8.8.8", 80))
ip = s.getsockname()[0]
s.close()
print(ip+':'+port)
os.system('python -m http.server --bind '+ip+' '+port)
@luqs1
luqs1 / BinaryTree.py
Created December 26, 2019 00:13
Binary Tree structure with in-order, pre-order, and post-order recursion support.
# Look at end for details
class Tree:
def __init__(self,data,left,right):
self.data = data
self.left = left
self.right = right
def traverse1(self,*f): #In Order
out = []
#out = ''
if self.left != -1:
@luqs1
luqs1 / Dijkstra.py
Last active December 26, 2019 00:26
A python implementation of Dijkstra's Algorithm
"""
https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm
USAGE:
use this file like a module (aka. create an init.py file at the directory you want to use it at and "import Dijkstra" in your code)
to create a node/ or a point:
variable = Dijkstra.Node('variableName', {'otherVariableName': distance,...}
and to create a graph/ table of nodes/ points:
tableOfPoints = Dijkstra.Graph([variable1, variable2, variable3, variable4])