Skip to content

Instantly share code, notes, and snippets.

View lurch's full-sized avatar

Andrew Scheller lurch

View GitHub Profile
@lurch
lurch / menu_launcher.py
Created April 26, 2012 00:37 — forked from abishur/menu_launcher.py
A simple menu system using python for the Terminal (Framebufer)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Topmenu and the submenus are based of the example found at this location http://blog.skeltonnetworks.com/2010/03/python-curses-custom-menu/
# The rest of the work was done by Matthew Bennett and he requests you keep these two mentions when you reuse the code :-)
# Basic code refactoring by Andrew Scheller
import curses, os #curses is the interface for capturing key presses on the menu, os launches the files
screen = curses.initscr() #initializes a new window for capturing key presses
curses.noecho() # Disables automatic echoing of key presses (prevents program from input each key twice)
curses.cbreak() # Disables line buffering (runs each key as it is pressed rather than waiting for the return key to pressed)
@lurch
lurch / add_backwards_language.patch
Last active December 18, 2015 10:18
Add a dummy "backwards English" auto-generated translation to https://github.com/raspberrypi/noobs to help with testing localisation
diff --git a/recovery/create_sdrawkcab_ts.py b/recovery/create_sdrawkcab_ts.py
new file mode 100755
index 0000000..1402833
--- /dev/null
+++ b/recovery/create_sdrawkcab_ts.py
@@ -0,0 +1,27 @@
+#!/usr/bin/env python
+import re
+import os
+
#!/usr/bin/env python2.7
# script by Alex Eames http://RasPi.tv
# explained here...
# http://raspi.tv/2013/controlled-shutdown-duration-test-of-pi-model-a-with-2-cell-lipo
# DO NOT use this script without a Voltage divider or other means of
# reducing battery voltage to the ADC. This is exaplained on the above blog page
import time
import os
import subprocess
import smtplib
@lurch
lurch / display_decimals.py
Last active April 28, 2022 12:56
Sample code to display decimal numbers on a 4-digit 7-segment display
# code modified, tweaked and tailored from code at
# http://raspi.tv/2015/how-to-drive-a-7-segment-display-directly-on-raspberry-pi-in-python
import RPi.GPIO as GPIO
import random
import time
NUMBER_OF_DIGITS = 4
def format_num(num):
digits_left = NUMBER_OF_DIGITS
@lurch
lurch / wam.py
Created March 7, 2016 13:12
Very simple whack-a-mole type game for the Pimoroni DrumHAT
#!/usr/bin/env python
import cap1xxx
import random
import time
"""
4 3 2
5 7 1
@lurch
lurch / pizero_usb_internet.sh
Last active November 1, 2022 16:59
Script to automatically provide internet access to a PiZero connected to a Linux host over a USB-network (only tested on Ubuntu 14.04)
#!/bin/bash
# Automatically setup routing and DNS for a PiZero connected over a USB-network
# NOTE: Before running this script for the first time, you need to run the
# following two commands on your Linux PC
# sudo sysctl -w net.ipv4.ip_forward=1
# sudo iptables -t nat -A POSTROUTING -s 169.254.0.0/16 -o eth0 -j MASQUERADE
# (replace eth0 in the second command with your internet-facing network device,
# e.g. wlan0 on a laptop)
# The Avahi-discovered hostname
#!/usr/bin/env python
import RPi.GPIO as GPIO
import sys
from signal import pause
def button_pressed(channel):
print("Button %d was pressed" % channel)
if len(sys.argv) < 2:
print("No port numbers were supplied!")
@lurch
lurch / download_all_releases.py
Created December 8, 2016 15:14
Attempt to download all the Etcher releases, to verify that the S3 links are correct
#!/usr/bin/env python
from __future__ import print_function
import requests
import re
import os
github_project = 'resin-io/etcher'
releases_url = 'https://github.com/' + github_project + '/releases'
aws_url = 'https://resin-production-downloads.s3.amazonaws.com/etcher'
@lurch
lurch / ensure-angular-dependencies-compatibility.sh
Created March 10, 2017 02:46
Bash script to check matching package versions
#!/bin/bash
###
# Copyright 2017 resin.io
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
diff --git a/main.c b/main.c
index e8e9b59..28475f0 100755
--- a/main.c
+++ b/main.c
@@ -5,6 +5,22 @@
#include <unistd.h>
+#include <sys/time.h>
+