Skip to content

Instantly share code, notes, and snippets.

View dalanmiller's full-sized avatar
👨‍💻

dalan dalanmiller

👨‍💻
View GitHub Profile
##
#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
@dalanmiller
dalanmiller / words_inner_trans_counter.py
Created October 18, 2014 07:01
Quick script to use `/usr/share/dict/words` and count the amount words which can be inner-transposed to another word. Also prints the average length of words with alternates.
from collections import Counter
words = []
with open("/usr/share/dict/words","r") as f:
for line in f:
words.append(line.strip())
words_list = []
import os
import re
import string
import random
path = "path_to_folder_just_about_set_of_text_files"
word = re.compile("\w*")
for x,y,z in os.walk(path):
for file in z:
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"]})
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
@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
@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,
<?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>
git --version
pwd
git init project1
ls -al
cd project1
ls -al
open .
which git