Skip to content

Instantly share code, notes, and snippets.

View mikkipastel's full-sized avatar

Monthira Chayabanjonglerd mikkipastel

View GitHub Profile
@mikkipastel
mikkipastel / activity_main.xml
Created September 21, 2022 10:03
add Button under TextView
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/textview"
android:layout_width="wrap_content"
@mikkipastel
mikkipastel / activity_main.xml
Created September 21, 2022 09:25
sample android layout
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/textview"
android:layout_width="wrap_content"
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.ascedncorp.androidbasic">
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
package com.ascedncorp.androidbasic
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.ascedncorp.androidbasic.databinding.ActivityMainBinding
class MainActivity: AppCompatActivity() {
private val binding: ActivityMainBinding by lazy {
ActivityMainBinding.inflate(layoutInflater)
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.ascedncorp.androidbasic"
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@mikkipastel
mikkipastel / server.js
Created August 28, 2022 10:22
default discord command bot
//include library
const { Client, GatewayIntentBits, SlashCommandBuilder, Routes } = require('discord.js');
const { REST } = require('@discordjs/rest');
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
// map command list
const commands = [
new SlashCommandBuilder().setName('ping').setDescription('Replies with pong!')
].map(command => command.toJSON());
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<ImageView
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_margin="16dp"
@mikkipastel
mikkipastel / calendar.js
Created April 20, 2022 14:48
Replies with 10 holiday date!
function getHolidayList() {
const nowDateTime = (new Date()).toISOString();
return axios.get(
getGoogleCalendarApiPath(process.env.CALENDAR_HOLIDAY_IN_BNAGKOK_ID),
{
params: {
orderBy: 'startTime',
singleEvents: true,
key: process.env.GOOGLE_API_KEY,
@mikkipastel
mikkipastel / app.js
Created April 20, 2022 14:31
register discord bot command
client.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return;
const { commandName } = interaction;
if (commandName === 'ping') {
const timeTaken = Date.now() - interaction.createdTimestamp;
await interaction.reply(`Pong! This message had a latency of ${timeTaken}ms.`);
} else if (commandName === 'holiday') {
await interaction.reply(await calendar.getHolidayList());