Skip to content

Instantly share code, notes, and snippets.

Avatar
🐍

Loreto Parisi loretoparisi

🐍
View GitHub Profile
@loretoparisi
loretoparisi / longest_subsequence_bisect.py
Created January 26, 2023 16:43
Longest Common Sub Sequence (LCS) Bisect
View longest_subsequence_bisect.py
def longest_subsequence_bisect(seq, mode='strictly', order='increasing',
key=None, index=False):
"""
@TODO: to replace longest_subsequence_linear
>>> longest_subsequence_bisect([1,2,3,4,5,6,7,2,2,2,2,2,5,1,7,8])
Return the longest increasing subsequence of `seq`.
@loretoparisi
loretoparisi / longest_subsequence_linear.py
Created January 26, 2023 16:42
Longest Common Sub Sequence (LCS) Linear
View longest_subsequence_linear.py
def longest_subsequence_linear(seq, keyfn=lambda value: value):
''' Longest Increasing Subsequence
>>> seq = [0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15]
>>> lis(seq)
[0, 2, 6, 9, 11, 15]
>>> lis([])
[]
'''
if not seq: return seq
@loretoparisi
loretoparisi / wavesurfer.js
Last active February 25, 2023 17:01
Wavesurfer js setup with timing labels and time formating callback
View wavesurfer.js
/**
* Wavesurfer.js minimalistic example with
* regions loading, save, plugins, waveform loading from json, waveform zoom, player events, keyboard codes, auto play
* @author: Loreto Parisi (loretoparisi at gmail dot com) - mainly, some code and functions adpated from Wavesurfer examples
* @disclaimer: code adapted from online examples
*/
// JavaScript
// Wrap the native DOM audio element play function and handle any autoplay errors
@loretoparisi
loretoparisi / REPRO_CONDA_SETUP.md
Created August 25, 2022 22:09 — forked from lmmx/REPRO_CONDA_SETUP.md
Demo of Stable Diffusion usage, storing the prompt in metadata https://twitter.com/permutans/status/1562471438501548034
View REPRO_CONDA_SETUP.md
@loretoparisi
loretoparisi / stablediffusionwalk.py
Created August 25, 2022 10:49 — forked from karpathy/stablediffusionwalk.py
hacky stablediffusion code for generating videos
View stablediffusionwalk.py
"""
stable diffusion dreaming
creates hypnotic moving videos by smoothly walking randomly through the sample space
example way to run this script:
$ python stablediffusionwalk.py --prompt "blueberry spaghetti" --name blueberry
to stitch together the images, e.g.:
$ ffmpeg -r 10 -f image2 -s 512x512 -i blueberry/frame%06d.jpg -vcodec libx264 -crf 10 -pix_fmt yuv420p blueberry.mp4
@loretoparisi
loretoparisi / diffusers.py
Created August 24, 2022 12:49
Stable Diffusion Pipeline
View diffusers.py
# make sure you're logged in with `huggingface-cli login`
import os
from torch import autocast
from diffusers import StableDiffusionPipeline, LMSDiscreteScheduler
lms = LMSDiscreteScheduler(
beta_start=0.00085,
beta_end=0.012,
beta_schedule="scaled_linear"
)
@loretoparisi
loretoparisi / coders.md
Last active June 3, 2022 12:55
coders+00001
View coders.md

coders+00001

Chief: "if this than that…"
Newbie Coder: "tap tap tap…" (coding)

(5 years later…)

Chief: "if this than that…"
Veteran Coder: (Go to team) "If this than that…"

(5 minutes later…)

@loretoparisi
loretoparisi / wikidata_properties.sparql
Created April 1, 2022 08:30
Wikidata Entity Properties Sparql query
View wikidata_properties.sparql
SELECT ?wdLabel ?ooLabel
WHERE {
VALUES (?s) {(wd:%@)}
?s ?wdt ?o .
?wd wikibase:directClaim ?wdt .
?wd rdfs:label ?wdLabel .
OPTIONAL {
?o rdfs:label ?oLabel .
FILTER (lang(?oLabel) = "en")
}
@loretoparisi
loretoparisi / wikidata_religions
Created March 30, 2022 13:43
Wikidata Query Religions
View wikidata_religions
https://query.wikidata.org/#SELECT%20%3Fitem%20%3Ffreebase_id%20%3Fmodified%20%3Fen%20%3Furl_en%20%3Fes%20%3Furl_es%20%3Fit%20%3Furl_it%20%3Ffr%20%3Furl_fr%20%3Fde%20%3Furl_de%20%3Fpt%20%3Furl_pt%20%3Fko%20%3Furl_ko%20%3Fja%20%3Furl_ja%20%3Fzh%20%3Furl_zh%20%20WHERE%20%7B%20%7B%20%3Fitem%20wdt%3AP31%20wd%3AQ9174.%20%7D%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20UNION%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%20%3Fitem%20wdt%3AP31%20wd%3AQ5390013.%20%7D%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20UNION%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%20%3Fitem%20wdt%3AP31%20wd%3AQ7257.%20%7D%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20UNION%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%20%3Fitem%20wdt%3AP31%20wd%3AQ71966963.%20%7D%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20UNION%20%20%20%20%20%2
@loretoparisi
loretoparisi / ukraine.css
Created March 2, 2022 17:15
SVG Lighting Effects With The feDiffuseLighting Filter Primitive
View ukraine.css
/* Add the seed attribute and set it to a random integer in <feTurbulence> to create your own variant! */
html,
body,
object {
height: 100%;
width: 100%;
margin: 0px;
padding: 0px;
}
div {