Skip to content

Instantly share code, notes, and snippets.

@chosa91
chosa91 / Breakpoints_v2.xcbkptlist
Created January 23, 2017 11:22 — forked from Ashton-W/Breakpoints_v2.xcbkptlist
My User Breakpoints_v2.xcbkptlist
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "2"
version = "2.0">
<Breakpoints>
<!-- All Exceptions -->
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.ExceptionBreakpoint">
<BreakpointContent
@chosa91
chosa91 / Channel.swift
Last active March 30, 2018 17:56 — forked from gokselkoksal/Channel.swift
Channel implementation
public class Channel<Value> {
private class Subscription {
weak var object: AnyObject?
private let notifyBlock: (Value) -> Void
private let queue: DispatchQueue
var isValid: Bool {
return object != nil
}
@chosa91
chosa91 / Scheduling-AppDelegate.swift
Created May 18, 2018 13:09 — forked from shaps80/Scheduling-AppDelegate.swift
NSNotification Scheduling Service in Swift. (the only required file is `SchedulingService.swift`)
//
// AppDelegate.swift
// Scheduling
//
// Created by Shaps Benkau on 19/02/2018.
// Copyright © 2018 152percent Ltd. All rights reserved.
//
import UIKit
@chosa91
chosa91 / KeyboardSizedView.m
Last active May 18, 2018 13:54
KeyboardSizedView
//
// Rewrited from Swift to obj-c
// Original source: https://github.com/objcio/app-architecture/blob/master/One-App-Eight-Architectures/MultiPattern/KeyboardSizedView.swift
//
@interface KeyboardSizedView ()
@property (nonatomic, strong) NSLayoutConstraint *keyboardConstraint;
@end
// # Challenge2
struct TestCase {
let nums: [Int]
let expectation: Int
}
let test1 = [3, 1, 2, 3] // => output: 9 | ok
/**
3, 3 => 3
@chosa91
chosa91 / XCUIApplication+Scrolling.swift
Created October 4, 2019 08:22 — forked from ryanmeisters/XCUIApplication+Scrolling.swift
Scrolling helpers automated ui tests using XCUIApplication
extension XCUIApplication {
private struct Constants {
// Half way accross the screen and 10% from top
static let topOffset = CGVector(dx: 0.5, dy: 0.1)
// Half way accross the screen and 90% from top
static let bottomOffset = CGVector(dx: 0.5, dy: 0.9)
}
var screenTopCoordinate: XCUICoordinate {
@chosa91
chosa91 / sources.md
Last active October 11, 2019 10:44
[INST][HW] Snapshot testing.md
import Foundation
public enum Method: String {
case GET
case POST
case PUT
case PATCH
case DELETE
}
@chosa91
chosa91 / DynamicUserDefaults.swift
Created November 15, 2019 10:50 — forked from marty-suzuki/DynamicUserDefaults.swift
Sample usage of Swift 5.1 dynamicMemberLookup that supports KeyPath.
import Foundation
@dynamicMemberLookup
final class DynamicUserDefaults {
static var standard: DynamicUserDefaults {
return DynamicUserDefaults(.standard)
}
private let keys = Keys()
import Foundation
struct AnyEquatable {
private let isEqualTo: (Any) -> Bool
let value: Any
init<A: Equatable>(_ value: A) {
self.value = value
isEqualTo = { other in
guard let o = other as? A else { return false }