When is hardcoding good?

Hardcoding is always seen as a bad practice. It makes the code inflexible. For example, making the code aware of the environment itself is a good thing so that we can reuse the code and avoid code duplication. Here, we are trying to copy a file to a user directory.

cp doc.txt to $HOME/

is better than

cp doc.txt to alex/

If this snippet is used in a deployment script for example, it can save a lot of time.

However if this snippet is used in a live environment, using variables might not be good because it can cause unpredictable behaviour and makes troubleshooting harder. Hence, hardcoding in production environment becomes a good thing.

Important CPANEL logs

These cpanel logs are important when troubleshooting: apache: /usr/local/apache/logs/ exim, ssh and others: /var/log/ cpanel: /usr/local/cpanel/logs/

Speeding up vagrant virtualbox disk access

Virtualbox driver is very slow. You can google about this all over the internet. There are 2 ways to speed up vagrant disk access using nfs, one way is to use vagrant-bindfs plugin and another way is the traditional way to change permissions in vm. This method outlines the later. shutdown vagrant using “vagrant halt” … Continue reading

Disable postfix to send email to outside world

disabling postfix to send email to outside world is important especially in development environment. you don’t want client to receive emails when you are testing in the dev environment. Unless software is using external smtp server to send email, you can simply update postfix config (main.cf) relayhost = and restart postfix

Custom ajax call in woocommerce

sometimes you need to update database via ajax. wordpress has tools to make it easy. Well not that easy… here for example, we want to create a link that when clicked, automatically change the order status of a woocommerce order and insert some notes. In the template, Note that we have to use nonce to … Continue reading

Creating custom pages in woocommerce

what if you want to have a custom page in woocommerce? For example a page called abc under my-account best way is to use shortcodes. Create a new page under my-account, ie my-account/abc and put in the shortcode [abc_shortcode] then in functions.php now you need to create the abc.php file which can contain anything

Symfony: Quick way to change bundle name

You have generated a new bundle under src/Oldnamespace/oldbundle and decided to change the bundle name or move it to a new name space. Symfony doesn’t provide any tools to do that. Sounds like a tedious job… There is no short cut to this solution but some Bash scripting can save your lots of time. Use … Continue reading

Installing phpmyadmin in hhvm

when installing phpmyadmin under hhvm and nginx especially, you might get an error like so: “Error during session start; please check your PHP and/or webserver log file and configure your PHP installation properly” this is due to hhvm settings, got /etc/hhvm/php.ini and comment out all the php options like so: ; php options ;session.save_handler = … Continue reading

CPanel exim unrouteable address

if exim is showing up errors like “unrouteable address”, it means that exim is trying to send mail locally. If your local dns is borked, you will get this error. The fix is to fix your local mx entry. If you have configured an external dns server, then you should go to DNS functions -> … Continue reading

Cpanel unblock IP

sometimes your IP gets blocked if you have done something funny on the server. Best way is to ssh into the server csf -r (Restart CSF) csf -d (quick deny an ip: csf -d xxx.xxx.xxx.xxx) csf -a (quick allow / whitelist an ip: csf -a xxx.xxx.xxx.xxx) csf -dr (unblock an ip and remove from the … Continue reading