Skip to content

Instantly share code, notes, and snippets.

View scttnlsn's full-sized avatar

Scott Nelson scttnlsn

View GitHub Profile
@scttnlsn
scttnlsn / README.md
Created March 10, 2018 21:00
Enable USB mass storage on Raspberry Pi Zero

Create new filesystem:

sudo dd if=/dev/zero of=/usb.bin bs=512 count=51200
sudo mkdosfs /usb.bin
  • Add dwc2 to /etc/modules-load.d/modules.conf
  • Add dtoverlay=dwc2 to /boot/config.txt
  • reboot
@scttnlsn
scttnlsn / mqtt_relay.py
Created January 18, 2018 16:12
ESP8266 + MQTT relay
import machine
import network
import ubinascii
from umqtt.simple import MQTTClient
SSID = ''
PASSWORD = ''
BROKER = ''
TOPIC = ''
@scttnlsn
scttnlsn / core.cljs
Created July 1, 2015 17:58
Reagent/Secretary nested routing
(ns nested-routing.core
(:require [goog.events :as events]
[goog.history.EventType :as EventType]
[reagent.core :as reagent]
[reagent.ratom :refer-macros [reaction]]
[re-frame.core :refer [dispatch dispatch-sync register-handler register-sub subscribe]]
[secretary.core :as secretary :refer-macros [defroute]])
(:import goog.History))
(declare route-components
@scttnlsn
scttnlsn / Makefile
Last active March 13, 2017 01:06
AVR Makefile
TARGET = example
MCU = atmega328p
PROG = avrisp
PORT = /dev/cu.*usb*
BAUD = 57600
F_CPU = 16000000
# Sources
LIBS = $(shell find lib/* -type d 2> /dev/null)
SRC = $(wildcard src/*.c) $(foreach LIB, $(LIBS), $(wildcard $(LIB)/*.c))
@scttnlsn
scttnlsn / core.cljs
Last active July 2, 2016 07:36
Om/Secretary nested routing
(ns nested-routing.core
(:require-macros [om.core :as om]
[secretary.core :refer [defroute]])
(:require [om.dom :as dom]
[om.core :as om]
[secretary.core :as secretary]
[goog.events :as events]
[goog.history.EventType :as EventType])
(:import goog.History))
@scttnlsn
scttnlsn / example.js
Last active December 30, 2015 23:39
CSP with JavaScript (ES6 only)
// node --harmony example.js
var go = require('./go');
var even = go.channel();
var odd = go.channel();
go(function* () {
for (var i = 0; i < 10; i += 2) {
yield even.put(i);
@scttnlsn
scttnlsn / example.html
Last active December 17, 2015 16:39
Flight-inspired mixin composition
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.js"></script>
<script src="http://underscorejs.org/underscore.js"></script>
<script src="http://backbonejs.org/backbone.js"></script>
<script src="wings.js"></script>
<script>
@scttnlsn
scttnlsn / .bashrc
Last active December 16, 2015 22:39
Redis launch agent
alias redis-start="launchctl start io.redis.redis-server"
alias redis-stop="launchctl stop io.redis.redis-server"
alias redis-status="launchctl list | grep io.redis.redis-server"
@scttnlsn
scttnlsn / env.js
Created January 31, 2013 17:55
RequireJS plugin to conditionally load modules based on environment
// Include { env: 'development' } in your RequireJS config
// When building (with r.js) set the value to 'production' or just omit it entirely
//
// Assuming the following directory structure:
// - config/
// - development.js
// - production.js
//
// Load the appropriate file based on the current env:
//
@scttnlsn
scttnlsn / coffeescript-ifer.sublime-snippet
Created June 11, 2012 16:56
ST2 Snippet: if (err) return callback(err)
<snippet>
<content><![CDATA[return ${1:callback} ${2:err} if ${2:err}?]]></content>
<tabTrigger>ifer</tabTrigger>
<scope>source.coffee</scope>
<description>ifer</description>
</snippet>