Skip to content

Instantly share code, notes, and snippets.

One More Time

Alex Artemev bartleby

One More Time
View GitHub Profile
View LinearScale.swift
open class LinearScale {
var domain: [CGFloat]
var range: [CGFloat]
public init(domain: [CGFloat] = [0, 1], range: [CGFloat] = [0, 1]) {
self.domain = domain
self.range = range
View do you even retain

Self в Swift и Objective-C

Дисклеймер: речь идёт об однопоточном коде, оставим ужасы параллельного исполнения за скобками. Также не рассматривается возможность overrelease.


Объект точно не ритейнится на время выполнения его метода, пруфы:

shazron / gist:943736
Created Apr 27, 2011
About XCode 4 Project Template (How To Create Custom Project Template)
View gist:943736
XCode 4 Projects and Files Template Folder: /Developer/Library/Xcode/Templates
/Developer/Library/Xcode/Templates/Project Templates/Base/Other/Empty.xctemplate
/Developer/Library/Xcode/Templates/Project Templates/Base/Base.xctemplate
/Developer/Library/Xcode/Templates/Project Templates/Mac/Mac Base.xctemplate
/Developer/Library/Xcode/Templates/Project Templates/Mac/Application/Command Line Tool.xctemplate
/Developer/Library/Xcode/Templates/Project Templates/Mac/Application/Cocoa Application.xctemplate
cmoulton / Custom HTTP Headers with Swift and Alamofire.swift
Last active Mar 26, 2020
Custom HTTP Headers with Swift 3 or 4 and Alamofire 4.0-4.7: See for explanations
View Custom HTTP Headers with Swift and Alamofire.swift
// MARK: - Adding a header to a single request
func doRequestWithHeaders1() {
let headers: HTTPHeaders = [
"X-Mashape-Key": MY_API_KEY,
"Accept": "application/json"
Alamofire.request("", headers: headers)
.responseJSON { response in
View Cluster.swift
class Number /* class cluser */ {
class Int8: Number {
var value: Swift.Int8
init(_ value: Swift.Int8) { self.value = value }
class Int: Number {
var value: Swift.Int
init(_ value: Swift.Int) { self.value = value }
ilyapuchka / StickyLayout.swift
Last active Feb 17, 2021
Really sticky collection view layout
View StickyLayout.swift
// The issue with sectionHeadersPinToVisibleBounds and sectionFootersPinToVisibleBounds is that they do not pin
// first header and last footer when bouncing. This layout subclass fixes that.
class StickyLayout: UICollectionViewFlowLayout {
override init() {
self.sectionFootersPinToVisibleBounds = true
self.sectionHeadersPinToVisibleBounds = true
mteece /
Last active Mar 13, 2021
List of NSTimeZone Abbreviations and Names (iOS 9.3.1)

NSTimeZone - Timezone Abbreviations ADT = "America/Halifax"; AKDT = "America/Juneau"; AKST = "America/Juneau"; ART = "America/Argentina/Buenos_Aires"; AST = "America/Halifax"; BDT = "Asia/Dhaka"; BRST = "America/Sao_Paulo"; BRT = "America/Sao_Paulo"; BST = "Europe/London";

ha1f / CIFilter+Extension.swift
Last active Apr 2, 2021
View CIFilter+Extension.swift
// Created by はるふ on 2017/12/11.
// Copyright © 2017年 ha1f. All rights reserved.
import Foundation
import CoreImage
import AVFoundation
extension CIFilter {
pkuecuekyan / WKWebViewSizeToFit.swift
Last active Jun 4, 2021
Adjust height of WKWebView frame based on scrollHeight of the webView's content
View WKWebViewSizeToFit.swift
// Since the WKWebView has no sizeToFit() method, increase the frame height of the webView to
// match the height of the content's scrollHeight
// The WKWebView's `navigationDelegate` property needs to be set for the delegate method to be called
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
if webView.isLoading == false {
webView.evaluateJavaScript("document.body.scrollHeight", completionHandler: { [weak self] (result, error) in
if let height = result as? CGFloat {
UHKim / example.ios.yml
Last active Jul 17, 2021
GitHub Action iOS build workflow example
View example.ios.yml
name: Example iOS Build
- development
runs-on: macos-latest