Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View dalanmiller's full-sized avatar
👨‍💻

dalan dalanmiller

👨‍💻
View GitHub Profile
<?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>
##
#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
#!/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")\
@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
@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 / 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 / gist:e68ef5570a236387100c
Created June 24, 2015 00:55
How to SSH Tunnel to a Docker container on a remote machine
ssh -nNT -L port_on_local_machine:ip_of_docker_container_on_remote_host:port_of_docker_container_on_remote_host username@remote_host
import rethinkdb as r
url = "http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/2.5_month.geojson"
def refresh_quakes():
conn = r.connect()
r.db("earthquakes").table("quakes").insert(
r.http(url)["features"].merge({
"time": r.epoch_time(
r.row['properties']['time'] / 1000
import pymongo
from pprint import pprint
mc = pymongo.MongoClient("localhost", 27017)
db = mc['yelp']
doctor = db.businesses.find_one()
reviews_on_business = db.reviews.find({"business_id" : doctor["business_id"]})

Keybase proof

I hereby claim:

  • I am dalanmiller on github.
  • I am dalanmiller (https://keybase.io/dalanmiller) on keybase.
  • I have a public key ASAQCRsgm5E5wH1wpGzk3IMIgHvgCmsVpKeFnqGR-hUE4Ao

To claim this, I am signing this object: