Skip to main content

Posts

Showing posts from 2020

(Docker Solved) Post-processing of the image failed likely because the server is busy or does not have enough resources ERROR

Hi All!   Photo by Markus Spiske on Unsplash   Post-processing of the image failed likely because the server is busy or does not have enough resources. Encountered this issue, when uploading media files to my 4nutz.tk website! To solve this issue it might comes from PHP setting and Nginx settings. Thus i took the chance to fix both!   Fix PHP settings First i increased the minimum size file upload in PHP settings by introducing new php.ini / uploads.ini file link to local file to the wordpress container  example in docker.yaml file setting.   wordpress:     depends_on:       - db     image: wordpress:5.1.1-fpm-alpine     container_name: anutz_wordpress     restart: unless-stopped     env_file: .env     environment:       - WORDPRESS_DB_HOST=db:3306       - WORDPRESS_DB_USER=$MYSQL_USER   ...

Git push changes to remote repo issue on different port

 Taking security precaution I have changed the SSH access port on my DO droplet. Recently as i have setup the docker Wordpress stack in the droplet an i wanted to keep track the version changes by pushing to git remote repo.      Unfortunately i encountered error.    xxx@ubuntuxxxx:~/wordpress$ git push origin main -v Pushing to git@github.com:aliaramli/xxx-docker.git ssh: connect to host github.com port 10xx: Connection timed out fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.   As we can see I'm using verbose flag to troubleshoot the issue, "-v". Error reported that the server unable to connect with github.com server tru port 10xx (i purposely censored the full port number)   to correct the issue i will need to set ssh connection to github server using github supported port which is 22.  eg setup of my ~/.ssh/config file  Host github.com  Port 22 ...

Dockerize Wordpress Stacks for Easy Migration

  Assalamualaikum,    Photo by Campaign Creators on Unsplash   After using Google Cloud free credit   for 3 months, its time to migrate our Wordpress website! I have launched https://4nutz.tk an e-commerce website that sells our own home-brand Natural Nut Butters!  To save money, development was done on Google Cloud Compute Engine, after 3 months running, putting all the contents there! Tracking our own sales, finally its time to migrate.  At the beginning, i don't want to put so much effort in running it up, used Bitnami image to run the Wordpress. Everything was easy and breezy! But aware of the time limit, yes we need to migrate eventually. Because the Google Cloud pricing is too expensive for me! $20 per month? kidding me.  Running the website on Digital Ocean is much cheaper $5 per month! Register using my referral link ya! you will get free $100 credit for 2 months! gets your hands dirty and start running you own web app / projects~ Ive b...

Restoring Database and Wordpress Site

  Command based Restoring Database and Wordpress Site First you need to have the backup files ready. Visit my recent post on how to backup database and wordpress site .   Photo by Carl Heyerdahl on Unsplash   Restore DB Having the backup files ready, following below steps to restore it properly. Ensure MySQL is installed For Windows users can checkout this tutorial https://dev.mysql.com/doc/refman/8.0/en/windows-installation.html Ensure mysql path is set in the environment For Windows users can checkout this tutorial https://dev.mysql.com/doc/mysql-windows-excerpt/5.7/en/mysql-installation-windows-path.html Run following commands to create db, assign new users, and restore db. Access MySQL by running below command mysql Create the user that you wanted to use / manage the db in wordpress later.  create USER testrestore@localhost IDENTIFIED BY '<the user password>'; Create the database that you wanted to use for wordpress later.  create DATABASE mydatabase...

Create Wordpress Website & MySQL Database Backup then Upload to Gdrive

 It's easy to use plugin, but you only need few commands to run :D Usually Wordpress user will just quickly find a plugin to backup the website and its databases. Is it to daunting to do it by ourselves? Photo by Science in HD on Unsplash     I find plugin is easy in certain way, but for an admin myself, i prefer simple command / script to get the job done.  Create database backup This is the command required to run a simple database backup in mysql.p/s you can change the destination path. I put in /tmp because i want to upload to gdrive later.   If you choose to upload to Gdrive Normally a user might just want to backup the file to its host server. For this case i wanted to upload the backup file(s) to Gdrive. And im using a third party Gdrive command client . You might want to checkout tutorial on how to get it installed in your server~   **Use at your own risk! the third party cli will have access and write permission to your Gdrive files!**   I...

