Skip to content

Instantly share code, notes, and snippets.

View mplewis's full-sized avatar
🐕
柴犬

Matt Lewis mplewis

🐕
柴犬
View GitHub Profile
@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);
}
@mplewis
mplewis / android_ble_char_props_cheat_sheet.md
Last active May 15, 2023 17:45
A cheat sheet for the bits in the bitmask of Android characteristic properties.

Characteristic Property Cheat Sheet

for Android Bluetooth Low Energy

Tired of remembering which properties go with which bits in the properties bitmask of a BluetoothGattCharacteristic? Me too. Here's an easy-to-read table. Source.

BluetoothGattCharacteristic

Properties

Bit Value | Meaning

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
@mplewis
mplewis / README.md
Last active December 30, 2016 09:10

git-merge-android-manifest

Git merge strategy for Android Manifest files. See main() for more info.

[email protected], created 2015-03-27

License: The MIT License


#include <Adafruit_NeoPixel.h>
#include "HSBColor.h"
// The pin that is connected to the NeoPixels
#define NEOPIXEL_PIN 1
// The pin connected to the button
#define BUTTON_PIN 2
// The amount of LEDs in the NeoPixels
# 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)