Skip to content

Instantly share code, notes, and snippets.

Utkarsh Patel PatelUtkarsh

Block or report user

Report or block PatelUtkarsh

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@PatelUtkarsh
PatelUtkarsh / dnsmasq.conf
Last active Apr 1, 2019
stubby cloudflare ipv4 and ipv6
View dnsmasq.conf
no-resolv
proxy-dnssec
server=::1#5353
server=127.0.0.1#5353
listen-address=::1,127.0.0.1
# Put any other line here like laravel valet using .test domain.
address=/.test/127.0.0.1
@PatelUtkarsh
PatelUtkarsh / snippet.js
Last active Feb 26, 2019
Get all hostname from homepage <a>
View snippet.js
var anchors = document.querySelectorAll('a');
var hosts = new Set();
anchors.forEach((anch) => {
hosts.add(anch.hostname);
});
console.table(Array.from(hosts));
View class-demo.php
<?php
/**
* The Demo class.
*
* @package xyz
*/
namespace UtkarshPatel\Demo
/**
@PatelUtkarsh
PatelUtkarsh / easyengine-cask.rb
Last active Nov 23, 2018
Easyengine Brew core and cask formula
View easyengine-cask.rb
cask 'easyengine' do
version '4.0.0'
homepage 'https://easyengine.io/'
url 'https://github.com/EasyEngine/easyengine/releases/download/v4.0.0/easyengine.phar'
sha256 '5d7f7ec95911883240717458024f0e7c69309f7bd3646353a0594e1b0900eaa6'
name 'Easyengine'
depends_on formula: 'php'
depends_on cask: 'docker'
container type: :naked
@PatelUtkarsh
PatelUtkarsh / notify.sh
Last active Jan 3, 2019
Get notification when internet is up, This uses pushbullet api.
View notify.sh
function notifynet(){
isdown=0
echo "Pres CTRL+C to stop..."
while :
do
sleep 5
if [ $(ping -q -c 1 -W 1 8.8.4.4 >/dev/null) ]; then
echo -n "1"
if [ $isdown -eq 1 ]; then
isdown=0
@PatelUtkarsh
PatelUtkarsh / fix-symlink-url.php
Last active Oct 29, 2018
Fix url when wp-content and mu-plugins are added as symlink.
View fix-symlink-url.php
@PatelUtkarsh
PatelUtkarsh / class-migrate.php
Last active Jun 28, 2018
Custom table to WordPress schema migration base class proof of concept. NOT TESTED.
View class-migrate.php
<?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 Dec 24, 2018
Git cheat sheet shallow clone
View readme.md

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 Oct 29, 2018
Valet share url fix for WordPress with https support
View wp-config.php
<?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.php
Last active Nov 18, 2018
Send pushbullet msg on website hit.
View index.php
<?php
/**
* Send pushbullet msg on website hit.
* Author: Utkarsh Patel (github.com/patelutkarsh)
*
* Usage: push.example.com?msg=webpush&title=Awesome&secret=SecretForAuthReplaceME
*/
// If unauthorized user kick him.
if ( ! isset( $_GET['secret'] ) || 'SecretForAuthReplaceME' !== $_GET['secret'] ) {
You can’t perform that action at this time.