Actualize Dreams

We are able

Trouble comparing dates in PHP — September 17, 2018

Trouble comparing dates in PHP

The scenario.

I’m building a custom tool which automates the curation of blogs from member bloggers’ feeds. These blogs must be fetched on a weekly basis because the intention is to make sure every member blogger, blogs at least once a week.

Where to the feed URLs come from?

Member joins by submitting a blog feed URL, which will save in the system manually at the moment.

The system(bot) must;

  1. Retrieve the feed URLs from the database.
  2. The system should loop the URLS.
  3. Connect to each URL.
  4. Fetch one feed item(latest).
  5. Get the feed item date and compare it to the date of last Sunday. If the feed date is greater than the date of last Sunday.
  6. Connect to the database again and retrieve a blog item whose item title is similar to the feed item title. If a blog item similar to the feed item is returned, skip that feed item since we already have it and move to the next. Repeating steps 2 to 6.
  7. If the blog item similar to the feed item is not returned, insert it in our blog database to store it permanently.

Tools used.

First of all, I chose PHP programming language to accomplish the task. I would have chosen Python, however, my hosting environment doesn’t have python. Yet am also more experienced in PHP than Python.

I also hard to extend WordPress so that I don’t have to build everything from scratch. Using WordPress will give me the opportunity to automate member sign up, log in and feed submission easier than if I used something different.

I will eventually build a frontend interface for the system. This interface will enable the public readers to choose and read any blog of their choice as well as enable bloggers to sign up from any part of the world. Building a WordPress theme will be much easier than if I built everything from scratch.

Alternative tools one could look at Joomla, Drupal and Django and many others.

What have I built so far?

So far I have built a WordPress plugin, with the following features.

  1. Automated Feed fetcher
  2. Shortcode which lists active bloggers. This is helpful for displaying member bloggers on the homepage or any page. Hence make it easy for readers to navigate blogs of any member(author)
  3. Shortcode for listing blogs. The intention of the system is to curate blogs from consistent bloggers around the world and make them accessible by consistent readers. This shortcode helps in displaying the blogs on the platform.

Challenges

  1. Comparing dates.

PHP has several inbuilt date functions and objects such as DataTime(), CreateDate() etc but they were not helpful. Sometimes they could function but they were never consistent. Luckily enough converting the date strings to time saved me after many trials and struggle.

Solution

$TimelastSunday = strtotime(‘last Sunday’);

$TimeFeedItem = strtotime($feedItem->get_date(‘m-j-Y’));

if($TimeFeedItem > $TimeLastSunday) {

// Do the rest

}

Whoa! Whoa!

Can’t wait to enable automated signing up, blog submission and attachment of categories and tags to the fetched/retrieved feeds.

Thanks for reading until next time.

Advertisements
How to move WordPress from Cpanel to VestaCP successfully? — August 23, 2018

How to move WordPress from Cpanel to VestaCP successfully?

Background

Cpanel from cpanel.net is the most popular, proven and robust web hosting platform out there. For both not technical and slightly technical, it simplifies the job a lot. It even has a free script installer as well as many paid for auto script installers such as softaculous. Other notable features are email, database and file management on top of robust web statistics aggregation. If you are hosting one or two websites in a shared host environment this is what you need absolutely. Most hosting providers, for example, Godaddy, Bluehost to mention but a few won’t charge you extra for it.

But if you’re a small and startup hosting provider it might require a huge investment as well as unnecessary expense. Say you host your websites in the cloud, dedicated and normal VPS servers, you have to spend $20 to $40 per month on Cpanel. If you’re smart and a good researcher you may look out for discount coupons and if you’re lucky enough,  you will land on buycpanel.com from which you can get VPS licenses from as low as $13.95. Did I mention setting it up, requires a professional or an experienced person like me for example? Setting up Cpanel requires you to choose the correct operating system usually CentOS and as of writing this article you CentOS7 and above versions are a must, since Cpanel announcement that it will be stopping support for CentOS 6 on all systems by November 30, 2020. If you install FTP, SSH, and exim services you won’t get away with your junior skill. Of course, there’re many individuals and agencies including CPanel support who offer the installation and hardening service at a certain fee.

If you are in a scenario like mine, you would realize going through all the above jargon is time-consuming and expenditure is overkill.

My scenario

I technically manage one of the most read news blog websites in Uganda. These are two websites which run on a single cloud KVM VPS at linode.com. Both websites get around a monthly traffic of 250k. Both websites are four to five years old.

