This file contains hidden or 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/env bash | |
| rel_path=../relative/path | |
| cd /path/to/here | |
| abs_path=$(readlink -f $rel_path) | |
| echo $abs_path # /path/to/relative/path |
This file contains hidden or 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 Functor { | |
| public: | |
| Functor() :sum_(0) {} | |
| int operator()(int n) { | |
| sum_ += n; | |
| return sum_; | |
| } | |
| private: | |
| int sum_; | |
| } |
This file contains hidden or 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
| package main | |
| import ( | |
| "context" | |
| "fmt" | |
| "google.golang.org/grpc" | |
| "github.com/onflow/cadence" | |
| // "github.com/onflow/flow-go-sdk" |
This file contains hidden or 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
| pub contract TopShot: NonFungibleToken |
This file contains hidden or 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
| pub event ContractInitialized() | |
| pub event PlayCreated(id: UInt32, metadata: {String:String}) | |
| pub event NewSeriesStarted(newCurrentSeries: UInt32) | |
| pub event SetCreated(setID: UInt32, series: UInt32) | |
| pub event PlayAddedToSet(setID: UInt32, playID: UInt32) | |
| pub event PlayRetiredFromSet(setID: UInt32, playID: UInt32, numMoments: UInt32) | |
| pub event SetLocked(setID: UInt32) | |
| pub event MomentMinted(momentID: UInt64, playID: UInt32, setID: UInt32, serialNumber: UInt32) |
This file contains hidden or 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
| // 目前正在進行的 series | |
| pub var currentSeries: UInt32 | |
| // 紀錄 play 的資訊 | |
| // 是一個 play ID -> play 資訊的 mapping | |
| access(self) var playDatas: {UInt32: Play} | |
| // 紀錄 set 的資訊 | |
| // 是一個 set ID -> set 資訊的 mapping | |
| access(self) var setDatas: {UInt32: SetData} |
This file contains hidden or 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
| // Play 就是一個精彩好球,比如說 LBJ 的 The block, | |
| // 所有的卡片只會包含一個 play, | |
| // 但同一個 play 可以被很多卡片或是系列包含 | |
| pub struct Play { | |
| // 每個 play 會有一個獨特的 ID 表示 | |
| pub let playID: UInt32 | |
| // 每個 play 也會有相應的 metadata, | |
| // 這裡的儲存方式是使用一個 string -> string 的 map |
This file contains hidden or 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
| // Set 就是一個系列,裡面可以包含很多個精彩好球 play | |
| pub struct SetData { | |
| // 每個 Set 有一個獨特的 ID 表示 | |
| pub let setID: UInt32 | |
| // Set 名字,例如 "Cool Cats" 系列 | |
| pub let name: String | |
| // Set 所屬的世代,像現在已經到了世代 3, |
This file contains hidden or 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
| // Moment 也就是一張卡片, | |
| pub struct MomentData { | |
| // 是在哪個 set 裡 | |
| pub let setID: UInt32 | |
| // 是哪個 play | |
| pub let playID: UInt32 | |
| // 序號是多少 |
This file contains hidden or 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
| // TopShotMomentMetadataView 就如變數名字所意, | |
| // 儲存所有 moment 相關的 metadata, | |
| // 像是球員名字、球員生日、所屬球隊等等 | |
| pub struct TopShotMomentMetadataView { | |
| pub let fullName: String? | |
| pub let firstName: String? | |
| pub let lastName: String? | |
| pub let birthdate: String? | |
| pub let birthplace: String? |