Skip to content

Instantly share code, notes, and snippets.

@acdimalev
acdimalev / server.py
Last active January 15, 2022 21:06
IRC client experiments
from socket import create_server
MAX_SOCKETS = 1024
BUFFER_SIZE = 4096
sockets = [(0, None)] * MAX_SOCKETS
buffers = [b''] * MAX_SOCKETS
connections = []
all() {
case $# in
0) false ;;
*) (
result=0
while read x; do
if ! "$@" "$x"; then
result=1
fi
done
# Python 3 is an iterator-first language.
# `bind` and `join` are reaching wider adoption under the names `flatmap` and `flatten`.
def flatmap(f, xs):
return (y for x in xs for y in f(x))
def flatten(xs):
return (y for x in xs for y in x)
# These don't match the `zip(*args)` behavior of `map`, but I have never actually seen that used.
import Optics
import Control.Monad.Random
headSwap :: [Int] -> Int -> [Int]
headSwap xs i =
xs
& (ix 0) .~ (xs !! i)
& (ix i) .~ (xs !! 0)
headSwapRand :: MonadRandom m => [Int] -> m [Int]
>>> from findme_packet_format import *
>>>
>>> # generate a public / private key pair for demonstration
>>> # curve and backend are hard-coded for convenience
>>> private = ec.generate_private_key(curve, backend)
>>> public = private.public_key()
>>>
>>> # take a peek at what the serialized public key looks like
>>> encode_public_key(public).hex()
'bbae416a73aac8b64786006b4b358d7261cc57eb780aeb61c15537d88eb9a6e68d48a0f737aafde8c99f6821be199aef49da91f7e60f3a42d524be06aac811a5'
xorshift linear
2 3 4 1 1 0 0 1
2
0 0 0 1 0 0 0 0 10
0 0 1 0 1 0 0 1 29
0 1 0 0 0 0 1 0 42
1 0 0 1 1 0 1 1 9b
0 0 1 1 0 1 0 0 34
Goal: Develop a secure protocol for machines to keep track of where each other are on the Internet (IP address) that doesn't rely on DNS.
Why: Because DNS does not scale to individual use, and there is no financial incentive for companies to develop an alternative.
Problem: Modern internet security is built on top of DNS. Building an alternative to DNS on modern internet security is a non-starter.
Solution: Experiment with prototypes using lower-level security primitives.
Theory: A "chain" of signatures can be used to track changes in IP address of any given device to prevent forgery or replay attacks.
Theory: A sequence of signed packets can be used to track availability at an IP address to prevent forgery or replay attacks.
Theory: A sequence of signed packets can also be used to authenticate queries for network information to limit network abuse.
# binary search division
# aka, long division
def partial_division(divisor, dividend):
difference = dividend - divisor
return (0, dividend) if difference < 0 else (1, difference)
def division8(divisor, dividend):

Packet Formats and Implementation Details

Common Packet Header

identification (public key)
signature
packet type  |  signed content body

... |

@acdimalev
acdimalev / user.js
Last active August 30, 2020 07:37
Firefox Settings
// stop Firefox from eating all my CPU and stuttering while playing full-screen videos
//user_pref("media.gpu-process-decoder", true);
// well... 50/50 on whether this actually reduces CPU consumption when Firefox is running full-screen
// stuttering is improved, but not gone
// ...apparently Firefox handles video playback a lot better when a proper VA-API driver is installed
// leaving this here for future troubleshooting
// this behavior also seems to be dependent on whether or not Steam has been running...