Skip to content

Instantly share code, notes, and snippets.

View abdulloooh's full-sized avatar
🏠
Working from home

Abdullah Oladipo abdulloooh

🏠
Working from home
View GitHub Profile
@abdulloooh
abdulloooh / index.html
Last active May 8, 2020 15:14
Displaying Dynamic Messages Using the Web Notification API to Inform the Users of Your Website when A New Version of Your App is Deployed
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
[aria-hidden="true"] {
display: none;
@abdulloooh
abdulloooh / disable_form_autocomplete.md
Last active May 10, 2020 07:45
Disable modern browsers from offering autofill and autocomeplete to your input forms

Disable HTML form autocompletion

It is common that when you build a user form, it tends to auto-fill particularly when a user has signed up or logged in on a browser before and saved the password in the browser.

Common approach is to set autocomplete="off" but this doesn't work in modern browsers anymore for all input field; instead, in password input field that is with type="password" inside form tag,
set autocomplete="new-password" and that will work.

@abdulloooh
abdulloooh / index.js
Last active March 1, 2021 15:03
FORMAT ALL VARIANTS OF WRITING NIGERIA NUMBER (+234**, 234**, 0**, ** ) TO COMMON 0**
function format(number) {
const pattern = /^(234|\+234)/
const contains234 = pattern.test(number)
if (contains234) {
if (number.indexOf("+") === 0) number = number.replace("+", "")
number = number.replace("234", "0")
}
if (number.indexOf("0") !== 0) number = "0" + number
return number
}
@abdulloooh
abdulloooh / 1_into2callback_promises.js
Last active March 31, 2021 04:17
Advanced Node.js lessons (LinkedIn Learning)
1 ==== INTRO
//CALLBACKS
//Sync with no callback
function hideString(str){
return str.replace(/[A-Za-z]/g, 'x')
}
const hidden = hideString("Hello world")
@abdulloooh
abdulloooh / 1. buffer_stream.js
Last active April 22, 2023 23:31
Advanced Node.js Streams
// BUFFER
// Load the whole content into a buffer/ into memory once before wrting it out to user
const http = require("http");
const media = "./testvid.mp4";
const fs = require("fs");
http
.createServer((req, res) => {
function strictEquals(a,b) {
if (Number.isNaN(a) && Number.isNaN(b)) return false;
if ((Object.is(a,0) || Object.is(b,0)) && Object.is(a, -b)) return true
return Object.is(a,b)
}
@abdulloooh
abdulloooh / toPsqlArray.js
Created April 7, 2022 12:20
Convert JS array to psql array
const toPsqlArray = (arr) => {
let value = 'array[]::text[]';
if (arr && arr.length > 0) {
value = 'ARRAY [';
arr.map((each) => {
value = `${value} '${each}',`;
});
value = `${value.slice(0, -1)} ]`;