Skip to content

Instantly share code, notes, and snippets.

View kimipeng's full-sized avatar
:octocat:
Focusing

Kimi Peng kimipeng

:octocat:
Focusing
  • Taipei
View GitHub Profile
// Includes functions for exporting active sheet or all sheets as JSON object (also Python object syntax compatible).
// Tweak the makePrettyJSON_ function to customize what kind of JSON to export.
var FORMAT_ONELINE = 'One-line';
var FORMAT_MULTILINE = 'Multi-line';
var FORMAT_PRETTY = 'Pretty';
var LANGUAGE_JS = 'JavaScript';
var LANGUAGE_PYTHON = 'Python';
@kimipeng
kimipeng / install-git-completion.sh
Created January 8, 2019 02:58 — forked from johngibb/install-git-completion.sh
Mac OS X - Install Git Completion
URL="https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash"
PROFILE="$HOME/.profile"
echo "Downloading git-completion..."
if ! curl "$URL" --silent --output "$HOME/.git-completion.bash"; then
echo "ERROR: Couldn't download completion script. Make sure you have a working internet connection." && exit 1
fi
@kimipeng
kimipeng / AlamofireUploadRequest.swift
Created September 17, 2018 10:25
Alamofire Upload request
// Alamofire 4 - Simple with URL request
Alamofire.upload(fileURL, with: urlRequest).validate().responseData { response in
debugPrint(response)
}
/**************************************************************************************************************/
// Alamofire 4 - - Complex with URL string
Alamofire.upload(fileURL, to: urlString, method: .put)
.uploadProgress(queue: DispatchQueue.global(qos: .utility)) { progress in
@kimipeng
kimipeng / AlamofireDownloadRequest.swift
Created September 17, 2018 10:21
Alamofire Download Request
// Alamofire 4 - Simple Download request
let destination = DownloadRequest.suggestedDownloadDestination()
Alamofire.download(urlString, to: destination).response { response in
print(response.request)
print(response.response)
print(response.temporaryURL)
print(response.destinationURL)
print(response.error)
}
@kimipeng
kimipeng / AlamofireDataRequest.swift
Last active September 17, 2018 10:02
Data Request - Complex with URL string
//
// ViewController.swift
// StudyAlamofire
//
// Created by Kimi Peng on 2018/9/17.
// Copyright © 2018年 Kimi Peng. All rights reserved.
//
import UIKit
import Alamofire
@kimipeng
kimipeng / AddUIRefreshControl.swift
Last active September 16, 2018 03:09
Simple Add UIRefreshControl
fileprivate func addRefreshControl() {
refreshControl = UIRefreshControl()
refreshControl?.addTarget(self, action: #selector(AQITableViewController.refresh), for: .valueChanged)
if let refreshControl = refreshControl {
self.tableView.addSubview(refreshControl)
}
}
@objc func refresh(sender: AnyObject) {
Alamofire.request(urlString).response { response in // method defaults to `.get`
debugPrint(response)
}
@kimipeng
kimipeng / UVI.swift
Created September 14, 2018 07:55
紫外線即時監測 資料定義
import Foundation
struct UVI: Codable {
var County: String
var PublishAgency: String
var PublishTime: String
var SiteName: String
var UVI: String
}
@IBAction func dismissKeyboard(_ sender: Any) {
calculateNumbers(calculatorSegControl)
}
// 點擊空白處,收鍵盤並執行calculateNumbers
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
self.view.endEditing(true)
calculateNumbers(calculatorSegControl)
}