Skip to content

Instantly share code, notes, and snippets.

View matthewspear's full-sized avatar
🔨
Always Be Learning

Matt Spear matthewspear

🔨
Always Be Learning
View GitHub Profile
//
// TableViewController.m
// BlogReader
//
// Created by Matthew Spear on 21/06/2014.
// Copyright (c) 2014 Matthew Spear. All rights reserved.
//
#import "TableViewController.h"
#import "BlogPost.h"
(*
File: OmniFocus_Due_List.scpt
Revision: 1.0
Revised: 2015-07-01
Summary: Create taskpaper list of tasks due +/- 7d from current date.
-----------------------------------------------------------
Script based on Justin Lancy (@veritrope) from Veritrope.com
@matthewspear
matthewspear / Unflag-All.scpt
Created November 12, 2015 00:48
Unflag all tasks within OmniFocus
tell application "OmniFocus"
tell default document
set flagged of (every flattened task whose flagged is true) to false
end tell
end tell
@matthewspear
matthewspear / Contents.swift
Last active January 20, 2016 01:22
Swift 2.0 FizzBuzz
//: Playground - noun: a place where people can play
func fizzBuzz(n: Int) -> String
{
let divThree = (n % 3 == 0)
let divFive = (n % 5 == 0)
var numberName = ""
if (divThree && divFive)
{
@matthewspear
matthewspear / calendarConversion.scpt
Created February 1, 2016 01:32
Calendar name conversion over all events (Manchester CS timetable)
tell application "Calendar"
tell calendar "Timetable"
--reload calendars
set theEvents to {}
set AllEvents to events
repeat with anEvent in AllEvents
@matthewspear
matthewspear / fizzbuzz.py
Last active February 15, 2016 22:07
Functional FizzBuzz Generator in Python
# Functional FizzBuzz Generator in Python
def fizz_buzz(num):
if num % 3 == 0 and num % 5 == 0:
return 'FizzBuzz'
elif num % 3 == 0:
return 'Fizz'
elif num % 5 == 0:
return 'Buzz'
else:
return str(num)
@matthewspear
matthewspear / Person.swift
Created April 28, 2016 18:16
Example using a lazy variable as a first class citizen + date formatters!
import UIKit
class Person
{
let name: String
let birthday: NSDate
lazy var age: Double = self.calculateAge()
init(name: String, birthday: NSDate)
{
@matthewspear
matthewspear / SimpleArraySum.swift
Last active May 5, 2016 17:59
Commandline Swift Script - use 'xcrun -sdk macosx swiftc SimpleArraySum.swift'
import Foundation
// Setup Standard Output, Error
let stderr = NSFileHandle.fileHandleWithStandardError()
let stdout = NSFileHandle.fileHandleWithStandardOutput()
func writeToStd(handle: NSFileHandle, _ str: String)
{
if let data = str.dataUsingEncoding(NSUTF8StringEncoding)
{
### Keybase proof
I hereby claim:
* I am matthewspear on github.
* I am matthewspear (https://keybase.io/matthewspear) on keybase.
* I have a public key whose fingerprint is 7430 C437 5A47 3405 AB10 D169 F8D6 8498 7F65 3D4E
To claim this, I am signing this object:
@matthewspear
matthewspear / selfcontrol-aliases
Last active July 29, 2016 12:57
SelfControl Terminal Shortcuts
# Add these lines to ~/.bash_profile or ~/.zshrc:
# SelfControl
alias sc-read="defaults read org.eyebeam.SelfControl"
alias sc-run="sudo /Applications/SelfControl.app/Contents/MacOS/org.eyebeam.SelfControl $(id -u $(whoami)) --install"
alias sc-check="sudo /Library/PrivilegedHelperTools/org.eyebeam.SelfControl $(id -u $(whoami)) --checkup"
sc-set()
{
if [ "$1" = "" ]; then