Skip to content

Instantly share code, notes, and snippets.

@swinton
swinton / http_sig_example.py
Created February 4, 2015 19:22
Shows example programs written in Python that illustrate how to work with version 4 signing in AWS (via http://docs.aws.amazon.com/general/latest/gr/sigv4-signed-request-examples.html).
# AWS Version 4 signing example
# EC2 API (DescribeRegions)
# See: http://docs.aws.amazon.com/general/latest/gr/sigv4_signing.html
# This version makes a GET request and passes the signature
# in the Authorization header.
import sys, os, base64, datetime, hashlib, hmac
import requests # pip install requests
#!/bin/bash
# For more info: https://help.ubuntu.com/community/UbuntuTime#Time_Synchronization_using_NTP
ntpdate ntp.ubuntu.com

Notes

  • All the examples below assume the user's timezone is US/Central.

Basics

All activities from a device

Activity.objects(device="sausages")

Explain plans for activity queries

For help on interpreting see this reference.

All activities from a device

db.activity.find({"device": "sausages"}).explain()
{
@swinton
swinton / notes.md
Last active August 29, 2015 14:13
Notes on using the samples supplied with the Amazon Kinesis Client Library for Python

Host

git clone https://github.com/awslabs/amazon-kinesis-client-python.git
cd amazon-kinesis-client-python/
mkdir vm
cd vm
vagrant init ubuntu/trusty64
# Include in Vagrantfile:
# config.vm.synced_folder "..", "/home/vagrant/existence",
@swinton
swinton / journey.geojson
Last active October 9, 2015 19:28
Journey home, via Iceland!
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@swinton
swinton / receipt.xml
Created November 21, 2014 21:36
A receipt, as seen by Evernote
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<!DOCTYPE recoIndex PUBLIC "SYSTEM"
"http://xml.evernote.com/pub/recoIndex.dtd">
<recoIndex docType="unknown" objType="image"
objID="5f5306f6cda9364ef734165ecaa43d31" engineVersion="6.5.17.7"
recoType="service" lang="en" objWidth="534" objHeight="778">
<item x="173" y="133" w="80" h="22">
<t w="78">Welcome</t>
<t w="46">Wei come</t>
<t w="42">Wei came</t>
@swinton
swinton / stunnel.md
Created November 12, 2014 19:26
Stunnel HOWTO

Basically:

Install stunnel

brew install stunnel

Create /usr/local/etc/stunnel/stunnel.pem

openssl genrsa -out key.pem 2048
var _ = require("underscore");
// A 2-dimensional array of jokes
var jokes = _.shuffle(
[
[
"Why did Santa's helper see the doctor?",
"Because he had a low \"elf\" esteem!\n"
],
[
@swinton
swinton / config.txt
Last active December 22, 2015 20:41
Example PHP web app for downloading a document from Igloo using their API.
CONFIG_API_APP_APIVERSION: 1
CONFIG_API_APP_ID: e829896b-0c31-488c-93c1-33952ebad173
CONFIG_API_APP_PASS: familiar-foreign-deeply-tube
CONFIG_API_COMMUNITY: resources.bluezonesproject.com
CONFIG_API_PASSWORD: BlueZonesAPIAdmin943!
CONFIG_API_USERNAME: bluezonesprojectusa@healthways.com