Create a Wordpress Cron Job to Send Reminder

 Hi All,     The following code is sample of how to create a WP Cron and send out email reminder to targeted seller/admin. You may use this as reference and change accordingly. Please read the code comments to understand the flow! This code will check seller users that is not active for 1 month to send reminder to them and delete seller products that is not active for 3 months. To better enhance the code you can actually just set the product as draft instead of deleting it directly.

Payment Method / Cara pembayaran yang Dibenarkan Oleh Google Ads untuk pengguna Malaysia

 Salam semua, ada beberapa comment dari youtube video saya di bagaimana cara untuk buat payment? berdasarkan input dari Google sendiri hanya 2 cara payment yang diterima oleh Google.  Melalui credit dan debit card.     Semua sedia maklum yang kalau kita takder credit card, kita boleh guna debit card.    Kerajaan telah pun mewajibkan semua pemegang ATM card untuk tukar kepada debit card.    Maka ATM card kita yang ada simbol VISA/MASTERCARD itu boleh digunakan untuk membuat pembayaran kepada Google Ads. Semuga ini membantu anda ya!

Using Regular Expression / Regex In Javascript!

Writing a simple function to extract matched strings using Regex in Javascript Today i want to show how to extract string data using Regular Expression in Javascript. A regular expression is an object that describes a pattern of characters. Syntax for javascript : / pattern / modifiers ; First we can create a simple function that will process the string extraction. example of string input will be something like this <p>This is just a simple example input string</p> (     [message] => "Hello",     [desc] => "its a handshake hello!" ) <p>The purpose is to extract message and desc pattern matching</p> Simple function that will process the string extraction function extract(stringInput) { var regexp = /\[(message|desc)\](.*)/gm; var arr = []; while (result = regexp.exec(stringInput)) { arr.push(result[0]); } return arr; } The ' extract ' function will look for a pattern on anything that has opening bracket with the matching ...

Simple Security Implementations to Control SSH Access in Digital Ocean Droplet/VPS

Image by S. Hermann & F. Richter from Pixabay By default Digital Ocean Droplet will allow root SSH access When we first create a droplet in DO, DO will send us the credential access through our email and we can access the droplet using DO console easily. After that we will change the password to our own password. Then whats next? Are we good to go? Before we go in depth. Let us revisit what is a brute force attack. A brute force attack is an attempt to crack a password or username or find a hidden web page, or find the key used to encrypt a message, using a trial and error approach and hoping, eventually, to guess correctly. - Kapersky In case of droplet users, we need to secure our VPS from being attacked by brute force attack. On SSH brute force attack the mechanism is slightly different. The mechanism is SSH brute-force attack, the mechanism is reversed. Instead of trying thousands of username and password combinations on a single server, the crooks try one username and pas...

Populate Whatsapp Link Based on Seller Phone Number WCFM

Hi all, Image from Pexels Today I'm going to share, how to populate WhatsApp link based on the seller number. My example today is based on Malaysia's phone number. The registration input doesn't have an input validator for the phone number, however, these are the most common number registered by users. 1) starting with 6 at front 2) starting with +6 at front 3) normal number without country code eg : 014xxxxxx Full code on how to populate whatsapp link for seller number basically, I introduced a simple pattern that has 2 groups. "#(^[6]\w*$)|(^[+][6]\w*$)#"; The patterns must have a delimeter added for PHP, in my case i use a `#`. You can use other delimiter that supported by PHP . The first pattern (^[6]\w*$) Checks whether the seller phone number starts with number 6 and followed with other characters. If it is matched, do nothing as the format is already correct. The second pattern (^[+][6]\w*$) Checks whether the seller phone ...

