Skip to content

Instantly share code, notes, and snippets.

@alexgleason
alexgleason / node-postgres-deno-bench.ts
Created June 20, 2024 03:16
Benchmark for node-postgres on Deno
import { Buffer } from 'node:buffer';
// @deno-types="npm:@types/pg@^8.11.6"
import pg from 'npm:pg@^8.12.0';
interface TestQuery {
text: string
values?: unknown[]
}
const params: TestQuery = {
@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 / 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 / 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 / animal-struggles.md
Created July 31, 2016 19:14
Chris Palmeri animal liberation speak-out

We all have struggles. We’re all trying to live our lives. We all have things that we are each worrying about. And a lot of the time it feels like that’s too much. So I understand how hard it is to acknowledge that all around us is a world of unspeakable horror and torment. In every burger, every milkshake, every omelette, every leather jacket and fur coat, there is unspeakable suffering and violence. We are all animals, and we need to figure out what kind of world we want to live in. Do we want to live in the kind of world where if you’re born the wrong shape, or you have the wrong brain, or you live in the wrong place, you are considered worthless and expendable? When we look into the eyes of another animal be they our cats or dogs at home, or the cows, chickens, pigs, and fish that are confined and slaughtered by trillions in our food system, we are not just looking at some “thing,” some “other,” some resource to be thrown away. We are looking at a part of us. And when they are imprisoned, and when they ar

@alexgleason
alexgleason / hallowagtailinlineonly.js
Last active June 7, 2016 20:25
Hallo Wagtail inline only
(function() {
(function($) {
return $.widget('IKS.inlineonly', {
options: {
uuid: '',
editable: null,
buttonCssClass: null
},
populateToolbar: function(toolbar) {
var whitelist = [
@alexgleason
alexgleason / facebookGroupMemberNamesToCsv.js
Created May 23, 2016 02:39
Takes the names of group members in a Facebook group and prints them as CSV output.
/*
Takes the names of group members in a Facebook group and prints them as CSV output.
*/
function facebookGroupMemberNamesToCsv() {
var people = document.querySelectorAll('.fsl.fwb.fcb a');
var output = 'First Name,Last Name\n';
for (var i=0; i<people.length; i++) {
names = (people[i].innerHTML).split(' ');
output += names[0] + ',' + names[names.length-1] + '\n';
}
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 / _triangles.scss
Last active May 5, 2016 22:51
Make elements pointy
$triangle-size: 60px !default;
@mixin triangle($hexstring, $side) {
position: relative;
&::after {
content: '';
background-repeat: no-repeat;
display: block;
position: absolute;
background-position: bottom;
@alexgleason
alexgleason / getAlbumDownloadLinks.js
Last active October 6, 2016 10:41
Download Facebook albums