Skip to content

Instantly share code, notes, and snippets.

View mikelane's full-sized avatar
💾
Engineering Software

Mike Lane mikelane

💾
Engineering Software
  • Portland, OR
View GitHub Profile
@mikelane
mikelane / shunting_yard.py
Last active January 16, 2021 23:11
Shunting Yard Algorithm in Python
import re
from collections import deque
from typing import List, Union
def tokenize(expression: str) -> List[Union[int, str]]:
tokens = [
int(token)
if token.isnumeric()
else token
@mikelane
mikelane / game_of_life.py
Last active March 21, 2022 22:52
Conway's Game of Life implemented using a 2d convolution.
import click
import difflib
import numpy as np
import random
import sys
import time
from os import name, system
from scipy.ndimage import convolve
def draw_square(side_length: int) -> None:
for _ in range(4):
turtle.forward(side_length)
turtle.right(90)
def draw_concentric_squares(number_of_squares: int = 5, radius_increase: int = 20) -> None:
turtle.begin_fill()
for length in range(radius_increase, 2 * number_of_squares * radius_increase, radius_increase * 2):
draw_square(length)
x, y = turtle.pos()
@mikelane
mikelane / # graphviz - 2016-11-02_07-57-07.txt
Last active November 2, 2016 15:00
graphviz on macOS 10.12.2 - Homebrew build logs
Homebrew build logs for graphviz on macOS 10.12.2
Build date: 2016-11-02 07:57:07
@mikelane
mikelane / index.html
Created December 6, 2015 02:32 — forked from mbostock/.block
Hierarchical Edge Bundling
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.node {
font: 300 11px "Helvetica Neue", Helvetica, Arial, sans-serif;
fill: #bbb;
}
.node:hover {
@mikelane
mikelane / node-and-npm-in-30-seconds.sh
Last active November 24, 2015 15:13 — forked from isaacs/node-and-npm-in-30-seconds.sh
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.com/install.sh | sh