Skip to content

Instantly share code, notes, and snippets.

View justinnhli's full-sized avatar

Justin Li justinnhli

View GitHub Profile
@justinnhli
justinnhli / spiral.py
Last active June 5, 2017 23:07
Pretty Spirals
from turtle import *
'''
Animated result: http://imgur.com/H49ukwF.gif
This script saves each image as 000.ps, 001.ps, ..., 180.ps
The Postscript files can be converted to jpgs/pngs using imagemagick:
$ convert -density 200 -geometry 50% -flatten 180.ps 180.png
import re
ORIGINAL_FILEPATH = '/Users/chloerainezeller/Desktop/Occidental/Oxy - Fourth Year/First Semester/COMPSCI COMPS/Debiasing-Word-Embeddings/fastText/data.txt'
NEW_FILEPATH = 'gender_neutral_data.txt'
MARKER = '_CHLOE_ROCKS'
REPLACEMENTS = [
['she','he'],
['her','him'],
@justinnhli
justinnhli / clap.py
Created October 15, 2018 19:41
👏👏, 👏👏👏, 👏👏👏👏; 👏👏.
#!/usr/bin/env python3
# vim: set fileencoding=utf-8
for num_claps in range(2, 5):
globals()[num_claps * 'clap'] = (lambda num_claps:
(lambda: print(num_claps * '👏'))
)(num_claps)
clapclap()
clapclapclap()
#!/bin/sh
export INSTALL_DIR=/usr/local
# download and install sqlite (required by proj)
curl -L https://www.sqlite.org/2020/sqlite-autoconf-3340000.tar.gz > sqlite.tar.gz
tar -xzvf sqlite.tar.gz
cd sqlite-autoconf-3340000/
CFLAGS="-DSQLITE_ENABLE_COLUMN_METADATA=1" ./configure --prefix=$INSTALL_DIR
make
#!/usr/bin/env python3
"""A recursive-descent arithmetic calculator."""
import re
from collections import namedtuple
from fractions import Fraction
Parse = namedtuple('Parse', 'value, index')
FAILURE = Parse(None, -1)