Skip to content

Instantly share code, notes, and snippets.

View lukewakeford's full-sized avatar
🚲
Cycling

Luke Wakeford lukewakeford

🚲
Cycling
View GitHub Profile
@shrayasr
shrayasr / fu-garmin-bulk-delete.js
Created March 28, 2018 06:03
Bulk delete activities in Garmin Connect
function foo() {
console.log("foo - start")
$("button.search-button").click()
setTimeout(function() {
var li = $(".list-item")[0]
var delButton = $(li).find("button.js-activity-delete")
var confirmDelButton = $(li).find("button.delete-yes")
console.log(delButton, confirmDelButton)
@reeichert
reeichert / ClosedConvexHullCLLocationCoordinate2D.swift
Created August 13, 2017 00:57
Closed convex hull CLLocationCoordinate2D
func sortConvex(input: [CLLocationCoordinate2D]) -> [CLLocationCoordinate2D] {
// X = longitude
// Y = latitudeß
// 2D cross product of OA and OB vectors, i.e. z-component of their 3D cross product.
// Returns a positive value, if OAB makes a counter-clockwise turn,
// negative for clockwise turn, and zero if the points are collinear.
func cross(P: CLLocationCoordinate2D, A: CLLocationCoordinate2D, B: CLLocationCoordinate2D) -> Double {
let part1 = (A.longitude - P.longitude) * (B.latitude - P.latitude)
@rgcottrell
rgcottrell / gist:5b876d9c5eea4c9e411c
Created September 21, 2014 17:38
An FM Synthesizer in Swift using AVAudioEngine
import AVFoundation
import Foundation
// The maximum number of audio buffers in flight. Setting to two allows one
// buffer to be played while the next is being written.
private let kInFlightAudioBuffers: Int = 2
// The number of audio samples per buffer. A lower value reduces latency for
// changes but requires more processing but increases the risk of being unable
// to fill the buffers in time. A setting of 1024 represents about 23ms of
@jonahsiegle
jonahsiegle / gist:9837352
Created March 28, 2014 16:45
Check if two NSDate objects are on the same day.
- (BOOL)isSameDayWithDateOne:(NSDate *)dateOne dateTwo:(NSDate *)dateTwo{
NSCalendar *calender = [NSCalendar currentCalendar];
unsigned unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit;
NSDateComponents *compOne = [calender components:unitFlags fromDate:dateOne];
NSDateComponents *compTwo = [calender components:unitFlags fromDate:dateTwo];
return ([compOne day] == [compTwo day] && [compOne month] == [compTwo month] && [compOne year] == [compTwo year]);