Skip to content

Instantly share code, notes, and snippets.

View simonbengtsson's full-sized avatar

Simon Bengtsson simonbengtsson

View GitHub Profile
@anhtuank7c
anhtuank7c / const_keyword.dart
Last active June 23, 2022 07:15
Exploring const keyword in Dart
class Contact {
// Constructor is marked 'const' so all fields must be final.
final String name;
final int age;
// const at class level have to go along with static keyword
static const alive = true;
// const constructor
const Contact(this.name, this.age);
@lattner
lattner / TaskConcurrencyManifesto.md
Last active December 6, 2025 10:37
Swift Concurrency Manifesto
@emaloney
emaloney / guard-closure.md
Last active August 1, 2023 00:24
A simplified notation for avoiding the weak/strong dance with closure capture lists

Simplified notation for avoiding the [weak self]/strongSelf dance with closures

  • Proposal: TBD
  • Author: Evan Maloney
  • Status: Draft
  • Review manager: TBD

Introduction

Frequently, closures are used as completion callbacks for asynchronous operations, such as when dealing with network requests. It is quite common to model these sorts of operations in such a way that an object instance represents a request/response transaction, for example:

@kitschpatrol
kitschpatrol / Mock CMDeviceMotion
Created December 20, 2013 18:39
Inline real-world CMDeviceMotion sample object for unit testing.
CMDeviceMotion *deviceMotion = [NSKeyedUnarchiver unarchiveObjectWithData:[[NSData alloc] initWithBase64EncodedString:
@"YnBsaXN0MDDUAQIDBAUINzhUJHRvcFgkb2JqZWN0c1gkdmVyc2lvblkkYXJjaGl2ZXLRBgdUcm9v"
"dIABowkKL1UkbnVsbN8QEgsMDQ4PEBESExQVFhcYGRobHB0eHyAhIiMkJSYnKCkqKywtLl8QJmtD"
"TURldmljZU1vdGlvbkNvZGluZ0tleU1hZ25ldGljRmllbGRYXxAla0NNRGV2aWNlTW90aW9uQ29k"
"aW5nS2V5Um90YXRpb25SYXRlWl8QKWtDTURldmljZU1vdGlvbkNvZGluZ0tleVVzZXJBY2NlbGVy"
"YXRpb25aXxAja0NNRGV2aWNlTW90aW9uQ29kaW5nS2V5UXVhdGVybmlvbldfEBxrQ01Mb2dJdGVt"
"Q29kaW5nS2V5VGltZXN0YW1wXxAla0NNRGV2aWNlTW90aW9uQ29kaW5nS2V5Um90YXRpb25SYXRl"
"WF8QNWtDTURldmljZU1vdGlvbkNvZGluZ0tleU1hZ25ldGljRmllbGRDYWxpYnJhdGlvbkxldmVs"
"XxAja0NNRGV2aWNlTW90aW9uQ29kaW5nS2V5UXVhdGVybmlvblpfECprQ01EZXZpY2VNb3Rpb25D"
"b2RpbmdLZXlEb2luZ1lhd0NvcnJlY3Rpb25fECtrQ01EZXZpY2VNb3Rpb25Db2RpbmdLZXlEb2lu"