Skip to content

Instantly share code, notes, and snippets.

View twitchyliquid64's full-sized avatar
🍔

Tom twitchyliquid64

🍔
View GitHub Profile
@twitchyliquid64
twitchyliquid64 / webcam_streamer.go
Last active June 24, 2017 21:21
Pure-go binary to open a webcam, and expose it for watching on port 8080. Openable in VLC or a web browser.
package main
//Exposes a MJPEG stream of the connected camera in pure-Go.
//Linux/Raspberry pi only.
//Author: twitchyliquid64
//
//This script shows how to:
//1. Use blackjack's awesome V4L2 library to open a connected camera,
//2. Setup the format / frame size of the connected camera
//3. Optionally transcode YUYV format to JPEG
@twitchyliquid64
twitchyliquid64 / modify_raspbian_image.py
Created May 7, 2017 12:26
Modifies a raspbian image file to set static networking parameters and a hostname, as well as turning on SSH.
# setuppi.py
# Author: twitchyliquid64
# Automatically modifies a raspbian .img file to:
# - Set a static IP address, gateway, and DNS server
# - Enable SSH
# - Set a hostname.
#
# Tested and working with a default install of Ubuntu 16.04
# USAGE: python setuppi.py <imagefile>
# EG: sudo python setuppi.py 2017-04-10-raspbian-jessie-lite.img
@twitchyliquid64
twitchyliquid64 / mcp2221a_set_strings.py
Created August 20, 2017 02:44
Example code for reading settings from the MCP2221 or MCP2221A chip, and writing product/vendor strings. Trivial to set/read other settings as well.
# Make sure you install pyusb and libusb on your system yo
import usb.core
import usb.util
import usb.control
HID_INTERFACE = 0x02
INPUT_ENDPOINT = 0x83
OUTPUT_ENDPOINT = 0x3
HID_PKT_SIZE = 64
@twitchyliquid64
twitchyliquid64 / play_on_home.go
Created November 2, 2017 09:22
Demonstrates playing a local media file on a google home.
package main
import (
"context"
"errors"
"flag"
"fmt"
"io"
"net"
"net/http"
@twitchyliquid64
twitchyliquid64 / uc_mke04z_cortexplus.go
Last active June 18, 2018 07:22
Hacky program to test if Unicorn can successfully emulate one of my firmware blobs
package main
// NOTE: You need to install 'unicorn' library from https://github.com/unicorn-engine/unicorn first.
import (
"encoding/binary"
"fmt"
"io/ioutil"
uc "github.com/unicorn-engine/unicorn/bindings/go/unicorn"
@twitchyliquid64
twitchyliquid64 / pirateLCD.py
Created October 11, 2018 03:20
Drive cheap I2C character LCDs using the bus pirate.
import math
import serial
import time
# Use can use the bus pirates' scan mode to find these.
deviceAddress = [0x4e]
# Corresponds to pins
LCD_BACKLIGHT = 0x08
LCD_ENABLE = 0b00000100
@twitchyliquid64
twitchyliquid64 / Makefile
Created November 10, 2018 01:29
My first kernel module
obj-m := crapmod.o
module_name-objs := crapmod.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
load: all
@twitchyliquid64
twitchyliquid64 / install_bossa.sh
Last active May 31, 2020 08:25
Installs BOSSA 1.9.1 on debian based systems.
#!/bin/bash
# Installs BOSSA 1.9.1 from source on debian based systems.
# Author: twitchyliquid64
#
# Copyright (c) 2019 twitchyliquid64. All rights reserved.
#
# This work is licensed under the terms of the MIT license.
# For a copy, see <https://opensource.org/licenses/MIT>.
URL='https://github.com/shumatech/BOSSA/archive/1.9.1.tar.gz'
@twitchyliquid64
twitchyliquid64 / bearing_raceway.scad
Last active September 9, 2023 04:52
bearing_raceway.scad
// Successful test on 0.3mm with 4.5mm balls:
// ball_r = 4.5/2,
// center_ext_p = 0.25,
// vert_ext_p = 0.2,
// ball_slop_r = 0.15
//
// The two halfs were super close, could stand to increase
// clearance a lil.
//