Skip to content

Instantly share code, notes, and snippets.

@fancellu
fancellu / kontext_gpu_4bit.py
Last active July 7, 2025 14:06
Gradio demo for FluxContextDev but 4bit quant, fits on a 4090
import gradio as gr
import numpy as np
import spaces
import torch
import random
from PIL import Image
from diffusers import FluxKontextPipeline
from diffusers.utils import load_image
@fancellu
fancellu / README.md
Last active July 4, 2025 20:12
Kokoro-TTS-Zero-CPU
@fancellu
fancellu / README.md
Last active July 4, 2025 14:56
bark-pytorch2.6-compatible

https://huggingface.co/spaces/Fancellu/bark-pytorch2.6-compatible

This solves the PyTorch 2.6 breaking change where weights_only=True became the default, causing issues with older model files that contain non-tensor objects, with monkey patch patched_load()

Updated to Python 3.11, latest Gradio, and requirements.txt

If you have a GPU, you can run from Docker Desktop directly

docker run -it -p 7860:7860 --gpus=all --platform=linux/amd64 registry.hf.space/fancellu-bark-pytorch2-6-compatible:latest python app.py

@fancellu
fancellu / InterruptableReadLine.scala
Created September 27, 2024 21:16
InterruptableReadLine ZIO example of a readLine that can be timedout
import zio._
import scala.{ Console => SConsole }
import scala.io.StdIn
import java.io.{ BufferedReader, IOException }
import scala.util.Try
object InterruptableReadLine extends ZIOAppDefault {
def altReadLine(reader: BufferedReader = SConsole.in) =
ZIO
@fancellu
fancellu / FakeConsoleExample.scala
Created September 27, 2024 20:58
FakeConsoleExample zio supplying a fake Console
import zio._
object FakeConsoleExample extends ZIOAppDefault {
private val program = ZIO.serviceWithZIO[Console] { console =>
for {
_ <- console.printLine("Going to the grocery store")
input <- console.readLine("How are you? ")
_ <- console.printLine(s"You said: $input")
} yield ()
@fancellu
fancellu / dining.go
Last active September 30, 2024 21:49
Dining philosophers in golang (I have other impls in Rust, Scala, Scala+Cats effect here)
package main
import (
"fmt"
"math/rand"
"sync"
"time"
"unsafe"
)
@fancellu
fancellu / main.go
Created August 24, 2024 10:55
Golang goroutine channel sync and timeout example
package main
import (
"fmt"
"time"
)
func greet(st string, done chan bool) {
fmt.Println(st)
done <- true
@fancellu
fancellu / mapf.go
Last active September 30, 2024 21:48
Example of a generic FP map function [T=>U], and filter(), that golang doesn't have out of the box
package main
import (
"fmt"
"strconv"
)
// Maps over collection of T and applies function f to each item
// Returns a new slice with the transformed items
func mapf[T any, U any](items []T, f func(T) U) []U {
@fancellu
fancellu / WindowedAverage.scala
Created August 9, 2024 15:33
FS2 moving average demo
import cats.effect.{IO, IOApp}
import fs2.{Stream, text}
import fs2.io.file.{Files, Path}
import fs2.io.{stdout, stderr}
import scala.util.Try
object WindowedAverage extends IOApp.Simple:
private object Fahrenheit:
@fancellu
fancellu / BreakDemo.scala
Created April 25, 2024 17:52
Scala3 boundary/break/label demo (uses Scala 3.4.1)
import scala.annotation.targetName
import scala.util.boundary
import scala.util.boundary.{Label, break}
// Works in Scala 3.4.1
def firstIndex[T](xs: List[T], p: T): Int = {
boundary:
for (x, i) <- xs.zipWithIndex do if (x == p) break(i)
-1