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
| // 目前正在進行的 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
| 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
| 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
| 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
| 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
| #!/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
| #!/bin/env bash | |
| # For example, iterate over files in the home directory. | |
| dir=~ | |
| for f in $dir/*; do | |
| echo $f | |
| done |
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
| // Fisher-Yates shuffle algorithm | |
| function shuffle(arr) { | |
| const result = [...arr]; | |
| for (let i = result.length - 1; i >= 0; i -= 1) { | |
| const j = Math.floor(Math.random() * (i + 1)); | |
| [result[i], result[j]] = [result[j], result[i]]; | |
| } | |
| return result; | |
| } |
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
| #!/usr/bin/env python | |
| # l: final length | |
| # e: epsilon | |
| # d: lambda | |
| # u: mu | |
| # dd: derivative of lambda | |
| from mpmath import * |