Skip to content

Instantly share code, notes, and snippets.

View liftoff's full-sized avatar

Dan McDougall liftoff

View GitHub Profile
@liftoff
liftoff / mbi5026.ino
Last active April 23, 2024 07:08
Arduino with MBI5026 IC
// I pasted this without even looking at it. It the code running in the video here: http://youtu.be/OZ_9Yg0PG3M
// The video is of an Arduino controlling a single 8x8 LED matrix via an MBI5026 chip + a single 74HC595 shift register.
// Link to the MBI5026: http://www.rayslogic.com/propeller/programming/AdafruitRGB/MBI5026.pdf
#define SDI 10
#define CLK 9
#define LE 8
#define LED 17
// 74HC595
#define SHSDI 3 // DS (pin 14 on shift register)
@liftoff
liftoff / shiftreg.py
Created November 21, 2014 02:07
Raspberry Pi Shift Register control module - It's super fast and can automatically invert the bits for you
#!/usr/bin/env python
"""
shiftreg.py
Shift register control module. Provides the :class:`Shiftter` class which
makes it easy to control shift registers.
.. note::
@liftoff
liftoff / split_ca_cert.py
Created May 14, 2014 14:29
Split up and/or remove duplicate certificates from a PEM-formatted CA bundle (e.g. ca-bundle.crt)
#!/usr/bin/env python
"""
Split up and remove duplicate CA certificates from a bundle (e.g.
ca-bundle.crt).
.. note::
This script will preserve comments and certificate metadata at
the expense of possibly missing duplicates (that don't have the
@liftoff
liftoff / json_cleaner.py
Created October 19, 2016 13:42
Allow comments and trailing commas in JSON files using two simple Python functions to clean them up before parsing
#!/usr/bin/env python
"""
An example of how to remove comments and trailing commas from JSON before
parsing. You only need the two functions below, `remove_comments()` and
`remove_trailing_commas()` to accomplish this. This script serves as an
example of how to use them but feel free to just copy & paste them into your
own code/projects. Usage::
json_cleaner.py some_file.json
@liftoff
liftoff / xcb_screenshot.py
Last active January 21, 2021 10:51
An example of how to capture a screenshot using xpyb (xcb bindings for Python). UPDATED 2013-02-13: Now using PIL's Image.frombuffer() method on the raw image data object given by xcb. It is an order of magnitude faster than converting the xcb object to a Python string and using PIL's Image.fromstring().
#!/usr/bin/env python
"""
An example demonstrating how to use xpyb (xcb bindings for Python) to take a
full-screen screenshot.
"""
# Meta
__version__ = '1.0'
__version_info__ = (1, 0)
@liftoff
liftoff / cleanup_json.py
Last active January 29, 2016 19:59
Clean up JSON-like data before decoding as JSON
import os, re, sys
comments_re = re.compile(
r'//.*?$|/\*.*?\*/|\'(?:\\.|[^\\\'])*\'|"(?:\\.|[^\\"])*"',
re.DOTALL | re.MULTILINE
)
trailing_commas_re = re.compile(
r'(,)\s*}(?=([^"\\]*(\\.|"([^"\\]*\\.)*[^"\\]*"))*[^"]*$)')
/*
* This file is part of the libopencm3 project.
*
* Copyright (C) 2009 Uwe Hermann <uwe@hermann-uwe.de>
* Copyright (C) 2011 Stephen Caudle <scaudle@doceme.com>
*
* This library is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
@liftoff
liftoff / htmltag.py
Last active December 16, 2015 03:49
htmltag.py - A simple module to wrap whatever string you want in HTML tags.
# -*- coding: utf-8 -*-
#
# Copyright 2013 Liftoff Software Corporation
#
# For license information see LICENSE.txt
# Meta
__version__ = '1.0.0'
__version_info__ = (1, 0, 0)
__license__ = "Apache 2.0"
@liftoff
liftoff / collector.sh
Created August 23, 2012 18:31
A little script to catch the collectors
#!/bin/bash
#
# Description: Hello, World
# Author: Anu Bs <anu.bs@youknowwhat.com>
echo "Hello, World."
@liftoff
liftoff / python-matplotlib_1.1.0.bb
Created May 30, 2012 02:15
matplotlib .bb file for OpenEmbedded/bitbake
DESCRIPTION = "matplotlib is a python 2D plotting library which produces publication quality figures in a variety of hardcopy formats"
SECTION = "devel/python"
LICENSE = "PSF"
LIC_FILES_CHKSUM = "file://README.txt;md5=83c5bf8b16a5f99507f2f47a21ae3b81"
PR = "r1"
SRC_URI = "${SOURCEFORGE_MIRROR}/matplotlib/matplotlib-${PV}.tar.gz \
"
S = "${WORKDIR}/matplotlib-${PV}"