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
List<Course> courses = new List<Course>(); | |
courses.Add(new Course | |
{ | |
ID = 1, | |
Subject = "LINQ Tutorials", | |
Rank = 5 | |
}); | |
courses.Add(new Course | |
{ | |
ID = 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
finishGame({ commit, state }) { | |
commit('removeLosers'); | |
// Đếm những quân xí ngầu thắng | |
var diceDic = countBy(state.dices, dice => dice); | |
for (const key in diceDic) { | |
const multiplier = diceDic[key] + 1; | |
const winners = Object.values(state.board[key]); | |
// Cộng điềm cho những người thắng |
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
const store = new Vuex.Store({ | |
state: { | |
players: {}, | |
status: WAITING_FOR_BET, | |
dices: [1, 2, 3], | |
board: { | |
1: {}, | |
2: {}, | |
3: {}, | |
4: {}, |
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
<div> | |
<div class="bc-table"> | |
<!-- Ảnh bầu cua --> | |
<img src="./../assets/baucua.jpg" alt class="image bc-image" /> | |
<div class="bc-overlay"> | |
<!-- 6 cells tương ứng với 6 con --> | |
<div class="boards" :key="key" v-for="(cell, key) in board"> | |
<transition-group | |
tag="div" | |
enter-active-class="animated bounceInDown" |
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
getBetFromComment(comment) { | |
const cleanedComment = textParser.charToNumber( | |
textParser.removeUnicode(comment.toLowerCase())); | |
const regex = /(\d+)( |-)?(cop|bau|ga|tom|ca|cua)/; | |
const matches = cleanedComment.match(regex); | |
if (!matches) return []; | |
const bets = matches.map(match => { |
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 io from 'socket.io-client'; | |
const socket = io('http://localhost:3002'); | |
socket.on('connect', () => { console.log('connected') }); | |
socket.on('newBet', function(newBet) { | |
const { id, name, avatar, bet, choice } = newBet; | |
const player = new Player(id, name, avatar); | |
store.dispatch('placeBet', { player, bet, choice }); | |
}); |
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 processHook(hookObject) { | |
for (const entry of hookObject.entry) { | |
for (const change of entry.changes) { | |
this.processEntryChange(change); | |
} | |
} | |
} | |
async processEntryChange(change) { | |
if (change.field !== 'feed') return; |
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
app.post('/webhook', async(req, res) => { | |
const hookObject = req.body; | |
console.log(JSON.stringify(hookObject, null, 2)); | |
await process.processHook(hookObject); | |
res.status(200).send("OK"); | |
}); |
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
isFlagEnable(flagName) { | |
// Lấy tên, email của người dùng hiện tại | |
const currentUser = userService.getCurrentUser(); | |
// Kiểm tra xem người dùng hiện tại | |
// có được dùng chức năng có tên "flagName" không | |
const flagEnable = flagService.getFlag(flagName, currentUser) | |
return flagEnable | |
} |
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
function showUI() { | |
// Dùng hàm isFlagEnable để lấy giá trị flag, thay vì hardcode | |
const SHOW_NEW_UI = isFlagEnable('show-new-ui'); | |
if (SHOW_NEW_UI) { | |
showPagesV2() | |
} else { | |
showPages() // Show UI cũ | |
} | |
} |