Technically I’m the single person in a number of publishers. For simplistic, the websites are proudly powered by WordPress which is slightly customized with custom fields, themes, and plugins.

My primary role is to manage the server and carry out routine security audits, performance, theme optimization, update WordPress and plugins. We also slightly handle emails on the server. But we don’t want to spoil our sender score or reduce the reputation of the IP of our server.

We’ve had Cpanel on our node for the last two years, despite being in a tight third world economy.

For some months the license was automatically deactivated due to our failure to submit a payment, throughout that duration we couldn’t access Cpanel support, then it became hard to make any code modifications, manage databases and email accounts.

During that time the only way of getting in the server was via ssh but we didn’t know every command, for example, to carry out a slight firewall fix.

Proposal

For regular management of the server, we had to find a solution. Thus we researched about website/web host control panels. We would filter by fees in relation to Cpanel, features, support, and age of first version and latest version.

One of the most interesting ones we came across was CentOs CP which looks so much like Cpanel but we settled for another.

Choosing VestaCP

  • It’s Opensource and free.
  • It supports more than one Linux distributions namely; Centos, Debian, Redhat, and Ubuntu. We actually installed it on CentOS7 but I later found out Ubuntu is recommended.
  • It’s minimum requirements i.e 1GM RAM, 20GB storage are friendly and can translate to slightly better performance than Cpanel.
  • Installation of VestaCP is the easiest yet takes as much as 15 minutes to be ready to set up and manage your websites.
  • To manage backups, databases, and emails is almost as simple as if not easier than Cpanel.
  • It has a growing support community through forums and paid for support.
  • File management. VestaCP doesn’t offer a free file management feature but that wasn’t big of an issue. The developers at VestaCP offer a file management plugin which is at $3 per month or $50 for a lifetime. We can also choose to use services such as codeanywhere.com to connect to the server via FTP hence manage our files without pain. Though codeanywhere.com has both free and paid plans, free code editors such as Notepad++, Atom, and Microsoft VS Code can connect to the server via FTP by the help of secure plugins and allow you to manage files of your websites. For us, this is great. It will help us save more than $179.5 which is a minimum of 661,986/= in Uganda Shillings currency today without including transaction fees.

Procedure of switch

Order a second node from linode.com

One of the sites is about 51GB in files(images contributing the biggest part) and 1GB for MySQL database. As much as I wanted to use a WordPress backup plugin especially duplicator. The PHP execution time and memory limit couldn’t enable the plugin to execute and complete successfully. I also didn’t use the Cpanel backup feature because it was downloading the files locally on my computer which wasn’t what I desired.

What did I do?

I accessed both the older and newer nodes via ssh.

Older node.

Create a backup archive.

$zip backup.zip -r /public_html

The command took some time to finish about 2hours. I would be glad to discover a faster solution because moving systems around is just getting started.

The next command I used was for backing up the database.

$mysqldump -u root -p database_name > /home/user/path/database-file.sql

The dump was blazing fast, motivating me to continue.

Newer node.

  • Setup the node with CentOS7. Coming from Cpanel, I’m used to CentOS for web hosting.
  • Install VestaCP.
  • Create a site, FTP account, database.
  • Download backup from the older node and restore.

Download commands
Navigate to the path where I want to download backup files.

$cd /home/user/web/domain.tld/public_html
$wget http://domain-on-older-node.ltd/backup-path/backup.zip
$wget http://domain-on-older-node.ltd/backup-path/database-file.sql
  1. Restoring files
    While at the path where I downloaded the backup.zip file, issued the command below.
$unzip backup.zip

If the files to extract at the root of public_html directory like in my case, I used the move (mv) command to move the files to the right location.

2. Restoring database

$mysql -u database-username -p
$use database-name;
$source database-file.sql;

Provide the password as the system will prompt you, the restoration of the database took less than two minutes.

Troubleshooting tips

1. I see a blank white screen when I visit the website

  • Check and verify that the .htaccess file was restored. If not copy it from the old node to the new node.
  • Increase the maximum execution time and memory limit. Which VestaCP can help you do without hunting down the PHP.INI file. Increased mine to 300 and 384 respectively. By the way, I made the setting server-wide because am sure, I will be the only person to create websites on this server.

2. Unable to upload photos through the media library.

This is caused by a file permission issue. You have to make sure that the website account owns the WordPress installation since by default website installations are owned by root. Use the command below.

$chown -R username:username /home/username/web/website.com/public_html

Note: replace username with the actual username of the account under which website.com belongs. The website path structure in VestaCP is like /home/username/web/website.com/public_html

