Skip to content

Instantly share code, notes, and snippets.

View derekcoder's full-sized avatar
👨‍💻
Focusing

ZHOU DENGFENG derekcoder

👨‍💻
Focusing
View GitHub Profile
@derekcoder
derekcoder / gist:a549631b25a44467d5590c2dffd95591
Created January 5, 2021 09:52
genstrings for SwiftUI project
find . -name \*.swift | xargs genstrings -SwiftUI
@derekcoder
derekcoder / Measure.swift
Created May 6, 2020 17:24 — forked from waylybaye/Measure.swift
SwiftUI view render performance Indicator
// Created by Baye Wayly on 2020/3/13.
// Copyright © 2020 Baye. All rights reserved.
import SwiftUI
struct Measure<Content: View>: View {
@State var cost: TimeInterval = 0
var content: Content
init(@ViewBuilder builder: () -> Content) {
@derekcoder
derekcoder / Alamofire.json
Created April 9, 2020 07:29 — forked from mattt/Alamofire.json
Extremely early proof-of-concept Markdown document generation output for swift-doc
{
"/Users/mattt/Desktop/Alamofire.swift" : {
"deinitializers" : [],
"functions" : [
{
"declaration" : {
"name" : "request",
"genericRequirements" : [],
"signature" : {
"output" : "DataRequest",
@derekcoder
derekcoder / cc.css
Created April 9, 2020 07:29 — forked from mattt/cc.css
Creative Commons Symbols @font-face CSS
@font-face {
font-family: "Creative Commons Symbols";
src: url(font_path("CreativeCommonsSymbols.woff2")) format("woff2"),
url(font_path("CreativeCommonsSymbols.woff")) format("woff");
font-weight: normal;
font-style: normal;
unicode-range: U+1F10D-1F10F, U+1F16D-1F16F;
}
i {
@derekcoder
derekcoder / gist:58964d4523e603e246465dc0280db4e6
Created January 14, 2020 03:48 — forked from CristinaSolana/gist:1885435
Keeping a fork up to date

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@derekcoder
derekcoder / LinkedList.swift
Last active April 9, 2020 07:31
The implementation of LinkedList data structure in Swift
//
// LinkedList.swift
//
// Created by Derek on 20/12/19.
// Copyright © 2019 DerekCoder. All rights reserved.
//
public class Node<Value> {
public var value: Value
@derekcoder
derekcoder / Stack.swift
Last active April 9, 2020 07:32
The implementation of Stack data structure in Swift
//
// Stack.swift
//
// Created by Derek on 18/12/19.
// Copyright © 2019 DerekCoder. All rights reserved.
//
public struct Stack<Element> {
private var storage: [Element] = []
import UIKit
import WebKit
// Disableing `WKWebView` user zooming by returning `nil` in `UIScrollViewDelegate`'s
// `viewForZooming` delegate method.
// On iOS 12, the delegate method only called when set the web view itself as the
// scroll view delegate.
class WebView: WKWebView {}
@derekcoder
derekcoder / UICollectionView.swift
Created September 13, 2019 09:25 — forked from fuxingloh/UICollectionView.swift
iOS Swift: How to count the width of the UILabel. And how to size UICollectionViewCell dynamically with label.
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
let text = collections[indexPath.row].name
let width = UILabel.textWidth(font: titleFont, text: text)
return CGSize(width: width + left + right, height: height)
}
@derekcoder
derekcoder / UIScrollView+Extensions.swift
Created September 9, 2019 02:34
private method _scrollToTop for UIScrollView
extension UIScrollView {
func scrollToTop() {
if let selectorName = "X3Njcm9sbFRvVG9wSWZQb3NzaWJsZTo=".base64Decoded {
let selector = NSSelectorFromString(selectorName)
if responds(to: selector) {
perform(selector, with: false)
}
}
}