Skip to content

Instantly share code, notes, and snippets.

View mplewis's full-sized avatar
🐕
柴犬

Matt Lewis mplewis

🐕
柴犬
View GitHub Profile
@mplewis
mplewis / scanner.ino
Last active August 29, 2015 14:01
Analog proximity sensor array scanner code. EE 4951W, Spring 2014, Group 10: Optical Guitar
/* Analog proximity sensor array scanner code
*
* EE 4951W Spring 2014
* Group 10: Optical Guitar
* Advisor: Dr. James Leger
* Group members: Sandra Arnold, Justin Buth, Matthew Lewis, Steffen Moeller, Anh Nguyen
*
* Target device: Teensy 2.0
* Program Teensy 2.0 with this sketch using Arduino software
*/
queries = {
activities: squel.select()
.from('strava_activities')
.field('name')
.field('type')
.field('start_date')
.field('distance_mi')
.field('pace_mins_per_mi')
.field('polyline')
.order('start_date', false)
@mplewis
mplewis / PTDIntelHex.h
Last active August 29, 2015 14:06
PTD's Intel Hex helper. This converts Intel Hex into NSData suitable for programming to a Bean. License: The MIT License
#import <Foundation/Foundation.h>
@interface PTDIntelHex : NSObject
@property (nonatomic, strong) NSString* name;
+ (PTDIntelHex*)intelHexFromHexString:(NSString*)hexString;
+ (PTDIntelHex*)intelHexFromFileURL:(NSURL*)file;
- (id)initWithHexString:(NSString*)hexString;
@mplewis
mplewis / gen_opc_wall.py
Created February 7, 2015 23:20
Generate JSON for a square wall of pixels for use with Open Pixel Control and Fadecandy.
import json
PER_SIDE = 12 # The size of the square wall, in pixels per side
TIGHTNESS = 20 # A higher number places dots closer together
half = int(PER_SIDE / 2)
axis = [(x + 0.5) / TIGHTNESS for x in range(-half, half)]
# We reverse the array and plot them z, then x because gl_server's layouts
# are weird when used with the Fadecandy examples
@mplewis
mplewis / uppercase.ino
Created February 11, 2015 00:17
Arduino sketch. Echo back all characters, making lowercase characters uppercase.
const int MAX_CHARS = 64;
char data[MAX_CHARS] = {0};
uint8_t out[MAX_CHARS] = {0};
void setup()
{
Serial.begin(57600);
}
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Generated;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
@mplewis
mplewis / macshots.py
Last active August 29, 2015 14:17
Like CloudApp, but for imgur, and free. License: MIT. Don't forget: pip3 install appdirs imgurpython watchdog pync
#!/usr/bin/env python3
import appdirs
from imgurpython import ImgurClient
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
from pync import Notifier
import os
import json
# Arduino makefile
#
# This makefile allows you to build sketches from the command line
# without the Arduino environment (or Java).
#
# The Arduino environment does preliminary processing on a sketch before
# compiling it. If you're using this makefile instead, you'll need to do
# a few things differently:
#
# - Give your program's file a .cpp extension (e.g. foo.cpp).
@mplewis
mplewis / unpacking.py
Last active August 29, 2015 14:19
This is why no one likes you, Java.
def coordsFromRaw(raw):
return raw.split(',')
lat, lng = getCoordsFromRaw('-87.142,60.330')
print(lat, lng)
@mplewis
mplewis / docker-clean.sh
Created April 21, 2015 05:43
Stupid Docker tricks because you're lazy
#!/bin/bash
# From https://www.calazan.com/docker-cleanup-commands/
echo '=============================='
echo 'Deleting stopped containers...'
echo '=============================='
docker rm $(docker ps -a -q)