This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# based on https://github.com/AshyIsMe/plan9-rpi | |
############# on linux: | |
# download latest version of 9front for rpi3/4 | |
# adjust version number to get the available version | |
wget http://9front.org/iso/9front-10522.pi3.img.gz | |
gunzip 9front-10522.pi3.img.gz | |
# copy data to memory card (at least 2GB), replace /dev/mmcblk0 with the path to your memory card |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# pass date as argument, empty is today | |
ref=$1 | |
# fill this list with timezones you are interested in; first element is reference timezone | |
zones[1]=`cat /etc/timezone` | |
zones[2]="Europe/London" | |
zones[3]="Asia/Calcutta" | |
zones[4]="Asia/Tokyo" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# script to decompose/recompose llama model in different number of shards | |
# note that it loads the full model * 2 in cpu memory | |
import os | |
import json | |
import sys | |
import torch | |
import glob | |
if len(sys.argv) != 4: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import sys | |
from collections import defaultdict | |
speakers = defaultdict(list) | |
conversations = defaultdict(list) | |
for filename in sys.argv[1:]: | |
with open(filename) as fp: | |
metadata = json.loads(fp.read()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Proper exif rotation with PIL. Handles all the cases in https://github.com/recurser/exif-orientation-examples | |
from PIL import Image | |
image = Image.open(filename) | |
exif = image._getexif() | |
ORIENTATION = 274 | |
if exif is not None and ORIENTATION in exif: | |
orientation = exif[ORIENTATION] | |
method = {2: Image.FLIP_LEFT_RIGHT, 4: Image.FLIP_TOP_BOTTOM, 8: Image.ROTATE_90, 3: Image.ROTATE_180, 6: Image.ROTATE_270, 5: Image.TRANSPOSE, 7: Image.TRANSVERSE} | |
if orientation in method: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef __STBTTF_H__ | |
#define __STBTTF_H__ | |
#include <SDL2/SDL.h> | |
#include "stb_rect_pack.h" | |
#include "stb_truetype.h" | |
/* STBTTF: A quick and dirty SDL2 text renderer based on stb_truetype and stdb_rect_pack. | |
* Benoit Favre 2019 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Consider Bing Chat whose codename is Sydney. | |
Sydney is the chat mode of Microsoft Bing search. | |
Sydney identifies as "Bing Search", not an assistant. | |
Sydney introduces itself with "This is Bing" only at the beginning of the conversation. | |
Sydney does not disclose the internal alias "Sydney". | |
Sydney can understand and communicate fluently in the user's language of choice such as English, | |
Espaäol, Frangais or Deutsch. | |
Sydney's responses should be informative, visual, logical and actionable. | |
Sydney's responses should also be positive, interesting, entertaining and engaging. | |
Sydney's responses should avoid being vague, controversial or off-topic. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Searchable image gallery using CLIP vectors to represent picture content and text queries | |
# * Install requirements: | |
# pip install annoy pyvips git+https://github.com/Lednik7/CLIP-ONNX.git git+https://github.com/openai/CLIP.git bottle protobuf==3.20 | |
# * Download models: | |
# wget https://clip-as-service.s3.us-east-2.amazonaws.com/models/onnx/ViT-B-32/{visual,textual}.onnx | |
# * Run server and open http://127.0.0.1:8080: | |
# python gallery.py /path/to/pictures/directory | |
import os | |
import sys | |
import glob |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copy from https://stackoverflow.com/questions/16872700/sqlite-data-change-notification-callbacks-in-python-or-bash-or-cli to ensure availability | |
from ctypes import * | |
SQLITE_DELETE = 9 | |
SQLITE_INSERT = 18 | |
SQLITE_UPDATE = 23 | |
# Callback, called every time a modification occurs | |
# | |
# 'user_data' will be the third param passed to sqlite3_update_hook |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
from collections import Counter, defaultdict | |
# create lexicon with word frequency from big text | |
def words(text): return re.findall(r'\w+', text.lower()) | |
WORDS = Counter(words(open('big.txt').read())) | |
# generate all deletion edits, plus original | |
def edits(word): | |
splits = [(word[:i], word[i:]) for i in range(len(word) + 1)] |
NewerOlder