Skip to content

Instantly share code, notes, and snippets.

View PatelUtkarsh's full-sized avatar
🧘

Utkarsh Patel PatelUtkarsh

🧘
View GitHub Profile
@PatelUtkarsh
PatelUtkarsh / dnsmasq.conf
Last active June 20, 2022 00:23
stubby cloudflare ipv4 and ipv6
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 February 26, 2019 15:44
Get all hostname from homepage <a>
var anchors = document.querySelectorAll('a');
var hosts = new Set();
anchors.forEach((anch) => {
hosts.add(anch.hostname);
});
console.table(Array.from(hosts));
@PatelUtkarsh
PatelUtkarsh / class-demo.php
Last active December 5, 2018 08:31
Singletone trait
<?php
/**
* The Demo class.
*
* @package xyz
*/
namespace UtkarshPatel\Demo
/**
@PatelUtkarsh
PatelUtkarsh / easyengine-cask.rb
Last active November 23, 2018 16:22
Easyengine Brew core and cask formula
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 January 3, 2019 01:54
Get notification when internet is up, This uses pushbullet api.
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 October 29, 2018 11:03
Fix url when wp-content and mu-plugins are added as symlink.
@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) {