This file contains 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 puppeteer = require("puppeteer"); | |
const crypto = require("crypto"); | |
const querystring = require("querystring"); | |
const axios = require("axios").default; | |
require("dotenv").config(); | |
static async login(req, res) { | |
try { | |
const code_challenge = crypto.randomBytes(64).toString("hex"); | |
const code_verifier = code_challenge; |
This file contains 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
select table_schema, table_name | |
from information_schema.columns | |
where table_schema not in | |
('information_schema','pg_catalog') | |
and column_name = 'id_masa' -- insert referencing column name, eq: id_masa |
This file contains 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
SELECT column_name | |
FROM information_schema.columns | |
WHERE table_name='table_name'; |
This file contains 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
// Check string contains only one space | |
const pattern = new RegExp(/^\S+(?: \S+)*$/); | |
// Check if string is url | |
const pattern = new RegExp('^(https?:\\/\\/)?'+ // protocol | |
'((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|'+ // domain name | |
'((\\d{1,3}\\.){3}\\d{1,3}))'+ // OR ip (v4) address | |
'(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*'+ // port and path | |
'(\\?[;&a-z\\d%_.~+=-]*)?'+ // query string | |
'(\\#[-a-z\\d_]*)?$','i'); |
This file contains 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 getFileSize(stream?: any, callback?): Promise<any> { | |
return new Promise((resolve, reject) => { | |
let bytes=0; | |
stream.on("data", (chunk) => { | |
bytes += chunk.length; | |
}); | |
stream.on("end", () => { |
This file contains 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
#!/bin/bash | |
#Examples to create docx files with month as input | |
month=$1 | |
for i in {1..31} | |
do | |
touch "2021-${month}-${i}_Nanda.docx" | |
done |
This file contains 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
create or replace function test_notify() | |
returns trigger | |
language plpgsql | |
as $function$ | |
begin | |
if ((new.status = '1' and old.status = '0') or (new.status = '0' and old.status = '1')) then | |
perform pg_notify('testEvent', row_to_json(new)::text); | |
end if; | |
return null; | |
end; |
This file contains 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 util = require('util') | |
console.log(util.inspect(myObject, {showHidden: false, depth: null, colors: true})) | |
// alternative shortcut | |
console.log(util.inspect(myObject, false, null, true /* enable colors */)) |
This file contains 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 minMaxSum(array = []) { | |
const sorted = array.sort((a, b) => a - b) // Ascended sort | |
const minSum = sorted.slice(0, array.length/2).reduce((p, c) => p+=c); | |
const maxSum = sorted.slice(array.length/2, array.length).reduce((p, c) => p+=c); | |
return [minSum, maxSum] | |
} |
This file contains 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 amPmConversion(time = "") { | |
const arr = time.split(":"); | |
const amPm = arr.slice(2,3).join("").split("").slice(2,4).join(""); | |
let converted = ["", arr[1], arr.slice(2,3).join("").split("").slice(0,2).join("")]; | |
if (amPm === "PM") { | |
if (arr[0] === "12") { | |
converted[0] = "12" |
OlderNewer