Skip to content

Instantly share code, notes, and snippets.

@billglover
billglover / YAPTMainViewController.swift
Last active August 29, 2015 14:21
The scaffold to my YAPT_Swift application.
import UIKit
class YAPTMainViewController: UIViewController {
// MARK: - Types
private enum IntervalType { case Work, Break }
private typealias Interval = (type:IntervalType, duration:Double)
// MARK: - UI Properties
@IBOutlet weak var timerLabel: UILabel!
@billglover
billglover / MyFirstExtension.swift
Last active August 29, 2015 14:21
Add computed properties to NSTimeInterval to return component parts of a time interval
extension NSTimeInterval {
var inHours: Double { return self.inMinutes/60 } // express the time interval in hours
var inMinutes: Double { return self/60 } // express the time interval in minutes
var inSeconds: Double { return self } // express the time interval in seconds
// express the time interval in hours, minutes and seconds
var inHoursMinutesSeconds: (hours: Double, minutes: Double, seconds: Double) {
let hours: Double = floor(round(self) / 60 / 60)
let minutes: Double = trunc((round(self) - (hours * 60 * 60)) / 60)
@billglover
billglover / InterfaceController.swift
Last active August 29, 2015 14:21
Using openParentApplication:reply: to pass Strings
import WatchKit
import Foundation
class InterfaceController: WKInterfaceController {
@IBAction func ButtonPress() {
var userInfo: [NSObject: AnyObject] = [:]
userInfo["request"] = "This is a string"
@billglover
billglover / AppDelegate.swift
Created May 27, 2015 05:54
Using application:handleWatchKitExtensionRequest:reply: to pass Strings
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(application: UIApplication, handleWatchKitExtensionRequest userInfo: [NSObject : AnyObject]?, reply: (([NSObject : AnyObject]!) -> Void)!) {
// expect a request String from the parent application
// send a response String in return
// Note: you may not see these in the console if debugging WatchKit
@billglover
billglover / InterfaceController.swift
Last active August 29, 2015 14:21
Using openParentApplication:reply: to pass UIColor
import WatchKit
import Foundation
class InterfaceController: WKInterfaceController {
@IBAction func ButtonPress() {
var userInfo: [NSObject: AnyObject] = [:]
userInfo["request"] = "This is a string"
@billglover
billglover / AppDelegate.swift
Last active August 29, 2015 14:21
Using application:handleWatchKitExtensionRequest:reply: to pass UIColor
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(application: UIApplication, handleWatchKitExtensionRequest userInfo: [NSObject : AnyObject]?, reply: (([NSObject : AnyObject]!) -> Void)!) {
// expect a request String from the parent application
// send a response UIColor in return
// Note: you may not see these in the console if debugging WatchKit

Keybase proof

I hereby claim:

  • I am billglover on github.
  • I am billglover (https://keybase.io/billglover) on keybase.
  • I have a public key whose fingerprint is 8880 C31E 00BC 4F55 DB20 29D9 845F 3ED6 0173 678F

To claim this, I am signing this object:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<h1>Hello World</h1>
</body>
</html>
@billglover
billglover / user-data.sh
Last active December 20, 2015 23:03
Install Apache and clone a simple website to demonstrate setting up an AWS web server.
#!/bin/bash
# update package repository
yum -y update
# upgrade all installed packages
yum -y upgrade
# install Apache httpd server
yum -y install httpd
@billglover
billglover / all_the_pies.sh
Created July 30, 2016 21:46
List the IP addresses for all Raspberry Pis on the network (range 192.168.2.0/24)
sudo fing -r1 -n 192.168.2.0/24 -o table,csv | awk -F ";" '$7 ~ /Raspberry/ {print $1}'