Skip to content

Instantly share code, notes, and snippets.

@milesgrimshaw
milesgrimshaw / Style.css
Created June 20, 2015 21:52
Custom style for map of personal data exhaust
#ubergeojson, #original {
line-color: @road;
line-width: 0.5;
[zoom>=11] { line-width: 0.5; }
[zoom>=12] { line-width: 0.7; }
[zoom>=13] { line-width: 1; }
[zoom>=14] { line-width: 1.2; }
[zoom>=15] { line-width: 1.4; }
[zoom>=16] { line-width: 1.6; }
}
@milesgrimshaw
milesgrimshaw / mindbody.R
Created March 17, 2015 14:42
Script to parse MindBody data
# Load libraries
library(ggplot2)
# Set working directory
setwd("~/Dropbox (Personal)/Personal/Github/MindBody/New/")
# Read in the data
data <- read.csv('mind_new.csv', header=TRUE, as.is=TRUE)
# Convert everything to lower case
@milesgrimshaw
milesgrimshaw / yelp.rb
Created March 16, 2015 23:10
Script to collect search count data for various terms in Yelp across top 60 US cities
require 'oauth'
require 'json'
require 'pp'
require 'csv'
consumer_key = '#YOURS'
consumer_secret = '#YOURS'
token = '#YOURS'
token_secret = '#YOURS'
@milesgrimshaw
milesgrimshaw / citymedia.rb
Created March 16, 2015 23:07
Script to collect data from CityGridMedia's Places API
require 'rubygems'
require 'nokogiri'
require 'pp'
require 'mechanize'
require 'open-uri'
require 'csv'
key = "## YOUR KEY HERE"
@milesgrimshaw
milesgrimshaw / mindbody.rb
Created March 16, 2015 23:06
Script to scrape the clients feed behind the map on MindBody's website
require 'nokogiri'
require 'pp'
require 'mechanize'
require 'open-uri'
require 'csv'
page = Nokogiri::XML(open('https://www.mindbodyonline.com/clients/feed/all.xml'))
items = page.css('marker')
CSV.open("mind_new.csv", "wb") do |csv|
@milesgrimshaw
milesgrimshaw / inbox_count
Created September 25, 2014 15:33
Google Apps Script to save the count of emails in your inbox
function processInbox() {
// get all threads in inbox
var threads = GmailApp.getInboxThreads();
data_id = '1t70IDdWcaJzCIIaNWm2nHSPKzetHfTxhkKc9jKkAlpA'
var dataSs = SpreadsheetApp.openById(data_id);
var sheet = dataSs.getSheets()[0];
var current_date = new Date();
sheet.appendRow([current_date, current_date.toISOString(),threads.length]);
};
@milesgrimshaw
milesgrimshaw / geocode_appscript
Created September 23, 2014 18:52
Geocode Restaurant Data in Google Sheet Appscript
function geocode_all() {
// grab basic sheet data
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
var values = rows.getValues();
// init some locals for looping over each row
var row;
@milesgrimshaw
milesgrimshaw / Citibike.R
Created August 6, 2014 11:49
R script to analyze personal Citibike data
library(ggplot2)
library(lubridate)
## Set the working directory
setwd("~/Dropbox (Personal)/Personal/Github/Citibike")
## Organize restaurant data
r <- read.csv('trips.csv', header=TRUE, as.is=TRUE)
head(r)
@milesgrimshaw
milesgrimshaw / citibike.rb
Created August 6, 2014 11:47
Script to collect and get routes for personal Citibike data
## API Structure
# {
# "name": "citibike_bay",
# "count": 8,
# "frequency": "realtime",
# "version": 1,
# "newdata": true,
# "lastrunstatus": "success",
# "lastsuccess": "Tue Jul 22 2014 21:50:19 GMT+0000 (UTC)",
# "results": {
@milesgrimshaw
milesgrimshaw / yelp.rb
Last active September 17, 2015 06:47
How many gyms/yoga/pilates in Boston/New York/LA? Ruby script to output a spreadsheet of the number of a given category in a given city according to Yelp.
require 'oauth'
require 'json'
require 'pp'
require 'csv'
consumer_key = 'NUM'
consumer_secret = 'NUM'
token = 'NUM'
token_secret = 'NUM'