Skip to content

Instantly share code, notes, and snippets.

View niranyousuf's full-sized avatar

Niran Yousuf niranyousuf

View GitHub Profile
@niranyousuf
niranyousuf / border-gradient.scss
Last active April 6, 2023 08:04
Border gradient color with transparent background and border-radius
.class_name {
border: 0.094rem solid transparent;
border-radius: 20px;
position: relative;
padding-top: 30px;
padding-bottom: 20px;
&::before {
position: absolute;
@niranyousuf
niranyousuf / mouseleave.js
Last active April 6, 2023 08:05
If any one want to leave from browser you can show him pop up
if (document.querySelector('.en-popup')) {
var popUp = document.querySelector('.en-popup');
document.addEventListener("mouseout", function popUpEventHandler(e) {
if (e.toElement === null) {
popUp.classList.add('show')
document.body.classList.add('popup-no-scroll')
this.removeEventListener('mouseout', popUpEventHandler);
}
})
var closePopUp = document.querySelectorAll('.close-popup');
@niranyousuf
niranyousuf / convertSeconds.js
Created February 15, 2022 06:47
Convert seconds to minutes and hours
function convertHMS(value) {
const sec = parseInt(value, 10); // convert value to number if it's string
let hours = Math.floor(sec / 3600); // get hours
let minutes = Math.floor((sec - (hours * 3600)) / 60); // get minutes
let seconds = sec - (hours * 3600) - (minutes * 60); // get seconds
// add 0 if value < 10; Example: 2 => 02
if (hours < 10) {hours = "0"+hours;}
if (minutes < 10) {minutes = "0"+minutes;}
if (seconds < 10) {seconds = "0"+seconds;}
return hours+':'+minutes+':'+seconds; // Return is HH : MM : SS
@niranyousuf
niranyousuf / wp_installation.php
Last active December 11, 2022 12:18
WordPress Active installation display on site
require_once(ABSPATH . 'wp-admin/includes/plugin-install.php');
$args = [
'slug' => 'YOUR PLUGIN NAME',
'fields' => [
'short_description' => false,
'icons' => true,
'reviews' => false,
],];
$data = plugins_api('plugin_information', $args);
echo $data->active_installs;
@niranyousuf
niranyousuf / disable_spacebar.js
Last active April 6, 2023 08:05
How to disable scrolling on pressing space bar
window.onkeydown = function(e) {
return !(e.keyCode == 32);
};
@niranyousuf
niranyousuf / reSizearea.js
Last active December 11, 2022 12:20
Resize all div with same class name
$(function () {
function reSizeArea(e) {
var arr = $.makeArray(e);
var ah = $.map(arr, function (h) {
return $(h).height();
});
var mh = Math.max.apply($(this).height(), ah);
e.height(mh);
}
reSizeArea($('YOUE_CLASS_NAME'));