Skip to content

Instantly share code, notes, and snippets.

View agiletalk's full-sized avatar

chanju Jeon agiletalk

View GitHub Profile
@agiletalk
agiletalk / yaml_to_json.py
Created March 28, 2022 17:14
[실용주의 프로그래머] 연습 문제 11: .yaml 파일을 .json 파일로 바꾸기
import os
import sys
import yaml
import json
def get_file_list_yaml(path):
return [file for file in os.listdir(path) if file.endswith(".yaml")]
def yaml_to_json(yaml_file, json_file):
with open(yaml_file, 'r') as yaml_in, open(json_file, 'w') as json_out:
func loadFeedEntries() async throws -> Feed.Entries {
let feed = try await loadFeed()
let banners = try await loadBanner()
let articles = try await loadArticles()
let status = try await loadRegularPayment()
let watching = try await loadWantedPlusWatching()
return Feed.Entries(
...
banners: banners,
@agiletalk
agiletalk / loadFeedEntries.swift
Created February 7, 2022 01:01
correct await
func loadFeedEntries() async throws -> Feed.Entries {
async let feed = loadFeed()
async let banners = loadBanner()
async let articles = loadArticles()
async let status = loadRegularPayment()
async let watching = loadWantedPlusWatching()
return try await Feed.Entries(
...
banners: banners,
@agiletalk
agiletalk / loadFeed.swift
Last active February 7, 2022 00:58
async
func loadFeed() async throws -> Feed.Entries {
try await withCheckedThrowingContinuation { continuation in
fetchFeed { result in
continuation.resume(with: result)
}
}
}
@agiletalk
agiletalk / InteractorTests.swift
Last active October 18, 2020 02:44
Interactor Tests
describe("뷰가 로드되었을 때") {
var interactor: EventKeywordNoticeInteractor!
var presenter: EventKeywordNoticePresenterMock!
let worker = EventKeywordNoticeWorkerMock()
beforeEach {
interactor = EventKeywordNoticeInteractor(worker: worker)
presenter = EventKeywordNoticePresenterMock()
interactor.presenter = presenter
}
var pagingArrayForType = try feeds.nestedUnkeyedContainer()
var pagingContainer = pagingArrayForType
while(!pagingArrayForType.isAtEnd) {
let feedItem = try pagingArrayForType.nestedContainer(keyedBy: FeedKeys.self)
let type = try feedItem.decode(FeedType.self, forKey: .type)
switch type {
case .job: // decode job item
case .company: // decode company item
case .content: // decode content item
case .event: // decode event item
import Foundation
struct Repo: Decodable {
let name: String
let private: Bool
let language: String
}
let json = """
[
struct Repo {
let name: String
let owner: User
let isPrivate: Bool
let license: String
enum CodingKeys: String, CodingKey {
case name
case owner
case isPrivate = "private"
{
"name": "LicensingViewController",
"owner": {
"login": "agiletalk",
...
"type": "User"
},
"private": false,
"license": {
"key": "mit",
struct User: Codable {
let login: String
var avatarUrl: String?
var name: String
var email: String?
let numberOfPublicRepos: Int
let numberOfPublicGists: Int
let followers: Int
let following: Int