CategoryTechnology

All the articles related to Information Technology related fields, including programming snippets, and other things I’m interested in

IIO Sensor proxy: screen rotation

One of the things,  I don’t get is why Linux enabled IIO Sensor Proxy default.

With a GNOME 3.18 (or newer) orientation changes will automatically be applied when rotating the panel.

Ambient light will be used to change the screen brightness. Geoclue will be able to read the compass data to show the direction in Maps.

It’s really annoying on the laptops if you accidentally rotate your monitor. So here’s is a what you got to do:

sudo systemctl stop iio-sensor-proxy.service
sudo systemctl disable iio-sensor-proxy.service

Enough with screen rotations.

PHP: Testing protected methods in CakePHP3

One of the things I recently had to deal with – PHP unit testing protected methods of the class in CakePHP 3. Few seconds of checking StackOverflow brought a nice and elegant way of checking protected methods using ReflectionClasses.

Sebastian Bergmann has a complete guide how to check non-public functionality of the classes in his archieves.

Here’s a short sample of the code using CakePHP3:

<?php
use Search\Model\Table\SaveSearchTable;
use Cake\TestSuite\TestCase;
class SaveSearchTableTest extends TestCase
{
public function setUp()
{
$this->SavedSearches = \Cake\ORM\TableRegistry::get('SavedSearches');
}
public function testProtectedMethod()
{
$methodName = 'protectedMethod';
$reflectionClass = new \ReflectionClass('\Search\Model\Table\SaveSearchesTable');
$method = $reflectionClass->getMethod($methodName);
$methodResult = $method->invokeArgs( $this->SavedSearches, ['arg1', ['arg2']]);
$this->assertNotEmpty($methodResult);
}
}

WP-CLI becomes part of make.wordpress.org

WP-CLI reached 1.x stable release. WordPress decided to make it as part of make.wordpress.org tools.

Great news from the WordPress community and those who spends most of their time in the console. No more weird sftpd/vsftpd installations.

It might come handy with composer bundle as we do it in Qobo for WordPress project templates.

PSR-7: storage-less sessions

As a frequent user of grep/ack for the codebase, ag seems to be a silver bullet, especially for the projects with large codebase. Available in rpm repositories.

What’s so great about Ag?

  • It is an order of magnitude faster than ack.
  • It ignores file patterns from your .gitignore and .hgignore.
  • If there are files in your source repo you don’t want to search, just add their patterns to a .ignore file. (*cough* *.min.js *cough*)
  • The command name is 33% shorter than ack, and all keys are on the home row!