Skip to content

Instantly share code, notes, and snippets.

View Shakil-Shahadat's full-sized avatar
🏠
Working from home

Shakil Shahadat Shakil-Shahadat

🏠
Working from home
View GitHub Profile
@Shakil-Shahadat
Shakil-Shahadat / float.css
Created December 20, 2020 18:42
Centering a floating item
.box
{
position: sticky;
bottom: 20px;
width: 600px;
margin: auto;
}
@Shakil-Shahadat
Shakil-Shahadat / ToDo.todo
Last active February 22, 2021 02:49
Basic ToDo File Structure
Bug:
Feature:
Improvement:
Change:
Other:
@Shakil-Shahadat
Shakil-Shahadat / loopOverArray.js
Last active December 18, 2021 01:24
Summary of 'for / in' & 'for / of' loop
let fruits = [ 'apple', 'orange', 'mango' ];
// for / of loop
for ( e of fruits )
{
// e is now an element of the array
console.log( e ); // Output: apple, orange, mango
}
// for / in loop
@Shakil-Shahadat
Shakil-Shahadat / position.css
Last active June 29, 2022 23:44
Types of CSS Positioning
static
absolute
fixed
relative
sticky
@Shakil-Shahadat
Shakil-Shahadat / miscellaneous.js
Last active April 18, 2024 08:23
★ Miscellaneous JavaScript Codes
// Reload current page
location.reload();
// Ref: https://developer.mozilla.org/en-US/docs/Web/API/Location/reload
// Reload page at an interval
setTimeout( function(){ location.reload(); }, 30 * 1000 ); // Reload at every 30 seconds
// Alternative
setTimeout( () => { location.reload(); }, 30 * 1000 ); // Reload at every 30 seconds
// Ref: https://developer.mozilla.org/en-US/docs/Web/API/setTimeout
@Shakil-Shahadat
Shakil-Shahadat / timing.js
Last active December 18, 2021 01:30
JavaScript Timing Events
// One time event
setTimeout( function(){}, 1000 );
// Repetitive event
setInterval( function(){}, 1000 );
// If these need to be canceled, then assign them
// to a variable and then clear them like this.
clearTimeout( assignedVar );
clearInterval( assignedVar );
@Shakil-Shahadat
Shakil-Shahadat / style.js
Last active October 23, 2020 02:54
Add CSS Styles within JavaScript
let s = document.createElement( 'style' );
s.innerText = `
.box
{
display: none;
}
`;
document.head.appendChild( s );
@Shakil-Shahadat
Shakil-Shahadat / query.js
Last active July 6, 2022 16:51
Functions to shorten querySelector* calls in JavaScript
function qs( cls )
{
return document.querySelector( cls );
}
function qsa( cls )
{
return document.querySelectorAll( cls );
}
@Shakil-Shahadat
Shakil-Shahadat / favicon.html
Created October 5, 2020 23:17
Favicon HTML Code
<link rel="shortcut icon" href="src/favicon.ico">
@Shakil-Shahadat
Shakil-Shahadat / post.php
Last active January 16, 2021 03:58
POST Request by Fetch
<?php
header( 'Access-Control-Allow-Origin: *' );
print_r( $_POST );