Skip to content

Instantly share code, notes, and snippets.

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

Md Ariful Islam marifuli

🏠
Working from home
View GitHub Profile
@marifuli
marifuli / copy-text.js
Last active December 25, 2021 11:54
Copy text to clipboard
const CopyText = function() {
let t;
const e = function(e) {
t || (t = document.createElement("textarea"), document.body.appendChild(t)), t.value = e, t.setAttribute("readonly", "true"), t.setAttribute("type", "text"), t.select(), t.setSelectionRange(0, 9999);
try {
return document.execCommand("copy"), !0
} catch (t) {
return !1
} finally {
t.setAttribute("type", "hidden")
@marifuli
marifuli / image-resizing-in-laravel.php
Last active December 18, 2021 19:56
Helper function for Image resizing in PHP, especially in php
function dynamic_image($url, $width = false, $height = -1, $quality = 80, $compression = 75)
{
$parsed = parse_url($url);
$path = $parsed['path'];
$file_name = basename($path);
$only_path = str_replace($file_name, '', $path);
$public_path = public_path($path);
if(file_exists($public_path))
@marifuli
marifuli / pagination.php
Created August 27, 2021 17:32
Raw PHP-MySQL Pagination
<?php
// php >= 7.0
function paginate ($total, $per_page, $curr_page)
{
$url = "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$result = [];
$result['html'] = '<div class="pagination">';
$result['offset'] = ($curr_page - 1) < 0 ? 0 : ($curr_page - 1) * $per_page ;
<?php
/*
* Resize images dynamically using wp built in functions
* @author Victor Teixeira
* @link http://core.trac.wordpress.org/ticket/15311
*
* php 5.2+
*
* Exemple use:
/*
Just add this JS code in you HTML however you want. it will check all kinds of AdBlocker with JS
*/
var adBlockEnabled = false;
var testAd = document.createElement('div');
testAd.innerHTML = '&nbsp;';
testAd.className = 'adsbox';
document.body.appendChild(testAd);
window.setTimeout(function() {
if (testAd.offsetHeight === 0) {