Skip to content

Instantly share code, notes, and snippets.

@gbaman
gbaman / HowToOTGFast.md
Last active June 7, 2026 20:18
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 - http://blog.gbaman.info/?p=791

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
gbaman / HowToOTG.md
Last active April 8, 2026 17:09
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

@paulz
paulz / remove-boilerplate-comments-from-xcode-templates.sh
Created December 13, 2015 08:06
Remove Useless Header comments from Xcode Templates
#!/bin/bash
# Usage:
# $ cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates
# $ bash ~/remove-boilerplate-comments-from-xcode-templates.sh
# Repeat for /Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates
find -E . -type f \
\( -regex '.*\.[chm]' -or -regex '.*\.swift' \) \
-exec sed -i '' '1,/^$/d' '{}' ';'
@nxhack
nxhack / supervisord
Last active July 15, 2023 15:25
python supervisor startup script for OpenWrt-yun
#!/bin/sh /etc/rc.common
# python supervisor
# (init script for OpenWrt-yun)
# Original : https://github.com/Supervisor/initscripts/blob/master/slackware
START=99
STOP=49
# set HOME for ssh
HOME=/root
@josefnpat
josefnpat / readme.md
Last active June 19, 2026 16:47
Going from Lua 5.2 to PICO-8's Lua

This information applies to the PICO-8 0.1.6 release.

This document is here to help folks with a proficiency in Lua understand the limitations and discrepencies between Lua and PICO-8's Lua.

You can always view the manual or yellowafterlife's extended 0.1.1 manual.

General

  • anything written in uppercase the PICO-8 editor or .p8 is made lowercase by the editor. → editing the .p8 file directly can work
  • print(function() end) outputs the string function instead of the string function: 0x0000000.
@LearnCocos2D
LearnCocos2D / gist:77f0ced228292676689f
Last active February 4, 2026 02:02
Overview of Entity Component System (ECS) variations with pseudo-code

For background and further references see: Entity Component Systems on Wikipedia

ECS by Scott Bilas (GDC 2002)

Entity->Components->Update
  • entity = class: no logic + no data OR at most small set of frequently used data (ie position)
  • component = class: logic + data
foreach entity in allEntities do
    foreach component in entity.components do
@hlung
hlung / UIRefreshControl+beginRefreshing.h
Last active October 10, 2018 09:31
A UIRefreshControl beginRefreshing method that actually works
//
// UIRefreshControl+beginRefreshing.h
// Kibo
//
// Created by Hlung on 3/6/15.
// MIT License
//
#import <UIKit/UIKit.h>
@jegger
jegger / main.py
Created March 22, 2015 16:21
WAMP autobahn reconnect
# Copied from https://gist.github.com/DenJohX/e6d0864738da10cb9685 -> DenJohX
# Slightly modified
import sys
from twisted.python import log
from twisted.internet import reactor
from twisted.internet.protocol import ReconnectingClientFactory
from autobahn.websocket.protocol import parseWsUrl
from autobahn.twisted import wamp, websocket
@tito
tito / utmotionevent.py
Last active August 29, 2015 14:16
Example of mock-MotionEvent for unittest
# subclass for touch event in unit test
class UTMotionEvent(MotionEvent):
def depack(self, args):
self.is_touch = True
self.sx = args['x']
self.sy = args['y']
self.profile = ['pos']
super(UTMotionEvent, self).depack(args)
@kumichou
kumichou / run.sh
Created June 24, 2014 18:36
Ever wanted to see how to do something simple like catch Ctrl-C in a BASH script? I'll illustrate how to start two different Python "apps" that would normally take over the terminal and stop them both
#!/usr/bin/env bash
CWD=`pwd`
function cleanup {
echo "You pressed Ctrl-C, time to exit the Python Services";
ps aux | grep myservice2 | grep -v grep | awk '{print $2}' | xargs kill -9;
ps aux | grep myservice1 | grep -v grep | awk '{print $2}' | xargs kill -9;
exit 1;
}