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
void setup() { | |
fullScreen(); | |
frameRate(15); | |
} | |
void draw() { | |
// Loads all pixels on screen into an array of size width*height | |
loadPixels(); | |
color onColor = #000000; | |
color offColor = #FFFFFF; |
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
extension UITabBarController { | |
/** | |
Show or hide the tab bar. | |
- Parameter hidden: `true` if the bar should be hidden. | |
- Parameter animated: `true` if the action should be animated. | |
- Parameter transitionCoordinator: An optional `UIViewControllerTransitionCoordinator` to perform the animation | |
along side with. For example during a push on a `UINavigationController`. | |
*/ |
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
extension UITextView { | |
var lineFrames: [CGRect] { | |
let numberOfGlyphs = layoutManager.numberOfGlyphs | |
var numberOfLines = 0 | |
var index = 0 | |
var lineRange = NSRange() | |
let maxNumberOfLines = textContainer.maximumNumberOfLines | |
var lineRects = [CGRect]() | |
while (index < numberOfGlyphs) { |
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
private var didBeginImport = false // This is a hack until I've figured out why completion block runs twice.. | |
private func createImportOperations(data: [String: AnyObject]) { | |
guard !didBeginImport else { return } | |
didBeginImport = true | |
if let ingredients = data["ingredients"] as? [[String: AnyObject]] { | |
ingredients.forEach { | |
let op = IngredientOperation(data: $0, repository: repo, state: state) | |
if let id = op.identifier { | |
state.ingredientOperations.updateValue(op, forKey: id) |
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
// | |
// debounce-throttle.swift | |
// | |
// Created by Simon Ljungberg on 19/12/16. | |
// License: MIT | |
// | |
import Foundation | |
extension TimeInterval { |
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
import PlaygroundSupport | |
PlaygroundPage.current.needsIndefiniteExecution = true | |
func debounce1<T>(delay: DispatchTimeInterval, queue: DispatchQueue = .main, action: @escaping ((T) -> Void)) -> (T) -> Void { | |
var currentWorkItem: DispatchWorkItem? | |
return { (p1: T) in | |
currentWorkItem?.cancel() | |
currentWorkItem = DispatchWorkItem { action(p1) } | |
queue.asyncAfter(deadline: .now() + delay, execute: currentWorkItem!) |
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
// | |
// UNNotification+Reschedule.swift | |
// Meal Plan | |
// | |
// Created by Simon Ljungberg on 17/11/16. | |
// License: MIT | |
// | |
import UIKit | |
import UserNotifications |
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
"data": [ | |
{ | |
"id": 1, | |
"type": "ingredient", | |
"attributes": { | |
"name": { | |
"en": "Cilantro", | |
"sv": "Koriander" | |
}, |
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
" Use Vim settings | |
set nocompatible | |
set encoding=utf-8 | |
" Use , as leader | |
let mapleader="," | |
" set the runtime path to include Vundle and initialize | |
set rtp+=~/.vim/bundle/Vundle.vim | |
call vundle#begin() |