Skip to content

Instantly share code, notes, and snippets.

View alexgleason's full-sized avatar

Alex Gleason alexgleason

View GitHub Profile
@alexgleason
alexgleason / bench.ts
Created April 24, 2024 18:38
Deno.KV vs lmdb-js benchmark
import lmdb from 'npm:lmdb';
const kv = await Deno.openKv();
const db = lmdb.open({ path: './bench.db' });
await kv.set(['hello'], 'world');
await db.put(['hello'], 'world');
Deno.bench('DenoKv.get', async () => {
await kv.get(['hello']);
@alexgleason
alexgleason / highlight_matches.py
Created March 10, 2016 16:57
Highlight search result match text in Python
import re
def highlight_matches(query, text):
def span_matches(match):
html = '<span class="query">{0}</span>'
return html.format(match.group(0))
return re.sub(query, span_matches, text, flags=re.I)
@alexgleason
alexgleason / m2m.py
Last active May 9, 2023 17:49
Many to many relationships in Wagtail
from django.db import models
from wagtail.wagtailsnippets.models import register_snippet
from wagtail.wagtailcore.models import Page
from modelcluster.fields import ParentalKey
from wagtail.wagtailadmin.edit_handlers import InlinePanel
@register_snippet
class Category(models.Model):
@alexgleason
alexgleason / american-policy.ts
Created March 25, 2023 14:43
strfry American Policy (example)
import type { Policy } from 'https://gitlab.com/soapbox-pub/strfry-policies/-/blob/develop/mod.ts';
/** Only American English is allowed. */
const americanPolicy: Policy<void> = (msg) => {
const { content } = msg.event;
const words = [
'armour',
'behaviour',
'colour',
@alexgleason
alexgleason / neat-flex-grid.scss
Created February 1, 2016 04:35
Bourbon/Neat Flexbox Grid
/*
Based on code by Kevin Lamping
source: http://codepen.io/klamping/pen/waMOeX
*/
@mixin flex-grid {
display: flex;
flex-wrap: wrap;
margin-left: -$gutter;
margin-top: -$gutter;
You: Yung Lean, will you go vegan?
Yung Lean: idk i Like meat tho
Yes, but _____ have feelings and do not want to die.
Animal species (plural): cows
You: Yes, but [cows] have feelings and do not want to die.
Yung Lean: ya [cows] iaght i smoked weed wit em but how Bout Milk tho aint hurt no1
The dairy industry is actually very cruel, they _____ cows.
@alexgleason
alexgleason / file-extensions.json
Last active December 14, 2018 02:54
Human readable descriptions for file extensions. Scraped from https://en.wikipedia.org/wiki/List_of_filename_extensions
{"DD": [{"description": "Macintosh file archive", "used_by": "DISKDOUBLER"}], "CHZ": [{"description": "Archive", "used_by": "CHARC"}], "EUI": [{"description": "Ensoniq EPS family CD image", "used_by": "AWAVE"}], "INI": [{"description": "Initialization file", "used_by": ""}], "CHI": [{"description": "ChiWriter Document", "used_by": "ChiWriter - Chiview"}], "OCT": [{"description": "Musical file", "used_by": "Pctalizer"}], "GFO": [{"description": "SGI Radiosity", "used_by": ""}], "QVD": [{"description": "QlikView Document (Data)", "used_by": "QlikView Compressed Database File"}], "MCW": [{"description": "Text file", "used_by": "MacWrite II"}], "HI": [{"description": "Game high scores table", "used_by": ""}], "ZUR": [{"description": "High level compressed file", "used_by": ""}], "FPU": [{"description": "Configuration file", "used_by": "FoxPro for Unix"}], "F": [{"description": "Archive", "used_by": "FREEZE"}, {"description": "Forth language source code file", "used_by": "Forth development systems"}, {"description
@alexgleason
alexgleason / ergodox-colemak.json
Last active May 5, 2018 18:37
Highly optimized Colemak layout for programming
{
"header": {
"Name": "MDErgo1",
"Variant": "standard",
"Layout": "Blank",
"Base": "Blank",
"Version": "0.1",
"Author": "HaaTa (Jacob Alexander) 2015",
"KLL": "0.3c",
"Date": "2015-09-12",
@alexgleason
alexgleason / trackpoint.sh
Created March 30, 2018 23:56
Set Thinkpad trackpoint speed/sensitivity
#!/bin/bash
if [ $# -ne 2 ]; then
echo "Usage: trackpoint <sensitivity> <speed>"
echo ""
echo "Sensitivity is the amount of pressure needed to make the cursor reach its max speed. Speed is the max speed."
echo "Note: Both values must be 0-250 with 250 being the most sensitive/fast."
exit 1
fi
@alexgleason
alexgleason / vegan.md
Last active April 12, 2017 14:11
A response to "but humans need meat"

American Dietetic Association

It is the position of the American Dietetic Association that appropriately planned vegetarian diets, including total vegetarian or vegan diets, are healthful, nutritionally adequate, and may provide health benefits in the prevention and treatment of certain diseases. Well-planned vegetarian diets are appropriate for individuals during all stages of the life cycle, including pregnancy, lactation, infancy, childhood, and adolescence, and for athletes.

Dietitians of Canada

A well planned vegan diet can meet all of these needs. It is safe and healthy for pregnant and breastfeeding women, babies, children, teens and seniors.

The British National Health Service