Skip to content

Instantly share code, notes, and snippets.

View pietrobasso's full-sized avatar

Pietro Basso pietrobasso

View GitHub Profile
import Foundation
import CoreGraphics
import UIKit
extension UIBezierPath {
convenience init?(quadCurve points: [CGPoint]) {
guard points.count > 1 else { return nil }
self.init()
@pietrobasso
pietrobasso / ExtractYouTubeId.playground
Last active October 7, 2020 22:59 — forked from zdk/extract_youtube_id.mm
A Regex to extract YouTube video ids from the given list of youtube URLs in Swift 4
//: Playground - noun: a place where people can play
//
// Created by Pietro Basso on 29/06/2018.
// Copyright (c) 2018 Pietro Basso. All rights reserved.
//
let urls = ["http://youtu.be/NLqAF9hrVbY",
"http://www.youtube.com/watch?feature=player_embedded&v=DJjDrajmbIQ",
"http://www.youtube.com/watch?v=dQw4w9WgXcQ",
"http://www.youtube.com/embed/NLqAF9hrVbY",
@Siemian
Siemian / UIView+Constraints.swift
Last active August 11, 2022 20:52
UIView extension for creating NSLayoutConstraints
//
// UIView+Constraints.swift
// CiLabs
//
// Copyright © 2019 Netguru.co. All rights reserved.
//
import UIKit
typealias Constraint = (_ layoutView: UIView) -> NSLayoutConstraint
@weihanglo
weihanglo / thoughts-on-react-native-from-an-ios-developer.md
Last active August 2, 2023 16:51
Thoughts on React Native from an iOS developer

Thoughts on React Native from an iOS developer

React Native

About two month ago, I started making a React Native app ["PyConTW 17"][pycontw-mobile] for the biggest annual Python conference in Taiwan ([PyCon Taiwan][pycontw]). The app is quite simple, but still took some efforts for me to build. As a complete React newbie, I would like to share some of my thoughts about React Native.

(written on 2017-07-30, based on React Native 0.44.2)

@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.

@grzegorzkrukowski
grzegorzkrukowski / CALayer+Pause.swift
Created May 12, 2017 10:34
Solving the problem of CALayer animations being removed when application goes to background
//
// CALayer+Pause.swift
//
// Created by Grzegorz Krukowski on 11/05/2017.
// Copyright © 2017. All rights reserved.
//
import Foundation
extension CALayer {
@username0x0a
username0x0a / SKStoreReviewDummyClass.m
Last active November 22, 2020 18:13
Dummy class easing detection whether the native StoreKit in-app Review alert has been fired or not. Useful as a callback when firing the limited system rating alert.
@interface SKStoreReviewDummyClass : NSObject @end
@implementation SKStoreReviewDummyClass
+ (void)load
{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
Class class = [self class];
// Swift 3
extension DateFormatter {
public static var iso8601: DateFormatter {
return DateFormatter.iso8601DateFormatter
}
private static let iso8601DateFormatter: DateFormatter = {
let formatter = DateFormatter()
formatter.locale = Locale(identifier: "en_US_POSIX")
@wojteklu
wojteklu / clean_code.md
Last active May 19, 2024 03:34
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

//
// KeyboardObserver.swift
// Product
//
// Created by muukii on 3/17/16.
// Copyright © 2016 eure. All rights reserved.
//
import Foundation
import RxSwift