Skip to content

Instantly share code, notes, and snippets.

Avatar
👨‍💻
hackerman

dalan dalanmiller

👨‍💻
hackerman
View GitHub Profile
View rethinkdb_statistical_reql_query_examples.js
##
#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
View inner_transpose.py
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:
@dalanmiller
dalanmiller / words_inner_trans_counter.py
Created Oct 18, 2014
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.
View words_inner_trans_counter.py
from collections import Counter
words = []
with open("/usr/share/dict/words","r") as f:
for line in f:
words.append(line.strip())
words_list = []
View ML_Proj_Example.py
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"]})
View earthquake-refresh.py
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 Jun 24, 2015
How to SSH Tunnel to a Docker container on a remote machine
View gist:e68ef5570a236387100c
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 Aug 29, 2015
A js file which watches a RethinkDB changefeed and pushes messages to PushBullet.
View watcherRethinkDB.js
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 Aug 29, 2015
Python script to run via cronjob, read sensor data, and push data into RethinkDB.
View pusherRethinkDB.py
import socket
import rethinkdb as r
import time
import Adafruit_DHT
import datetime
import logging
import sys
logging.basicConfig(
level=logging.INFO,
View feed.rss
<?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>
View 2012-07-12-command-history.txt
git --version
pwd
git init project1
ls -al
cd project1
ls -al
open .
which git
You can’t perform that action at this time.