Skip to content

Instantly share code, notes, and snippets.

View antonybudianto's full-sized avatar
💪
Build up!

Antony Budianto antonybudianto

💪
Build up!
View GitHub Profile
@antonybudianto
antonybudianto / firebase-auth-manual-indexdb.js
Last active April 10, 2024 12:51
How to authenticate Firebase on localhost through already auth-ed host
var db;
function createDatabase() {
const request = window.indexedDB.open('firebaseLocalStorageDb', 1);
request.onsuccess = (e) => {
// Create DB connection
db = request.result;
};
}
createDatabase();
alias c='clear'
alias h='cd ~'
alias pb='cd ~/Documents/public'
alias gs='git status'
alias dev='pnpm run'
alias sshnginx='ssh root@172.0.0.1'
GIT_PS1_SHOWDIRTYSTATE=true
# load version control information
@antonybudianto
antonybudianto / console-warn-to-log.js
Last active December 8, 2022 05:09 — forked from mksoni88/overridelog.js
Override console.warn to log so that it is not aliased to error
const _log = console.log;
global.console.warn = function() {
_log.apply(null, arguments);
};
@antonybudianto
antonybudianto / snake2camel.js
Last active May 28, 2022 10:50
snake to camel
const A = (O) => {
const keys = Object.keys(O);
const newO = {};
keys.forEach((k) => {
const newK = k
.split("_")
.map((s, i) => {
if (i > 0) {
return s[0].toUpperCase() + s.substring(1);
}

What

Open https://codesandbox.io/s/aloha-css-uyox7.

The app has an animating Box and "Hello" divs, however we got unexpected repaints over and over, and somehow the idle "hello" div also got repainted.

Debug

You can debug this issue by using Chrome Layers tab, you can see each element layering. You can enable flashing indicator by opening Chrome Rendering tab, and check "Paint flashing"

Why

ua=[];
document.querySelectorAll('.kbnDocTable__row').forEach(n => {
let fdiv = n.querySelectorAll('.kbnDocTableCell__dataField')[1]
let txt = fdiv.querySelector('div > span').innerHTML
ua.push({txt, modern: /Chrome\/([1-9][0-9][0-9]|[7-9][0-9]|6[1-9])/.test(txt)})
})
==== 2: GKE ======
gcloud config set compute/zone us-central1-b
gcloud container clusters create [CLUSTER-NAME]
gcloud container clusters get-credentials [CLUSTER-NAME]
kubectl run hello-server --image=gcr.io/google-samples/hello-app:1.0 --port 8080
location.search.substring(1).split('&').map(p => p.split('=')).reduce((a,c) => {
a[c[0]] = c[1]
return a
}, {})
const registerServiceWorker = async () => {
const swRegistration = await navigator.serviceWorker.register(
'/service-worker.js'
)
return swRegistration
}
const requestNotificationPermission = async () => {
const permission = await window.Notification.requestPermission()
// value of permission can be 'granted', 'default', 'denied'
function cur (n) {
let minus = n < 0
n = minus ? Math.abs(n) : n
return (minus ? '-' : '') + (n).toString().split('').reverse().reduce((a,b,i) => i % 3 === 0 ? a+'.'+b : a+b).split('').reverse().join('')
}