Skip to content

Instantly share code, notes, and snippets.

View postylem's full-sized avatar
🔣
these are status symbols

Jacob Hoover Vigly postylem

🔣
these are status symbols
View GitHub Profile
@postylem
postylem / similar_common_uncommon.ipynb
Last active May 18, 2022 01:44
getting a list of pairs of common and uncommon words which are similar to each other
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
### A Pluto.jl notebook ###
# v0.17.4
using Markdown
using InteractiveUtils
# This Pluto notebook uses @bind for interactivity. When running this notebook outside of Pluto, the following 'mock version' of @bind gives bound variables a default value (instead of an error).
macro bind(def, element)
quote
local iv = try Base.loaded_modules[Base.PkgId(Base.UUID("6e696c72-6542-2067-7265-42206c756150"), "AbstractPlutoDingetjes")].Bonds.initial_value catch; b -> missing; end
from skimage.measure import regionprops, label
def crop_image(x, threshold=230, plot=True):
'''
finds large connected components using skimage.measure.label,
and displays them with matplotlib.pyplot.
'''
im = train_images[x]
mask = np.where(im > threshold, 1, 0)
# now get label_im, a version of the thresholded image, but
@postylem
postylem / n-cycle-quinemaker.py
Created August 16, 2013 19:03
outputs a program that prints itself after n iterations.
# a clunky n-cycle (iterated quine) generator:
def quiner(n):
'''prints a program that will print itself after n iterations'''
quotes = '"'*3
toprint = ''
for i in range(1,n):
toprint += 'def q' + str(i) + '(x):'"""
quotes = '"'*3
print 'q""" + str(i+1) + "(' + quotes + x + quotes + ')'\n\n"
@postylem
postylem / onelinequine.py
Last active January 16, 2021 15:03
This is the simplest model of a quine (a program that prints itself) I could think of in English: «print this followed by itself in quotes: "print this followed by itself in quotes:"». My first try at making this in Python was a little less elegant: «print (lambda x: x + '(' + repr(x) +')')("print (lambda x: x + '(' + repr(x) +')')")» Then I rea…
print (lambda x: x + str((x,)))('print (lambda x: x + str((x,)))',)