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_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
@lmmx
lmmx / REPRO_CONDA_SETUP.md
Last active July 29, 2023 20:06
Demo of Stable Diffusion usage, storing the prompt in metadata https://twitter.com/permutans/status/1562471438501548034
conda create -n diffusers
conda activate diffusers
conda install -y pytorch torchvision torchaudio cudatoolkit=11.6 -c pytorch -c conda-forge
pip install diffusers transformers piexif

OUTDATED For hf_stablediffusion_img2img.py download https://github.com/huggingface/diffusers/blob/main/examples/inference/image_to_image.py (edit: this has been deprecated)

For hf_stablediffusion_inpaint.py run pip install git+https://github.com/huggingface/diffusers.git (not yet been released). At time of writing the DDIM scheduler worked, the default PNDM one did not.

@gante
gante / pt_img_gen.py
Last active July 29, 2023 20:08
Portuguese image generation
from diffusers import StableDiffusionPipeline
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
from torch import autocast
PT_PROMPT = "Um gato com um chapéu, pintura a aguarelas" # A cat with a hat, watercolor painting
# translation PT -> EN
transl_model_id = "Narrativa/mbart-large-50-finetuned-opus-pt-en-translation"
tokenizer = AutoTokenizer.from_pretrained(transl_model_id)
text_model = AutoModelForSeq2SeqLM.from_pretrained(transl_model_id)
@karpathy
karpathy / stablediffusionwalk.py
Last active March 29, 2024 09:33
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
from sagemaker.huggingface.model import HuggingFaceModel
from sagemaker.serverless import ServerlessInferenceConfig
from sagemaker.serializers import DataSerializer
import sagemaker
import boto3
try:
role = sagemaker.get_execution_role()
except ValueError:
iam = boto3.client('iam')
@loretoparisi
loretoparisi / ukraine.css
Created March 2, 2022 17:15
SVG Lighting Effects With The feDiffuseLighting Filter Primitive
/* 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 {
@loretoparisi
loretoparisi / resumable.js
Last active January 31, 2022 16:21
Resumable.JS - NodeJS Express example - fixed deprecations, updated to latest express
var fs = require("fs"),
path = require("path"),
util = require("util"),
Stream = require("stream").Stream;
module.exports = resumable = function (temporaryFolder) {
var $ = this;
$.temporaryFolder = temporaryFolder;
$.maxFileSize = null;
$.fileParameterName = "file";
@loretoparisi
loretoparisi / List_of_Wikipedias.json
Created October 13, 2021 16:19
List of Wikipedias as JSON
[{
"language": "English",
"language_local": "English",
"wiki": "en",
"articles": "6,393,265",
"totals": "1,044,989,942",
"edits": "1,077",
"admins": "42,366,457",
"users": "125,915",
"active_users": "895,061"