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 rest = new REST({ version: '9' }).setToken(process.env.DISCORD_BOT_TOKEN); | |
rest.put(Routes.applicationGuildCommands(process.env.BOT_CLIENT_ID, process.env.SERVER_ID), { body: commands }) | |
.then(() => console.log('Successfully registered application commands.')) | |
.catch(console.error); |
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 commands = [ | |
new SlashCommandBuilder().setName('ping').setDescription('Replies with pong!'), | |
new SlashCommandBuilder().setName('holiday').setDescription('Replies with 10 holiday date!') | |
].map(command => command.toJSON()); |
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
client.once('ready', async () => { | |
console.log('Ready!'); | |
try { | |
const webhook = new WebhookClient({ id: process.env.WEBHOOK_ID, token: process.env.WEBHOOK_TOKEN }); | |
await cron.schedule('00 10 * * Mon-Fri', async () => { | |
webhook.send('@everyone, standup meeting', {}); | |
}); |
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
client.once('ready', async () => { | |
console.log('Ready!'); | |
try { | |
const channel = client.channels.cache.get(process.env.GENERAL_CHANNEL_ID); | |
await cron.schedule('00 10 * * Mon-Fri', async () => { | |
channel.send('@everyone, standup meeting', {}); | |
}); |
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 checkTodayIsHoliday(webhook) { | |
let minNow = new Date(); | |
minNow.setHours(7, 0, 0, 0); | |
const timeMin = minNow.toISOString(); | |
let maxNow = new Date(); | |
maxNow.setDate(maxNow.getDate() + 1); | |
maxNow.setHours(7, 0, -1, 0); | |
const timeMax = (new Date(maxNow)).toISOString(); |
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 setRoleIdString() { | |
const roleId = process.env.ROLE_ID; | |
return '<@&' + roleId + '>'; | |
} | |
module.exports = { | |
setRoleIdString | |
} |
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
pragma solidity ^0.8.0; | |
contract EtherStore { | |
mapping(address => uint256) public balances; | |
function deposit() public payable { | |
balances[msg.sender] += msg.value; | |
} | |
function withdraw() public { |
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
pragma solidity ^0.6.0; | |
/* | |
* Step | |
* 1. Deploy TimeLock Contract | |
* 2. Deploy Attack(TimeLock) contract | |
* 3.1 Try attack() -> automated process | |
* 3.2 Manual | |
* 1) Deposit x ether | |
* 2) Get locktime (for checking) |
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] ประกาศ solidity ว่าใช้ version อะไร | |
pragma solidity ^0.8.7; | |
// [2] import smart contract อื่นเข้ามา ซึ่งอันนี้ไม่ต้องก็ได้ เผื่อใช้ 3rd-party | |
////import "openzeppelin-contracts/token/ERC20/ERC20.sol"; | |
////import "openzeppelin-contracts/access/Ownable.sol"; | |
// [3] ชื่อของ smart contract ในที่นี้ชื่อ Token | |
// และ inherit สืบทอดคุณสมบัติต่างๆของ smart contract อะไร ในที่นี้คือ ERC20 และ Ownable ใส่หลัง is | |
contract Token is ERC20, Ownable { |
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 android.content.Context | |
import android.graphics.* | |
import android.util.AttributeSet | |
import android.view.View | |
class SegmentCircleView @JvmOverloads constructor( | |
context: Context, | |
attrs: AttributeSet? = null, | |
defStyleAttr: Int = 0 | |
) : View(context, attrs, defStyleAttr) { |