3. The uploaded file could not be moved to /wp-content/uploads/year/month

This is also a file permission problem on the uploads directory, you should make sure user and group can all write to this directory. Which you have to fix using the command below.

$chmod -R 777 /home/username/web/website.com/public_html/wp-content/uploads

Conclusion

I would have moved the websites in less than 6 hours but because it was my first time doing this, I didn’t have experience of what I experienced during the process. I was playing trial, error and referring to  Google.

I believe this is going to help you and I get a lot of local businesses online by offering them a cheaper performant alternative.

Will also get web developers, online without having to cough more than $5USD per month for a robust node.

Curiosity

Does VestaCP work with docker? How can it be set up? How is the performance?

Web application development – Part 5 — January 14, 2018

Web application development – Part 5

Welcome back, today in the web application development series, part 5 we look at how WordPress makes the task easier than ever before. Previously in part 4 we covered the components that make up web applications, which you can find here if you missed.

Of course they are many tools in contention but of all why WordPress?

Truth be told for over a decade, developers have used and are still using a Model View Controller aka MVC pattern architecture to develop web applications. Giving security, separation of interface from logic, maintainability and scalability as reasons for the pattern’s popularity. Popular web applications providing this architecture are Laravel, cakePHP, CodeIgnitor among others.

WordPress follows a MAP aka Monolithic Architecture Pattern which is defined as, a monolithic application describes a single-tiered software application in which the user interface and data access code are combined into a single program from a single platform by wikipedia.

Not to conclude that MAP methodology is better than MVC in comparison. The fact is that both are good fit for different scenarios. My major reason to use WordPress is to help someone learn an alternative way of powering web applications if  they know of another way.

To come up with a fully functional application we shall have develop a theme and plugin, thereby learning about developing a WordPress theme and plugin.

The tutorial will also offer a good opportunity to discover WordPress plugins you might have never heard of.

WordPress comes with

A database

Already available to us is the a small but powerful WordPress database with fewer tables than other systems for which you have to create your own database. WordPress’ consideration to introduce meta tables is one of the best things about it.

User management and authentication

Additionally one of the most hardest part about developing web applications is the authentication system, which can easily be broken if developed poorly.  This is what we have to be happy about with WordPress, they provide an easily extendable yet secure authentication system.

Back-end user interface.

For the biggest part of our development we shall engineer the front-end system because WordPress has got us covered with a fully customizable back-end user interface called the WordPress Dashboard.

Let’s tune in next time and get the job done.

Meanwhile you can take a look at Custom post types, custom fields, custom taxonomies, theme and plugin development in WordPress by searching in google. I recommend reading articles of codex.org and wpbeginner.com.

Cheers!

 

 

Learn to develop web applications the modern way – Part 4 — January 7, 2018

Learn to develop web applications the modern way – Part 4

Hi, there!

Before we continue into the 4th of part of the series, I would like to put forward a word of thanks to everyone putting in the effort to consistently follow my tutorial. I’m sure it will pay off in the long run, don’t give up yet!

So far we have looked at the requirements, compared web designing and web application developing  and looked at extending as being a smart practice that every coder must adapt.

I would like us to continue by looking at the components which make up a web application. It’s important to understand the basics which is a good fallback as you continue in the journey of a great career.

Let’s get to it.

In a nutshell they are two components which make a web application i.e. the User interface and the storage engine.

Continued on 1/14/2018

User Interface also known as UI is the component through which we (users) interact with the web applications. A fully functional web application’s UI is divided into two parts; one being the front-end and other the back-end. The front-end usually used by the public whereas the back-end used by users who are allocated special privileges  of the web application.

A good example of a web application is WordPress and using it as an example, the administrator can add new users who can be administrators, contributors, subscribers and editors. Additionally if you create a Website/blog on WordPress, the public looks at the front-end to read your posts while you login to the dashboard to write posts.

Storage engine commonly known as a database. This makes the major difference between a website and a web application. Not to say, that websites don’t have databases or storage engines. Rather to emphasize that web applications will normally have some sort of storage engine. Databases can come in many types depending on the type of content to be stored and used. Example of databases powering web applications today are MySql, PostgreSQL, SQLite and WebSQL.

You want to learn more about these components which make up web applications? Just visit google and start your research, you will find millions of helpful information.

Let’s go straight to the next part of the series about learning how to develop web applications utilizing modern methods.

 

Learn to develop web applications the modern way – Part 3 — December 23, 2017

Learn to develop web applications the modern way – Part 3

