Skip to content

Instantly share code, notes, and snippets.

View xlambein's full-sized avatar

Xavier Lambein xlambein

View GitHub Profile
@xlambein
xlambein / toposort.py
Last active August 22, 2019 15:07
Python graph vertex with topological sorting
# The class `Vertex` is represents a vertex of a DAG that owns
# references to its children. A topological ordering of a vertex `v`
# and its children can be obtained by calling `v.toposort()`
class Vertex:
def __init__(self, name, children=None):
self.name = name
self.children = children or []
def toposort(self, visited=None):
@xlambein
xlambein / progressbar.jl
Last active June 3, 2016 13:37
A command-line progress bar macro for Julia for loops
function print_progress_bar(i, n, t; length=20)
pc = floor(Int, i/n*100)
nbr = floor(Int, i/n*length)
print('[', repeat("=", nbr), '>',
repeat(" ", length-nbr), ']')
print(" ($pc%)")
rem = t*(n/i-1.0)
print("\t")
if rem < 60.0
print("$(ceil(Int, rem))s")