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
const useGame<State>((set, get) => ({ | |
gameState: GameState.START, | |
level: 1, | |
line: 0, | |
score: 0, | |
matrix: buildMatrix(), | |
currentPiece: createCurrentPiece(generatePieceType()), | |
nextPieceType: generatePieceType(), | |
gameLoop() { |
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
A game has 7 types of Tetrimino: I, L, J, Z, S, O, T. | |
show board that contains 20 * 10 Blocks. | |
show the current moving piece that is controlled by the player. | |
show the future position where the current piece will drop | |
show the next piece, and the piece that is held | |
show the score, level, and line | |
when the game state is GAME_OVER or PAUSE | |
press enter to start the game | |
when the game state is START | |
for every tick (0.8 - (level - 1) * 0.007) ** (level - 1) second |
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 GraphQL::Execution::Interpreter::Runtime | |
def run_eager | |
# retrieve query root intormation | |
root_operation = query.selected_operation | |
root_op_type = root_operation.operation_type || "query" | |
root_type = schema.root_type_for_operation(root_op_type) | |
selection_response = GraphQLResultHash.new(nil, nil) | |
# create instance of type object, the #authorized_new method checks |
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
>> GraphQL.parse(query) | |
=> # <GraphQL::Language::Nodes::Document:0x00007fcd9c4dea10 | |
@definitions= | |
[#<GraphQL::Language::Nodes::OperationDefinition:0x00007fcd9c4deb28 | |
@operation_type="query", | |
@selections= | |
[#<GraphQL::Language::Nodes::Field:0x00007fcd9c4dec68 | |
@arguments= | |
[#<GraphQL::Language::Nodes::Argument:0x00007fcd9c4df870 | |
@name="id", |
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
const Unitialized = -1; | |
const Pending = 0; | |
const Resolved = 1; | |
const Rejected = 2; | |
function suspenseFetch(url) { | |
const payload = { | |
_status: Unitialized, | |
_result: () => fetch(url) | |
} |
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
const Unitialized = -1; | |
const Pending = 0; | |
const Resolved = 1; | |
const Rejected = 2; | |
function lazy(ctor) { | |
// hold component state in closure | |
const payload = { | |
_status: Unitialized, | |
_result: ctor |
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
<ErrorBoundary> | |
<ProfileDetails resource={resource}/> | |
</ErrorBoundary> |
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 Listing | |
attr_reader :filename, :line_numbers, :left_just, :repository, :tag, :git_cmd | |
def initialize(filename:, line_numbers: nil, left_just: nil, repository: nil, tag: nil, git_cmd: nil) | |
@filename = filename | |
@line_numbers = line_numbers | |
@repository = repository | |
@left_just = left_just | |
@tag = tag | |
@git_cmd = git_cmd |
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 Bicycle | |
attr_reader :size, :chain, :tire_size | |
def initialize(args = {}) | |
@size = args[:size] | |
@chain = args[:chain] | |
@tire_size = args[:tire_size] | |
end | |
def self.default_chain |
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 Maybe | |
def initialize(val) | |
@val = val | |
end | |
def fmap | |
return self if @val.nil? | |
self.class.new(yield @val) | |
end |
NewerOlder