Skip to content

Instantly share code, notes, and snippets.

View vikingosegundo's full-sized avatar

Manuel Meyer vikingosegundo

  • Groningen, Netherlands
View GitHub Profile
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
NSArray *dates = @[
[[NSCalendar currentCalendar] dateFromComponents:({
NSDateComponents *c = [[NSDateComponents alloc] init];
c.year = 2010;
c.month = 12;
@vikingosegundo
vikingosegundo / NSArray+FunctionalTools.h
Last active August 29, 2015 14:14
Implementing Block Based Sorting
//
// NSArray+FuntionalTools.h
// arraytools
//
// Created by vikingosegundo on 28.08.11.
// Copyright (c) 2011 vikingosegundo. All rights reserved.
//
#import <Foundation/Foundation.h>
@vikingosegundo
vikingosegundo / ABController.h
Created May 12, 2015 19:30
AB Testing Prototype
//
// ABController.h
// ABTestPrototype
//
// Created by Manuel Meyer on 12.05.15.
// Copyright (c) 2015 Manuel Meyer. All rights reserved.
//
#import <Foundation/Foundation.h>
@vikingosegundo
vikingosegundo / 0000-HashVisitable.md
Last active March 16, 2017 14:17 — forked from regexident/0000-HashVisitable.md
Swift Evolution Proposal Draft for replacing `Hashable` with `Hasher` and `HashVisitable`.

HashVisitable

Introduction

Replace the Hashable protocol by two new procotols (Hasher and HashVisitable) to improve safety, versatility and learnability.

import Foundation
extension Date {
func add(years: Int = 0, months: Int = 0, days: Int = 0, hours: Int = 0, minutes: Int = 0, seconds: Int = 0) -> Date? {
let comp = DateComponents(year: years, month: months, day: days, hour: hours, minute: minutes, second: seconds)
return Calendar.current.date(byAdding: comp, to: self)
}
func subtract(years: Int = 0, months: Int = 0, days: Int = 0, hours: Int = 0, minutes: Int = 0, seconds: Int = 0) -> Date? {
indirect enum Note {
case note (Pitch, Duration)
case triplet((Pitch, Pitch, Pitch), Duration)
case chord([Pitch], Duration)
case rest(Duration)
case hold(Note)
indirect enum Pitch {
case a
case b
case c
[ ♪(.c,.¼), ♪(.d,.¼), ♪(.e,.¼), ♪(.f,.¼), ♪(.g,.¼), ♪(.a,.¼), ♪(.b,.¼) ]
[ ♪(.c,.¼), ♪(.d,.¼), ♪(♭.e,.¼), ♪(.f,.¼), ♪(♭.g,.¼), ♪(.a,.¼), ♪(♭.b,.¼) ]
[ ♪(.e,.¼), ♪(♯.f,.¼), ♪(♯.g,.¼), ♪(.a,.¼), ♪(.b,.¼), ♪(♯.c,.¼), ♪(♯.d,.¼) ]
prefix operator ♪; prefix func ♪(n: (Note.Pitch, Note.Duration) ) -> Note { .note(n.0, n.1) }
prefix operator ▿; prefix func ▿(x: (Note.Duration, (Note.Pitch,Note.Pitch,Note.Pitch))) -> Note { .triplet(x.1, x.0) }
prefix operator ▬; prefix func ▬(d: Note.Duration ) -> Note { .rest(d) }
prefix operator ♯; prefix func ♯(note: Note.Pitch ) -> Note.Pitch { .sharp(note) }
prefix operator ♭; prefix func ♭(note: Note.Pitch ) -> Note.Pitch { .flat (note) }
prefix operator ⩀; prefix func ⩀(note: Note ) -> Note { .hold (note) }