Skip to content

Instantly share code, notes, and snippets.

View thexande's full-sized avatar

Alexander Murphy thexande

  • Ibotta
  • Denver, CO, USA, Planet Earth
View GitHub Profile
@lattner
lattner / TaskConcurrencyManifesto.md
Last active June 1, 2024 06:16
Swift Concurrency Manifesto
@leoiphonedev
leoiphonedev / EventCreator-Cretae an event on device calendar.swift
Last active September 10, 2018 22:40
Create event on device clandar using swift
func createEventinTheCalendar(with title:String, forDate eventStartDate:Date, toDate eventEndDate:Date) {
store.requestAccess(to: .event) { (success, error) in
if error == nil {
let event = EKEvent.init(eventStore: self.store)
event.title = title
event.calendar = self.store.defaultCalendarForNewEvents // this will return deafult calendar from device calendars
event.startDate = eventStartDate
event.endDate = eventEndDate
@lattner
lattner / async_swift_proposal.md
Last active April 21, 2024 09:43 — forked from oleganza/async_swift_proposal.md
Concrete proposal for async semantics in Swift

Async/Await for Swift

Introduction

Modern Cocoa development involves a lot of asynchronous programming using closures and completion handlers, but these APIs are hard to use. This gets particularly problematic when many asynchronous operations are used, error handling is required, or control flow between asynchronous calls gets complicated. This proposal describes a language extension to make this a lot more natural and less error prone.

This paper introduces a first class Coroutine model to Swift. Functions can opt into to being async, allowing the programmer to compose complex logic involving asynchronous operations, leaving the compiler in charge of producing the necessary closures and state machines to implement that logic.

@ericdke
ericdke / emojiImage.swift
Created June 17, 2017 08:56
Swift 4 String extension for converting an emoji to an NSImage. Idea and original code by Daniel Jalkut http://indiestack.com/2017/06/evergreen-images/.
import Cocoa
extension String {
// https://stackoverflow.com/a/36258684/2227743
var containsEmoji: Bool {
for scalar in self.unicodeScalars {
switch scalar.value {
case 0x1F600...0x1F64F, // Emoticons
0x1F300...0x1F5FF, // Misc Symbols and Pictographs
extension Sequence {
func map<T>(_ keyPath: KeyPath<Element, T>) -> [T] {
return self.map {
$0[keyPath: keyPath]
}
}
func flatMap<T>(_ keyPath: KeyPath<Element, T?>) -> [T] {
return self.flatMap {
$0[keyPath: keyPath]
@lelandrichardson
lelandrichardson / react-native.js
Last active July 21, 2022 17:56
React Native flow types
declare var __DEV__: boolean;
declare module 'react-native' {
declare type Color = string | number;
declare type Transform =
{ perspective: number } |
{ scale: number } |
{ scaleX: number } |
@DejanEnspyra
DejanEnspyra / Obfuscator.swift
Created May 31, 2017 17:51
Obfuscation of hard-coded security-sensitive strings.
//
// Obfuscator.swift
//
// Created by Dejan Atanasov on 2017-05-31.
//
import Foundation
class Obfuscator: AnyObject {
@kharrison
kharrison / Country.swift
Last active February 16, 2021 15:35
Swift Hash Functions
import Foundation
struct Country {
let name: String
let capital: String
var visited: Bool
}
extension Country: Equatable {
static func == (lhs: Country, rhs: Country) -> Bool {
@patpohler
patpohler / Big List of Real Estate APIs.md
Last active May 29, 2024 04:46
Evolving list of Real Estate APIs by Category

Big List of Real Estate APIs

Listings / Property Data

####Rets Rabbit http://www.retsrabbit.com

Rets Rabbit removes the nightmare of importing thousands of real estate listings and photos from RETS or ListHub and gives you an easy to use import and Web API server so you can focus on building your listing search powered website or app.

@krodak
krodak / SKMultilineLabel.swift
Created November 30, 2016 08:57 — forked from craiggrummitt/SKMultilineLabel.swift
Multi line label in Sprite Kit in Swift
//
// SKMultilineLabel.swift
//
// Created by Craig on 10/04/2015.
// Copyright (c) 2015 Interactive Coconut.
// MIT License, http://www.opensource.org/licenses/mit-license.php
//
/* USE:
(most component parameters have defaults)
let multiLabel = SKMultilineLabel(text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", labelWidth: 250, pos: CGPoint(x: size.width / 2, y: size.height / 2))