This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func downloadFile(from remoteURL: URL, completion: @escaping (_ localURL: URL) -> Void) { | |
let documentsDirectoryURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first! | |
let destinationUrl = documentsDirectoryURL.appendingPathComponent(randomString) | |
if FileManager.default.fileExists(atPath: destinationUrl.path) { | |
DispatchQueue.main.async { completion(destinationUrl) }; return | |
} | |
URLSession.shared.downloadTask(with: remoteURL, completionHandler: { (location, response, error) -> Void in | |
guard let location = location, error == nil else { return } | |
do { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var cursorX = 0 | |
var cursorY = 0 | |
document.onmousemove = function(e){ | |
cursorX = e.pageX; | |
cursorY = e.pageY; | |
} | |
document.addEventListener('keypress', function (e) { | |
var key = e.which || e.keyCode; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/local/bin/zsh | |
authorName="Sungdoo Yoo" #Put your Name here | |
dayStart="8am" #Put the time when you start your day | |
for refName in $(git for-each-ref --format='%(refname)' refs/heads/); | |
do | |
boilerPlateToRemove="refs/heads/" | |
branchName="${refName//$boilerPlateToRemove/""}" | |
result="" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# Generate Log with commits with certain prefixes ( `-`, `*`, `.`) | |
git log $1...$2 --no-merges --format="%Cgreen## %s%n%Creset%b" --grep "- " --grep "\. " --grep "\* " >> changelog.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let dateFormat = DateFormatter() | |
dateFormat.dateFormat = "yyyy/MM/dd/HH/mm/ss" | |
print(dateFormat.date(from: "20160610090000")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let dateFormat = DateFormatter() | |
dateFormat.dateFormat = "yyyy/MM/dd/HH/mm/ss" | |
dateFormatter.locale = Locale(identifier:"en_US_POSIX") // 추가 된 코드 | |
print(dateFormat.date(from: "20160610090000")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ModelController: NSObject { | |
var kittisList = ["🐱", "😹", "😼", "😸", "😽", "😾"] | |
var smileyList = ["😐", "😂", "😏", "😊", "😊", "😠", "😱"] | |
} | |
class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate { | |
// MARK: - View | |
@IBOutlet var tableView: UITableView! | |
@IBOutlet var segmentControl: UISegmentedControl! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ViewController: UIViewController { | |
// MARK: - View | |
@IBOutlet var tableView: UITableView! | |
@IBOutlet var segmentControl: UISegmentedControl! | |
// MARK: - DatSources | |
var dataSources:[UITableViewDataSource] = [] | |
let catDataSource = CatDataSource() | |
let smileyDataSOurce = SmileyDataSource() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 옛날 버전. "세그먼트 콘트롤이 눌리면 테이블뷰를 리로드하라"로 밖에 읽히지 않는다. | |
@IBAction func segementSelected(_ sender: UISegmentedControl) { | |
tableView.reloadData() | |
} | |
// 리팩토링버전. "선택된 세그먼트에 해당되는 데이터로 테이블을 채워라"라는 의도가 보인다. | |
@IBAction func segementSelected(_ sender: UISegmentedControl) { | |
tableView.dataSource = dataSources[sender.selectedSegmentIndex] | |
tableView.reloadData() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SmileyDataSource: NSObject, UITableViewDataSource { | |
var dataList: [String] = [] | |
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | |
return dataList.count | |
} | |
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
let item = dataList[indexPath.row] | |
let cell = tableView.dequeueReusableCell(withIdentifier: "smileyCell", for: indexPath) | |
cell.textLabel?.text = item |
OlderNewer