Skip to content

Instantly share code, notes, and snippets.

@endolith
endolith / Borda 1781.md
Last active July 18, 2026 06:45
Borda count

Page 657

MEMOIR

ON ELECTIONS BY BALLOT

By M. de Borda

It is a generally accepted opinion, and one against which I do not recall anyone ever having raised objections, that in an election by ballot, the plurality of votes always indicates the will of the electors—that is to say, that the candidate who obtains this plurality is necessarily the one whom the electors prefer to his competitors. But I am going to show that this opinion, which is true in the case where the election is between only two candidates, can lead to error in all other cases.

#!/usr/bin/python
# Copyright (c) 2016, Gordon JC Pearce <[email protected]>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
@endolith
endolith / .gitignore
Last active February 13, 2026 04:57
I tried to plot AGI on the Chatbot Arena Elo scale by comparing to "both bad" and "tie" votes
*.json
*checkpoint.ipynb
@endolith
endolith / README.md
Last active June 5, 2023 19:48
Turn BOINC on or off depending on how warm the room is

Written by ChatGPT and me.

I also had to enable temperhum as a non-root user and set up a cron job to call this script every once in a while.

@endolith
endolith / README.md
Last active August 28, 2025 16:20
Qalculate keyboard shortcut with AutoHotkey

Qalculate Hotkey for inline calculations

Finally Qalculate has been ported to Windows. Now we can do unit-aware calculations inline, in any document, with AutoHotkey, similar to Monster.ahk but with units.

Instructions:

  1. Install Qalculate
  2. Install AutoHotkey
  3. Add qalc.exe to your PATH. I use Rapid Environment Editor for this.
  4. Run qalc.ahk
@endolith
endolith / whisper_transcribe.py
Created March 27, 2023 02:33
Transcribe a long audio recording using OpenAI Whisper API
"""
Break up a long recording to fit within the Whisper API's limits, with some
overlap, so no words are missed, and then feed to OpenAI Whisper API to
transcribe it to .txt file. Written by endolith and ChatGPT-4.
"""
import openai
import math
import os
import subprocess
@endolith
endolith / README.md
Last active January 11, 2026 14:29
Cyclic noise from filtering white noise in Python

This generates cyclic/repeating/perfect loop noise by low-pass filtering white noise in a cyclic way. Useful for "random" but looping animations, etc.:

This one loops in both space and time, for instance:

ezgif-5-bea77d8739ezgif-5-bea77d8739

Simplex noise typically has a more trapezoidal value distribution:

lmas/opensimplex#18 (comment)

@endolith
endolith / db_to_gpx.py
Created September 9, 2022 01:08
Maprika sqlite database to GPX track converter
"""
Written by GPT3 from this English prompt (with one tweak to the prompt, to get
the timestamp parameter to not error out, and PEP8 fixes):
----
1. Open a sqlite database with a name like `2022-07-17 17.48.19.db` or
`2021-04-11 08.44.16.db`
2. Inside is a table called `locations`, with headers [LOCTYPE INTEGER,
TIMESTAMP BIGINT, LATITUDE REAL, LONGITUDE REAL,ALTITUDE REAL, ACCURACY
@endolith
endolith / estimated_variance_of_estimated_probability.py
Last active December 13, 2023 18:20
Confirm the formula for estimating the variance of an estimated probability. (Trying to understand error bars for https://github.com/endolith/elsim/issues/13)
"""
Confirm the formula for estimating the variance of an estimated probability.
Created on Fri May 27 11:06:43 2022
"""
import numpy as np
def func(x):
"""
@endolith
endolith / README.md
Last active February 6, 2024 19:13
Single neuron experiments

My first keras experiments:

  1. simplest.py — A single neuron with no activation function and no bias (so just input→weight→output, can learn y=mx functions only). Show the function for a few random weights. (Doesn't learn anything.)
  2. linear with bias.py — A single neuron with no activation function but with bias (so it can learn y=mx+b functions, such as relationship between Celsius and Fahrenheit).
  3. single_neuron_buffer.py — A single neuron with sigmoid activation and no bias, trained to learn a digital logic buffer.
  4. single_neuron_inverter.py — A single neuron with sigmoid activation and no bias, trained to learn an inverting analog amplifier.