Skip to content

Instantly share code, notes, and snippets.

View etaubman's full-sized avatar

Ethan T etaubman

View GitHub Profile
@etaubman
etaubman / trainingpeaks_to_csv.py
Created October 18, 2018 22:15
Pull Data from TrainingPeaks into CSV File
import pandas as pd
import json
from bs4 import BeautifulSoup
import requests
URL = "http://home.trainingpeaks.com/athlete/workout/UzpDb"
file_contents = requests.get(URL).text
soup = BeautifulSoup(file_contents,'html.parser')
Public Const DEVELOPMENT_MODE As Boolean = True
Public Sub Assert(ByRef bConditional As Boolean, _
Optional ByRef TestName As String)
If DEVELOPMENT_MODE Then
Debug.Print bConditional, TestName
End If
End Sub
import csv
import time
import datetime as dt
import re
files = ["data/2013-7.csv","data/2013-8.csv","data/2013-9.csv","data/2013-10.csv","data/2013-11.csv", "data/2013-12.csv","data/2014-1.csv", "data/2014-2.csv"]
def convert_to_timestamp(time_string):
month = re.search("\d+",time_string).group(0)
if len(month) == 1: month = "0" + str(month)
import random
from time import time
class OpenDoorsOutOfRangeError(Exception):
def __init__(self):
pass
class Monty:
initial = False
@etaubman
etaubman / ShortenNumbers.js
Last active April 10, 2021 23:11
Shorten Numbers Using Javascript
function shortenNumber(n, d) {
if (n < 1) return "<1";
var k = n = Math.floor(n);
if (n < 1000) return (n.toString().split("."))[0];
if (d !== 0) d = d || 1;
function shorten(a, b, c) {
var d = a.toString().split(".");
if (!d[1] || b === 0) {
return d[0] + c
@etaubman
etaubman / parse_log_files.php
Created July 27, 2013 00:59
Pull data from my last Gist into a single CSV. This doesn't handle station data yet.
<?php
/**
* Utility file for turning my JSON log files into usable data
* parse_log_files.php
*/
$start_time = time();
date_default_timezone_set("America/New_York");
function write_file ($contents, $name)
{
@etaubman
etaubman / get_data.php
Created July 26, 2013 23:48
Pull Station Data from CitiBikeNYC
<?php
/**
* Utility file to pull Citibike Station Data and write to a log file
* get_data.php
*/
function get_data () {
$href = "http://citibikenyc.com/stations/json";
$json = file_get_contents($href);
return $json;
@etaubman
etaubman / time_since.php
Last active December 17, 2015 12:29 — forked from danoc/time_since.php
<?php
/**
* Return a "human-readable" time such as 8 hours ago.
*
* @author Dan O'Connor, Modified by Ethan Taubman
*
* @param string $time such as: 2013-03-18 21:13:59
* @param string $format optional such as: "<em>%d</em> %s%s since last post."
*
@etaubman
etaubman / pre-and-post-filters.php
Last active December 16, 2015 05:08
A method for extending CodeIgniter to have pre and post filters simliar to RoR and Cake. The actual method call is left in for reference. This is and addition to the file ./system/core/CodeIgniter.php
<?php //this is a snippet from ./system/core/CodeIgniter.php
/*
* ------------------------------------------------------
* Is there a pre-filter on the requested method?
* ------------------------------------------------------
*/
if (isset($CI->pre_filter) && is_array($CI->pre_filter))
{
foreach ($CI->pre_filter as $pre_filter_action => $filtered_action)