Skip to content

Instantly share code, notes, and snippets.

View jkyin's full-sized avatar
💭
I may be slow to respond.

Jack Yin jkyin

💭
I may be slow to respond.
View GitHub Profile
//
// ContentView.swift
// AnimationTimingCurve
//
// Created by Chris Eidhof on 25.09.19.
// Copyright © 2019 Chris Eidhof. All rights reserved.
//
import SwiftUI
@nathantannar4
nathantannar4 / Switch.swift
Created December 20, 2018 23:57
Re-Engineering UISwitch
//
// Switch.swift
// Re-Engineering UISwitch
//
// Created by Nathan Tannar on 15/12/18.
// Copyright © 2018 Nathan Tannar. All rights reserved.
//
import UIKit
@mayoff
mayoff / !README.md
Last active August 14, 2023 15:09
Debugging Objective-C blocks in lldb

The attached lldb command pblock command lets you peek inside an Objective-C block. It tries to tell you where to find the source code for the block, and the values captured by the block when it was created.

Consider this example program:

#import <Foundation/Foundation.h>

@interface Foo: NSObject
@end

@implementation Foo

@kh4zad
kh4zad / GZIPEncoding.swift
Last active September 18, 2024 07:15
GZIP encoding for Alamofire requests
import Alamofire
import Gzip // using https://github.com/1024jp/GzipSwift
public struct GZIPEncoding: ParameterEncoding {
public func encode(_ urlRequest: URLRequestConvertible, with parameters: Parameters?) throws -> URLRequest {
var request = try urlRequest.asURLRequest()
guard let parameters = parameters else { return request }
@zxhfighter
zxhfighter / localhost.md
Last active September 19, 2024 20:24
127.0.0.1 和 0.0.0.0 的区别

127.0.0.1、localhost、0.0.0.0、本机IP地址

localhost

首先,localhost 就是一个域名,域名指向 127.0.0.1,两者是一样的,如果是 mac,可以在 /etc/hosts 文件中看到这一行。

127.0.0.1     localhost
@kean
kean / AutoRetry.swift
Last active November 2, 2024 15:47
Smart Auto Retry using RxSwift
// The MIT License (MIT)
//
// Copyright (c) 2017 Alexander Grebenyuk (github.com/kean).
import Foundation
import RxSwift
import RxCocoa
extension ObservableType {
@lattner
lattner / TaskConcurrencyManifesto.md
Last active November 15, 2024 05:45
Swift Concurrency Manifesto
@qmchenry
qmchenry / enumCaseName.swift
Created April 21, 2017 18:07
Swift enum name string with associated values
// Swift enums cannot be declared with a rawValue if they have associated values
// like good ol' Amargasaurus has. Using String(describing: dino) on a case with
// associated also includes the values, but works fine on unassociated cases.
// Mirror(reflecting: dino) can extract the name of an associated case, but is
// nil for unassociated cases. Our hero ?? swoops in to save the day!
enum Sauropoda {
case Amargasaurus(things: Int64, hasOtherThing: Bool?)
case Antetonitrus
// ...
@nolanw
nolanw / AttributedNumberFormatter.swift
Last active February 22, 2019 15:16
An NSNumberFormatter for iOS that usefully implements attributedStringForObjectValue…
import Foundation
/// A number formatter that usefully implements `attributedString(for:withDefaultAttributes:)`, which iOS's NumberFormatter does not.
final class AttributedNumberFormatter: NumberFormatter {
override func attributedString(for obj: Any, withDefaultAttributes defaultAttributes: [NSAttributedString.Key : Any]? = nil) -> NSAttributedString? {
guard
let number = obj as? NSNumber,
let plain = string(from: number)
else { return nil }
@evantoli
evantoli / GitConfigHttpProxy.md
Last active November 14, 2024 06:03
Configure Git to use a proxy

Configure Git to use a proxy

In Brief

You may need to configure a proxy server if you're having trouble cloning or fetching from a remote repository or getting an error like unable to access '...' Couldn't resolve host '...'.

Consider something like: