How to enable xdebug for PHP 7.0 in AMPPS 3.7

Submitted by luxian on Thu, 10/12/2017 - 00:23

AMPPS is a great, but it lacks xdebug support. If you run the latest AMPPS version 3.7 on OS X you probably don't have the xdebug extension in the php-7.0/lib/extension folder.

To enable it you have to the following:

1. Select the PHP version you want to run via AMPPS GUI (in my case was PHP 7.0)

2. Make sure you use AMPPS' PHP binary inside terminal by running the following command

ls -l `which php`

The output should be something like:

/Applications/AMPPS/php/bin/php

If not try to run this:

export PATH="/Applications/AMPPS/php/bin:$PATH"

Try to run the previous command again and the path you see should be the one inside AMPPS directory.

3. Copy the phpinfo() output from localhost/cgi-bin/phpinfo.cgi

4. Download the right xdebug version you need from xdebug.org/wizard.php (you will have to paste the page text copied at step 1)

5. Untar/unzip xdebug files. - I used Zipeg, but should work  with tar command in the terminal as well

7.  Inside the folder with the xdebug files start running the command recommended by xdebug download page. First command to run is:

phpize

8. Second command requires some custom parameters to make it compatible with AMPPS (see Issues with enabling Xdebug on AMPPS)

./configure --enable-xdebug CC="gcc -arch i386" CXX="g++ -arch i386"

7.  Third command will be simple: 

make

8. Copy files to AMPPS:

