Skip to content

Instantly share code, notes, and snippets.

@jyaunches
jyaunches / linked-list-w-sequence.swift
Created Sep 28, 2017
Linked list implementation in Swift using Sequence protocol
View linked-list-w-sequence.swift
class Link<T> {
let value: T
let nextLink: Link<T>?
init(_ value: T, next: Link<T>?){
self.value = value
self.nextLink = next
}
}
@jyaunches
jyaunches / contains-implementation.swift
Created Sep 28, 2017
Contains functionality requires ability to iterate
View contains-implementation.swift
func contains(e: Element) -> Bool {
var elementFound = false
for item in elements {
if e == item {
elementFound = true
}
}
return elementFound
}
@jyaunches
jyaunches / for-in-no-sequence.swift
Created Sep 28, 2017
For-in loop without Sequence protocol
View for-in-no-sequence.swift
let numbers = [1, 2, 3]
let index = numbers.count
var i = 0;
while i < index {
print(numbers[i])
i += 1
}
@jyaunches
jyaunches / for-in.swift
Created Sep 28, 2017
Swift collections for-in basic
View for-in.swift
let numbers = 1...3
for number in numbers {
print(number)
}
// Prints "1"
// Prints "2"
// Prints "3"
View swift
Auth0
.authentication().createUser(email: email,
username: username,
password: "hellogrow",
connection: "Username-Password-Authentication",
userMetadata: [:]).start { result in
switch result {
case .success( _):
UserAuthenticationManager.sharedInstance.username = username
UserAuthenticationManager.sharedInstance.email = email
View .swift
it("should return this week when last order over 7 days but under 13 and next order tomorrow") {
let thisWeek = Order.createNewEntity() as! Order
thisWeek.arrivalDate = NSDate().dateByAddingTimeInterval(NSDate.oneWeekInterval() + NSDate.oneDayInterval() * -1)
thisWeek.isAlternateWindow = false
let nextWeek = Order.createNewEntity() as! Order
nextWeek.arrivalDate = NSDate().dateByAddingTimeInterval(NSDate.oneDayInterval())
nextWeek.isAlternateWindow = false
let futureWeek = Order.createNewEntity() as! Order
@jyaunches
jyaunches / gist:5859082
Created Jun 25, 2013
Live version of 'Here comes the sun'
View gist:5859082
{ response = {
songs = ({
"artist_id" = ARW9QSZ1187FB4B93E;
"artist_name" = "George Harrison";
id = SOGKRTA12AF72A065D;
message = "OK (match type 8)";
score = 44;
title = "Here Comes The Sun";
}
);
View Madonna-echonest-response
{
"response": {
"status": {
"version": "4.2",
"code": 0,
"message": "Success"
},
"track": {
"status": "complete",
"analyzer_version": "3.1.3",
View INXS-echonest-response
{
"response": {
"status": {
"version": "4.2",
"code": 0,
"message": "Success"
},
"track": {
"status": "complete",
"song_id": "SOEUZFE12B0B809F99",
@jyaunches
jyaunches / gist:5145308
Created Mar 12, 2013
synthesizing a property in an implementation file
View gist:5145308
@implementation SomeObject
@synthesize containedObject;
@end