Skip to content

Instantly share code, notes, and snippets.

View mujahidi's full-sized avatar

Mujahid Ishtiaq mujahidi

  • Pakistan
View GitHub Profile
@mujahidi
mujahidi / download-upload-file-folder-commands.txt
Last active March 4, 2019 20:57
Download/Upload file/folder through terminal commands
#Download File
scp user@host:/path/to/remote-file-to-download local-copy-of-file
#Download Folder
scp -r user@host:/path/to/remote-folder-to-download local-copy-of-folder
#Upload File
scp local-file user@host:/path/to/destination-where-local-file-is-uploaded
#Upload Folder
@mujahidi
mujahidi / highest-value-in-wp-post-meta.php
Created May 25, 2018 21:58
Get the highest value from WordPress post meta
<?php
// WordPress saves post meta values as 'longtext' type
// and hence, it makes it impossible to fetch the highest value based on a number.
// So I came up with the following solution to get the highest value from the post meta
// CHANGE [YOUR_META_KEY] with yours post meta key
global $wpdb;
$highest_val = $wpdb->get_var( "SELECT
meta_value
FROM
@mujahidi
mujahidi / wp_user_query_pagination.php
Created May 29, 2018 12:49
Pagination with WP_User_Query object
<?php
// number of users we want to show per page
$number = 10;
// to pinpoint the current pagination number
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
// count the number of users that should be passed over in the pages (offset) – this will take effect at the second page onwards.
$offset = ($paged - 1) * $number;
@mujahidi
mujahidi / index.html
Created September 26, 2018 19:26
Sticky Sidebar
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<script src="https://code.jquery.com/jquery-3.1.0.js"></script>
<title>JS Bin</title>
<style id="jsbin-css">
.head, .foot{
background: #ccc;
@mujahidi
mujahidi / google-maps-api-marker-arrow.css
Created October 10, 2018 17:22
Change Google Maps marker arrow's position using css
.gm-style div div:nth-child(3) div div div div:nth-child(1) div:nth-child(1){ position: static !important; }
.gm-style div div:nth-child(3) div div div div:nth-child(1) div:nth-child(3){ display: none !important; }
.gm-style .gm-style-iw{ overflow: visible; }
.gm-style .gm-style-iw::before {
content: "\f141";
position: absolute;
top: -7px;
left: -47px;
font-family: 'dashicons';
font-size: 50px;
@mujahidi
mujahidi / bitnami-fix-cache.txt
Created February 13, 2019 15:33
FIX BITNAMI WEIRD CACHE ISSUE:
FIX BITNAMI WEIRD CACHE ISSUE:
1)Comment out these lines in /opt/bitnami/apache2/conf/httpd.conf using # in front of these 2:
Include conf/pagespeed.conf
Include conf/pagespeed_libraries.conf
2) PHP has Op Cache enabled by these lines in sudo nano /opt/bitnami/php/etc/php.ini
opcache.enable=1
@mujahidi
mujahidi / responsive-images.css
Created March 26, 2019 20:51
Responsive Images
.myImg {
object-fit: cover; /* also works for videos. Can also use contain*/
width: 320px;
height: 180px;
}
/* The Netflix Way */
/*
this one works everywhere and it is my favorite! You’ll need to wrap your image with a relative padded parent.
@mujahidi
mujahidi / functions.php
Created May 3, 2019 16:17
Remove class hook in WordPress
<?php
function remove_class_hook( $tag, $class_name = '', $method_name = '', $priority = 10 ) {
global $wp_filter;
$is_hook_removed = false;
if ( ! empty( $wp_filter[ $tag ]->callbacks[ $priority ] ) ) {
$methods = wp_list_pluck( $wp_filter[ $tag ]->callbacks[ $priority ], 'function' );
$found_hooks = ! empty( $methods ) ? wp_list_filter( $methods, array( 1 => $method_name ) ) : array();
foreach( $found_hooks as $hook_key => $hook ) {
if ( ! empty( $hook[0] ) && is_object( $hook[0] ) && get_class( $hook[0] ) === $class_name ) {
@mujahidi
mujahidi / acf-user-field-type.php
Created May 6, 2020 17:09
Querying posts by ACF User field type
<?php
$search_value = 'xyz'; // whatever
$field_value = sprintf( '^%1$s$|s:%2$u:"%1$s";', $search_value, strlen( $search_value ) );
$args = array(
'post_type' => 'post',
'meta_query' => array(
array(
'key' => 'user_field',
'value' => $field_value,
@mujahidi
mujahidi / vimeo-video.html
Last active November 23, 2021 21:06
Vimeo background video inside container
<div class="video-container">
<div class="another-container">
<iframe src="https://player.vimeo.com/video/VIMEO-ID?background=1" width="640" height="360" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
</div>
</div>
<style>
.video-container{ height: 550px; overflow: hidden; }
.another-container{ height:0; overflow:hidden; position: relative; padding-bottom: 56.25%; /* 16:9 */ }
#mobile_video_container iframe{