Skip to content

Instantly share code, notes, and snippets.

View jorgeavaldez's full-sized avatar
🦀
vibin

Jorge Valdez jorgeavaldez

🦀
vibin
View GitHub Profile
use kalosm::language::*;
#[tokio::main]
async fn main() {
let local_source = LlamaSource::new(
FileSource::Local("path/to/llama/model".into()),
FileSource::Local("path/to/llama/tokenizer.json".into()),
)
.with_group_query_attention(
// 1 for llama, 8 for mistral
@kconner
kconner / macOS Internals.md
Last active May 6, 2024 22:20
macOS Internals

macOS Internals

Understand your Mac and iPhone more deeply by tracing the evolution of Mac OS X from prelease to Swift. John Siracusa delivers the details.

Starting Points

How to use this gist

You've got two main options:

@rphlmr
rphlmr / clear-db.ts
Last active April 30, 2024 14:41
Drizzle snippets
// Credits to Louistiti from Drizzle Discord: https://discord.com/channels/1043890932593987624/1130802621750448160/1143083373535973406
import { sql } from "drizzle-orm";
const clearDb = async (): Promise<void> => {
const query = sql<string>`SELECT table_name
FROM information_schema.tables
WHERE table_schema = 'public'
AND table_type = 'BASE TABLE';
`;
""""""""""""""""""""""
" Leader
""""""""""""""""""""""
" let mapleader=,
" can't set leaders in Obsidian vim, so the key just has to be used consistently.
" However, it needs to be unmapped, to not trigger default behavior: https://github.com/esm7/obsidian-vimrc-support#some-help-with-binding-space-chords-doom-and-spacemacs-fans
unmap ,
" map ; to : in normal mode, so that I don’t rely on the shift key
" nmap ; :
@vnl
vnl / MediaDownloader.yaml
Created October 5, 2021 20:10
Docker-compose file which shows how to set up Sonarr, Radarr, Prowlarr, Lidarr, Jackett, QBittorrent and a VPN container so that all all traffic from the containers is routed through the VPN. Also includes get_iplayer containers, which is not routed through the VPN.
version: "3"
services:
vpn:
image: qmcgaw/gluetun
container_name: vpn
cap_add:
- NET_ADMIN
ports:
- 8888:8888/tcp # HTTP proxy
- 8388:8388/tcp # Shadowsocks
@cb109
cb109 / remove_custom_fk_uniqueconstraint_django_mysql.md
Last active February 9, 2024 18:42
Fix: Cannot remove UniqueConstraint on ForeignKey with Django/MySQL

Django allows you to define custom UniqueConstraints to specify which combinations of values are allowed in a row, but removing these later can be problematic when some ForeignKey is involved, at least with MySQL it may throw a Cannot drop index '...': needed in a foreign key constraint at you.

The example below shows you how to resolve such a situation in 3 small individual migrations:

  • We start with an existing UniqueConstraint.
class MyModel(models.Model):
    other_model = models.ForeignKey("OtherModel", on_delete=models.CASCADE)
    name = models.CharField(max_length=128)
{
"GUPPY":{
"mint":"guppyrZyEX9iTPSu92pi8T71Zka7xd6PrsTJrXRW6u1"
},
"WHALE":{
"mint":"whaLeHav12EhGK19u6kKbLRwC9E1EATGnm6MWbBCcUW"
},
"KILLER WHALE":{
"mint":"kLwhLkZRt6CadPHRBsgfhRCKXX426WMBnhoGozTduvk"
},

ICS: Cinderella Tokens: An Async/IBC friendly alternative to flash loans

Flashloans are a fascinating economic coordination mechanism that has emerged out the Ethereum architecture as a result of a synchronous, sequential, atomic transaction system. It allows anonymous coordination between capital providers and arbitrageurs because the capital providers can condition providing any capital on protocol enforced guarantee that the entire arbitrage is profitable denominated in the token being lent.

One of the effects of this process has been the it ensures an efficient and healthy liquidation market for the collateral in long term debt instruments. It also enables low cost scaling of economic exploits.

Why don’t flash loans exist in IBC world?

Flash loans are impossible in an IBC world because IBC semantics require finalizing a block on the origin chain rather than on the receiving chain. This makes atomicity for the lender difficult and moves us into the domain of over collateralized lending.

#!/usr/bin/awk -f
# This program is a copy of guff, a plot device. https://github.com/silentbicycle/guff
# My copy here is written in awk instead of C, has no compelling benefit.
# Public domain. @thingskatedid
# Run as awk -v x=xyz ... or env variables for stuff?
# Assumptions: the data is evenly spaced along the x-axis
# TODO: moving average
@0atman
0atman / Makefile
Last active February 27, 2023 19:41
Full-stack, pure Nim. Backend and JS using the same staticly-typed model.
app:
nim c app.nim
clean:
rm app
run:
./app