Skip to content

Instantly share code, notes, and snippets.

View mynameisvinn's full-sized avatar

v mynameisvinn

View GitHub Profile
Generating image embeddings for Hub
# we know the following graph is nilpontent
m = np.array([[0, 1, 0, 0, 0, 0],
[0, 0, 1, 1, 0, 0],
[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 1],
[0, 0, 0, 0, 0, 1],
[0, 0, 1, 0, 0, 0]])
for k in range(len(m)):
print(m)
@mynameisvinn
mynameisvinn / test_acyclicity.py
Last active May 30, 2020 21:06
test acyclicity by evaluating whether adjacency matrix is nilpontent
"""
graph examples collected from https://www.cs.hmc.edu/~keller/courses/cs60/s98/examples/acyclic/
in the first example, we have an acylic graph. there exists k such its adjacency
matrix m^k == 0. because we cant produce a path of arbitrarily high length (eg
greater than k), the graph does not have a cycle.
in the second example, we have a cyclic graph. there is no k where its adjacency
matrix m^k == 0.
@mynameisvinn
mynameisvinn / lisp_parser.py
Last active April 28, 2020 16:06
recurse center, pair programming
def create_tokens(source):
"""convert source to tokens.
convert a string "(first (list 1 (+ 2 3) 9))" into a python list
['(', 'first', '(', 'list', '1', '(', '+', '2', '3', ')', '9', ')', ')'].
this conversion allows us to recursively inspect each element in the list.
"""
return source.replace('(',' ( ').replace(')',' ) ').split()
class Vertex(object):
"""represent vertices in a tree/graph."""
def __init__(self, name):
self.name = name
self.children = {}
self.status = None
def add_child(self, child):
key = child.name
self.children[key] = child
@mynameisvinn
mynameisvinn / gist:ac8e37881d9eb5c198f953b8132c0b5b
Created November 27, 2016 15:51 — forked from CristinaSolana/gist:1885435
Keeping a fork up to date

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
# Image processing function
# Usage: In the Terminal, run: bash images.sh
# Get user input and resize images
function process () {
# rename
a=1
for i in *.${ext}
do