Skip to content

Instantly share code, notes, and snippets.

import math
import pygame
import random
from ctypes import windll, Structure, c_long, byref
user32 = windll.user32
screensize = user32.GetSystemMetrics(78), user32.GetSystemMetrics(79)
arpruss /
Last active Feb 22, 2020
accrete falling pixels
# public domain
import pygame
from random import randint
width = 400
height = 400
screen = pygame.display.set_mode((width, height))
color = (255,255,255)
arpruss /
Created Feb 3, 2020
Look for a counterexample for a conjecture regarding Level Set Integrals
from random import *
pa = 0.25
pb = 0.25
def E(f):
fa,fb = f
return fa + (fb-fa) * pb if fa < fb else fb + (fa-fb) * pa
def r():
arpruss /
Last active Jan 3, 2020
Saitek x45 mouse emulation
import sys
import time
import win32gui, win32con, win32api, win32file, win32event, win32gui_struct, winnt
import threading
from pywinusb import hid
RIGHT_CLICK = 1<<(5-1)
LEFT_CLICK = 1<<(6-1)
ACTIVE = 1<<(11-1)
UP = 1<<(23-1)
arpruss /
Last active Jan 15, 2020
Black's or Nanson's voting algorithm
import sys
# MIT Licensed code by Alexander R Pruss
# Implements Black's Procedure: Condorcet backed up with Borda to generate a ranked list from ranked votes
# and Nanson's Method: drop all candidates with Borda scores below average
# require n [default: None]
View amazon-offers.js
var url = window.location.href;
var m = url.match("/(dp|gp/product)/([^/]+)");
var pid = undefined;
if(m) {
var pid = m[2];
var s = url.match("[^:]*://[^/]+")[0];"/gp/offer-listing/"+pid);
arpruss /
Last active Jan 17, 2020
cec to keyboard map
import cec
from time import sleep, time
from evdev import UInput, ecodes
import os
import sys
from threading import Thread
DEBUG = False
logfile = sys.stdout
arpruss /
Last active Jun 28, 2019
Runs specified commands on ctrl-w press
import evdev
from select import select
from sys import argv, exit
from os import system
TRIGGER_KEY = evdev.ecodes.KEY_W
keysDown = set()
arpruss /
Last active Feb 19, 2019
averaging priors vs averaging posteriors
from random import *
from math import *
def randomOpen():
while True:
r = random()
if 0 < r:
return r
class Grid(object):
# Volume and pause/play in Netflix and Acorn with Philips 642 DVD remote
# PageUp/Down with projector remote
import win32com.client
import win32api, win32con, win32gui
from espremote import ESPRemote
from showtime import showtime
You can’t perform that action at this time.