Skip to content

Instantly share code, notes, and snippets.

@IsaacXen
IsaacXen / README.md
Last active April 16, 2024 15:54
(Almost) Every WWDC videos download links for aria2c.
@juliengdt
juliengdt / SomePlayground.swift
Last active September 21, 2019 15:55
Strongly Type Identifiers For Class Or Struct By Using Protocol and associated types
/*
In response of Tom Lokhort's article.
A third alternative: alternative 2 under steroïds
---
Source: http://tom.lokhorst.eu/2017/07/strongly-typed-identifiers-in-swift
*/
struct GenericIdentifier<T>: RawRepresentable, Hashable, Equatable {
let rawValue: String
@chriseidhof
chriseidhof / Shoes.swift
Last active April 21, 2022 17:02
shoes in swift
import Cocoa
class MyAppDelegate: NSObject, NSApplicationDelegate {
let window = NSWindow()
var didFinishLaunching: NSWindow -> () = { _ in () }
func applicationDidFinishLaunching(aNotification: NSNotification) {
didFinishLaunching(window)
}
}
@oleganza
oleganza / async_swift_proposal.md
Last active May 12, 2023 10:06
Concrete proposal for async semantics in Swift

Async semantics proposal for Swift

Modern Cocoa development involves a lot of asynchronous programming using blocks and NSOperations. A lot of APIs are exposing blocks and they are more natural to write a lot of logic, so we'll only focus on block-based APIs.

Block-based APIs are hard to use when number of operations grows and dependencies between them become more complicated. In this paper I introduce asynchronous semantics and Promise type to Swift language (borrowing ideas from design of throw-try-catch and optionals). Functions can opt-in to become async, programmer can compose complex logic involving asynchronous operations while compiler produces necessary closures to implement that logic. This proposal does not propose new runtime model, nor "actors" or "coroutines".

Table of contents

@mac-cain13
mac-cain13 / Readme.md
Last active August 29, 2015 14:11
Automatically copy all PNG assets to the correct Android drawable folder when exporting from for example Sketch.

Android assets folder action

Automatically copy all PNG assets to the correct Android drawable folder. Very helpful when exporting assets with @?x-suffix from, for example, Sketch and putting them into the correct folder without human interaction.

Setup

  1. Copy the AppleScript file to ~/Library/Workflows/Applications/Folder Actions
  2. Create a export folder where you'll put all exported PNGs
  3. Right click the folder, choose configure folder actions, check the "Enable folder actions" checkbox and attach the android_assets.scpt to your folder
  4. Open the terminal and create a symbolic link by typing ln -s /path/to/android-project/app/src/main/res /path/to/export-folder-you-just-created
@mac-cain13
mac-cain13 / NetworkActivityIndicatorManager.swift
Last active December 7, 2015 11:59
Swift class to manage the UIApplication.networkActivityIndicatorVisible in an effective and simple way
//
// NetworkActivityIndicatorManager.swift
//
// Created by Mathijs Kadijk on 30-10-14.
// From: https://gist.github.com/ab1b9196c99dcc16e5fe
// License: Public domain
//
@objc
class NetworkActivityIndicatorManager {