Python 2.7.13 running on Android

I stumbled across a very interesting project called LBRY a while back, which I can describe as bitcoin meets bittorrent, Youtube and Soundcloud and and they all have a baby. The app includes a daemon developed in Python which is used to communicate with the LBRY network, and the goal was to get this running on Android one way or another. Prior to this, I had absolutely no idea there was a way to actually get Python on Android. I mean, it was theoretically possible since Android is based on Linux, but I had just never come across anything related to that.

Then I found out about Kivy, and the python for android (p4a) project. P4A makes use of a mechanism called recipes which define how certain Python modules or components should be built for a platform. There was a joint effort to get the daemon to compile and actually run on Android, which was eventually successful, but the Python version for the current p4a master branch is 2.7.2. I wasn’t exactly satisfied with this, so I went down the rabbit hole of getting Python 2.7.13 up and running. This took quite some time and effort, but I managed to get it to work. I found it to be quite frustrating at times, but it was also very exciting and I had a feeling of satisfaction after I had finished.

Funny story, after figuring it all out, I discovered there were pull requests created in Github for the p4a project related to building with Python version 2.7.11. If I had found them earlier, my life would have been a whole lot easier! Either way, it was a good learning experience and I’m glad to say it works pretty well.

You can find the LBRY Android project on Github if you’re interested in the recipes for building and running Python 2.7.13.

Installing Visual Studio 2017 Community edition on Windows 10 1607 (Anniversary Update) could break your boot process

Well, that’s a long title. I decided to give Xamarin a shot for cross-platform Android and iOS development a couple of days ago which led me to install the Visual Studio 2017 Community edition. I performed a basic installation with only Xamarin selected (I already have the Android SDK and NDK, so I unchecked those). The installation was successful and my system ran fine until the next day when I tried to launch a VirtualBox VM. This failed with an error stating that it was unable to start, asking me to check my VBoxHardening.log file. I couldn’t make any sense of the last entry in relation to starting to VM, so I decided to try the good old solution to everything.

I restarted my laptop, only to be greeted with a blue screen of death and the stop code: CRITICAL_SERVICE_FAILED. I tried restarting a couple more times and was greeted with the same error. I went through the usual troubleshooting process. I tried:

  • Using startup repair. This failed spectacularly with an error asking me to check C:\Windows\System32\LogFiles\Srt\SrtTrail.txt. The last line in this file started with: Unknown bugcheck: 0x5A param 0x1 xy. Searching for this led me to try some startup options.
  • Tried to use System Restore, but it turned out I didn’t have any restore points. I probably disabled this due to the Windows taking up more and more space on the SSD partition created for the OS. Why?!
  • Tried to boot into Safe Mode after startup repair. Got the same CRITICAL_SERVICE_FAILED blue screen.
  • Based on some of the search results I found for the bugcheck error in #1, I tried booting with the Driver Signature Verification option disabled and this worked. However, I got an popup error that nvcpl.dll (NVIDIA Control Panel-related) failed to start, and my WiFi device wasn’t working (failed to start error in device manager). I updated my WiFi driver which seemed to fix the WiFi device problem, but I didn’t bother rebooting to test it out.

Trying to remember the last major change I made to my computer, I figured it must have been the VS2017 installation from the day prior that may have interfered with certain things. This led to me searching for a combination keywords related to Visual Studio 2017 breaking Windows 10, which led to me a reddit thread with 2 people having encountered something very similar: install VS2017 Community Edition, CRITICAL_SERVICE_FAILED blue screen of death upon next boot. Installing the Windows 10 Creator’s Update fixed the problem for them, and I tried the exact same thing. And that worked. I no longer have any problems booting. And VirtualBox works fine too.

So, if you would like to install Visual Studio 2017 Community edition, make sure you upgrade to the Windows 10 Creator’s Update first. I was able to do this using the Windows 10 Update Assistant. Steps to fix if you encounter the BSOD boot loop:

  • Boot with Driver Signature Verification disabled.
  • Download the Windows 10 Update Assistant and upgrade to Windows 10 Creator’s Update.
  • Reboot as many times as you like after the upgrade is complete.

No idea if it’s a combination of hardware or software and drivers installed on my notebook, a Lenovo Y700, that caused this issue, but it’s 2017 and I just find it bizarre how installing VS2017 which is meant to be a developer tool should affect the Windows boot process. But hey, if you do encounter the issue, now you know what to do!

Joining the “top 3%” of talent

I initially heard about Toptal 2 years ago, but I never really considered joining because as a freelancer, I just didn’t see the need to have to take an interview, due to the fact that I felt I only really needed to prove my skills and deliver a competent solution after the initial questions and clarifications have been answered on a particular job.

To provide some context, I have been freelancing on Freelancer.com and Upwork for more than 13 years, and it has been worthwhile, simply due to the amount of experience gained from working for various people in the United States, Canada, Europe, Asia and Australia. However, the high quality projects are few and far between, and as I have grown older, I have gradually realised that I can no longer afford the luxury of having to spend a lot of time sifting through the chaff.

I am also active on Topcoder, where the projects are very interesting and your code will be used by high profile clients including NASA, IBM or Paypal, but the long wait time to get paid is discouraging. It takes about 7 to 15 days for a project to close (5 to 7 days to build a solution, 2 to 3 days for a code review to select a winner, a few more days for final fixes, project closure and client approval), after which you receive a payment if you win  first or second place prize. You are not able to withdraw the payment until it gets released, which adds an additional wait time of 30 days. Essentially, that is about 37 to 45 days from the start of a project until you are able to receive your compensation.

