Skip to content

Instantly share code, notes, and snippets.

View loretoparisi's full-sized avatar
🐍
NightShift

Loreto Parisi loretoparisi

🐍
NightShift
View GitHub Profile
@loretoparisi
loretoparisi / activemq_run.sh
Last active May 31, 2023 10:22
ActiveMQ Up & Run Linux
wget https://dlcdn.apache.org//activemq/5.18.1/apache-activemq-5.18.1-bin.tar.gz
gunzip apache-activemq-5.18.1-bin.tar.gz
tar -xvf apache-activemq-5.18.1-bin.tar
cd apache-activemq-5.18.1
cd conf
myIP=$(LANG=C /sbin/ifconfig | sed -ne $'/127.0.0.1/ ! { s/^[ \t]*inet[ \t]\\{1,99\\}\\(addr:\\)\\{0,1\\}\\([0-9.]*\\)[ \t\/].*$/\\2/p; }')
sed -i "s/localhost/${myIP}/" jetty.xml
cd ..
cd bin
./activemq start
@loretoparisi
loretoparisi / longest_subsequence_bisect.py
Created January 26, 2023 16:43
Longest Common Sub Sequence (LCS) Bisect
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
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 December 20, 2023 00:08
Wavesurfer js setup with timing labels and time formating callback
/**
* 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
@loretoparisi
loretoparisi / stablediffusionwalk.py
Created August 25, 2022 10:49 — forked from karpathy/stablediffusionwalk.py
hacky stablediffusion code for generating videos
"""
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
# 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

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
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
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