Skip to content

Instantly share code, notes, and snippets.

View PatelUtkarsh's full-sized avatar
🧘

Utkarsh Patel PatelUtkarsh

🧘
View GitHub Profile
@PatelUtkarsh
PatelUtkarsh / class-migrate.php
Last active June 28, 2018 13:05
Custom table to WordPress schema migration base class proof of concept. NOT TESTED.
<?php
/**
* Migration Abstract class.
*
* Should inherit this class and all documented class variable must overwrite in child class for this to work.
*
* @package rtCamp
*/
namespace rtCamp\TableMigrate;
@PatelUtkarsh
PatelUtkarsh / readme.md
Last active May 9, 2022 20:52
Git cheat sheet shallow clone

All i know about shallow clone

Usecases:

  • For all readonly purpose this works great.
  • For big repo like linux project, mozilla firefox or WordPress like project it's really boring to wait for git to fetch all refs since we rearely needs all refs (if you know you're not gonna need).
  • You can contribute even after shallow clone but it works only in somecases mentioned below.

Fetch only one commit

git clone -b master git_url --depth 1
@PatelUtkarsh
PatelUtkarsh / wp-config.php
Last active October 29, 2018 08:24
Valet share url fix for WordPress with https support
<?php
/**
* Add this block in wp-config.php file.
*
* Move any other `WP_HOME` or `WP_SITEURL` in else condition if present.
*/
if ( isset( $_SERVER['HTTP_X_ORIGINAL_HOST'] ) ) {
$is_ssl = isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] );
$actual_link = ( $is_ssl ? "https" : "http" ) . "://{$_SERVER[ 'HTTP_X_ORIGINAL_HOST' ]}";
define( 'WP_HOME', $actual_link );
@PatelUtkarsh
PatelUtkarsh / index.js
Last active January 14, 2020 06:01
Send pushbullet msg on website hit.
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
/**
* Respond to the request
* @param {Request} request
*/
async function handleRequest(request) {
@PatelUtkarsh
PatelUtkarsh / backup-sites.sh
Last active February 7, 2017 10:52
Backing up small wp site with DB
#!/bin/bash
# Generate your Dropbox token: https://www.dropbox.com/developers/apps
DROPBOX_TOKEN={dropbox access token here}
# Directory that holds your WordPress sites' root folders
PREFIX=/var/www
# If you have multiple folders with WordPress sites, add/remove them from this array
directories=( "foo.com" "bar.com" )
@PatelUtkarsh
PatelUtkarsh / execute-wp-cron.sh
Last active July 10, 2016 08:25
Running wp-cron with wp-cli
#!/bin/bash
WP_PATH="/path/to/wp"
# Check for WP-CLI
if ! hash wp 2>/dev/null; then
echo "WP-CLI is not available"
exit
fi

Keybase proof

I hereby claim:

  • I am patelutkarsh on github.
  • I am utkarshpatel (https://keybase.io/utkarshpatel) on keybase.
  • I have a public key ASBj2OJgHP6USNvVqXiGww94HtJgp8r0cPz2lnnl5PBn_Qo

To claim this, I am signing this object:

@PatelUtkarsh
PatelUtkarsh / ee-vip-go-local.sh
Created May 11, 2016 05:54
Setup vip-go in local environment for site which are already created with easyengine.
#!bin/bash
#
# NOTE:This file takes param as site name for
#
# This script currenty only works with easyengine.
#
# What this does essentially is clones mu-plugin repo of vip-mu-plugins-public
# and write nginx rule to handle static files via php.
#
# WARNING: This does not match extact vip go environment like php version and stuff
@PatelUtkarsh
PatelUtkarsh / phpcs.md
Created April 29, 2016 12:54
PHPCS for Linux

Installation

Install PEAR

sudo apt-get install php-pear

Install PHP_CodeSniffer

@PatelUtkarsh
PatelUtkarsh / search_columns.sql
Created March 15, 2016 12:30
Search mysql database columns
SELECT DISTINCT TABLE_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME LIKE '%awesome%'
AND TABLE_SCHEMA='YourDatabase';