There is the compromise of getting a full-time job, but that would mean giving up quite a number of freedoms including a very flexible schedule and the ability to travel at will, amongst others. Now, this isn’t necessarily a bad thing, and it does work for some people, but I appreciate being able to spend more time with my family since I can choose when I want to work.

Having various opportunities available is never a bad thing for a freelancer, and one of the best skills you can have is the ability to adapt and evolve. Today, I have decided to join the Toptal web engineering community. Do I have what it takes to pass their rigorous screening process and join the top 3%? I may not have the answer to that question at this point, but I am fairly confident. So, challenge accepted!

SEO-friendly, user-readable URLs with phpBB 3.2

I set up a forum using phpBB 3.2 this week and I wanted the URLs to be user readable and SEO-friendly (although this doesn’t really matter to search engines anymore, still figured it’d be a nice-to-have feature). I decided to make some changes to the phpBB core files. Now, my approach isn’t exactly ideal, because there will definitely be problems that arise from merging if any of the files modified for this are updated in newer versions of phpBB, but it gets the job done. If you would like to achieve this, you can proceed with the steps below after the friendly warning.

Disclaimer: Proceed with these steps at your own risk. I am not liable for any damage or harm that may occur to your forum, database, server, computer, or even pets from making use of the modified files in order to achieve the desired functionality. Always remember to make multiple backups of your files before making any changes.

First things first. Here are the fancy URL formats that we want to achieve.

  • /memberlist.php becomes /members
  • /memberlist.php?mode=viewprofile&u=2 becomes /members/u2-admin
  • /viewforum.php?f=1 becomes /f1-awesome-forum-url
  • /viewtopic.php?t=1&f=2 becomes /f2-another-awesome-forum/t1-just-do-it

This can be achieved by adding the following Apache rewrite rules to your .htaccess file (or your httpd configuration). Please note that mod_rewrite needs to be enabled for this to work.

If you’re running on nginx, you can add the following lines to your configuration.

Once you’ve updated your configuration files, unpack the ZIP archive into the top-level folder of your phpBB installation. Remember to make a backup of all your files before doing this. For reference, here are the files that will be overwritten after extracting the files in the archive.

  • .htaccess
  • index.php
  • memberlist.php
  • posting.php
  • search.php
  • viewforum.php
  • viewonline.php
  • viewtopic.php
  • includes/functions.php
  • includes/functions_content.php
  • includes/functions_display.php
  • includes/functions_posting.php
  • phpbb/feed/helper.php

You can view the modifications in action at https://www.eresidency.co. To reiterate, this is not an ideal solution, and you have to watch out for conflicts if you’re trying to upgrade to newer versions of phpBB, but it gets the basic job done. If there are any improvements you’d like to see, post a comment below.

The archive can be downloaded from https://drive.google.com/open?id=0B27L6m8VLspCSjExREJweHBUS1U.

Configure Redis as an in-memory only cache like Memcached

There’s a new project I have been working on where I needed to make use of an in-memory cache to take some load off of the database. Memcached has been around for a long time, and it’s what I thought about using at first, but I decided to use the opportunity to learn about Redis instead. Working with Redis is fairly straightforward, and it provides very useful and helpful data types in addition to simple strings such as sets and maps.

Redis stores every object in memory, but it turns out it also dumps the contents of memory to disk by default. I needed to disable this, so after digging around, I came up with this minimal configuration which makes Redis act more like Memcached, in-memory only with no disk writes. Of course, keep in mind that if you have to restart the Redis instance, the data will be lost, so it only makes sense to use this if the data which you need to cache can be repopulated from a persistent store.

Implementing cross-origin resource sharing (CORS) using middleware in CakePHP 3.3

I worked on a project recently where I had to allow XMLHttpRequests from a different domain. I initially thought about adding the necessary Access-Control headers at the controller level, but after doing some reading, it turned out it was a better idea to make use of a dispatcher filter. However, dispatcher filters would only apply prior to CakePHP 3.3 since they are now deprecated.

Enter middleware, which I found to be quite familiar since I have made use of a similar concept in Express during my Node.js development. Think of middleware as reusable components which you can use to handle your web requests and modify responses.

The CakePHP middleware classes should be placed in the src/Middleware folder. You can create the folder if it doesn’t already exist in your project.

We’ll create a class in the Middleware folder called CorsMiddleware.php.

The code listing is pretty straightforward. The response is modified with the necessary headers to enable the cross origin requests to be successfully handled by the browser.

You can modify the header values as you see fit, like limiting the Access-Control-Allow-Origin header to specific domains – the wildcard (*) allows requests to be accepted from all domains – or the the request methods to just GET and POST, or the allowed request headers.

To make use of the cors middleware, modify src\Application.php and add the middleware using:
$middleware->add(new CorsMiddleware())

And that’s all there is to it. There are more details about what you can do with middleware in the CakePHP documentation, so be sure to check it out.

Reboot

Hello and welcome to Antinormal. I used to maintain this as a personal blog but I decided to start all over since I wanted to take things in a different direction. I hope to make useful posts going forward.

My name is Akinwale and my favourite things are computers, video games, good movies and books. As I’ve grown older, I find that I haven’t had much time to play games anymore, but I still play The Division fairly regularly. The only other games I have played this year are Deus Ex: Mankind Divided and X-COM 2.

I like science fiction, technology and programming. I have also recently taken up an interest in single board computers and you can find my blog dedicated to that at nanite.co.

Thank you for reading! Comments and feedback are welcome.