Adding Custom Field for Vendor Settings in WCFM

Hi all, just a quick sharing. How to add Custom Field for Vendor Settings in WCFM Image by Clker-Free-Vector-Images from Pixabay I wanted to add a custom field for Vendor Settings in WCFM . The field will be a checkbox with a label of "Verified". This field can only be filled by an admin. The purpose tells is to tell whether this vendor is verified or not and data is stored in `wp_usermeta` table. Okay, of course, if I use the paid extension for WCFM plugin this feature already included. But come on! I just want to add this simple function without paying any penny :P Thus I decided to DIM (Do it Myself). I was lucky that previously other WCFM users did a custom field for Vendor Settings and shared his solution on the WCFM forum. Aha. So I tested out, in the beginning, it was not working. The working code I included here for your reference. I also added the admin user check to ensure the field is only loaded for admin view :D. This code needed to be in...

AWS Workspace Device is not Authorized Linux Client

Have you guys tried the AWS Workspace? They are offering the service for free from April - June 2020. For a limited time, in response to COVID-19 , starting April 1, 2020 through June 30, 2020, Amazon WorkSpaces Free Tier provides up to 50 WorkSpaces with Windows Standard bundle with 80 GB Root and 50 GB User Volumes, running in AutoStop mode for up to 10,000 hours of combined use per month across all AWS Regions where WorkSpaces Free Tier is currently available. Additionally, the Amazon WorkSpaces Free Tier provides one WorkSpace with Windows Performance bundle with 80 GB Root and 100 GB User Volumes, running in AutoStop mode for up to 200 hours, two WorkSpaces with Linux Standard bundle with 80 GB Root and 50 GB User Volumes, running in AutoStop mode for up to 400 hours, and one WorkSpace with Windows Value bundle with 80 GB Root and 10 GB User Volume, running in AutoStop mode for up to 200 hours. All new customers that start using WorkSpaces for the first time during ...

Step by Step Read Android Logs using ADB Logcat in Ubuntu

Having ADB Logcat will be helpful in debugging our android application to check important logs for troubleshooting purposes. Using Ubuntu as your main operating system, you might come across this matter on how to debug our device application easily? Instead of installing doubtful Logcat applications on Google Play Store why not we just do it ourselves? Android Apps Awesome! Steps to Read Android Application Logs in Ubuntu using ADB Logcat. 1. Enable the developer mode in our Phone  This step varies from different phone models. Please checkout you phone-specific instructions to enable developer mode 2. Then enable the USB debugging in our phone  Usually in Settings > Additional Settings > Developer Options > Usb Debugging 3. Install the ADB tools  sudo apt install adb 4. Plug in the phone ensure that Ubuntu recognizes the phone you can see the "Android" / Phone device is mounted properly   5. Now run the ADB command to list available...

Python Quizzes for Job Interview Preparation

Sample of Python Quizzes and Questions for Job Interview I'm doing some revision on python programming. May this helps you as well. Please try to understand the logic ya after seeing the code answer. Image by Shahid Abdullah from Pixabay Data Structure Quiz Implement a group_by_owners function that: Accepts a dictionary containing the file owner name for each file name. Returns a dictionary containing a list of file names for each owner name, in any order. For example, for dictionary {'Input.txt': 'Randy', 'Code.py': 'Stan', 'Output.txt': 'Randy'} the group_by_owners function should return {'Randy': ['Input.txt', 'Output.txt'], 'Stan': ['Code.py']} . My code answer Result : defaultdict( , {'Randy': ['Input.txt', 'Output.txt'], 'Stan': ['Code.py']})  Some additional info : A defaultdict works exactly like a normal dict, but it ...

Easily include Seller Bank details in On-hold Order Email WCFM

