Skip to content

Instantly share code, notes, and snippets.

View mhasan3's full-sized avatar
🎯
Focusing

Mahmudul Hasan mhasan3

🎯
Focusing
View GitHub Profile
@mhasan3
mhasan3 / amp-google-tag-manager.php
Created October 23, 2019 05:10 — forked from westonruter/amp-google-tag-manager.php
Plugin demonstrating how to inject GTM for the AMP plugin, in response to support forum topic: https://wordpress.org/support/topic/amp-with-google-tag-manager/
<?php
/**
* Plugin Name: AMP Google Tag Manager
*
* @package AMP_Google_Tag_Manager
* @author Weston Ruter, Google
* @license GPL-2.0-or-later
* @copyright 2019 Google Inc.
*
* @wordpress-plugin
@mhasan3
mhasan3 / youtube_id_regex.php
Created September 21, 2019 09:58 — forked from ghalusa/youtube_id_regex.php
Extract the YouTube Video ID from a URL in PHP
<?php
// Here is a sample of the URLs this regex matches: (there can be more content after the given URL that will be ignored)
// http://youtu.be/dQw4w9WgXcQ
// http://www.youtube.com/embed/dQw4w9WgXcQ
// http://www.youtube.com/watch?v=dQw4w9WgXcQ
// http://www.youtube.com/?v=dQw4w9WgXcQ
// http://www.youtube.com/v/dQw4w9WgXcQ
// http://www.youtube.com/e/dQw4w9WgXcQ
// http://www.youtube.com/user/username#p/u/11/dQw4w9WgXcQ
{
"type": "email",
"customer": {
"email": "{{customer.email}}",
"firstName":"{{customer.firstName}}",
"lastName":"{{customer.lastName}}"
},
"subject": "Low NPS rating from customer {{customer.firstName}} {{customer.lastName}}",
"mailbox": {
"id": MAILBOX-ID
@mhasan3
mhasan3 / gist:21823412e872d3fa2109e40be9605fb5
Created June 21, 2018 10:25 — forked from Mikodes/gist:be9b9ce42e46c3d4ccb6
All Media queries for resolutions
/* (320x480) iPhone (Original, 3G, 3GS) */
@media only screen and (min-device-width: 320px) and (max-device-width: 480px) {
/* insert styles here */
}
/* (320x480) Smartphone, Portrait */
@media only screen and (device-width: 320px) and (orientation: portrait) {
/* insert styles here */
}
@mhasan3
mhasan3 / delete-posts.sql
Created May 8, 2018 15:09 — forked from wpsmith/delete-posts.sql
SQL: Delete all posts of a custom post type with its associated meta data (taxonomies, post meta)
DELETE a,b,c
FROM {PREFIX}_posts a
LEFT JOIN {PREFIX}_term_relationships b ON (a.ID = b.object_id)
LEFT JOIN {PREFIX}_postmeta c ON (a.ID = c.post_id)
WHERE a.post_type = 'POST_TYPE' AND a.post_date < '2014-01-01'
@mhasan3
mhasan3 / d8module.install
Created January 26, 2018 13:19 — forked from laradevitt/d8module.install
(Drupal 8) Create a table in a database other than the default during module installation. Database must already be specified in settings.php.
<?php
/**
* @file
* Install, update and uninstall functions for the d8module module.
*/
function d8module_schema_otherdb() {
$schema['mytable'] = array(
'description' => 'My table description',
@mhasan3
mhasan3 / repeatable-fields-metabox.php
Created November 17, 2017 12:31 — forked from helen/repeatable-fields-metabox.php
Repeating Custom Fields in a Metabox
<?
/**
* Repeatable Custom Fields in a Metabox
* Author: Helen Hou-Sandi
*
* From a bespoke system, so currently not modular - will fix soon
* Note that this particular metadata is saved as one multidimensional array (serialized)
*/
function hhs_get_sample_options() {
@mhasan3
mhasan3 / class-tgm-plugin-activation.php
Created September 21, 2017 18:20 — forked from al5dy/class-tgm-plugin-activation.php
TGM 'Warning: sprintf(): Too few arguments...' bugfix
/**
* Sets install skin strings for each individual plugin.
*
* Checks to see if the automatic activation flag is set and uses the
* the proper strings accordingly.
*
* @since 2.2.0
*/
public function add_strings() {
if ( 'update' === $this->options['install_type'] ) {
@mhasan3
mhasan3 / OrganizeFiles.sh
Created July 14, 2017 17:32 — forked from towfiqpiash/OrganizeFiles.sh
Run this shell script to organize files into separate folders
#!/bin/bash
folders='Compressed Documents Images Music Programs Videos'
ext_comp="*.zip *.tar.gz"
ext_doc="*.htm* *.php *.txt *.css *.doc* *.pdf *.PDF *.ppt* *.js"
ext_img="*.jp*g *.JPG *.png *.gif"
ext_music="*.mp3 *.aac *.wma"
ext_progrm="*.deb *.exe *.run"
ext_vid="*.mp4 *.mkv *.flv *.avi *.webm *.wmv"
@mhasan3
mhasan3 / gist:1cee7fb21e76dd9bc9ea1b09ebfbf2df
Created October 15, 2016 17:32 — forked from paulallies/gist:0052fab554b14bbfa3ef
Remove node_modules from git repo
#add 'node_modules' to .gitignore file
git rm -r --cached node_modules
git commit -m 'Remove the now ignored directory node_modules'
git push origin master