Skip to content

Instantly share code, notes, and snippets.

Avatar

Jung Kim godrm

  • Codesquad
  • Seoul, KOREA
  • Twitter @godrm
View GitHub Profile
View ForecastViewModel.swift
protocol ViewModelBinding {
associatedtype Key
associatedtype Data
func updateNotify(changed: @escaping (Key, Data)->())
}
class ForecastImageViewModel : ViewModelBinding {
typealias Key = [UIImage]?
typealias Data = (duration: Double, firstImage: UIImage?)
View OAuth-ViewController.swift
import UIKit
import OctoKit
import AuthenticationServices
extension URL {
/// Returns a new URL by adding the query items, or nil if the URL doesn't support it.
/// URL must conform to RFC 3986.
func appending(_ queryItems: [URLQueryItem]) -> URL? {
guard var urlComponents = URLComponents(url: self, resolvingAgainstBaseURL: true) else {
// URL is not conforming to RFC 3986 (maybe it is only conforming to RFC 1808, RFC 1738, and RFC 2732)
View archiver.swift
//
// archiver.swift
//
// Created by JK on 2020/02/27.
// Copyright © 2020 codesquad. All rights reserved.
//
import Foundation
class NBeverage : NSObject, NSCoding, Codable {
@godrm
godrm / EchoServer.swift
Last active Jan 28, 2020
EchoServer with Network.Framework
View EchoServer.swift
//
// EchoServer.swift
// CS16
//
// Created by JK on 2020/01/14.
// Copyright © 2020 codesquad. All rights reserved.
//
import Foundation
import Network
@godrm
godrm / LadderGame+Refactor.swift
Last active Nov 18, 2019
HughLadderGame 리팩토링
View LadderGame+Refactor.swift
struct InputView {
enum Prompt : String {
case height = "> 사다리 높이를 입력해주세요.\n> "
case names = "> 참여할 사람 이름을 입력하세요.\n> "
}
static private func read(with prompt: Prompt) -> String {
print(prompt.rawValue)
let value = readLine() ?? ""
return value
View KeyPaths.swift
struct User {
var username: String
private var age : Int = 1
init(username : String) {
self.username = username
}
}
View CustomViewController.swift
//
// ViewController.swift
// SideView
//
// Created by JK on 2019/11/11.
// Copyright © 2019 codesquad. All rights reserved.
//
import UIKit
View process.c
#import <Carbon/Carbon.h>
#import <dlfcn.h>
/*
* 컴파일 명령 : gcc process.c -framework CoreServices
*/
CFArrayRef CopyLaunchedApplicationsInFrontToBackOrder(void)
{
CFArrayRef (*_LSCopyApplicationArrayInFrontToBackOrder)(uint32_t sessionID) = NULL;
void (*_LSASNExtractHighAndLowParts)(void const* asn, UInt32* psnHigh, UInt32* psnLow) = NULL;
View FizzBuzz.swift
struct FizzBuzz {
func makeIf(with value: Int) -> String {
guard value > 0 else { return "" }
if value % 15 == 0 {
return "fizzbuzz"
}
else if value % 3 == 0 {
return "fizz"
}
else if value % 5 == 0 {
View Codable+Class.swift
class Animal : Codable {
var type : String {
return "animal"
}
}
class Dog : Animal {
override var type : String {
return "dog"
}