Shurn the Awesomer
Installing Memcache on Ubuntu 16.04 for PHP

Installing Memcache on Ubuntu 16.04 for PHP

Written on Fri, 24 November 2017

Installing Memcache on Ubuntu 16.04 is a breeze. All you need are just the right commands and everything is installed.

apt install memcached php-memcached

After that, you just need to restart apache.

systemctl apache2 restart

That's it. You can verify that memcached is installed and working with phpinfo().

Sonarwhal - The best linting tool, so far

Sonarwhal - The best linting tool, so far

Written on Thu, 23 November 2017

I have been using Sonarwhal to check my website for errors for quite a while. This is quite a useful tool to get your website checked for best practises and errors.

So far, I have managed to clear out many issues raised by the online scanner provided free-of-charge. The downside of the scanner right now, is that I cannot set rules. Like I can't ignore certain domains that are not under my control, thus it reports their errors. The other downside I face is also a timeout between scans. I like to scan each time I make a site modification, which can be seconds apart. You can install this tool on your local premise to overcome these limitations.

Some of the errors and best practises I have done are like HSTS, PWA, and other security headers. It's a good tool to use. Give it a try for free.

All the hype about Note 8

All the hype about Note 8

Written on Mon, 11 September 2017

Seems like the world is getting so excited about the new Note 8 from Samsung. There is no shortage of Note 8 reviews. I'm not about to start doing one right now. I'll probably share about me and my wife's experience transiting to the new Note 8.

For me, I've been a long time Android user. Transiting it over from my previous Galaxy S6 Edge is a mere breeze. But my wife has been a long time iPhone 5S user. But you wouldn't believe me when I tell you that she picked up Android really fast. To be fair, she actually used the OPPO R9 model for about a month before she got her hands on Samsung Galaxy Note 8. Using OPPO R9 was already easy enough that when she landed her hands on Note 8, it was just another android to feast her eyes on.


That's her unboxing the phone. You can already tell how excited she is.


From the left, we have Galaxy S6 Edge, Galaxy Note 8, and Oppo R9. Clearly, Note 8 is the tallest of the 3, with R9 coming close.


But when it comes to screen real estate, the Note 8 is clearly the winner.

The data transfer from S6 Edge to Note 8 wasn't as smooth. To be fair, it isn't the fault of Android or Samsung. It's just that the apps ain't designed to transfer well with Smart Switch. The 160+ apps I have to restore through download from Google Play sure took a long time. Eventually, I am still able to smoothly transit to Note 8.

The transition from R9 to Note 8 had an extra hurdle. Smart link won't automatically install on R9. I had to download it from Google Play directly. I suspect it's because it runs on ColorOS, a variant of Android. Other than that, every other procedure is smooth.


If you're on budget, you might want to know that your purchase probably comes with a free phone case.


As expected, you should receive the fast charger. If you're using other phones that supports Qualcomm's Quick Charge, the fast charge should work too.


Now, this is arguably the accessory that stood out most. The ear piece by AKG is absolutely beautiful to listen to. The insulation is very good. I could actually hear more of the audio range than the previous ear piece provided by Samsung. Listening back to my old songs and noticing other instruments that I missed out previously is really eye opening.


I did not get to try out Dex Station much as I did not have a HDMI monitor available at this point of writing. Just one thing I noted, when I attempt to charge my phone with it, it wasn't on fast charge even though the charger supports it. And the phone case I was using interfered with the connection, that it could not fully plug into the Dex Station.

All in all, this is a very good device, as long as it doesn't explode.

Disclaimer: Even though all the photos in this blogpost is shot with Note8, the images have been edited and optimised for web by degrading it slightly, for faster download speeds.

Speed up your website with TCP BBR

Speed up your website with TCP BBR

Written on Wed, 30 August 2017

Google has come up with a new way of handling network congestion, by pretending there is no congestion. OK, maybe exaggerated, but who can blame me when they outrightly state that "1980s-era algorithm assumes that packet loss means network congestion".

BBR stands for Bottleneck Bandwidth and Round-trip propagation time. According to Google, YouTube network throughput improved by 4 percent on average globally. Wordpress also experience massive improvements of up to 2700 times better than the previous best loss-based congestion control.

Sounds impressive? Why not let's give it a try.

Warning


Back up your server before proceeding. You're likely going to need to change Linux Kernal and other system level changes.

Updating Linux Kernel


Check the Linux Kernel Version

uname -mrs


If it's any version less than 4.9, you need to upgrade it. Otherwise, you can skip ahead to the next section.

Search for the latest linux kernal in the repository.

apt search linux-generic

At the time of writing, the latest version is linux-image-4.11.0-14-generic. TCP BBR is only introduced in 4.9 and higher, so choose any version 4.9 or higher and install.

apt install linux-image-4.11.0-14-generic

You need to reboot the server after this.

reboot

Enable TCP BBR


Enable it at sysctl.conf

nano /etc/sysctl.conf

Append the following lines

net.core.default_qdisc=fq
net.ipv4.tcp_congestion_control=bbr

Apply the settings

sysctl --system

Verify the new settings

sysctl net.core.default_qdisc
sysctl net.ipv4.tcp_congestion_control


You should see the output as what you typed in the sysctl.conf

Test it


Does it work? Maybe. When I did a speed test before and after implementing TCP BBR, there was hardly any noticable improvement in speedtest.

Speeding up CakePHP3

Speeding up CakePHP3

Written on Sun, 23 July 2017

Googled up how to speed up CakePHP and I noticed how little articles have reference to CakePHP3. While there are other articles written on how to speed up CakePHP2, there's none on CakePHP3 that I found. So I'm going to share about my experience trying to speed up CakePHP3.

Note that this article is specifically about CakePHP3 and not PHP in general. Google up on speeding up PHP for more ways to speed up your web application. Also, unless you are experience a lot of traffic on your website or you have some heavy-duty processing, this optimisation won't give you significant speed.

The Beauty and Curse of Automagic


One of the beautiful things about CakePHP3 is that it does a lot of automagic things for the developer so that you can rapidly prototype an application. The downside of it is that it uses a lot of processing power and a big lot of memory. I'm going to show you how you reduce CPU cycles and memory. Why memory? Simply because you wouldn't want your application start using swap space, which will drastically reduce your application speed.

Use Database Select


When we do a data retrieval, we would normally do this:

$this->Articles->find("all");

With CakePHP's automagic, we would get every single column. This adds to processing time, both on the database and CakePHP. You see, CakePHP will process all the columns according to the type, especially if it is a date or a datetime field. On top of that, it will be stored as an array. Learn more about how big PHP arrays really are and you will know why it storing huge datasets in array is a bad idea.

So what we should do is to select very specific columns that you really need in your application by:

$this->Articles->find("all", ["fields" => ["id", "title"]]);


or

$this->Articles->find("all")->select(["id", "title"]);

With this trick, you use less processing power from the database and PHP. You will certainly reduce memory usage by a significant factor, especially if your query returns a huge dataset.

About Me

Greetings Earthlings , Shurn the Awesomer is here to give you an awesome time.

This little site is a record of my life, opinions, and views. I'm mainly writing about Technology & Gadgets, Busting Creationist Myths, and other philosophical stuff.

This site is done using CakePHP.

Uptime

With this uptime, how much more can I be proud of to showcase to the world? This uptime monitoring is brought to you by StatusCake since 13th May 2017.

Copyright

I will always check for copyright usage before using any materials on my site. Whenever due, credit shall be given.

However, if you notice that I may have infringed on any copyright material. Please do not hesitate to contact me. All works of every artist deserves to be honoured and respected.