Skip to content

Instantly share code, notes, and snippets.

View asharirfan's full-sized avatar

Ashar Irfan asharirfan

View GitHub Profile
@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 / install-simple-geoip.bash
Created August 9, 2018 17:01
Install simple-geoip NPM package
npm install simple-geoip --save
@asharirfan
asharirfan / sample-app.bash
Created August 9, 2018 16:58
Create a new NodeJS App quickly
npm init -y
@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 / test-db.php
Last active March 15, 2022 20:40
🚀 📦 🔥 Create and test connection to an external database in WordPress using this plugin. ⚠️NOTE: Change the values of the constants according to your database.
<?php
/**
* Plugin Name: WP Test External DB
* Plugin URI: https://asharirfan.com
* Description: Create and test connection to an external WordPress database.
* Author: Ashar Irfan
* Version: 1.0.0
* Text Domain: test-db
* Author URI: https://asharirfan.com/
* License: GPL2
@asharirfan
asharirfan / reset-post-time.php
Created February 11, 2018 17:14
WordPress Plugin — Reset Post Time
<?php
/**
* Plugin Name: Reset Post Time
* Plugin URI: https://github.com/asharirfan/reset-post-time
* Description: WordPress plugin to set the seconds of publish/schedule time of post types to zero.
* Author: mrasharirfan
* Author URI: https://AsharIrfan.com/
* Version: 1.0.0
* License: GPL2+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
@asharirfan
asharirfan / eslint.js.md
Last active September 20, 2024 15:50
Introducing ESLint in your JS workflow

Introducing ESLint in Your JS Workflow

👀 TL;DR

  1. ESLint is a modern linting tool for JS development to make your code consistent and bug free.
  2. Use npm install eslint --global to install ESLint globally.
  3. Go to your project in the terminal and run eslint --init to initiate and setup linting for your project.
  4. Install and automate your workflow in VSCode using ESLint extension.

📦 Step 1: Installation

To install ESLint, you need Node — version greater or equal to 4.0 — and npm — version greater or equal to 2. Open the terminal and enter npm install eslint --global. This command will install ESLint globally in your computer.

@asharirfan
asharirfan / git-commit-emojis.md
Created February 5, 2018 15:51 — forked from jhermann/git-commit-emojis.md
Useful emoji for git commit messages

Useful emoji for git commit messages

If you add emoji to your commit messages for a GitHub repo, they become less boring, and you can convey the kind of change you're adding. See the full set of GitHub supported emoji here (also useful for easy copy&paste via a simple click).

Example commit message

The following is a possible scheme to use:

@asharirfan
asharirfan / tmr-custom-page-settings.php
Created November 27, 2017 15:58
WPC — Settings on a Custom Settings page for Tell My Role plugin 💯
<?php
/**
* Settings Init.
*
* Initialize settings for the plugin.
*
* @since 1.0.0
*/
function tmr_settings_init() {
// Register a new section in the "tmr-options-page" page.
@asharirfan
asharirfan / tmr-print-user-roles-with-setting.php
Created November 27, 2017 14:23
WPC — Print current user roles in WP admin dashboard with Custom Setting 💯
<?php
/**
* Tell My Role.
*
* Get the roles of current user and display it.
*
* @since 1.0.0
*/
function tmr_display_current_user_role() {
// Get current user.