{{ message }}

Instantly share code, notes, and snippets.

💭
what? statuses on github too now?

# jac lou hoo postylem

💭
what? statuses on github too now?
Created Oct 26, 2019
View crop_image.py
 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
Created Aug 16, 2013
outputs a program that prints itself after n iterations.
View n-cycle-quinemaker.py
 # 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"
Last active Jan 16, 2021
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…
View onelinequine.py
 print (lambda x: x + str((x,)))('print (lambda x: x + str((x,)))',)