Skip to content

Instantly share code, notes, and snippets.

View av1d's full-sized avatar
🎯
Focusing

av1d

🎯
Focusing
View GitHub Profile
@av1d
av1d / three_ai.py
Created May 3, 2024 16:57
Make 3 AI LLM models speak amongst themselves randomly (ollama, llama.cpp, RK3588 NPU server)
import json
import random
import re
import requests
import textwrap
# a random model is selected each time without the possibility
# of selecting the same one twice in a row (so it doesn't speak to itself)
# Terminal colors
@av1d
av1d / rkllm-update.cpp
Last active May 2, 2024 18:20
RK3588 NPU example, load prompt from text file
// Copyright (c) 2024 by Rockchip Electronics Co., Ltd. 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
// distributed under the License is distributed on an "AS IS" BASIS,
@av1d
av1d / llama.py
Last active April 27, 2024 19:43
discord llama.cpp chat bot with context
import asyncio
import discord # discord.py==1.7.3
import re
import requests
import time
from collections import defaultdict
from discord import activity
from discord.ext import commands
# llama.cpp front end chat bot for Discord
@av1d
av1d / div.html
Created April 6, 2024 21:06
perfectly centered div
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Centered Div</title>
<style>
/* Styles to center the div */
.centered-div {
position: absolute;
@av1d
av1d / ai_menu.sh
Last active March 25, 2024 22:01
llama.cpp menu/launcher for storing models in one directory (folder) and easily loading them into llama.cpp quickly
#!/bin/bash
: <<'COMMENT'
Creates a menu system so it's easier to launch models. Example output:
[1] alicecomfy_miqu-70b-openhermes-full-b2131-iMat-c32_ch1000-IQ1_S_v3.gguf (13862 MB)
[2] deepsex-34b.Q2_K.gguf (13881 MB)
[3] ggml-model-q4_0.gguf (18564 MB)
[4] mistral-7b-instruct-v0.2.Q3_K_M.gguf (3355 MB)
[5] mlewdboros-l2-13b.Q3_K_L.gguf (6608 MB)
@av1d
av1d / bluetooth_repair.md
Last active February 27, 2024 18:16
Troubleshooting / repairing Bluetooth on Linux, bluetoothctl connection issues

Make sure you check dmesg periodically between these steps for errors...

First try this:

sudo apt-get update
sudo apt-get install --reinstall linux-modules-$(uname -r)
sudo apt-get install --reinstall linux-headers-$(uname -r)
sudo dkms autoinstall
hciconfig -a

if still nothing

@av1d
av1d / extract_links.py
Created February 24, 2024 06:22
extract relative & absolute paths from CSS and JS files
@av1d
av1d / find_gaps.py
Created February 20, 2024 19:03
file & page gap finder for sequentially-named files and archives
import os
import re
"""
Finds page gaps in pages / archives / research papers / publications / books / numerical archives / files / ranges.
Use it to find if you are missing any items in an archive.
You can use this on multi-volume archives or files of any type, it simply just searches for strings in the filename.
Example output:
@av1d
av1d / ble_probe.py
Last active February 19, 2024 18:53
Connect to Bluetooth LE (BLE) device, read all its data for each UUID/Characteristic/Handle/Descriptor/Property/Value
from bluepy.btle import Peripheral, UUID, BTLEInternalError # bluepy==1.3.0
device_address = "00:00:00:00:00:00"
try:
# check if address is 'random' or 'public' type
octets = device_address.split(':')
first_octet_binary = bin(int(octets[0], 16))[2:]
if first_octet_binary[-1] == '1':
addr_type = 'random'
@av1d
av1d / ble_services.py
Created February 18, 2024 23:43
List all Bluetooth LE (BLE) services and properties of a device
from bluepy.btle import Peripheral, UUID
device_address = "00:00:00:00:00:00"
peripheral = Peripheral(device_address, addrType='random')
services = peripheral.getServices()
for service in services:
characteristics = service.getCharacteristics()