Skip to content

Instantly share code, notes, and snippets.

View jirawatee's full-sized avatar
🔥
Better Together

Jirawat Karanwittayakarn jirawatee

🔥
Better Together
View GitHub Profile
@jirawatee
jirawatee / MyFirebaseMessagingService.java
Last active July 14, 2022 20:58
FCM - MyFirebaseMessagingService.java
package com.example.fcm;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
@jirawatee
jirawatee / liff-plugin.html
Last active July 4, 2022 08:19
Example of LIFF Plugin
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0,viewport-fit=cover">
<title>LIFF Plugin</title>
<link rel="stylesheet" href="css/plugin.css">
</head>
<body>
<div id="container">
@jirawatee
jirawatee / liff-bmi.js
Last active July 4, 2022 07:38
Example of LIFF plugin
class BMIPlugin {
constructor() {
this.name = "bmi";
}
install(context, option) {
return {
today: this.localDate(context.liff.getLanguage(), option.date),
greet: this.greeting,
cal: this.calculate
@jirawatee
jirawatee / storage5.html
Last active June 14, 2022 03:39
Full source code
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0,viewport-fit=cover">
<title>Listing files in Cloud Storage for Firebase</title>
<link rel="shortcut icon" href="favicon.ico">
<style>
ul { list-style-type: none; padding:0 }
li { float: left; width:200px; height:232px; margin:8px; text-align:center; border:1px solid #ddd }
@jirawatee
jirawatee / follower-do-while.js
Last active May 27, 2022 10:31
Get followers by do-while
const main = async() => {
let result = {}
let next = ''
const valueArray = []
let round = 0
do {
result = await getFollowerIds(next)
for (const userId of result.userIds) {
valueArray.push(userId)
@jirawatee
jirawatee / follower-for.js
Last active May 27, 2022 10:29
Get followers by for loop
const main = async() => {
const valueArray = []
let result = {}
let next = ''
// 23794 คือค่า targetedReaches ที่ได้มาจาก Get Number of Followers API
const rounds = Math.ceil(23794/1000);
for (i = 0; i < rounds; i++) {
result = await getFollowerIds(next)
@jirawatee
jirawatee / follower-while.js
Last active May 27, 2022 10:29
Get followers by while loop
const main = async() => {
const valueArray = []
let result = {}
let next = ''
let round = 0
while(next != undefined) {
result = await getFollowerIds(next)
for (const userId of result.userIds) {
valueArray.push(userId)
@jirawatee
jirawatee / followers-api.js
Created May 27, 2022 05:49
Get followers by API
const axios = require('axios')
const LINE_MESSAGING_API = "https://api.line.me/v2/bot"
const LINE_HEADER = {
"Content-Type": "application/json",
Authorization: `Bearer ${config.CHANNEL_ACCESS_TOKEN}`
}
const getFollowerIds = async(next) => {
try {
const json = await axios({
@jirawatee
jirawatee / linespacing.json
Created March 10, 2022 15:29
Example of lineSpacing in Flex Message
{
"type": "bubble",
"body": {
"type": "box",
"layout": "vertical",
"contents": [
{
"type": "text",
"text": "เชื่อว่านักพัฒนาที่เป็นแฟนพันธุ์แท้ของ LINE ต่างรอคอยการมาของฟีเจอร์ใหม่ๆใน Flex Message เพื่อมาเติมเต็มจินตนาการในการแสดงผลข้อความใน LINE แบบ \"Think out of the box\" ทั้งการส่งผ่าน LINE Chatbot ก็ดี หรือส่งผ่าน LIFF app ก็เกร๋\n\nสำหรับใครที่เปิดมาเจอบทความนี้ แล้วได้ยินคำว่า Flex Message เป็นครั้งแรก ก็อยากแนะนำให้ไปทำความรู้จักกับความสามารถของมันที่บทความนี้ก่อนนะครับ",
"wrap": true,
@jirawatee
jirawatee / maxWidthHeight.json
Last active March 10, 2022 14:35
Example of maxWidth and maxHeight in Flex Message
{
"type": "bubble",
"body": {
"type": "box",
"layout": "vertical",
"contents": [
{
"type": "box",
"layout": "horizontal",
"contents": [