Skip to content

Instantly share code, notes, and snippets.


Andrew Mulholland gbaman

View GitHub Profile
gbaman /
Created Nov 1, 2017
An example on using the Github GraphQL API with Python 3
# An example to get the remaining rate limit using the Github GraphQL API.
import requests
headers = {"Authorization": "Bearer YOUR API KEY"}
def run_query(query): # A simple function to use to make the API call. Note the json= section.
request ='', json={'query': query}, headers=headers)
if request.status_code == 200:
gbaman /
Last active Nov 27, 2020
Simple guide for setting up OTG modes on the Raspberry Pi Zero, the fast way!

Setting up Pi Zero OTG - The quick way (No USB keyboard, mouse, HDMI monitor needed)

More details -

For this method, alongside your Pi Zero, MicroUSB cable and MicroSD card, only an additional computer is required, which can be running Windows (with Bonjour, iTunes or Quicktime installed), Mac OS or Linux (with Avahi Daemon installed, for example Ubuntu has it built in).
1. Flash Raspbian Jessie full or Raspbian Jessie Lite onto the SD card.
2. Once Raspbian is flashed, open up the boot partition (in Windows Explorer, Finder etc) and add to the bottom of the config.txt file dtoverlay=dwc2 on a new line, then save the file.
3. If using a recent release of Jessie (Dec 2016 onwards), then create a new file simply called ssh in the SD card as well. By default SSH i

gbaman /
Created May 18, 2016
PiNet web access tester
# Part of PiNet
# See LICENSE file for copyright and license details
# Tool for checking if all the domains used by PiNet are accessable.
# Run with python3
def testSiteConnection(siteURL, timeoutLimit = 5):
gbaman / Farset-3D-printer.ini
Created Apr 25, 2016
Farset labs 3D printer config file
View Farset-3D-printer.ini
layer_height = 0.1
wall_thickness = 0.8
retraction_enable = True
solid_layer_thickness = 0.6
fill_density = 20
nozzle_size = 0.4
print_speed = 50
print_temperature = 210
print_temperature2 = 0
gbaman /
Last active Nov 20, 2020
Simple guide for setting up OTG modes on the Raspberry Pi Zero

Raspberry Pi Zero OTG Mode

Simple guide for setting up OTG modes on the Raspberry Pi Zero - By Andrew Mulholland (gbaman).

The Raspberry Pi Zero (and model A and A+) support USB On The Go, given the processor is connected directly to the USB port, unlike on the B, B+ or Pi 2 B, which goes via a USB hub.
Because of this, if setup to, the Pi can act as a USB slave instead, providing virtual serial (a terminal), virtual ethernet, virtual mass storage device (pendrive) or even other virtual devices like HID, MIDI, or act as a virtual webcam!
It is important to note that, although the model A and A+ can support being a USB slave, they are missing the ID pin (is tied to ground internally) so are unable to dynamically switch between USB master/slave mode. As such, they default to USB master mode. There is no easy way to change this right now.
It is also important to note, that a USB to UART serial adapter is not needed for any of these guides, as may be documented elsewhere across the int

gbaman /
Last active Aug 23, 2020
How to clone an SD card for use in a classroom

##Creating SD card clones for classrooms

The basic idea for creating SD cards in a classroom is you create a master SD card, make all the required changes (install software, edit configuration files etc), then read it back onto the computer and flash it onto the rest of your SD cards like a normal Raspbian SD card image.

##Shameless plug If you have a networked classroom or are able to set one up, my free and open-source Raspi-LTSP project will save you a lot of time and hastle!

###A few key tips

  1. Be careful what size of SD card you use! As you will be cloning the entire SD card (even blank areas) it is important you create the master image with your smallest SD card. For example, if you are using 8gb cards that are all exactly the same make and model, it shouldn't be much of a problem. The issue is different manufacturers when they create an 8gb sd card, it may be a few kilobytes bigger than that other brands 8gb SD card. So if you use the bigger one to cr
You can’t perform that action at this time.