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 / 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 / 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-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 / 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 / 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": [
@jirawatee
jirawatee / video.json
Last active March 10, 2022 06:03
Video component
{
"type": "bubble",
"hero": {
"type": "video",
"url": "https://mokmoon.com/videos/Brown.mp4",
"previewUrl": "https://scdn.line-apps.com/n/channel_devcenter/img/fx/01_1_cafe.png",
"altContent": {
"type": "image",
"size": "full",
"aspectRatio": "20:13",
@jirawatee
jirawatee / thaiid.js
Created February 22, 2022 15:18
Extract data from Thai ID card
const functions = require("firebase-functions");
exports.myCallable = functions.https.onCall(async (data, context) => {
// รับค่า base64 ที่ได้จาก LIFF app โดย split เพื่อตัด type ที่นำหน้าออก
const base64 = data.base64.split(",")
// import และ initial ตัว lib ของ Cloud Vision API
const vision = require('@google-cloud/vision')
const client = new vision.ImageAnnotatorClient()