Author Archives: invtr

Transfer Divi site to another hosting

If you are building site for customer, you probably want to design it on your own web hosting first. After the design completed, then only you will transfer it to your customer web hosting.

Below are quick steps on how to transfer complete Divi website from one wordpress setup to another (within same server or different server.

1. Export wordpress content
Go to Tools > Export. Choose “All content” then click “Download Export File”

2. Export Divi Theme Options
In navigation menu. Go to Divi > Theme Options.
Click the “arrow up and down” icon at top right.
Then click on “Export Divi Theme Options” button

3. Export Divi Theme Customizer
In navigation menu. Go to Divi > Theme Customizer
Click the “arrow up and down” icon at top left.
Then click on “Export Divi Theme Customizer” button

After setting up new WordPress, don’t forget to do the following steps before importing

  1. Import Divi theme
  2. Activate Divi
  3. Apply api key in Divi > Theme Options > Updates
  4. Set the main static page in Settings > Reading

Once all done and set, you can now start importing all exported files. Start with the 3, 2 and 1.

VS Code Extensions

Some useful extension I’m using

  1. PHPIntelliphense – one of the feature is to show methods and functions in outline (on left bar)
  2. PHP Intellisense
  3. Projects – to quickly switch between projects instead of need to open new window and choose folder from explorer
  4. Auto Close Tag – automatically add close tag (html) when a tag is opened
  5. Bracket Pair Colorizer – easy to detect open and close curly braces
  6. Gitlens
  7. Prettier – code formatter. To enable format on save, go to settings (cmd+,) and search format on save. Tick to enable and prettier will do its job when a file is saved. Or to run it manually go to run (cmd+shift+p), type in Format Document

Resize digital ocean droplet

  1. Choose droplet and click menu “Resize”
  2. Choose the new package. Click on “Turn off” droplet and Click on “Resize”
  3. There is a progress bar just below the droplet name on top area to show progress of the resizing
  4. Wait until resize successful message “Droplet has been resized” displayed.
  5. Once the resize completed, go to menu “Power”. Turn on back the droplet.

The whole process may take 2-5 minutes. The estimation given is 1minute for ever 1GB disk size but normally it is a lot faster.

DO reference:
https://docs.digitalocean.com/products/droplets/how-to/resize/

Deploy codeigniter 3.x on hosting

To deploy the application securely

1. All application and system source code to be placed not in public_html directory

public_html should contain index.php, assets with css and js files and .htaccces that should look like this if you want to get rid of the index.php thing in the routing)

2. Modify .htaccess file

RewriteEngine On 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 

RewriteRule ^(.*)$ index.php?/$1 [L]

3. Update config files such as config.php, database.php and routes.php

4. Modify index.php set

  • $system_path = '../system';
  • $application_folder = '../application'

Flutter

Steps to install can refer here
https://flutter.dev/docs/get-started/install

Install Flutter for Mac

  1. Download latest Flutter SDK File
  2. Make the path global so can run flutter command anywhere
    export PATH="$PATH:`pwd`/flutter/bin"
  3. Run flutter doctor to check on other dependencies

Install VS Code extension

  1. Flutter
  2. Awesome Flutter Snippets

Start new application in VS Code

  1. Press cmd+shift+P to launch Command Pallette
  2. Type Flutter
  3. Choose Flutter: New Application Project
  4. Wait until main.dart shown on page
  5. Can run the app by pressing F5 or use the play icon on the top right corner
  6. Application will be run on chrome browser

Javascript notes

Some notes for me to refer and remind myself

unlike PHP, a variable must be declared first before been assigned. or it can be declared and assigned at the same time
var myVar = 1;

to get string length:
stringLength = aString.length;

to get nth letter in a string
letter = aString[aString.length-1] // get the last letter

array in javascript. array can also contains array as element
myArray = [“this is string”, 200, true, [“Bulls”, 23]];

use .push() to push element to an array. .pop() to remove last element. .shift() to remove first element and return the element (can assign to a variable)
myArray.push(“another element”);
deletedLastElement = myArray.pop();

List of Javascript built-in objects

Using Divi on cPanel shared hosting

Download Divi.zip from Divi member page

Install a wordpress using softaculous

Go to Appearance > Themes > Add New > Upload Theme

Choose Divi.zip and click on “Install Now”

If error ““The link you followed has expired.” is displayed, go to cPanel > MultiPHP INI Editor. Change “post_max_size” and “upload_max_filesize” to bigger than Divi.zip file size (e.g. 15MB)