Skip to content

Instantly share code, notes, and snippets.

Avatar
💻
Stick with study regardless your situation.

Azizul Haque azizultex

💻
Stick with study regardless your situation.
View GitHub Profile
@azizultex
azizultex / Can't connect to local MySQL server through socket
Created Oct 17, 2018
Can't connect to local MySQL server through socket '/usr/local/ampps/var/mysql.sock' (111) Ampps ubuntu error
View Can't connect to local MySQL server through socket
// 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 Oct 13, 2018
Download or fetch remote image files from base link and file names file_get_contents file_put_contents
View Download or fetch remote image files from base link and file names
@azizultex
azizultex / Linux Commands
Last active Mar 14, 2019
Repo that stores al the commands I used while using Linux system
View Linux Commands
// 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
View 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 Jun 5, 2017
Fixing MySQL user permission issue
View mysql-user-permission.txt
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 Apr 24, 2017
Generate Youtube and Vimeo Video Embed URL dynamically
View generate_video_embed_url.php
/**
* 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 Mar 3, 2017
Custom Search and Category Widgets WordPress
View 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 Mar 3, 2017
Get Categories by Tag
View 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 Mar 1, 2017
Custom Post Type URL Rewrite Made Easy!
View 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 Mar 12, 2019
Override a plugin shortcode in WordPress
View 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.
/*********************************************
You can’t perform that action at this time.