Language change detection in Android Jellybean 4.2+

In the current project I’m working on we had to detect system language change. We wanted to rely on Android configuration change mechanism, that handles this for us, but we had to do some additional state modifications beside UI. So, the easy way is to detect configuration changes and handle them, following Handling Runtime Changes. Ok, so we […]

Xcode switch tip

Today I’ve found a tip from Google about iOS development, on their “Route 85” Youtube video series. I always code defensively, and adding a default case option is one of the things you usually do on a switch when programming defensively. But in the case they show, this is a bad thing. When you write […]

Debug Cordova apps using GenyMotion

Debugging Cordova apps using GenyMotion is fully supported. You just have to bear in mind that it behaves as a real device for ADB. So, to launch it from the command line you just have to run: cordova run android From your project directory. All credit must go to Nextneed on Stackoverflow.

Generating Repetitive CSS with Loops in LESS

Less is an amazing tool for simplifying your CSS: allows you to “extend” selectors (i.e. put selectors inside other selectors), to use mixins (i.e. a kind of “functions” that allow repeating optionally parametrized sets of CSS rules) and to use variables. One missing feature is not having loops, for example to create a repetitive rule. […]

Converting a physical machine to VM

After many years in software development, I’ve switched machines many times. But I always tried to keep the old ones stored, just in case. Today I’ve finally decided to convert this old machines to a VM, and store only a hard disk and not the whole hardware. First of all, I started the conversion using VMware […]

Atomically increment a limited value in MySQL and PHP

Sometimes you need to acquire a limited resource in an atomically, concurrent way. This is what semaphores are for. But when this resource is in a MySQL row, apparently there is no straightforward way of doing it. In my case, I had a row with two fields used to limit maximum resource usage: ‘used’ and […]

Switching to Firefox again

The other day I stumbled upon the article Windows Timer Resolution: Megawatts Wasted and to make long story short, I ran powercfg -energy duration 5 on my system and found that Chrome, Spotify and Naver’s Line client for Windows were making my system to increase timer resolution to 1 ms, wasting energy and making my laptop run warmer […]

Disabling right click and swipe on Windows Store Apps without using code-behind

A month ago I was working on a Windows Store project and I needed to disable right click and swipe for some grid controls. Of course, the property to disable/enable swipe is well known: IsSwipeEnabled. Just put a false there and you’re ready to go! But I could not find an equivalent property to disable […]

Showing a rotation-locked activity programatically in Android

Sometimes you need an activity showing in a locked orientation (i.e. no rotation allowed), but you need to decide which orientation should be the activity display dynamically by code. In my case, I had to implement a chroma-keyed camera app and the backgrounds where either landscape or portrait. When the user tapped the background to […]