Skip to content

Instantly share code, notes, and snippets.

View paulsmith's full-sized avatar
😀
Hi, friends

Paul Smith paulsmith

😀
Hi, friends
View GitHub Profile
@paulsmith
paulsmith / bufscan.go
Created November 20, 2024 00:52
buffered Go scanner
package bufscan
type GoToken struct {
Pos token.Pos
Tok token.Token
Lit string
}
type BufGoScanner struct {
scan *scanner.Scanner
@paulsmith
paulsmith / LLM.md
Created May 2, 2023 13:47 — forked from rain-1/LLM.md
LLM Introduction: Learn Language Models

Purpose

Bootstrap knowledge of LLMs ASAP. With a bias/focus to GPT.

Avoid being a link dump. Try to provide only valuable well tuned information.

Prelude

Neural network links before starting with transformers.

/**
* 8x8 monochrome bitmap fonts for rendering
* Author: Daniel Hepper <daniel@hepper.net>
*
* License: Public Domain
*
* Based on:
* // Summary: font8x8.h
* // 8x8 monochrome bitmap fonts for rendering
* //
enum Kind {
File,
Directory,
}
struct Entry {
name: String,
kind: Kind,
size: usize,
parent: Option<usize>,
@paulsmith
paulsmith / when-to-use-generics.md
Created December 21, 2021 17:51
When to use generics in Go

When to use generics

aka generic guidelines

It's late 2021, and Go is about to add "generics" (i.e., type parameters for types and functions) to upcoming release version 1.18.

Here is some guidance for Go programmers, cribbed from a talk by Ian Lance Taylor.

First, write Go programs by writing code, not by defining types.

@paulsmith
paulsmith / mybar.txt
Created June 22, 2021 14:58
Created from Remix Form!
The quick brown fox jumps over the lazy dog.
paul@pumpkin:/tmp/SQLite-cf538e27$ python3.7 -c 'import sqlite3; print(sqlite3.connect(":memory").execute("select sqlite_version()").fetchone())'
('3.27.2',)
paul@pumpkin:/tmp/SQLite-cf538e27$ ldd /usr/lib/python3.7/lib-dynload/_sqlite3.cpython-37m-x86_64-linux-gnu.so
linux-vdso.so.1 (0x00007ffff752e000)
libsqlite3.so.0 => /usr/lib/x86_64-linux-gnu/libsqlite3.so.0 (0x00007f89e005b000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f89e003a000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f89dfe79000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f89dfcf6000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f89dfcf1000)
/lib64/ld-linux-x86-64.so.2 (0x00007f89e01da000)
@paulsmith
paulsmith / utf8decode.c
Created April 25, 2018 14:16
utf-8 decoder
/* decodes next unicode code point in utf-8-encoded buffer. returns number of bytes
read so stream can be advanced, -1 if invalid utf-8 sequence. */
size_t decode_next_utf8(const unsigned char *str, size_t len, int *cp)
{
*cp = 0;
if (*str <= 0x7f) {
*cp = (int)*str;
return 1;
} else if (((*str & 0xe0) == 0xc0) && len > 1) {
if ((*(str+1) & 0xc0) != 0x80) {
@paulsmith
paulsmith / food-feelings.md
Created February 9, 2018 21:16
Feelings about food (draft blog post)

My family attended a Quaker meeting in Frederick, Maryland when I was growing up, and many of its members were closely associated with a food co-op there. We would volunteer to run the register or stock shelves and do other admin jobs. I remember the strange smell of bulk food items like spices and grains mixing together. I remember the "weird" items that were like items you'd get in regular grocery stores, but were weird because instead of chocolate the candy bars were made with carob. I remember that the co-op was a strong component of the identity of the people who worked, volunteered, and shopped there, including the Quakers and my family.