Skip to content

Instantly share code, notes, and snippets.

View godrm's full-sized avatar

Jung Kim godrm

  • Codesquad
  • Seoul, KOREA
  • X @godrm
View GitHub Profile
protocol ViewModelBinding {
associatedtype Key
associatedtype Data
func updateNotify(changed: @escaping (Key, Data)->())
}
class ForecastImageViewModel : ViewModelBinding {
typealias Key = [UIImage]?
typealias Data = (duration: Double, firstImage: UIImage?)
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)
//
// 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 November 9, 2022 22:25
EchoServer with Network.Framework
//
// 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 November 18, 2019 08:06
HughLadderGame 리팩토링
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
struct User {
var username: String
private var age : Int = 1
init(username : String) {
self.username = username
}
}
//
// ViewController.swift
// SideView
//
// Created by JK on 2019/11/11.
// Copyright © 2019 codesquad. All rights reserved.
//
import UIKit
#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;
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 {
class Animal : Codable {
var type : String {
return "animal"
}
}
class Dog : Animal {
override var type : String {
return "dog"
}