Skip to content

Instantly share code, notes, and snippets.

View dalanmiller's full-sized avatar
👨‍💻

dalan dalanmiller

👨‍💻
View GitHub Profile
@dalanmiller
dalanmiller / watcherRethinkDB.js
Last active August 29, 2015 14:26
A js file which watches a RethinkDB changefeed and pushes messages to PushBullet.
var r = require("rethinkdb");
var Promise = require("bluebird");
var fs = require("fs");
var PushBullet = require('pushbullet');
Promise.promisifyAll(fs);
fs.readFileAsync("token").then(function(val) {
PUSHER = new PushBullet(val.toString().trim());
})
.then(function(){
@dalanmiller
dalanmiller / pusherRethinkDB.py
Last active August 29, 2015 14:26
Python script to run via cronjob, read sensor data, and push data into RethinkDB.
import socket
import rethinkdb as r
import time
import Adafruit_DHT
import datetime
import logging
import sys
logging.basicConfig(
level=logging.INFO,
@dalanmiller
dalanmiller / download_rethinkdb_for_raspberry_pi_2.sh
Last active September 19, 2016 10:30
A quick script to download and compile RethinkDB on Raspberry Pi 2
sudo apt-get install g++ protobuf-compiler libprotobuf-dev libboost-dev curl m4 wget
#At this point make sure you check to see that 2.0.4 is still the most recent version of RethinkDB! http://rethinkdb.com
wget http://download.rethinkdb.com/dist/rethinkdb-latest.tgz
tar xf rethinkdb-latest.tgz
rm rethinkdb-latest.tgz
cd rethinkdb-*
./configure --with-system-malloc --allow-fetch
#Export the proper C++ flags for Raspberry Pi 1/2
#!/usr/bin/python
import rethinkdb as r
from datetime import datetime, timedelta
conn = r.connect("localhost", 28015, db="telemetry_pi")
##
#Finding the average temperature & humidity for the past 24 hours
##
day_ago = datetime.now() - timedelta(hours=24)
cursor = r.table("observations")\
##
#Finding the hottest observations per day (or a _single_ maxima for each day)
##
r.db("telemetry_pi").table("observations").create_index
r.db('telemetry_pi').table("observations").group({index: "datetime"}).max("temp").ungroup()("reduction")
##
#Finding some basic statistics and calculating a simple linear regression (y_humidity = alpha + beta_temp * temp)
##
# https://en.wikipedia.org/wiki/Simple_linear_regression
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>RethinkDB: the open-source database for the realtime web</title>
<description>News and updates from the RethinkDB team.</description>
<link>http://rethinkdb.com</link>
<atom:link href="http://rethinkdb.com/feed.xml" rel="self" type="application/rss+xml" />
<item>
@dalanmiller
dalanmiller / Dockerfile
Created December 16, 2015 17:32
jekyll deploy dockerfile
FROM ruby:latest
RUN mkdir /root/.ssh/
RUN touch /root/.ssh/known_hosts
RUN ssh-keyscan -T 60 github.com >> /root/.ssh/known_hosts
COPY autodeploy /root/.ssh/
RUN curl -sL https://deb.nodesource.com/setup_5.x | bash -
RUN apt-get install --yes nodejs git
@dalanmiller
dalanmiller / netbeez-install.sh
Last active January 21, 2016 06:18
Netbeez install script is broken - https://netbeez.net/product/install-netbeez-software-agent/ - this is fixed.
#!/bin/sh
sudo echo deb http://repo.netbeez.net wheezy main >> /etc/apt/sources.list
sudo wget -O - http://repo.netbeez.net/netbeez_pub.key | sudo apt-key add -
sudo apt-get update
sudo apt-get install netbeez-agent
@dalanmiller
dalanmiller / asyncio-changefeeds.py
Created May 2, 2016 22:39
asyncio & RethinkDB changefeeds example
import rethinkdb as r
import asyncio
r.set_loop_type("asyncio")
async def get_connection():
return await r.connect("localhost", 28015)
async def changefeed_old():
Verifying that +dalanmiller is my blockchain ID. https://onename.com/dalanmiller