Skip to content

Instantly share code, notes, and snippets.

View chand1012's full-sized avatar

Chandler chand1012

View GitHub Profile
@pdtgct
pdtgct / convert_hf_llama_to_ggml.md
Created April 28, 2023 15:27
Convert HF to GGML

The LLaMA model weights may be converted from Huggingface PyTorch format back to GGML in two steps:

  1. download from decapoda-research/llama-7b-hf and save as pytorch .pth
  2. use the ggerganov/llama.cpp script, convert-pth-to-ggml.py to convert from pytorch .pth to GGML

This process will result in ggml model with float16 (fp16) precision.

Prerequisite

@chand1012
chand1012 / fetchWithTimeout.ts
Last active September 20, 2024 13:52
Deno fetch with optional timeout parameter. If the request takes longer than 10 seconds (or whatever you set it to), throws an error.
// LICENSE: https://chand1012.mit-license.org
const fetchWithTimeout = (url: string, options: RequestInit, timeout: number = 10000): Promise<any> => {
return new Promise(async (resolve, reject) => {
const controller = new AbortController();
const signal = controller.signal;
const timer = setTimeout(() => {
controller.abort();
reject(new Error("Request timed out"));
}, timeout);
@0xJohnnyGault
0xJohnnyGault / deploy-local.sh
Created May 18, 2022 01:38
Deploy using forge with bash
#!/usr/bin/env bash
set -Eeuo pipefail
# Experiment to see how using foundry for deploys would work
if [ "${BASH_VERSINFO:-0}" -lt 4 ]; then
echo "script requires bash version >= 4"
exit 1
fi
@0xJohnnyGault
0xJohnnyGault / hash.sh
Created May 18, 2022 01:33
Create a keccak256/abi.encodePacked hash
#!/usr/bin/env bash
set -Eeuo pipefail
trap 'rm -f -- "${TMPFILE}"' EXIT
TMPFILE=$(mktemp) || exit 1
cat << EOF > ${TMPFILE}
pragma solidity ^0.8.0;
contract Hasher {
@acro5piano
acro5piano / how-to-use.tsx
Last active June 26, 2021 07:34
Background blur-ed Twilio video track
export const MyComponent() {
const { toggleVideoBlur, isVideoBlur } = useBlurLocalTrack({})
const _toggleVideoBlur = async () => {
twilioRoom.localParticipant.videoTracks.forEach((track) => track.unpublish())
const videoTrack = await toggleVideoBlur()
await wait(1000)
participant.publishTrack(videoTrack)
}
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]"></script>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow-models/[email protected]"></script>
<style>
.relative {
position: relative;
}
.renderer {
width: 400px;
@InterStella0
InterStella0 / HelpCommand_walkthrough_guide.md
Last active September 6, 2024 19:17
Walkthrough guide on subclassing HelpCommand
@shakna-israel
shakna-israel / LetsDestroyC.md
Created January 30, 2020 03:50
Let's Destroy C

Let's Destroy C

I have a pet project I work on, every now and then. CNoEvil.

The concept is simple enough.

What if, for a moment, we forgot all the rules we know. That we ignore every good idea, and accept all the terrible ones. That nothing is off limits. Can we turn C into a new language? Can we do what Lisp and Forth let the over-eager programmer do, but in C?


@JoeyBurzynski
JoeyBurzynski / 55-bytes-of-css.md
Last active November 17, 2024 14:13
58 bytes of css to look great nearly everywhere

58 bytes of CSS to look great nearly everywhere

When making this website, i wanted a simple, reasonable way to make it look good on most displays. Not counting any minimization techniques, the following 58 bytes worked well for me:

main {
  max-width: 38rem;
  padding: 2rem;
  margin: auto;
}
@vbe0201
vbe0201 / music_bot_example.py
Last active November 14, 2024 23:13
A simple music bot written using discord.py rewrite and youtube_dl.
# -*- coding: utf-8 -*-
"""
Copyright (c) 2019 Valentin B.
A simple music bot written in discord.py using youtube-dl.
Though it's a simple example, music bots are complex and require much time and knowledge until they work perfectly.
Use this as an example or a base for your own bot and extend it as you want. If there are any bugs, please let me know.