Skip to content

Instantly share code, notes, and snippets.

import os
import pickle
import hashlib
import asyncio
class Cache:
def __init__(self, cache_file):
self.cache_file = cache_file
os.makedirs(os.path.dirname(cache_file), exist_ok=True)
if os.path.exists(cache_file):
@SunMarc
SunMarc / finetune_llama_gptq.py
Last active October 12, 2025 03:18
Finetune GPTQ model with peft and tlr
# coding=utf-8
# Copyright 2023 The HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
@gimenete
gimenete / safeParse.ts
Last active March 15, 2024 16:05
A wrapper around the fetch function that validates the response body against a Zod schema
import z from "zod";
export async function safeFetch<T>(
schema: z.Schema<T>,
input: RequestInfo,
init?: RequestInit
): Promise<T> {
const response = await fetch(input, init);
if (!response.ok) {
@evadne
evadne / lecture.md
Last active September 15, 2025 10:56
How to Sell Elixir (2023)

How to Sell Elixir AGAIN (2023)

Presented by Evadne Wu at Code BEAM Lite in Stockholm, Sweden on 12 May 2023

Synopsis

We have celebrated 10 years of Elixir and also nearly 25 years of Erlang since the open source release in December 1998.

Most of the libraries that were needed to make the ecosystem viable have been built, talks given, books written, conferences held and training sessions provided. A new generation of companies have been built on top of the Elixir / Erlang ecosystem. In all measures, we have achieved further reach and maturity than 5 years ago.

@fullcontrol-xyz
fullcontrol-xyz / svg_demo.ipynb
Last active November 27, 2023 02:51
svg_demo.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# Go to https://www.twitch.tv/wallet?tab=bits-usage-history
# Hold down 'page down' key until nothing more loads
# Right click table -> Inspect element
# Find the table tag
# right click -> edit as html
# ctrl-a, ctrl-c -> save as foo.html
from bs4 import BeautifulSoup
from pathlib import Path
from pprint import pprint
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@fullcontrol-xyz
fullcontrol-xyz / electronic_circuit_demo.ipynb
Last active November 27, 2023 02:52
electronic_circuit_demo.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@hwchase17
hwchase17 / langchain_chat_gpt.py
Last active December 5, 2023 16:10
LangChain ChatGPT API Wrapper
from langchain.llms.base import LLM
from typing import Optional, List, Mapping, Any
import requests
from langchain.llms.utils import enforce_stop_tokens
class CustomLLM(LLM):
def __init__(self, url: str):
self.url = url
@breadthe
breadthe / sd.sh
Created September 2, 2022 17:56
Stable Diffusion prompt script
#!/bin/bash
echo -n "Enter a prompt: "
read prompt
echo -n "Steps (default 10): "
read steps
if [[ -z "$steps" ]]; then
steps=10