Skip to content

Instantly share code, notes, and snippets.

Erica Sadun erica

Block or report user

Report or block erica

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:0c445044e1bf97778263

"JUST BECAUSE YOU'RE USING SWIFT DOESN'T MEAN YOUR QUESTION IS ABOUT SWIFT"

How To Get Answers

Ask your question and then be patient. Tell us what you want to happen, what is actually happening, and include any error messages you find:

  • Provide a scenario. "I am trying to do X, I do so by calling APIs W and Y, but Z happens instead. I see the following error messages:..."
  • Focus on the goal. Ask about what you're trying to achieve (the big story) rather than the specific technical detail that you believe is holding you back.
  • Don't solicit help. Don't say, "Does anyone here know about (for example) Protocol Extensions". Just ask your question.
  • Do your homework. Search the web before asking in-channel.
  • Be courteous Don't just paste Stack Overflow questions in-channel.
  • Remember the topic Refer questions about third party libraries to their developers.
View playgroundRender.swift
import PlaygroundSupport
import SwiftUI
extension UIView {
var renderedImage: UIImage {
let image = UIGraphicsImageRenderer(size: self.bounds.size).image { context in
UIColor.lightGray.set(); UIRectFill(bounds)
context.cgContext.setAlpha(0.75)
self.layer.render(in: context.cgContext)
}
return image
@erica
erica / keywords.md
Last active Aug 15, 2019
Introducing Role Keywords to Protocol Implementations
View keywords.md

Introducing Role Keywords to Protocol Implementations to Reduce Code Errors

Introduction

This proposal eliminates several categories of user errors. It mitigates subtle, hard-to-find bugs in Swift protocol code that compile without warning. Introducing "role" keywords that document code intent will increase protocol safety and enable the compiler to test for issues by matching desired behaviors against actual code.

View monoid.swift
import Foundation
// 3456789012345678901234567890123456789012345678901234567890123456789012345678
/*
Monoid reduction, for strictly binary operation combination.
Note: The monoid approach does not throw right now.
View fold.md
View linuxrw3.swift
#if os(Linux)
import Glibc
#else
import Darwin
#endif
// Still not lovely but tested under OS X Swift 3 and Linux Swift 3
// Use fopen/fwrite to output string
func writeStringToFile(string: String, path: String) -> Bool {
View with.swift
// @discardableResult to be added
// @noescape needs to move to type annotation
// needs to add _ for item
public func with<T>(item: T, @noescape update: (inout T) throws -> Void) rethrows -> T {
var this = item; try update(&this); return this
}
View skylight
0000000000253db8 s GCC_except_table1026
0000000000253de4 s GCC_except_table1096
0000000000253e10 s GCC_except_table1097
0000000000253e3c s GCC_except_table1243
0000000000253e68 s GCC_except_table1245
0000000000253e88 s GCC_except_table1247
0000000000253ec4 s GCC_except_table1249
0000000000253ee4 s GCC_except_table1252
0000000000253f10 s GCC_except_table1253
0000000000253f3c s GCC_except_table2726
View example1.swift
import UIKit
import XCPlayground
class ViewController: UIViewController {
func action() { print("Bing!") }
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .whiteColor()
View #iphonedev README and FAQ.md

ASK A SPECIFIC QUESTION

How To Get Answers

Ask your question and then be patient. Tell us what you want to happen, what is actually happening, and include any error messages you find:

  • Provide a scenario. "I am trying to do X, I do so by calling APIs W and Y, but Z happens instead. I see the following error messages:..."
  • Focus on the goal. Ask about what you're trying to achieve (the big story) rather than the specific technical detail that you believe is holding you back.
  • Don't solicit help. Don't say, "Does anyone here know about (for example) Core Foundation". Just ask your question.
  • Do your homework. Search the web before asking in-channel.
  • Be courteous Don't just paste Stack Overflow questions in-channel.
  • Remember the topic Refer questions about third party libraries to their developers.
You can’t perform that action at this time.