Do you have a scenario when using WCFM , you would want to allow buyer to directly pay to seller bank account by bank transfer? Well I do. This is due our Marketplace offered free service to sellers. At the beginning we charge them some commission fees, but that does not really work. As the job to handle the delivery is more troublesome with our limited resources and our sellers are not coming from big companies who are willing to pay higher commission fees. I'm going to share with you how easily you can add the Seller account details on the Customer on-hold order email template. I'm adding this in an extended child-theme ..okay. Never write in the original Woocommerce plugin module, nor the parent theme module. That is 100% wrong, as LATER on, you will have trouble to manage and upgrade the theme and plugins to the latest version. Add the Woocommerce template directory in child theme Create the directory for Woocommerce emails and copy the file over. Update the c...

The right way to load Javascript and CSS files in Wordpress.

The way we load Javascript and CSS files in Wordpress is different from the normal HTML way. First of all, we need to identify where do we want to load the scripts. Is it in our theme or plugin?. Lets say we want to load it to  our theme, we can easily create a new folder in our child theme and place the scripts in it. for example Then we can load it in our child theme functions.php file. Ok when we load, we need to understand the parameters that we want to pass in... for wp_enqueue_styles is quite straight forward. but for wp_enqueue_script.. Pay attention on deps parameter. whether the script that we want to load has dependencies with other scripts / jquery. Same goes to in_footer parameter, do we want to load in header or before the body closing tag. If we do not define properly. Our scripts might not be loaded properly. Pay attention on those two parameters.

Get all meta keys of wp_usermeta using sql query

To get all meta keys of wp_usermeta we can easily group field of meta_key and meta_value. For example: select group_concat(meta_key) as meta_keys from wp_usermeta group by user_id limit 1 \G; Results: *************************** 1. row *************************** meta_keys: nickname,first_name,last_name,description,rich_editing,syntax_highlighting,comment_shortcuts,admin_color,use_ssl,show_admin_bar_front,locale,wp_capabilities,wp_user_level,dismissed_wp_pointers,show_welcome_panel,wp_dashboard_quick_press_last_post_id,wc_last_active,wp_user-settings,wp_user-settings-time,_previous_login,_current_login...

Get the last active time from users in woocommerce using sql query

To easily get the last active time from users (under Woocommerce extended plugin) we can easily query from database using the meta_key of "wc_last_active" example query: select user_id, meta_value from wp_usermeta where meta_key= "wc_last_active" and user_id in (11111,112222); results: +-------------+------------------+ | user_id    | meta_value | +-------------+-------------------+ |   11111   | 1556755200 | |   112222 | 1566518400 |

How to easily parse PHP array to Javascript Array

Hi All, how are you doing? Stucked? Haa. Today i'm going to share with you how to easily parse a PHP array to Javascript array! Let's say we have a php array with key pair values defined. Example We want to change it to javascript object. first we will need to parse the array to json format Then we can use in javascript, either tru api or directly Same goes if we have an array of objects in PHP example Then we parse to json And access it in Javascript Hope this helps! Please leave some comment so that i can help it out~

hiddenInput issue when integrating intl-tel-input in Woocommerce custom gateway plugin

Checkout my full post here.. on the workaround. If you have any question. please drop a comment, i ll will reply https://github.com/jackocnr/intl-tel-input/issues/1020 for those who are having issue on woocommerce ajax checkout update call, **i faced this when using Woocommerce deposit, i updated to check if there's any post data on form initialization, if yes, i will reassigned the variable value. Example:

Never write long post title! Here's why

Guys! I'm writing blog post on daily basis, and doing some experiment. Every morning after i woke up and booted my laptop, the first thing that i will do is actually checking my blog traffics. After disappointed with the number of traffic. Previously what i always tried to do is adding more post and more keywords. but that's not just it! The title must be attractive and clean enough! Why. I discovered that when using "queries" by visitors of my blog that i get from google search console , i noticed that..my post title is toooooooooooo long. and google result cut off the most important word !! as below example, google result cut off the total price of the 12 days  trip to 6 Europe countries !which is the highlight of the post! Example: Ok. knowing this... i want to share with all of you. Always keep you title simple and attractive but do not exceed the 50-56 characters limits! You can use a word processor software to count the total of characters, or can...