Skip to content

Instantly share code, notes, and snippets.


Ashar Irfan asharirfan

Block or report user

Report or block asharirfan

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
asharirfan / SampleSensor.php
Created Sep 11, 2019
Template for a new sensor for WP Security Audit Log (WordPress) plugin.
View SampleSensor.php
* Sample sensor.
* @package wsal
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
asharirfan / wfcm-clear-notifications.php
Last active Jun 3, 2019
Clear the file changes notifications of WFCM plugin on activation.
View wfcm-clear-notifications.php
* Plugin Name: WFCM Clear Notifications
* Plugin URI:
* Description: Clear the file changes notifications of WFCM plugin.
* Author: mrasharirfan
* Contributors: WP White Security, mrasharirfan
* Version: 1.0
* Text Domain: wfcm-clear-notifications
* Author URI:
asharirfan / dbtest.php
Last active May 2, 2019
💾 DB Connectivity Tests
View dbtest.php
* DB Connectivity Tests
* @package dbtest
// Define database constants.
asharirfan / freemius-opt-in-out.php
Created Feb 13, 2019
Custom Freemius Opt-in/out Code Snippet.
View freemius-opt-in-out.php
// $choice contains the user's input to opt-in or out.
if ( 'yes' === $choice ) {
if ( ! is_multisite() ) {
my_freemius()->opt_in(); // Opt in.
} else {
// Get all sites on the WP multisite network.
$sites = Freemius::get_sites();
$sites_data = array();
asharirfan / regexCheatsheet.js
Created Jan 15, 2019 — forked from sarthology/regexCheatsheet.js
A regex cheatsheet 👩🏻‍💻 (by Catherine)
View regexCheatsheet.js
let regex;
/* matching a specific string */
regex = /hello/; // looks for the string between the forward slashes (case-sensitive)... matches "hello", "hello123", "123hello123", "123hello"; doesn't match for "hell0", "Hello"
regex = /hello/i; // looks for the string between the forward slashes (case-insensitive)... matches "hello", "HelLo", "123HelLO"
regex = /hello/g; // looks for multiple occurrences of string between the forward slashes...
/* wildcards */
regex = /h.llo/; // the "." matches any one character other than a new line character... matches "hello", "hallo" but not "h\nllo"
regex = /h.*llo/; // the "*" matches any character(s) zero or more times... matches "hello", "heeeeeello", "hllo", "hwarwareallo"
asharirfan / wp-session-example.php
Last active Dec 27, 2018
WP Session Entry Example.
View wp-session-example.php
* WP Session Entry Example.
$wp_session_entry = array(
'a97941ac30b27091e9016f9fbe2a16a798a5dd17d7db58235890107bb6ce485f' => array( // User Session Token.
'expiration' => 1545975258 // Session Expiration Timestamp.
'ip' => '' // IP Address of the User.
'ua' => 'Mozilla/5.0 (Macintosh...' // User Agent.
'login' => 1545802458 // Login Timestamp.
asharirfan /
Created Nov 15, 2018
🎯 How to rename a Git branch

Rename your local branch.

If you are on the branch you want to rename:

git branch -m new-name

If you are on a different branch:

git branch -m old-name new-name

Delete the old-name remote branch and push the new-name local branch.

git push origin :old-name new-name

asharirfan / .zshrc
Created Nov 5, 2018
🏎 Sync fork in seconds with zsh alias and function
View .zshrc
# Alias for adding upstream remote.
# Usage: grau
alias grau="git remote add upstream"
# Function to sync fork with upstream remote.
function gsyncfork() {
git fetch upstream
git pull upstream master
git push origin master
asharirfan /
Last active Oct 17, 2018
How to Generate a Static Website Using GatsbyJS & Host the Website on Linode Server

How to Generate a Static Website Using GatsbyJS & Host the Website on Linode Server

  • Login to & create a linode server.

  • Install Ubuntu Latest LTS — Long Term Support — version on it.

  • Login to the server using SSH.

  • Install easy engine on it.

asharirfan / simple-geoip.js
Created Aug 9, 2018
Query GeoIP Lookup of an IP Address using simple-geoip
View simple-geoip.js
// Include the package.
const simpleGeoIP = require('simple-geoip');
// Create a new instance of the package using your API key.
let geoIP = new simpleGeoIP('YOUR_API_KEY');
// Send a request for GeoIP lookup.
geoIP.lookup('', (err, data) => {
if (err) throw err; // Look for errors (if any).
console.log(data); // Dump the results to the log.
You can’t perform that action at this time.