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
| chess|1 1 | |
| chess|2 2 | |
| go|1 2 | |
| go|2 1 |
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 ruby | |
| class Reducer | |
| attr_accessor :key, :game_type | |
| def initialize(key) | |
| @key = key | |
| @player_scores = Hash.new | |
| end | |
| def accumulate(splitted_line) |
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
| 1 game_log chess | |
| 1 player_log 1 1 | |
| 1 player_log 2 0 | |
| 2 game_log go | |
| 2 player_log 1 2 | |
| 2 player_log 2 5 |
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
| 1 player_log 1 1 | |
| 2 player_log 1 2 | |
| 1 player_log 2 0 | |
| 2 player_log 2 5 | |
| 1 game_log chess | |
| 2 game_log go |
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 ruby | |
| class Mapper | |
| # initialize a mapper with raw data. | |
| def initialize(line) | |
| # chomp will remove endline characters | |
| # split will split the line for every tab character \t | |
| # strip will remove whitespaces at begining and end of every words | |
| @data = line.chomp.split("\t").map(&:strip) |
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
| Player_id GameType AverageRank | |
| 1 chess 1 | |
| 1 go 2 | |
| 2 chess 2 | |
| 2 go 1 |
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
| GameId Type | |
| 1 chess | |
| 2 go |
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
| PlayerId Score GameId | |
| 1 1 1 | |
| 1 2 2 | |
| 2 0 1 | |
| 2 5 2 |
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
| async function main () { | |
| const user = await User.findOne({}) | |
| // execution is paused until a user is found and returned | |
| console.log(user.email) | |
| } |
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
| import app from '../../app' | |
| import fixtures from '../ourFixtures' | |
| import * as supertest from 'supertest-as-promised' | |
| const request = supertest(app) | |
| describe('Things', () => { | |
| before(async () => { | |
| await fixtures.clearDb() // assume clearDb is a function that returns a promise | |
| await Thing.create({}) // mongoose style | |
| })) |