Skip to content

Instantly share code, notes, and snippets.

@drmaq
drmaq / HowToOTG.md
Created October 22, 2018 03:22 — forked from gbaman/HowToOTG.md
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

@drmaq
drmaq / mosquitto-on-uberspace.txt
Created September 24, 2018 20:02 — forked from probonopd/mosquitto-on-uberspace.txt
mosquitto MQTT on uberspace
# Make a directory
mkdir ~/mosquitto
cd ~/mosquitto
# Get mosquitto for CentOS 6 and locally unpack it
wget ftp://ftp.pbone.net/mirror/ftp5.gwdg.de/pub/opensuse/repositories/home:/oojah:/mqtt/RedHat_RHEL-6/x86_64/mosquitto-1.2-6.1.x86_64.rpm
rpm2cpio mosquitto-*.rpm | cpio -idmv
mosquitto-*.rpm
# Set up ~/service on uberspace
# Instructions
## Content
1. Install OS
2. Connecting to the Pi
3. Setting up Raspian
4. Enable secure login
5. Install openHAB
6. Install mosquitto

Setup MQTT with SSL

  • :1883 will be for local use only
  • :8083 websocket secure
  • :8883 mqtt secure
sudo apt-get install mosquitto

Getting certificate & Auto-Renewal

Don't forget to change the domain and allow port 443 through firewall

@drmaq
drmaq / install_mosquitto.sh
Created September 24, 2018 20:02 — forked from ludeeus/install_mosquitto.sh
171272017_mosquitto_fix
#!/bin/bash
function mosquitto-show-short-info {
echo "Mosquitto Installer for Hassbian"
}
function mosquitto-show-long-info {
echo "Installs the Mosquitto package for setting up a local MQTT server"
}
@drmaq
drmaq / setup-mysql.sh
Created September 24, 2018 15:07 — forked from sheikhwaqas/setup-mysql.sh
Install MySQL Server on Ubuntu (Non-Interactive Installation)
# Download and Install the Latest Updates for the OS
apt-get update && apt-get upgrade -y
# Set the Server Timezone to CST
echo "America/Chicago" > /etc/timezone
dpkg-reconfigure -f noninteractive tzdata
# Enable Ubuntu Firewall and allow SSH & MySQL Ports
ufw enable
ufw allow 22
@drmaq
drmaq / vagrantfile
Created February 25, 2018 18:59
vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
# config.vm.box = "ubuntu/xenial64"
#config.vm.network "private_network", ip: "10.0.0.10"
config.vm.define "webscraper" do |webscraper|
webscraper.vm.box = "ubuntu/xenial64"
webscraper.vm.network "forwarded_port", guest: 80, host:8080
webscraper.vm.network "private_network", ip: "10.0.0.10"
@drmaq
drmaq / lxd-usage.txt
Created August 25, 2017 03:19 — forked from ruanbekker/lxd-usage.txt
LXD Usage
Docs - LXD Helpful Docs:
https://www.stgraber.org/2016/03/30/lxd-2-0-image-management-512/
https://www.flockport.com/flockport-first-look-at-lxd/
http://insights.ubuntu.com/2016/03/14/the-lxd-2-0-story-prologue/
Docs - Installation:
http://insights.ubuntu.com/2016/03/14/the-lxd-2-0-story-prologue/
Docs - API:
https://linuxcontainers.org/lxd/getting-started-cli/
### Keybase proof
I hereby claim:
* I am drmaq on github.
* I am shinobi (https://keybase.io/shinobi) on keybase.
* I have a public key whose fingerprint is E03A F081 95AA 01CC FA1D 1C84 D4CF B203 5892 DB05
To claim this, I am signing this object:
#!/usr/bin/env python
import RPi.GPIO as gpio
from time import sleep
import re
import sys
gpio.setmode(gpio.BCM)
red = 23
yel = 24