In the programming industry like others, you will find many terms(vocabulary) which are not usual in  common speech. In this article of the series about “learning how to develop web applications in the modern way”, allow me introduce to some of those terms. In case you missed reading some parts,  click here to read part one or click an item in the table of contents below.

  1. Prerequisite
  2. Web design vs Web applications development
  3. Extending is smart!
  4. Components of a Web application.
  5. Powering web applications with WordPress
  6. The do list application

What is extending in programming? 

In simple terms it’s the opposite of developing applications from scratch. In detail it means a coder will write his/her own application from the start to finish without using and relying on other programmers code. Therefore to extend is when a coder starts with someone’s code to develop an application or feature.

In Object Oriented Programming paradigm, to extend means to derive/instantiate objects which inherit features in terms of method and properties from existing class(es).

What are the advantages of extending?

  1. It makes programming a lot easier because you don’t have to write every line of code by yourself.
  2. It is cheaper than starting from scratch which will require a bigger team and tools for the team besides investing in the team to learn how to work together.
  3. Availability of help from all corners though this depends on the choice of framework. Most programmers choose a framework which has a large number of contributors, the profile of the founder, the number of tools in place and how old it is.
  4. Easier learning curve due to availability and supply of learning material on top of a comprehensive documentation.
  5. Ask me how people become better than others at coding and I will tell you that the secrete is hidden in reading code written by others whether good or bad coders.

My personal recommendation is to spend more time creating solutions than learning how to create solutions. In the upcoming part, share about the basic and major components of a Web application.

Merry Christmas and a marvelous New year.

The difference! Website designing and Web application development. — December 18, 2017

The difference! Website designing and Web application development.

Are these just industry terms to confuse the novice and the customer? Is the difference really worth knowing and understanding or is it a wastage of time? As we continue on the journey to learn how to do develop web applications, I thought it would be good someone clear the question before us.

What is web design?

In my opinion is the process of using a set of tools to create and put together a navigable elements and content accessible through a web browser. The set of tools are majorly the graphics design applications such Adobe illustrator, Adobe Photoshop, GIMP, Sketch and content management systems such as WordPress etc. Though web designing could involve use of coding with HTML, CSS and JavaScript, code is not mandatory. That said someone who has never touched code can put things together and produce a highly performance website.

What is Web application development?

In my opinion is the art and science of using coding to develop software that is accessible through a web browser. Though they are tools like script-case that help I.T professionals to come up with web applications, web application development requires someone to have some good coding skill to come with a fully functional web application. Examples of web developers are people capable of developing systems like facebook, linkedin and WordPress to mention but a few.

Why even care?

You may wonder, why of all things must I know about the differences between website designing and web application development. Many people’s reasons could differ from mine. I think if you want to become something, there is something that competes with what you have in mind, therefore you must ultimately pay attention because it’s very vital in helping one choose the right path sooner than later in life. Since developing a career involves investment of valuable resources… it’s always good to look at the right direction and avoid destruction.

Let’s meet next week for the next item on the agenda of How to develop web applications utilizing modern ways which is Extending is smart!

How to develop web applications. Prerequisites — December 10, 2017

How to develop web applications. Prerequisites

Allow me start by apologizing for missing to post in the previous week. Without further a do, let me start from where we stopped in part one of the series about learning the modern way of developing web applications.

But who am I and why do I fit to be your tutor this festive season?

I’m an African Ugandan internet student, businessman and trainer. Besides technology, I purposely encourage and guide people through the process of becoming self-aware for mindfulness and peace.

Over the years I have studied and learned about PHP, JavaScript, HTML, CSS, SQL and Content Management Systems which has helped build a skill, career and establish Gagawala Graphics Limited a business offering web hosting, web management and web design in addition to printing and graphics design to people of Uganda both within and in diaspora.

I tut at Hostalite Cyber Academy and part of the core volunteer team at You Inspire You.

What do I need to know before following the series?

  • I wouldn’t say you need much if you’re passionate besides being able to code in HTML, CSS, JavaScript(jQuery) and VueJs, and PHP(OOP).
  • You should also be able to find a web host to practice or alternatively install Lamp(linux) or MAMP(iOS) or WAMP or XAMPP(windows).
  • Ability to install and setup WordPress.
  • Lastly but not least you should be able to read and understand English.

What next?

For now get ready for next part of the series which is Web design vs Web applications development.

In that article I will share my opinion backed by 5 year experience about the differences between web design and web application development. I find this necessary because many people confuse the two.

See you next week.

Learn the modern way of developing Web applications this festive season for free. — November 26, 2017

