Skip to content

Instantly share code, notes, and snippets.

@mdonkers
mdonkers / server.py
Last active May 31, 2023 00:21
Simple Python 3 HTTP server for logging all GET and POST requests
View server.py
#!/usr/bin/env python3
"""
License: MIT License
Copyright (c) 2023 Miel Donkers
Very simple HTTP server in python for logging requests
Usage::
./server.py [<port>]
"""
from http.server import BaseHTTPRequestHandler, HTTPServer
@phansch
phansch / yardoc_cheatsheet.md
Last active May 19, 2023 13:30 — forked from chetan/yardoc_cheatsheet.md
Improved YARD cheatsheet
View yardoc_cheatsheet.md
@gbaman
gbaman / HowToOTG.md
Last active April 21, 2023 09:54
Simple guide for setting up OTG modes on the Raspberry Pi Zero
View HowToOTG.md

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

@junegunn
junegunn / gist:f4fca918e937e6bf5bad
Last active April 23, 2023 10:51
Browsing git commit history with fzf
View gist:f4fca918e937e6bf5bad
# fshow - git commit browser (enter for show, ctrl-d for diff, ` toggles sort)
fshow() {
local out shas sha q k
while out=$(
git log --graph --color=always \
--format="%C(auto)%h%d %s %C(black)%C(bold)%cr" "$@" |
fzf --ansi --multi --no-sort --reverse --query="$q" \
--print-query --expect=ctrl-d --toggle-sort=\`); do
q=$(head -1 <<< "$out")
k=$(head -2 <<< "$out" | tail -1)
@emiller
emiller / git-mv-with-history
Last active May 31, 2023 15:40
git utility to move/rename file or folder and retain history with it.
View git-mv-with-history
#!/bin/bash
#
# git-mv-with-history -- move/rename file or folder, with history.
#
# Moving a file in git doesn't track history, so the purpose of this
# utility is best explained from the kernel wiki:
#
# Git has a rename command git mv, but that is just for convenience.
# The effect is indistinguishable from removing the file and adding another
# with different name and the same content.
@chetan
chetan / yardoc_cheatsheet.md
Last active May 18, 2023 08:53
YARD cheatsheet
View yardoc_cheatsheet.md