Skip to content

Instantly share code, notes, and snippets.

Avatar
✏️
Studying

SeongHo Hong cozzin

✏️
Studying
View GitHub Profile
View IteratorExample.java
import java.util.Iterator;
public class IteratorExample {
public static void main(String[] args) {
Iterable<Integer> iterable = () -> new Iterator() {
int i = 0;
final static int MAX = 10;
public boolean hasNext() {
return i < MAX;
@cozzin
cozzin / UserAgentFetcher.swift
Created Sep 24, 2020
Using WKWebview to get userAgent synchronously
View UserAgentFetcher.swift
public final class UserAgentFetcher: NSObject {
private let webView: WKWebView = WKWebView(frame: .zero)
@objc
public func fetch() -> String {
dispatchPrecondition(condition: .onQueue(.main))
var result: String?
@cozzin
cozzin / gitignore 기준으로 다시 트래킹 하기
Last active Aug 16, 2020
[Git] gitignore 기준으로 다시 트래킹 하기
View gitignore 기준으로 다시 트래킹 하기
git rm -r --cached .
git add .
git commit -am 'refresh git tracking'
git push
View CachedClassifier.swift
class CachedClassifier {
private var sumCache = [Int: Int]()
func sumOfFactors(_ number: Int) -> Int {
if let cachedValue = sumCache[number] {
return cachedValue
}
let sum = aliquotSum(factors(number))
View EscapingClousureTest.swift
//: Playground - noun: a place where people can play
import UIKit
class TestClass {
deinit {
print("deinit \(self)")
}
@cozzin
cozzin / HeaderFooterViewHeight.swift
Last active Aug 9, 2018
여러 UI 컴포넌트들이 있는 HeaderView의 높이 계산해주기
View HeaderFooterViewHeight.swift
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
guard let headerView = headerView(at: section) else {
return nil
}
return headerView.systemLayoutSizeFitting(CGSize(width: targetView.frame.width, height: CGFloat.greatestFiniteMagnitude), withHorizontalFittingPriority: .required, verticalFittingPriority: .fittingSizeLevel).height
}
@cozzin
cozzin / Emptiable+Extension.swift
Created Aug 8, 2018
check isNotEmpty isNotNilNotEmpty
View Emptiable+Extension.swift
//
// Emptiable+Extension.swift
// sieum
//
// Created by 홍성호 on 2018. 8. 8..
// Copyright © 2018년 홍성호. All rights reserved.
//
// https://github.com/artsy/Emergence/blob/master/Emergence/Extensions/Apple/Occupyable%2BisNotEmpty.swift
//
View SHSideMenu.podspec
Pod::Spec.new do |s|
s.name = "SHSideMenu"
s.version = "0.0.4"
s.summary = "Simple side menu view controller 🍔"
s.description = <<-DESC
Simple side menu view controller for ios 🍔
DESC
s.homepage = "https://github.com/cozzin/SHSideMenu"
s.license = "MIT"
View SideMenuViewController.swift
//
// SideMenuViewController.swift
// sieum
//
// Created by 홍성호 on 2018. 6. 26..
// Copyright © 2018년 홍성호. All rights reserved.
//
import UIKit
import SnapKit
View SwiftExtensionForObjc.swift
@objc protocol AAA {
}
extension AAA {
var aa: Int {
return 0
}
}