Skip to content

Instantly share code, notes, and snippets.

View asharirfan's full-sized avatar

Ashar Irfan asharirfan

View GitHub Profile
@asharirfan
asharirfan / guq-view-export-users.php
Last active February 11, 2020 07:59
GUQ Drupal View Export Source Users
$view = new view();
$view->name = 'users_data';
$view->description = 'List, add, and edit users.';
$view->tag = 'admin';
$view->base_table = 'users';
$view->human_name = 'Users Data';
$view->core = 0;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
@asharirfan
asharirfan / SampleSensor.php
Created September 11, 2019 11:28
Template for a new sensor for WP Security Audit Log (WordPress) plugin.
<?php
/**
* Sample sensor.
*
* @package wsal
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
@asharirfan
asharirfan / wfcm-clear-notifications.php
Last active June 3, 2019 09:52
Clear the file changes notifications of WFCM plugin on activation.
<?php
/**
* Plugin Name: WFCM Clear Notifications
* Plugin URI: http://www.wpwhitesecurity.com/
* 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: https://asharirfan.com/
@asharirfan
asharirfan / dbtest.php
Last active May 2, 2019 08:58
💾 DB Connectivity Tests
<?php
/**
* DB Connectivity Tests
*
* @package dbtest
*/
// Define database constants.
define( 'DBTEST_HOST', 'localhost' ); // REPLACE THE CONSTANT VALUE WITH YOUR HOST.
define( 'DBTEST_USER', 'root' ); // REPLACE THE CONSTANT VALUE WITH YOUR USERNAME.
@asharirfan
asharirfan / freemius-opt-in-out.php
Created February 13, 2019 06:48
Custom Freemius Opt-in/out Code Snippet.
<?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
asharirfan / regexCheatsheet.js
Created January 15, 2019 09:51 — forked from sarthology/regexCheatsheet.js
A regex cheatsheet 👩🏻‍💻 (by Catherine)
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
asharirfan / wp-session-example.php
Last active December 27, 2018 05:28
WP Session Entry Example.
<?php
/**
* WP Session Entry Example.
*/
$wp_session_entry = array(
'a97941ac30b27091e9016f9fbe2a16a798a5dd17d7db58235890107bb6ce485f' => array( // User Session Token.
'expiration' => 1545975258 // Session Expiration Timestamp.
'ip' => '172.17.0.1' // IP Address of the User.
'ua' => 'Mozilla/5.0 (Macintosh...' // User Agent.
'login' => 1545802458 // Login Timestamp.
@asharirfan
asharirfan / ReadMe.md
Created November 15, 2018 10:55
🎯 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
asharirfan / .zshrc
Created November 5, 2018 14:47
🏎 Sync fork in seconds with zsh alias and function
# Alias for adding upstream remote.
# Usage: grau https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git
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
asharirfan / ReadMe.md
Last active June 10, 2022 17:10
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 https://www.linode.com & 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.