Skip to content

Instantly share code, notes, and snippets.

View abachman's full-sized avatar
🙌
good times

Adam Bachman abachman

🙌
good times
View GitHub Profile
@abachman
abachman / notify
Created February 28, 2017 15:31
Mac generic CLI notification tool
#!/usr/bin/env ruby
# based on http://apple.stackexchange.com/questions/57412/how-can-i-trigger-a-notification-center-notification-from-an-applescript-or-shel
require 'optparse'
SOUNDS = %w[
Basso Frog Hero Pop Submarine Blow Funk Morse Purr Tink Bottle Glass Ping Sosumi
].sort
@abachman
abachman / streams-curl.sh
Created February 16, 2017 21:40
Two ways to get at the IO data creation API
export API_KEY=
export USER=
export DATA_URL=https://io.adafruit.com/api/v2/$USER/feeds/test-feed/data
# accept system timestamp
curl -X POST -H 'Content-Type: application/json' -H "X-AIO-Key: $API_KEY" \
-d '{"datum":{"value": "10"}}' \
$DATA_URL
# single
@abachman
abachman / notes.md
Created February 7, 2017 19:05
Cassandra data modeling notes

Based on http://datascale.io/cassandra-partitioning-and-clustering-keys-explained/

Primary Keys

A single column Primary Key is also called a Partition Key.

When Cassandra is deciding where in the cluster to store this particular piece of data, it will hash the partition key. The value of that hash dictates where the data will reside and which replicas will be responsible for it.

@abachman
abachman / cplay-nightlight.ino
Last active January 3, 2017 21:05
Circuit Playground - Reading Light
// https://www.adafruit.com/products/3000
#include <Adafruit_CircuitPlayground.h>
#define COLOR uint32_t
#define arr_len( x ) ( sizeof( x ) / sizeof( *x ) )
COLOR colorChoices[] = {
0x000000,
0x111111,
0x333333,
0x777777,
@abachman
abachman / pre-commit
Last active October 15, 2017 06:37
A git pre commit hook for adafruit/io-api developers
#!/bin/sh
# check modified JSON files
files=$(git diff --cached --name-only --diff-filter=ACM | grep "v[12].json$")
if [ "$files" = "" ]; then
exit 0
fi
pass=true
@abachman
abachman / Demo.h
Last active July 29, 2016 15:08
The Best Circuit Playground Demo!
#ifndef DEMO_H
#define DEMO_H
// Define each mode with the following interface for a loop and modePress
// function that will be called during the main loop and if the mode button
// was pressed respectively. It's up to each mode implementation to fill
// these in and add their logic.
class Demo {
public:
virtual ~Demo() {}
/*
* A simple programme that will change the intensity of
* an LED based on the amount of light incident on
* the photo resistor.
*
*/
//PhotoResistor Pin
int lightPin = 0; //the analog pin the photoresistor is
//connected to
@abachman
abachman / Adafruit Naming Examples.md
Last active March 28, 2021 17:05
Adafruit Naming Examples

To run these examples, you'll need the Ruby MQTT library:

$ gem install mqtt

And you'll need to set the various environment variables the scripts expect to find. To do that, create a file named profile in the same directory you plan to run the scripts from. Fill in the AIO_USER and AIO_KEY values with your own.

$ cat &lt; profile

Keybase proof

I hereby claim:

  • I am abachman on github.
  • I am abachman (https://keybase.io/abachman) on keybase.
  • I have a public key ASAOvFn89LGpjyL2D-Dbk7u-19_YIFLqZ3REEUQflPmjfgo

To claim this, I am signing this object:

@abachman
abachman / groutes
Created May 26, 2016 20:11
groutes - a Rails routes grep helper
#!/bin/bash
#
# Add to your local ~/bin/ and search. Caches the `rake routes` command
# so it doesn't have to run again if config/routes hasn't changed.
#
if [ ! -f Rakefile -o ! -f config/routes.rb ]; then
echo "groutes will only work in rails project directories :("
exit 1
fi