Learn the modern way of developing Web applications this festive season for free.

If there is anything I’m passionate about nothing beats the passion to use technology to benefit fellow humans.

Since I got the opportunity to live in the generation where the world is a global community because of internet, it gifts me the privilege to learn and share. This festival season, I would like teach you about developing functional web applications using modern tools and approaches.

Take a look at the table of contents.

  1. Prerequisite
  2. Web design vs Web applications development
  3. Extending is smart!
  4. Components of a Web application.
  5. Powering web applications with WordPress
  6. The do list application

At the end of the tutorial I expect the reader to:-

  • To differentiate web design from web development.
  • To learn the different components together with their functionality in web applications.
  • To develop web applications using WordPress as an underlying framework.

Stay tuned for the next post, in which I will reveal my experiences and the requirements you need to benefit from this short but practical tutorial.

 

 

 

How to remove Woocommerce sidebar from front-page using hooks — January 18, 2017

How to remove Woocommerce sidebar from front-page using hooks

Woocommerce is one of the most popular plugins for WordPress because it’s used by anyone wants to setup online shop without the need writing a single line of code.

Themes are one of the notable features that come with Woocommerce out of box. It comes with a default theme as well as you can download many out from WordPress.org theme repository and many theme stores online. In fact most of those themes on the WordPress repository and theme stores are fully compatible with WordPress.

Therefore this post is targeting people with custom themes made by themselves or got from somewhere but haven’t come with Woocommerce support.

Let’s start right away!

Go to Appearance -> Edit after logging in to the WordPress Dashboard where Woocommerce is installed.

Look for the functions.php file. For experienced WordPress coders you can create your own site specific plugin. This is where you can add custom code.

Let’s remove a Woocommerce sidebar action.

Use the code below in your themes functions.php or site specific plugin.

<?php

remove_action( ‘woocommerce_sidebar’, ‘woocommerce_get_sidebar’, 10 );

Save and reload the front-end of your shop page.

As simple as that.

 

 

 

Good News: Equity bank and PayPal announcement to improve investment. — September 16, 2016

Good News: Equity bank and PayPal announcement to improve investment.

In a bid to improve their service for Kenya citizens PayPal and Equity Bank Kenya have just announced improvements in their service.

PayPal is an online (internet based) payment service originating from United States of America. PayPal helps individuals and business/organisations to send or receive payments across different countries of the world.

However not all PayPal features are available in to the citizens of every country. For example, the citizens of Kenya’s neighbor to the West “Uganda”, is able to use PayPal features such pay for goods and send payments but is not able receive payments and pay for goods.

This has been different for citizens in Kenya, especially for the Equity Bank customers and US bank account holders. Even though of recent funds withdrawn from PayPal wallet to Equity bank Kenya had to take 8 days ( more than a week) to be deposited on the bank account.

This announcement made by both financial giants confirm the reduction of this delay by 5 days, to bring the delay down to a maximum of 3 days.

This is means more cash flow for the I.T population which largely earns from online money making like blogging, working on upwork and other freelance platforms.

This moves is also a step forward towards increasing the chances of investment by the locals who earn online.

For instance, in 30 days, a earner of 100 USD online in a period of 10 days, will have access to 300 USD in cash feasible to be invested.

 

 

 

CMS Africa Summit here again and this time in Abuja. — September 12, 2016

CMS Africa Summit here again and this time in Abuja.

It’s happening for the forth time in Africa, it’s a summit to learn and share a lot of information especially about web technologies, content management systems in particular.

Catch up the recap of the recent CMS Africa Summit 2016 in Kampala at Gems Cambridge International school below.

When you go to this event  you could become an influencer in your niche. You could as well improve the market for your products and services. You could also discover new ideas and ways of executing them. My biggest take away was networking with many new people who love what you love.

Similarly if you attended as a participant there is a lot more to learn, competitions to participate in and win.

In 2017, CMS Africa Summit will happen on 10th and 11th March, 2017 in Abuja at FUNTAJ INTERNATIONAL SCHOOL

What’s amazing are the friendly prices of the attendance tickets. Imagine a full day ticket goes for 3000 NGN while a 2 day ticket is at 5000 NGN. Every ticket you get qualifies you to Entrance, Coffee Break, Certificate, and Workshop. What a cheap way to learn, educate, and network.

This year’s theme is empowering technology through opensource. I encourage you to come as individual, or team or group of friends,  you won’t be disappointed.

Membership types are attend, speaker and sponsor. Click here to buy a ticket and learn more about the event.