Skip to content

Instantly share code, notes, and snippets.

View asharirfan's full-sized avatar

Ashar Irfan asharirfan

View GitHub Profile
@asharirfan
asharirfan / ip-geolocation-api-endpoint
Created August 9, 2018 15:48
IP Geolocation API HTTP Request
https://geoipify.whoisxmlapi.com/api/v1?apiKey=YOUR_API_KEY&ipAddress=IP_ADDRESS_TO_BE_QUERIED
@asharirfan
asharirfan / sample-app.bash
Created August 9, 2018 16:58
Create a new NodeJS App quickly
npm init -y
@asharirfan
asharirfan / install-simple-geoip.bash
Created August 9, 2018 17:01
Install simple-geoip NPM package
npm install simple-geoip --save
@asharirfan
asharirfan / simple-geoip.js
Created August 9, 2018 17:12
Query GeoIP Lookup of an IP Address using simple-geoip
// 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('8.8.8.8', (err, data) => {
if (err) throw err; // Look for errors (if any).
console.log(data); // Dump the results to the log.
@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.

@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
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 / 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 / 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 / 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();