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
"use client"; | |
import { X } from "lucide-react"; | |
import React, { useEffect } from "react"; | |
import { createPortal } from "react-dom"; | |
import ReactFocusLock from "react-focus-lock"; | |
export default function AccessibleDialogOrModal() { | |
return ( | |
<> |
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
// ref https://codepen.io/Pestov/pen/BLpgm | |
const tree = { | |
root: { | |
root1: { name: "Kakek", deceased: true }, | |
root2: { name: "Nenek", deceased: false }, | |
childs: [ | |
{ | |
name: "Anak 1", | |
spouse: [{ name: "Istri anak 1", deceased: false, divorced: true }], |
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
/** | |
* 58. Length of last word | |
* https://leetcode.com/problems/length-of-last-word/ | |
*/ | |
const lengthOfLastWord = s => { | |
s = s.trim().split(' '); | |
const word = s[s.length - 1]; | |
return word.length; | |
}; |
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
// simple function to check duplicate exist | |
function dupe(arr) { | |
return [...new Set(arr)].length === arr.length | |
} | |
// BOW | |
const misuh_warning = [ | |
'asu','4su','45u','a5u', | |
] |
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 findDupe(str) { | |
let hash = {} | |
for (let x of str) { | |
hash[x] ? hash[x] += 1 : hash[x] = 1; | |
if (hash[x] === 2) return x | |
} | |
} |
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 isExist(target, array) { | |
let sorted = array.sort((a, b) => a - b); | |
let midPoint = Math.floor(sorted.length / 2); | |
if (sorted[midPoint] === target) { | |
console.log('exist'); | |
} else if (sorted.length <= 1) { | |
console.log('not exist'); | |
} else if (sorted[midPoint] < target) { | |
isExist(target, sorted.slice(midPoint, sorted.length)); |
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
// with first convert to string | |
function isPalindrome(int) { | |
if (int < 0) return false | |
return +(''+int).split('').reverse().join('') === int | |
} | |
// without convert to string (bukan aku yang kerjain, this is brilliant) | |
function isPalindrome(int){ | |
if(int<0) return false; | |
let reverse=0; |
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 sockMerchant(n, ar) { | |
// create color hash | |
const colors = {}; | |
// count total matches (pairs) | |
let matches = 0; | |
ar.forEach(x => { | |
// if color with truthy value exist, increment pairs by 1 and set color to zero to make it falsy | |
if (colors[x]) { | |
matches++; | |
colors[x] = 0 |
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 nodemailer = require('nodemailer'); | |
const smtpTransport = require('nodemailer-smtp-transport'); | |
const transporter = nodemailer.createTransport( | |
smtpTransport({ | |
service: 'yandex/google', | |
host: 'smtp.yandex.ru/smtp.gmail.com', | |
auth: { | |
user: '[email protected]', | |
pass: 'yourEmailPassword', |
NewerOlder