Skip to content

Instantly share code, notes, and snippets.

>>> tprint("test","mix")
†Ɛѕ†
>>> tprint("test","mix")
tᏋѕt
>>> tprint("test","mix")
꓄єร꓄
# Import library
from undouble import Undouble
# Init with default settings
model = Undouble(method='phash', hash_size=8)
# Import example data
targetdir = model.import_example(data='flowers')
# Importing the files files from disk, cleaning and pre-processing
# Load library
import matplotlib.pyplot as plt
from clustimage import Clustimage
# init
cl = Clustimage()
# Load example digit data
X = cl.import_example(data='mnist')
print(X)
# Each row is an image that can be plotted after reshaping:
# Load library
import matplotlib.pyplot as plt
from clustimage import Clustimage
# init
cl = Clustimage()
# Load example digit data
X = cl.import_example(data='mnist')
print(X)
# Each row is an image that can be plotted after reshaping:
# Get the unique images
unique_samples = cl.unique()
#
print(unique_samples.keys())
# ['labels', 'idx', 'xycoord_center', 'pathnames']
#
# Collect the unique images from the input
X[unique_samples['idx'],:]
# Plot unique images.
# Make scatterplot
cl.scatter(zoom=None)
# Plot the image that is in the center of the cluster
cl.scatter(zoom=4)
# Lets change some more arguments to make a pretty scatterplot
cl.scatter(zoom=None, dotsize=200, figsize=(25, 15), args_scatter={'fontsize':24, 'gradient':'#FFFFFF', 'cmap':'Set2', 'legend':True})
@cache
def factorial(n):
return n * factorial(n-1) if n else 1
>>> factorial(10) # no previously cached result, makes 11 recursive calls
3628800
>>> factorial(5) # just looks up cached value result
120
>>> factorial(12) # makes two new recursive calls, the other 10 are cached
479001600
from functools import lru_cache
@lru_cache(maxsize=30)
def get_articles(on_date):
# Здесь затратная операция, выбирающая статьи
# на определённую дату.
articles = [...]
<div id="d1">
<ol id="ol1">
<li id="li1">1</li>
<li id="li2">2</li>
</ol>
var div = document.getElementById('d1')
var elems = div.getElementsByTagName('*')
for(var i=0; i<elems.length; i++) alert(elems[i].id)