Skip to content

Instantly share code, notes, and snippets.

View nathanhere's full-sized avatar
🤠

Nathan nathanhere

🤠
View GitHub Profile
@nathanhere
nathanhere / calc-gpu-layers.py
Created March 17, 2024 09:08 — forked from mrseanryan/calc-gpu-layers.py
Rough PoC using binary search to find the optimal number of model layers to offload to the GPU, for this LLM and this hardware.
"""
Rough PoC using binary search to find the optimal number of model layers to offload to the GPU, for this LLM and this hardware.
"""
import time
def call_llm(prompt, gpu_layers):
# TODO fill in the actual call to LLM here
# dummy GPU memory limit
test_best_layers = 60
@mrseanryan
mrseanryan / calc-gpu-layers.py
Created October 22, 2023 16:06
Rough PoC using binary search to find the optimal number of model layers to offload to the GPU, for this LLM and this hardware.
"""
Rough PoC using binary search to find the optimal number of model layers to offload to the GPU, for this LLM and this hardware.
"""
import time
def call_llm(prompt, gpu_layers):
# TODO fill in the actual call to LLM here
# dummy GPU memory limit
test_best_layers = 60
import prefect
from prefect import task, Flow
from prefect.tasks.notifications import SlackTask
from typing import cast
import traceback
def exception_to_string(excp):
# from https://stackoverflow.com/questions/4564559/get-exception-description-and-stack-trace-which-caused-an-exception-all-as-a-st/58764987#58764987
stack = traceback.extract_stack()[:-3] + traceback.extract_tb(
@kjmph
kjmph / A_UUID_v7_for_Postgres.sql
Last active May 15, 2024 22:32
Postgres PL/pgSQL function for UUID v7 and a bonus custom UUID v8 to support microsecond precision as well. Read more here: https://datatracker.ietf.org/doc/draft-peabody-dispatch-new-uuid-format/
-- Based off IETF draft, https://datatracker.ietf.org/doc/draft-peabody-dispatch-new-uuid-format/
create or replace function uuid_generate_v7()
returns uuid
as $$
begin
-- use random v4 uuid as starting point (which has the same variant we need)
-- then overlay timestamp
-- then set version 7 by flipping the 2 and 1 bit in the version 4 string
return encode(
# This little bit of magic is great
# It will run a simple script that pulls vars from vault
echo -n "Vault Password: "
read -s PW
echo ""
LVT=$(curl -ks --request POST --data "{\"password\": \"$PW\"}" https://localhost:8200/v1/auth/userpass/login/pez | jq -r '.auth.client_token')
echo "LVT: [ $LVT ]"
curl -ks --header "X-Vault-Token: $LVT" https://localhost:8200/v1/kv/data/zshrc | jq -r '.data.data | to_entries | .[] | .key + "=" + .value' | while read i; do
@fabiolimace
fabiolimace / UUIDv6.sql
Last active May 12, 2024 03:47
Functions for generating UUIDv6 and UUIDv7 on PostgreSQL
/*
* MIT License
*
* Copyright (c) 2023-2024 Fabio Lima
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@neuralline
neuralline / promise-allSettled-async-loop.ts
Created April 19, 2020 11:26
Promise.allSettled async await loop with map
//Promise.allSettled() vs Promise.all()
//allSettled: returns when all promises have either resolved or rejected
const getGitHubUser = async (usernames: []) => {
const result = await Promise.allSettled(
usernames.map(async (name: string) => {
try {
const response = await fetch(
`https://api.github.com/users/${name}`
)
@erquhart
erquhart / selection-command.js
Last active February 29, 2024 10:31
Text selection commands for Cypress.io
/**
* Credits
* @Bkucera: https://github.com/cypress-io/cypress/issues/2839#issuecomment-447012818
* @Phrogz: https://stackoverflow.com/a/10730777/1556245
*
* Usage
* ```
* // Types "foo" and then selects "fo"
* cy.get('input')
* .type('foo')
@gea0
gea0 / arch-rpi-64-full-disk-encryption-ssh-unlock.md
Last active March 24, 2024 14:36
Tutorial for installing a 64-bit Arch Linux ARM system on the Raspberry Pi 3B+, with an encrypted root filesystem, and the option to remotely unlock it via a pre-boot SSH daemon.

Arch Linux ARM 64 on Raspberry Pi 3 B+ With Full Disk Encryption And SSH Unlock: 2018 Edition

There are multiple ways to get a full disk encrypted arch linux system on raspberry. In this tutorial, we will install a 64-bit arch linux armv8 system, using dropbear as ssh server for remote pre-boot unlocking of the root filesystem. However, it will still be possible to unlock and use the pi as usual, with a keyboard and monitor. We will also create an unencrypted partition in the installation process, usable as a rescue system.

Differences to the 32-bit arch linux arm version:

  • probably better performance
  • can run 64-bit software
  • comes without the proprietary video-driver blobs
@pramsey
pramsey / 0-spatial-sql-postgis.md
Last active November 13, 2023 18:33
Spatial SQL and PostGIS