Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View aslamdoctor's full-sized avatar
💭
Always working but happy to talk 👍

Aslam Doctor aslamdoctor

💭
Always working but happy to talk 👍
View GitHub Profile
@aslamdoctor
aslamdoctor / fix-mobile-nav-height.js
Created April 5, 2024 20:33
Fix 100vh issue on mobile
// First we get the viewport height and we multiple it by 1% to get a value for a vh unit
let vh = window.innerHeight * 0.01;
// Then we set the value in the --vh custom property to the root of the document
document.documentElement.style.setProperty('--vh', `${vh}px`);
// We listen to the resize event
window.addEventListener('resize', () => {
// We execute the same script as before
let vh = window.innerHeight * 0.01;
document.documentElement.style.setProperty('--vh', `${vh}px`);
@aslamdoctor
aslamdoctor / cookieHelper.js
Created February 20, 2024 16:30
Javascript Cookie Helper
// Cookie helper functions
const CookieHelper = {
/**
* Set Cookie.
*
* @param {string} name
* @param {string} value
* @param {string} minutes
*/
setCookie( name, value, minutes ) {
server {
listen 80;
listen [::]:80;
server_name mysite.local;
location / {
proxy_pass http://localhost:3000/;
}
}
@aslamdoctor
aslamdoctor / settings.json
Last active April 19, 2023 07:51
PHPCBF VSCode Settings for WordPress
# For Normal Theme
{
"phpsab.standard": "WordPress",
"phpsab.executablePathCBF": "/Users/aslamdoctor/.composer/vendor/bin/phpcbf",
"editor.formatOnSave": true,
"scss.validate": false,
"[javascriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
@aslamdoctor
aslamdoctor / wp-delete-spam-users.php
Created January 17, 2023 09:03
Delete Spam Users from WordPress
<?php
add_action(
'init',
function() {
if ( isset( $_GET['cleanup_spams'] ) ) {
global $wpdb;
$query = "SELECT *
FROM $wpdb->users
WHERE user_email LIKE '%.be'";
$users = $wpdb->get_results( $query );
@aslamdoctor
aslamdoctor / coordinatestoname.js
Created December 27, 2022 03:26 — forked from AmirHossein/coordinatestoname.js
Get City and Country name by coordinates via Google Maps api
// Demo: http://jsfiddle.net/xuyp8qb5/
// Note: You need Google Map API Key to run demo; bit.ly/2pBgToW
var latlng;
latlng = new google.maps.LatLng(40.730885, -73.997383); // New York, US
//latlng = new google.maps.LatLng(37.990849233935194, 23.738339349999933); // Athens, GR
//latlng = new google.maps.LatLng(48.8567, 2.3508); // Paris, FR
//latlng = new google.maps.LatLng(47.98247572667902, -102.49018710000001); // New Town, US
//latlng = new google.maps.LatLng(35.44448406385493, 50.99001635390618); // Parand, Tehran, IR
//latlng = new google.maps.LatLng(34.66431108560504, 50.89113940078118); // Saveh, Markazi, IR
// Get The Page ID You Need
get_option( 'woocommerce_shop_page_id' );
get_option( 'woocommerce_cart_page_id' );
get_option( 'woocommerce_checkout_page_id' );
get_option( 'woocommerce_pay_page_id' );
get_option( 'woocommerce_thanks_page_id' );
get_option( 'woocommerce_myaccount_page_id' );
get_option( 'woocommerce_edit_address_page_id' );
get_option( 'woocommerce_view_order_page_id' );
get_option( 'woocommerce_terms_page_id' );
@aslamdoctor
aslamdoctor / index.html
Last active October 6, 2022 07:16
Swiper JS Integration
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swiper@8/swiper-bundle.min.css" />
<script src="https://cdn.jsdelivr.net/npm/swiper@8/swiper-bundle.min.js"></script>
<div class="swiper">
<div class="swiper-wrapper">
<div class="swiper-slide">
Slide 1
</div>
<div class="swiper-slide">
Slide 2
@aslamdoctor
aslamdoctor / index.html
Created October 5, 2022 02:37
Readmore.js Integration
<script src="https://cdnjs.cloudflare.com/ajax/libs/Readmore.js/2.0.2/readmore.min.js" integrity="sha512-llWtDR3k09pa9nOBfutQnrS2kIEG7M6Zm7RIjVVLNab1wRs8NUmA0OjAE38jKzKeCg+A3rdq8AVW41ZTsfhu5Q==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
@aslamdoctor
aslamdoctor / php-mysql-crud-class.php
Last active August 29, 2022 07:13
Very Simple CRUD Class using PHP
<?php
class CRUD {
protected $conn;
protected $tablename = 'MY_DEFAULT_TABLENAME';
function __construct() {
$this->conn = new mysqli( 'HOST', 'USERNAME', 'PASSWORD', 'DB_NAME' );
if ( $this->conn->connect_error ) {
die( $this->conn->connect_error );