Skip to content

Instantly share code, notes, and snippets.

@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
@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 / aiyprojects-ubuntu.txt
Last active July 4, 2018 07:30
How to run the google aiyprojects voice kit code on Ubuntu desktop.
# set up a python virtualenv:
virtualenv --system-site-packages -p python3 google-assistant-sdk
# enter the virtualenv:
source google-assistant-sdk/bin/activate
# install dependencies:
pip3 install google-assistant-sdk[auth_helpers]==0.1.0 grpc-google-cloud-speech-v1beta1==0.14.0 protobuf==3.1.0
# the google code actually works out of the box on a default ubuntu install:
@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"

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:

// 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);
// 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;
@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;
@ali1234
ali1234 / bb8.py
Created October 17, 2015 15:47
Control Sphero BB-8 from Linux.
#!/usr/bin/env python
# BB-8 Python driver by Alistair Buxton <a.j.buxton@gmail.com>
from bluepy import btle
import time
class BB8(btle.DefaultDelegate):
def __init__(self, deviceAddress):
@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