Skip to content

Instantly share code, notes, and snippets.

@aredden
aredden / pytorch_colormap.py
Last active May 21, 2023 01:33
Helper class for efficiently creating a torch.uint8 colormaped (H, W, 3) image (entirely on device) from a (H, W) float32 tensor
import torch
from einops import rearrange
_magma_table = [
(0.001462, 0.000466, 0.013866),
(0.002258, 0.001295, 0.018331),
(0.003279, 0.002305, 0.023708),
(0.004512, 0.003490, 0.029965),
(0.005950, 0.004843, 0.037130),
(0.007588, 0.006356, 0.044973),
@davidbegin
davidbegin / Voices.txt
Created December 19, 2022 00:07
List of AI Voice Options
ishowspeed
sonic-cd
norm-pf
merg
kevin-spencer-narrator
cobra-bubbles
aunt-grandma
eduardo
thomas-leokimvideo
diego
# Script for converting a HF Diffusers saved pipeline to a Stable Diffusion checkpoint.
# *Only* converts the UNet, VAE, and Text Encoder.
# Does not convert optimizer state or any other thing.
# Written by jachiam
import argparse
import os.path as osp
import torch
@PJUllrich
PJUllrich / big-o.md
Last active June 28, 2024 20:25
Big-O Time Complexities for Elixir Data Structures

Big-O Time Complexities for Elixir data structures

Map [1]

Operation Time Complexity
Access O(log n)
Search O(log n)
Insertion O(n) for <= 32 elements, O(log n) for > 32 elements [2]
Deletion O(n) for <= 32 elements, O(log n) for > 32 elements
@jerry73204
jerry73204 / tch-serde.rs
Created June 3, 2020 19:09
serde on tch-rs types example
use failure::Fallible;
use serde::{
de::Error as DeserializeError, ser::Error as SerializeError, Deserialize, Deserializer,
Serialize, Serializer,
};
use std::fs;
use tch::{Device, Kind, Tensor};
fn main() -> Fallible<()> {
let json = fs::read_to_string("example.json")?;
@atomkirk
atomkirk / cloud-files.md
Last active January 18, 2023 17:23
Storing files on S3 with Elixir

I have this abstraction in my application code called a "CloudFile". This is where I store in the database information about files on S3 and it gives me a resource for other resources to own. For example, a user would have an avatar_cloud_file_id. On the front-end, I would load this relationship and display the avatar with user.avatar_cloud_file.download_url

defmodule RL.CloudFile do
  use Ecto.Schema
  import Ecto.Changeset

  @timestamps_opts type: :utc_datetime_usec
@andersevenrud
andersevenrud / alacritty-tmux-vim_truecolor.md
Last active July 19, 2024 17:36
True Color (24-bit) and italics with alacritty + tmux + vim (neovim)

True Color (24-bit) and italics with alacritty + tmux + vim (neovim)

This should make True Color (24-bit) and italics work in your tmux session and vim/neovim when using Alacritty (and should be compatible with any other terminal emulator, including Kitty).

Testing colors

Running this script should look the same in tmux as without.

curl -s https://gist.githubusercontent.com/lifepillar/09a44b8cf0f9397465614e622979107f/raw/24-bit-color.sh >24-bit-color.sh
@atomkirk
atomkirk / endpoint.ex
Created February 23, 2018 16:50
raw body plug parser
plug Plug.Parsers,
parsers: [ZB.Parsers.RAWBODY, :urlencoded, :multipart, :json],
pass: ["*/*"],
json_decoder: Poison
@oliveratgithub
oliveratgithub / emojis.json
Last active July 12, 2024 23:12
Emoji-list with emojis, names, shortcodes, unicode and html entities [massive list]
{
"emojis": [
{"emoji": "👩‍👩‍👧‍👧", "name": "family: woman, woman, girl, girl", "shortname": ":woman_woman_girl_girl:", "unicode": "1F469 200D 1F469 200D 1F467 200D 1F467", "html": "&#128105;&zwj;&#128105;&zwj;&#128103;&zwj;&#128103;", "category": "People & Body (family)", "order": ""},
{"emoji": "👩‍👩‍👧‍👦", "name": "family: woman, woman, girl, boy", "shortname": ":woman_woman_girl_boy:", "unicode": "1F469 200D 1F469 200D 1F467 200D 1F466", "html": "&#128105;&zwj;&#128105;&zwj;&#128103;&zwj;&#128102;", "category": "People & Body (family)", "order": ""},
{"emoji": "👩‍👩‍👦‍👦", "name": "family: woman, woman, boy, boy", "shortname": ":woman_woman_boy_boy:", "unicode": "1F469 200D 1F469 200D 1F466 200D 1F466", "html": "&#128105;&zwj;&#128105;&zwj;&#128102;&zwj;&#128102;", "category": "People & Body (family)", "order": ""},
{"emoji": "👨‍👩‍👧‍👧", "name": "family: man, woman, girl, girl", "shortname": ":man_woman_girl_girl:", "unicode": "1F468 200D 1F469 200D 1F467 200D 1F467", "html": "&#128104;&zwj;&#128105;&z
@jcalz
jcalz / tuple.md
Last active March 1, 2024 03:33
TypeScript tuple inference

You can use the tuple() function in tuple.ts to infer tuple types in TypeScript and cut down on the need to repeat yourself. Without tuple(), declaring a constant of a tuple type looks like this:

const daysOfTheWeek: ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"] = 
  ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"];

You can't do this:

const daysOfTheWeek = ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"];