Skip to content

Instantly share code, notes, and snippets.

View colourful987's full-sized avatar
💭
Quantitative change, Then Qualitative change

PMST colourful987

💭
Quantitative change, Then Qualitative change
  • Bytedance
  • Hangzhou
View GitHub Profile
@colourful987
colourful987 / Decoding_JSON_In_Swift.swift
Last active August 29, 2016 15:13
Decoding JSON In Swift (一)
// From Soroush Khanlou ,URL: [Decoding JSON in Swift](http://khanlou.com/2016/04/decoding-json/)
import Foundation
struct ParserError:Error{
let message:String
}
struct Parser {
@colourful987
colourful987 / Pokemon.swift
Last active September 16, 2016 15:55
Seven Demo For Explaining Swift Closures Capture Semantics
//: Playground - noun: a place where people can play
import UIKit
import PlaygroundSupport
PlaygroundPage.current.needsIndefiniteExecution = true
class Pokemon :CustomStringConvertible{
let name: String
@colourful987
colourful987 / defineSkills.c
Last active September 16, 2016 16:30
#Define Little Skills
/**
引自 Pointers on C 一书
1. 在调用宏时,首先对参数进行检查,查看是否包含任何由 `#define` 定义的符号,如果是,这些符号首先被替换掉
2. 替换文本随后被插入到程序中原来文本的位置,对于宏,参数名被它们的值所替换。
3. 最后,再次对结果文本进行扫描,看看它是否包含了任何由#define 定义的符号,如果是,就重复上述处理步骤。
宏参数和#define 定义可以包含其他#define 定义的符号,但是,宏不可以出现递归!
当预处理器搜索#define定义的符号时,字符串常量的内容不被检查,如果想把宏参数插入到字符串常量中,有以下几种方式:
*/
@colourful987
colourful987 / OPP-Logger.swift
Created September 20, 2016 14:31
OPP - Logger
// 面向协议的日志输出
enum LogLevel: Int {
case verbose = 1
case debug = 2
case info = 3
case warning = 4
case error = 5
}
@colourful987
colourful987 / swift-talk-episode1-networking.swift
Created October 4, 2016 16:15
Swift Talk Episode 1 - Networking
import Foundation
let url = URL(string:"http://localhost/test1.json")!
typealias JSONDictionary = [String:AnyObject]
// 资源的链接 & 解析闭包
struct Resource<A>{
@colourful987
colourful987 / struct_initializer.m
Last active May 30, 2017 12:15
三种初始化结构体的方式
struct student{
const char *name;
int age;
char tag;
};
int main(int argc, const char * argv[]) {
// 方式一
struct student st_student1 = {"Alan",10,'1'};
@colourful987
colourful987 / get_file_time.sh
Last active July 15, 2019 06:26
How to get file modify time or access time in OSX
stat -f "Access (atime): %Sa%nModify (mtime): %Sm%nChange (ctime): %Sc%nBirth (Btime): %SB" Screenshot_FFFDA56C-3018-4EA8-8A8B-2589E9C47865.jpg
date -r Screenshot_FFFDA56C-3018-4EA8-8A8B-2589E9C47865.jpg +%Y-%m-%d-%H:%M:%S