This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum DiffModification<T: Equatable> { | |
case inserted(position: NSIndexPath, value: T) | |
case deleted(position: NSIndexPath, value: T) | |
case moved(position: NSIndexPath, newPosition: NSIndexPath, value: T) | |
} | |
extension DiffModification: CustomDebugStringConvertible { | |
var debugDescription: String { | |
switch self { | |
case .inserted(let position, let value): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// License: MIT | |
import Foundation | |
/** | |
A struct representing a range of dates. | |
*/ | |
public struct DateRange { | |
// MARK: Properties |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
A default implmentation that provides a few convenience methods for starting and stopping coordinators. | |
*/ | |
extension Coordinator { | |
// Default implementation, so that we don't have to do this for all coordinators. | |
func startChild<T: NSObject where T: Coordinator>(coordinator coordinator: T, withIdentifier identifier: String, callback: CoordinatorCallback?) -> T { | |
childCoordinators[identifier] = coordinator | |
coordinator.start(withCallback: callback) | |
return coordinator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//: Playground - noun: a place where people can play | |
import UIKit | |
/// Just an object specific to my use case. | |
class AppContext { } | |
/// Save some typing | |
typealias CoordinatorCallback = (Coordinator) -> Void |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// String+Typography.swift | |
// FilibabaKit | |
// | |
// Created by Simon Ljungberg on 09/05/16. | |
// Copyright © 2016 Filibaba. All rights reserved. | |
// | |
import Foundation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var minutes = $('.todo .content a').map(function (index, itm) { | |
var pattern = /^\[(\d+)\]/; | |
var matches = $(itm).text().match(pattern); | |
return matches ? parseInt(matches[1], 10) : 0; | |
}); | |
var total = 0; | |
for (var i = minutes.length - 1; i >= 0; i--) { total += minutes[i]; } | |
console.log(total/60); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function lpg_get_attachment( $attachment_id ) { | |
$attachment = get_post( $attachment_id ); | |
return array( | |
'alt' => get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ), | |
'caption' => $attachment->post_excerpt, | |
'description' => $attachment->post_content, | |
'href' => get_permalink( $attachment->ID ), | |
'src' => $attachment->guid, | |
'title' => $attachment->post_title | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function test() { | |
for (var i=0;i < 5;i++) { | |
console.log('orig: '+ i); | |
setTimeout((function (x) { | |
return function () { | |
console.log('cb: '+ x); | |
} | |
}(i)), 100); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
var Foobar = function MyModule() { /* ... */ }; | |
var hasDefine = typeof define === 'function' && define.amd; | |
var hasExport = typeof exports !== 'undefined'; | |
if (hasDefine) { | |
define('Foobar', Foobar); | |
} |