cp modules/* /Applications/AMPPS/php/lib/extensions/

8. Enable xdebug inside php.ini by un-commenting this line inside the php.ini (make sure you adjust paths for different versions if needed):

Android O highlights

Submitted by luxian on Tue, 09/05/2017 - 09:00

ArsTechnica has a in-dept article covering new version of the mobile operating system: Android 8.0 Oreo, thoroughly reviewed. My highlights from that article are:

Project Treble

Project Treble introduces a "Vendor Interface"—a standardized interface that sits between the OS and the hardware. As long as the SoC vendor plugs into the Vendor Interface and the OS plugs into the Vendor Interface, an upgrade to a new version of Android should "just work.

So you should get Android updates faster as long the vendor provided firmware is still supported. Google decides which version it will support based on data collected (how many devices are still on that version).

ROMs shouldn't need to be painstakingly hand-crafted for individual devices anymore—a single build should cover multiple Treble devices from multiple manufacturers. Imagine the next time a major new version of Android is released. On Day One of the AOSP code drop, a single build (or a small handful of builds) could cover every Treble device with an unlocked bootloader, with a "download Android 9.0 here" link on XDA or some other technical website.

Also graphics driver can now be updated through Play Store like any other app.

The Great Background Processing Lockdown

Apps can't just run in background using CPU, RAM and battery as they want. With Oreo they are required to show a notification saying that they are doing background work so you get to decide if an app is doing too much or not. Also, some events will not trigger background processing for all apps like before, making the UI more smoother. And to prevent apps for consuming the battery, all the background processing work will be done through a scheduler in batches, allowing phone to "sleep" more to preserve battery.

New Emoji

Tags

First-mover (dis)advantage

Submitted by luxian on Tue, 08/29/2017 - 12:23

Most people know about first-mover advantage, but a few know that it might also be a disadvantage. When the business relies on technology you may end up outdated pretty fast unless you invest heavily in technology or be lucky/smart enough to bet on the winning technological approach (most of the cases you are not).

A few examples come into my mind. First, road tax. Most developed countries from western Europe use stickers applied on the windshield for verification. Some have automatic cameras to check them, others still rely on random human inspection. Eastern European countries introduced road tax years later -- and because the technology was available and (most probably) cheaper they use a completely electronic system. You don't get a sticker - they scan your license plate instead. They are easier to buy online and more flexible. For the countries that already have stickers it might not be economical feasible to update their system, so they might end up waiting years before upgrading.

Another is example is the internet infrastructure. Western countries had cooper wires from the 50s already in place and they used that. The cost to upgrade to fiber optics is harder to justify when have already a working system. Poorer countries didn't have cooper wires everywhere or they were in pretty bad shape. When they decided to get online fiber optic was already available and they started with that directly. That's why some underdeveloped countries have better Internet connection.

These are the stories that come in to my mind whenever I think about upgrading my 6 years old PC. I try to postpone the move as much as possible just to make the jump in performance as big as possible to better justify the cost and also to avoid being one of the first using i9 or Ryzen Threadripper.

 

 

 

Tags

How to commit whitespace and coding standard changes in legacy code

Submitted by luxian on Tue, 07/25/2017 - 07:38

The project I'm working on has inconsistency issues when it comes to coding style. Even though it's a Drupal project, it doesn't follow Drupal's coding standards and on top of that the .php files are saved using various character encoding and line endings. This forced me to develop a workflow that I use before changing legacy files which helped me to keep changes history readable.

Committing together a file encoding change, white-space conversion and a bug-fix will be a source of regret if you ever have to look at that diff again. Most likely you will pull your hair out trying to figure out what is a code change and what's only a code style fix. That's why I separate the coding standard fixes in a single commit before doing anything else. This commits will be easy to ignore when checking history and can provide a cleaner diff for the changes that follow.

The steps I follow are:

Tags

Disable Apache 2.x logging for favicon.ico or apple-touch-icon

Submitted by luxian on Wed, 07/19/2017 - 08:43

One of the features I like in nginx is the ability to disable logging for certain paths. For example whenever a browser sends a requests for a favicon.ico which doesn't exists the web server will respond with a 404 error but will also write the request to access_log and error_log -- which is totally useless. Most of the time nobody cares about these favicon and apple-touch-icon requests, so logging them is quite useless and is just a waste of CPU cycles and IO throughput.

If you use nginx is quite easy to disable logging for them with something like

location = /favicon.ico { 
  access_log off; 
  log_not_found off; 
} 

But Apache is more tricky to set up, the log configuration is not very straightforward. So here is what I was able to find on this subject after some hours of searching.

Tags

Ulauncher is my new favorite app launcher for Linux.

Submitted by luxian on Fri, 07/14/2017 - 08:19

Some time ago I wrote about Mutate. After a few weeks of using it I decided I need something better. Mutate had a major drawback, it couldn't handle properly .desktop files. That means that some apps were displayed with the wrong or missing icon and Chrome Apps did not work. For example when I tried to open Wunderlist (Chrome App) it will open just another Chrome window. It works well if I use normal app menu.

After trying to fix it myself for a while I gave up. The project is almost abandoned on Github.

This is how I ended up installing Ulauncher which works great with .desktop files. So no more issues with opening Chrome Apps or wrong app icons. It's also fast and reliable.

It was very easy to install following the instruction from the Github repository. The only problem I had was the autostart. By default it adds only the following line to autostart:

ulauncher --hide-window

But in my case that location was not in the $PATH variable, so I had to write the full path to Ulauncher in there.

 

Tags

Extract SSH public key from private key

Submitted by luxian on Thu, 03/09/2017 - 11:03

In the last couple of days I spent a lot of time debugging the deployment script called via GitLab CI. The script worked well on one server (dev), but failed on the second one (prod).

GitLab CI was using a docker container with an injected SSH private key to connect to server and run some scripts. The whole setup was exactly as described in the official tutorial. From the beginning I was surprised to see that public key was never added to the container. But since it did the job well  I didn't spend too much time to see how it actually works.

When I tried to make deployment work for a second server, things didn't work so smoothly. It refused to connect over SSH. After some digging and with ssh debugging enabled it was clear that the public key used by CI container was missing from the authorized_keys file on that server. The authorized_keys file was big on the first server, the one that work, and I had no idea which key was the one I needed to copy over. So I tried to see if I can extract the public key from the private key. To my delight, this seems to be a very easy task. You just need to run the following command:

ssh-keygen -y -f ~/.ssh/id_rsa

Where ~/.ssh/id_rsa is the file with your private key. This command will print the associated public key. With this key in place, the deployment script worked without issues.

Lessons learned:

  • private keys contain the public key so in case you lose it you can re-create it
  • I need a better systems for deploying and managing authorized_keys across all the servers

Tags

Deep learning gallery: Quadcopter trail navigation

Submitted by luxian on Tue, 02/28/2017 - 18:57

Deep Learning Gallery

I have deeplearninggallery.com in my bookmarks for quite some time but I didn't have time to check until today. As you probably guessed by the domain name itself, it's a gallery with a lot of cool deep learning projects. It's worth checking it out.

To stir your curiosity is a cool project I saw today:

Quadcopter trail navigation in forest

Project goal was to make a drone that can follow a trail through the forest using only one camera (no 3D images). You can see the results in the video. They pretty much did it. If you want to read more, you will find more links in the video description.

 

 

 

Google's AI becomes aggresive in stressful situation

Submitted by luxian on Mon, 02/13/2017 - 21:07

Actually this is not something very new if you have read all the previously recommended links in the article that started this serie "Artificial Inteligence". This new article is proving that depending on environment (how abundant resources are, goal definition and the connections between AI agents) the behavior of AI can be either aggressive or highly cooperative.

The full story can be found in the article Google's New AI Has Learned to Become "Highly Aggressive" in Stressful Situations. Following quotes are from it:

(...) the message is clear - put different AI systems in charge of competing interests in real-life situations, and it could be an all-out war if their objectives are not balanced against the overall goal of benefitting us humans above all else.

(...) the initial results show that, just because we build them, it doesn't mean robots and AI systems will automatically have our interests at heart.