Skip to content

Instantly share code, notes, and snippets.

@jyaunches
jyaunches / linked-list-w-sequence.swift
Created September 28, 2017 16:30
Linked list implementation in Swift using Sequence protocol
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 September 28, 2017 16:28
Contains functionality requires ability to iterate
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 September 28, 2017 16:26
For-in loop without Sequence protocol
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 September 28, 2017 16:24
Swift collections for-in basic
let numbers = 1...3
for number in numbers {
print(number)
}
// Prints "1"
// Prints "2"
// Prints "3"
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
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 June 25, 2013 14:51
Live version of 'Here comes the sun'
{ response = {
songs = ({
"artist_id" = ARW9QSZ1187FB4B93E;
"artist_name" = "George Harrison";
id = SOGKRTA12AF72A065D;
message = "OK (match type 8)";
score = 44;
title = "Here Comes The Sun";
}
);
{
"response": {
"status": {
"version": "4.2",
"code": 0,
"message": "Success"
},
"track": {
"status": "complete",
"song_id": "SOEUZFE12B0B809F99",
{
"response": {
"status": {
"version": "4.2",
"code": 0,
"message": "Success"
},
"track": {
"status": "complete",
"analyzer_version": "3.1.3",
@jyaunches
jyaunches / gist:5145308
Created March 12, 2013 18:04
synthesizing a property in an implementation file
@implementation SomeObject
@synthesize containedObject;
@end