Skip to content

Instantly share code, notes, and snippets.

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

Dhaval Shah dhavalgshah

🏠
Working from home
View GitHub Profile
@dhavalgshah
dhavalgshah / disable-ipv6.sh
Created October 8, 2020 18:05 — forked from kwilczynski/disable-ipv6.sh
Amazon Linux OS tweaks
#!/bin/bash
set -u
set -e
set -o pipefail
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
cat <<'EOF' > /etc/modprobe.d/blacklist-ipv6.conf
@dhavalgshah
dhavalgshah / ttfb.sh
Last active February 18, 2020 16:18
Test time to first byte for specific URL
#!/usr/bin/env sh
# bash ttfb.sh url [num_of_tests]
# bash ttfb.sh https://example.org 11
if [[ -z $@ ]]
then
echo "Pass url and number of test runs to execute. By default 10 tests are executed."
echo "bash ttfb.sh url [num_of_tests]"
echo "E.g: $ bash ttfb.sh https://example.org 10"
@dhavalgshah
dhavalgshah / install_100_most_popular_wp_themes.bash
Created October 5, 2018 14:19
Automate installing most popular 100 themes for WordPress using WordPress.org API and WP-CLI
@dhavalgshah
dhavalgshah / class-wc-admin-duplicate-order.php
Created May 21, 2018 18:39 — forked from gerdneuman/class-wc-admin-duplicate-order.php
Duplicate Order functionality for WooCommerce
<?php
/**
* Duplicate order functionality
*
* @author WooThemes
* @category Admin
* @package WooCommerce/Admin
* @version 2.7.0
*/
@dhavalgshah
dhavalgshah / functions.php
Created May 9, 2018 06:09 — forked from jnlsn/functions.php
WP Query Orderby Taxonomy Term Name
add_filter('posts_clauses', 'posts_clauses_with_tax', 10, 2);
function posts_clauses_with_tax( $clauses, $wp_query ) {
global $wpdb;
//array of sortable taxonomies
$taxonomies = array('example-taxonomy', 'other-taxonomy');
if (isset($wp_query-&gt;query['orderby']) &amp;&amp; in_array($wp_query-&gt;query['orderby'], $taxonomies)) {
$clauses['join'] .= "
LEFT OUTER JOIN {$wpdb-&gt;term_relationships} AS rel2 ON {$wpdb-&gt;posts}.ID = rel2.object_id
LEFT OUTER JOIN {$wpdb-&gt;term_taxonomy} AS tax2 ON rel2.term_taxonomy_id = tax2.term_taxonomy_id
LEFT OUTER JOIN {$wpdb-&gt;terms} USING (term_id)
@dhavalgshah
dhavalgshah / ICS.php
Created April 4, 2018 21:18 — forked from jakebellacera/ICS.php
A convenient script to generate iCalendar (.ics) files on the fly in PHP.
<?php
/**
* ICS.php
* =======
* Use this class to create an .ics file.
*
* Usage
* -----
* Basic usage - generate ics file contents (see below for available properties):
@dhavalgshah
dhavalgshah / patch-xorg-ubuntu-16.04.4.sh
Last active March 6, 2018 04:57
How to patch xorg in ubuntu 16.04.4 (bug of keyboard layout change)
# Bug https://bugs.launchpad.net/ubuntu/+source/xorg-server/+bug/1683383
# Original article https://habrahabr.ru/post/87408/
# @Todo- Automate the version detection
# @Todo- Use version variable in commands below so script don't break when new major or minor versions are released
# create directory
mkdir xorg-server
cd xorg-server
# get sources of required package