Skip to content

Instantly share code, notes, and snippets.

View asharirfan's full-sized avatar

Ashar Irfan asharirfan

View GitHub Profile
@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 / 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 / custom-permalink-from-meta.php
Created September 6, 2017 11:52 — forked from petenelson/custom-permalink-from-meta.php
WordPress permalink for custom post type based on post meta
@asharirfan
asharirfan / webhook-mailer.php
Created March 13, 2017 08:03 — forked from boucher/webhook-mailer.php
Stripe Webhook PHP Example
<?php
// SETUP:
// 1. Customize all the settings (stripe api key, email settings, email text)
// 2. Put this code somewhere where it's accessible by a URL on your server.
// 3. Add the URL of that location to the settings at https://manage.stripe.com/#account/webhooks
// 4. Have fun!
// set your secret key: remember to change this to your live secret key in production
// see your keys here https://manage.stripe.com/account
@asharirfan
asharirfan / single-vr_rental.js
Created August 24, 2016 13:56 — forked from ahmadawais/single-vr_rental.js
Owl Carousel: Dynamic Image Pagination on Click
/**
* Click on the pagination thumbnail
* to drag the owlcarosel to a particular clicked image
* and highlight its thumbnail.
*
* @author Ahmad Awais
* @since 1.0.0
*/
$('.vr_carousel__pagDiv').click(function() {
// Efficient $this.
@asharirfan
asharirfan / wp-post-publish-first.php
Created August 2, 2016 09:05 — forked from Jonnyauk/wp-post-publish-first.php
Detect if WordPress post is published for the first time
<?php
/*
* On first publish set a special date in advance in custom field
*/
add_action('transition_post_status','tanc_first_schedule_publish_set',10,3);
function tanc_first_schedule_publish_set($new, $old, $post) {
// REFERENCE
// $new = new post status ('publish')
// $old = old post status ('draft')
@asharirfan
asharirfan / LICENSE-MIT
Created July 31, 2016 13:50 — forked from electricg/LICENSE-MIT
Stopwatch in javascript
Copyright (c) 2010-2015 Giulia Alfonsi <electric.g@gmail.com>
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
@asharirfan
asharirfan / wp-config.php
Last active August 29, 2018 10:38 — forked from ahmadawais/wp-config.php
WP Debug Logging
// Enable WP_DEBUG mode.
define( 'WP_DEBUG', true );
// Enable Debug logging to the /wp-content/debug.log file.
// Create this file yourself.
define( 'WP_DEBUG_LOG', true );
// Disable display of errors and warnings.
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );
@asharirfan
asharirfan / wordpress-default.css
Created February 16, 2016 20:39 — forked from madalinignisca/wordpress-default.css
Default WordPress classes for using with CSS
/**
* Default Body Class Styles
*/
.rtl {}
.home {}
.blog {}
.archive {}
.date {}
.search {}