Skip to content

Instantly share code, notes, and snippets.

View toshsan's full-sized avatar
🌴
On vacation

Santosh Sahoo toshsan

🌴
On vacation
View GitHub Profile
@toshsan
toshsan / gist:ec7afd3c72445c40f2d5
Last active August 29, 2015 14:02 — forked from econchick/gist:4666413
Python implementation of Dijkstra's Algorithm
class Graph:
def __init__(self):
self.nodes = set()
self.edges = defaultdict(list)
self.distances = {}
def add_node(self, value):
self.nodes.add(value)
def add_edge(self, from_node, to_node, distance):
@toshsan
toshsan / gist:7faf3f67e6768196b7ad
Last active August 29, 2015 14:01 — forked from adamgreig/gist:6233882
TOPT Code generator, for use with Google Authenticator
import time
import hmac
import struct
import base64
import hashlib
def code(secret):
key = base64.b32decode(secret)
message = struct.pack(">Q", int(time.time()) / 30)
h = hmac.new(key, message, hashlib.sha1).digest()