Skip to content

Instantly share code, notes, and snippets.

View azizultex's full-sized avatar
🌍
Working from anywhere 😊

Azizul Haque azizultex

🌍
Working from anywhere 😊
View GitHub Profile
@azizultex
azizultex / Can't connect to local MySQL server through socket
Created October 17, 2018 04:48
Can't connect to local MySQL server through socket '/usr/local/ampps/var/mysql.sock' (111) Ampps ubuntu error
// resource:
// 1. https://www.zyxware.com/articles/5539/solved-cant-connect-to-local-mysql-server-through-socket-var-run-mysqld-mysqld-sock
sudo service mysql start
or
/etc/init.d/mysql start
ps -A|grep mysql
sudo pkill mysql
@azizultex
azizultex / Download or fetch remote image files from base link and file names
Last active October 13, 2018 07:02
Download or fetch remote image files from base link and file names file_get_contents file_put_contents
@azizultex
azizultex / Linux Commands
Last active March 14, 2019 05:16
Repo that stores al the commands I used while using Linux system
// CREATE, ADD, PERMIT, AND CHECK A USER TO A GROUP
1. adduser username // 'username' is your expected username and follow the prompts to set the new user's information.
2. sudo usermod -aG docker ${USER} // 'docker' is group name. If you need to add a user to the docker group that you're not logged in as, declare that username "${USER}" explicitly using.
3. su - ${USER} // Use the su command to switch to the new user account.
4. id -nG // Confirm that your user is now added to the docker group by typing. It will list all the groups of this user
// SEARCH INSTALLED PACKAGES USING KEYWORD
dpkg -l | grep -i docker
// UNINSTALL A PROGRAM COMPLETELY
@azizultex
azizultex / git-commands
Last active September 24, 2019 06:28
Git commands
# Delete everything and upload new version
# resource: https://stackoverflow.com/questions/11071420/delete-everything-and-upload-new-version#11072408
git fetch
git merge -s ours origin/master --allow-unrelated-histories
git push origin master
# ignore remote files and push new files and updates to remote
git push --force origin master
@azizultex
azizultex / mysql-user-permission.txt
Created June 5, 2017 03:51
Fixing MySQL user permission issue
sudo chown -R _mysql:wheel /usr/local/mysql/data
sudo /usr/local/mysql/support-files/mysql.server restart
@azizultex
azizultex / generate_video_embed_url.php
Created April 24, 2017 17:21
Generate Youtube and Vimeo Video Embed URL dynamically
/**
* get youtube video ID from URL
* http://stackoverflow.com/questions/6556559/youtube-api-extract-video-id
* @param string $url
* @return string Youtube video id or FALSE if none found.
*/
function youtube_id_from_url($url) {
$pattern =
'%^# Match any youtube URL
(?:https?://)? # Optional scheme. Either http or https
@azizultex
azizultex / Custom Search and Category Widgets WordPress
Last active March 3, 2017 05:05
Custom Search and Category Widgets WordPress
/*
WEBSITE : http://www.oldstructures.com/tag/projects/
*/
/* customer search form for widgets azizultex */
add_filter('widget_text','do_shortcode');
/* search form shortcode that populate tag automatically by tag page */
function searchFormByTag() {
@azizultex
azizultex / Get Categories by Tag
Last active March 3, 2017 05:06
Get Categories by Tag
/*
WEBSITE : http://www.oldstructures.com/tag/projects/
*/
/* get categories related to tags */
function categoriesbytags_func() {
$tag = get_queried_object();
$args = array(
'tag' => $tag->slug,
@azizultex
azizultex / Custom Post Type URL Rewrite Made Easy!
Created March 1, 2017 09:38
Custom Post Type URL Rewrite Made Easy!
/*
You can rewrite custom post type links anyway you want following below code. I have completely replaced CPT slug with a custom metabox field for each post type.
Resources:
1. http://wordpress.stackexchange.com/questions/83531/custom-post-type-404s-with-rewriting-even-after-resetting-permalinks
2. http://shibashake.com/wordpress-theme/custom-post-type-permalinks-part-2
*/
/* Register Custom Post Type */
function viz360_project_post_type() {
@azizultex
azizultex / Override a plugin shortcode in WordPress
Last active September 3, 2023 20:29
Override a plugin shortcode in WordPress
Best way to override a plugin function is to use mu-plugins (Must Use Plugins)
https://gregrickaby.com/2013/10/create-mu-plugin-for-wordpress/#comment-14420
Aleternatively, follow below :
1. Copy the plugin shortcode function and put it anywhere in Child Theme and rename it like custom_cs_user_login_shortcode.
2. use 'wp_head' action to remove the plugin shortcode and register the new shortcode again with the new function name like custom_cs_user_login_shortcode.
/*********************************************