Skip to content

Instantly share code, notes, and snippets.

# basic pfctl control
# ==
# Related: http://www.OpenBSD.org
# Last update: Tue Dec 28, 2004
# ==
# Note:
# this document is only provided as a basic overview
# for some common pfctl commands and is by no means
# a replacement for the pfctl and pf manual pages.
@shakhmehedi
shakhmehedi / word_press_cheatsheet.md
Created January 20, 2017 10:12
WordPress cheatsheet

#remove wordpress shortcode from post_content if get the content directly from database

$content = preg_replace("[\[([^\[\]]*)\]]", '', $content);

#Remove htmltags from content

$content = strip_tags($content);
@shakhmehedi
shakhmehedi / magento2_how_to_get_a_module_file_system_path.php
Created September 24, 2016 22:39
Magento 2: How to get a module filesystem path programmatically From https://mage2.pro/t/topic/57
/**
* @param string $moduleName
* @param string $type [optional]
* @return string
* @throws \InvalidArgumentException
*/
function df_module_dir($moduleName, $type = '') {
/** @var \Magento\Framework\ObjectManagerInterface $om */
$om = \Magento\Framework\App\ObjectManager::getInstance();
/** @var \Magento\Framework\Module\Dir\Reader $reader */
@shakhmehedi
shakhmehedi / ubuntu-16.md
Created September 23, 2016 18:34
Ubuntu 16.04: Add environment variable globally permanantly

For this example I have used magento2 cli. Asuming magento2 cli is located in /var/www/magento2/bin.

#create the script file
echo "export PATH=$PATH:/var/www/magento2/bin" > /etc/profile.d/magento2_bin.sh

#run the file to load 
source /etc/profile.d/magento2_bin.sh
@shakhmehedi
shakhmehedi / magento2_quick_reference.md
Last active September 22, 2016 03:01
Magento 2: Quick References

#Install Magento cli glovally

export PATH=$PATH:/var/www/html/magento2/bin

#Enable Disable Maintanance mode Enable or disable maintenance mode

magento maintenance:enable [--ip=<ip address> ... --ip=<ip address>] | [ip=none]
magento maintenance:disable [--ip=<ip address> ... --ip=<ip address>] | [ip=none]
magento maintenance:status
@shakhmehedi
shakhmehedi / install_mailhog_on_ubuntu_16.04.md
Last active November 8, 2018 10:19
Install MailHog on Ubuntu 16.04

#Prerequisit

Install Go programming language and Configure home directory for Go language

Digital Ocean Doc

cd ~
curl -O https://storage.googleapis.com/golang/go1.6.linux-amd64.tar.gz
tar xvf go1.6.linux-amd64.tar.gz
sudo chown -R root:root ./go
sudo mv go /usr/local
@shakhmehedi
shakhmehedi / git_amend_old_commit.md
Created September 12, 2016 23:23
Git Amend Old commit

Source stackoverflow.com
#Use the awesome interactive rebase:

git rebase -i @~9   # Show the last 9 commits in a text editor

Find the commit you want, change pick to e (edit), and save and close the file. Git will rewind to that commit, allowing you to either:

  1. use git commit --amend to make changes, or
  2. use git reset @~ to discard the last commit, but not the changes to the files (i.e. take you to the point you were at when you'd edited the files, but hadn't committed yet). The latter is useful for doing more complex stuff like splitting into multiple commits.
@shakhmehedi
shakhmehedi / bash_backup_all_mysql_databases.sh
Created September 2, 2016 19:00
Bash scripts to backup all databases in a MySQL server with the option to exclude some databases.
#!/usr/bin/env bash
#This script backups selected databases in local MySQL server
#REQUIREMENTS
##mysqldump gzip
##mysql database has no root password. This script uses 'root' MySQL user without password as no 'root' password is set.
##This is not good practice. User with more restrictive permission should be used.
#set database user
@shakhmehedi
shakhmehedi / mysql_command_examples.md
Created September 1, 2016 15:19
MySQL Command Examples

MySQL Command Examples

#Stored procedure and function ##Bulk delete stored procedure

delete from mysql.proc WHERE db LIKE 'yourDbName';

##mysqldump/backup stored procedure only