Skip to content

Instantly share code, notes, and snippets.

View rjcorwin's full-sized avatar

R.J. (Steinert) Corwin rjcorwin

View GitHub Profile
npm install -g thingpipe;
mkdir pipe1;
cd pipe1;
pipe init;
npm install thingpipe_random;
npm install thingpipe_phant;
pipe thing thingpipe_random;
pipe reservoir thingpipe_phant;
pipe interval 2000;
# Create a new stream at https://data.sparkfun.com with `Fields` set to `value`

The Internet of Things (IoT) has, since its inception, been in a standards war over protocols, database technologies, hardware, etc. What if instead of talking about standards, we had a philosophy that could help guide those decisions on standards? In our work on the Open Pipe Kit project, we're really digging Unix Philosophy for developing software that connects the Internet of Things.

Write programs that do one thing and do it well. Write programs to work together. Write programs to handle text streams, because that is a universal interface -- [Doug McIlroy, creator of the Unix Pipe]

Example scenario

Programmer wants to get data from this thing to that database.

Programmer finds a software project that will help but says, "I am a Python programmer and this project is written in Java! Ignored!"

Hold your horses Ms./Mrs./Mr. Programmer. That Java project is a command-line interface.

@rjcorwin
rjcorwin / generate-jack-in-the-box.template
Created April 28, 2015 14:18
An underscore template that generates a Jack-in-the-Box data pipe from sensors to database (WIP, see https://github.com/open-eio/Open-Pipe-Kit-Project/issues/27)
<%
var drivers = [
{
url: "",
name: "",
install: "",
}
]
@rjcorwin
rjcorwin / setup-drupal8-rest-server-and-test-it.sh
Last active August 29, 2015 14:21
Set up environment and do a round of CRUD on the page content type.
curl -sS https://getcomposer.org/installer | php
composer global require drush/drush:dev-master
drush qd --core=drupal-8.0.x
# Note the password created for admin will be different from the examples. Either change example or in your Drupal install.
cd quick-drupal
drush en rest hal basic_auth -y
# Create a new page node
curl --include \
--request POST \
--user admin:password \

RESTful Drupal 8 CRUD Example using jQuery and core REST module

CREATE Item

var package = {}
package.title = [{'value':'t1'}]
package.body = [{'value':'b1'}]
package._links = {"type":{"href":"http://local.drupal8.org/rest/type/node/page"}}

$.ajax({
<?php
/**
* @file
* Code for the recipe feature.
*/
include_once 'recipe.features.inc';
function recipe_menu() {
$items = array();
$allowed_cors_origins = array('http://localhost:9000/', 'http://isovera.github.io/');
if (in_array($_SERVER['HTTP_REFERER'], $allowed_cors_origins)) {
header("Access-Control-Allow-Origin: " . substr($_SERVER['HTTP_REFERER'], 0, -1));
header("Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE");
header("Access-Control-Allow-Headers: content-type, X-CSRF-Token");
header("Access-Control-Allow-Credentials: true");
}
@rjcorwin
rjcorwin / wpa2-wifi-connect.sh
Last active April 26, 2022 23:07
A simple `wifi` command for Debian that will connect you to a WPA2 WiFi network
#!/bin/sh
## A simple `wifi` command for Debian that will connect you to a WPA2 WiFi network
## usage:
## sudo ./wpa2-wifi-connect.sh <ssid> <pass>
ifdown wlan0
# build the interfaces file that will point to the file that holds our configuration
rm /etc/network/interfaces
touch /etc/network/interfaces