Skip to content

Instantly share code, notes, and snippets.

@ali1234
ali1234 / mpbridge.py
Created February 27, 2021 21:06
32blit multiplayer bridge (doesn't work)
import click
import pyudev
import socket
import serial
import serial.threaded
class Worker(serial.threaded.Protocol):
def __init__(self, socket):
self.socket = socket
@ali1234
ali1234 / burn.cpp
Last active January 31, 2020 13:38
image retention test. don't run this.
// Tearing test
#include "32blit.hpp"
uint16_t width = 160;
uint16_t height = 120;
uint32_t prev_buttons = blit::buttons;
uint32_t updates = 0;
// Update test
#include <unistd.h>
#include "32blit.hpp"
#include "../../../../../../usr/include/zconf.h"
uint16_t width = 160;
uint16_t height = 120;
uint32_t prev_buttons = blit::buttons;
// Tearing test
#include "32blit.hpp"
uint16_t width = 160;
uint16_t height = 120;
uint32_t prev_buttons = blit::buttons;
void init(void) {
blit::set_screen_mode(blit::lores);

Keybase proof

I hereby claim:

  • I am ali1234 on github.
  • I am ali1234 (https://keybase.io/ali1234) on keybase.
  • I have a public key whose fingerprint is ADFD E886 043E 00DA F5ED 052C 4B13 38E2 0316 1411

To claim this, I am signing this object:

@ali1234
ali1234 / blender-script.py
Created October 29, 2018 01:52
A Python script which runs itself inside Blender upon being run from the command line. Passes through command line arguments.
#!/usr/bin/env python3
import sys
try:
import bpy
except ImportError:
print('Running myself inside Blender')
import subprocess
exit(subprocess.call(['blender', '--background', '--python', __file__, '--'] + sys.argv))
@ali1234
ali1234 / notify-when-done
Created October 15, 2018 13:36
Bash script to time a long running command and display a notification when it finishes.
#!/bin/bash
SECONDS=0
"$@"
e=$?
if [ $? -eq 0 ]; then
RESULT="Succeeded"
@ali1234
ali1234 / input.py
Last active December 24, 2022 00:54
Unbuffered, non-blocking stdin in Python
import fcntl
import termios
import sys
import os
import time
class NonBlockingInput(object):
def __enter__(self):
@ali1234
ali1234 / icon.py
Created April 25, 2018 20:46
Find the path Gtk loads an icon from.
#!/usr/bin/env python3
import sys
import pathlib
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
if __name__ == '__main__':
@ali1234
ali1234 / life.py
Created March 11, 2018 01:04
PySDL2 Life Demo
import sys
import sdl2
import sdl2.ext
import numpy as np
class Life(object):
def __init__(self, height, width):
self.width = width