Skip to content

Instantly share code, notes, and snippets.

@gkoehler
gkoehler / ViewController.swift
Created November 12, 2015 13:23
UICollectionView: performBatchUpdates example
//
// ViewController.swift
// collView2
//
// Created by Gavin Koehler on 11/11/15.
// Copyright © 2015 From Now On, LLC. All rights reserved.
//
import UIKit

Switching from Nike+ to Strava, but don't want to lose your runs? Here's how I did it.

  1. Go to Matt Stuehler's site and download all of your runs. Change your Nike+ password afterward if you're paranoid.
  2. Create a Strava account andgo to "import from a file."
  3. Drag 25 .gpx files from your desktop to the "choose files" button.
  4. Next, Strava will want you to classify each as a run, ride, etc. Open the javascript console and run this to select "Run" for each of them:

var $ = jQuery; $('.activity-type').each(function() { var acttype=this; $('.selection', this).click(); setTimeout(function(){ $('[data-value="Run"] a', acttype).click(); }, 300); });

  1. Repeat step #3 as needed.
@gkoehler
gkoehler / post_to_twitter.py
Created January 3, 2014 01:14
Posts a Pelican article link & title to Twitter.
import os, re, sys, getopt, twitter, pelicanconf, publishconf
from urlparse import urljoin
# Posts a Pelican article to Twitter.
# usage: post_to_twitter.py -a articlename
# (articlename is the filename, minus the extension)
# The script will look for articlename.md inside /content, parse out Title & Slug,
# then tweet out "%title% %siteurl%/%slug%.html" under your account.
@gkoehler
gkoehler / NormalizeArguments.js
Last active December 27, 2015 08:29
Very simple way to normalize arguments, just like a regular JS function would receive. Useful for Node.js shell scripts.
// very simple way to normalize arguments, just like a regular JS function would receive
// so, this:
// script.js -arg1=argval -arg2=newargval -arg3
// would translate to:
// {arg1:argval, arg2:newargval, arg3:undefined}
// (there are also other parameters Node adds)
// If the same argument is used twice with different values,
// their values are comma-delimited.
// so, this:
// script.js -file=filename1.txt -file=filename2.txt
// Macbook air 2011 product page: http://www.amazon.com/gp/offer-listing/B005CWHZP4/sr=/qid=/ref=olp_page_next?ie=UTF8&colid=&coliid=&condition=used&me=&qid=&shipPromoFilter=0&sort=sip&sr=&startIndex=30
// Went to all three pages under the "used" tab and called this function on the console:
Array.prototype.slice.call( document.querySelectorAll('.result .price')).map(function(el) { return parseInt(el.innerText.replace('$','').replace(',','')); })
// this generated the following array of prices:
var prices = [600, 750, 800, 800, 825, 850, 889, 896, 899, 898, 899, 900, 935, 944, 950, 950, 950, 959, 975, 999, 999, 999, 1000, 1000, 1000, 1000, 1049, 1099, 1100, 1100, 849, 1100, 1150]
// finding the average price: