Not All EOLs Are Created Equal

As I was playing with the Wordpress shortcode methods, I came upon an interesting problem.

I wanted to change text in the particular line of the shortcode content and thus standard PHP explode and implode methods seemed like a best bet:

add_shortcode('something', 'something_callback');

function snippet_pre_shortcode_callback($atts, $content = null) {
    $lines = **explode('\n', $content)**;
    $lines[1] = "My line 2";
    return **implode('\n', $lines)**;
}

Nice and simple solution that didn’t work. The big content string I was sure had some lines, wouldn’t split. It took me a while to notice the error - single quote in PHP does not specify character but string with a minimal escaping. Most of the time they behave same as the double quotes which actually allow for much richer escaping.

Most annoying was that I knew this “feature” from before. However, too much work in the proper programming languages kinda made me overlook this trivial error multiple times while debugging. After taking a “frustration break” and coming back after 5 minutes, mistake was obvious.

The easy solution would be to swap one quotes for another. However, in this case a bit nicer solution exists - use the damn PHP_EOL constant:

function snippet_pre_shortcode_callback($atts, $content = null) {
    $lines = **explode(^^PHP_EOL^^, $content)**;
    $lines[1] = "My line 2";
    return **implode(^^PHP_EOL^^, $lines)**;
}

PHP, who wouldn’t love you… :/

Update All the Same

Illustration

Some might have noticed that pretty much all my current programs got an update. More observant among you might have noticed that update bears the same major and minor version. For example, QText was bumped from 4.10 to 4.10. Why is that?

Reason lies in the need to resign my executables as my current certificate expires on March 1st and after that date you wouldn’t get nice install prompt but ugly red one. Programs would work all the same but, based on what happened two years ago, I would be swamped with e-mails. To avoid any misunderstanding, I simply recompiled application with the new certificate. All functionality remains unchanged, it is just certificate that is new.

Developers among you might ask why I am not timestamping my signature so they are still valid after certificate expires. I am doing that but devil is in the details.

My previous certificate (bought from StartSSL), had lifetime signing “feature” (WTD_LIFETIME_SIGNING_FLAG). Somewhat unexpectedly this means not that your signature is valid forever, but that it expires together with certificates, regardless of timestamping. Go figure…

In any case, SSLStart gave me non-“lifetime” certificate this year so timestamping should work in the future beyond their expiry. If not, I will repeat this post in two years. :)

Ham Check 1.10

Illustration

After a few months, a first update for my ham exam program is in order. Nothing much to see here, just a small refresh.

A new exam type has been added. Flash exam will provide you with an usual exam practice experience, the only difference being that it gives you the correct answer immediately. When learning for the first time, quick determination of the correct answer might be quite beneficial.

Useful for presentation is the ability to independently scale menu and content. This is a nice option to have when dealing with different resolutions - especially on annoyingly small projectors.

That is all for the first update, download the latest version from program’s pages.

73

Microsoft Accounts on NAS4Free Samba

Illustration

With Windows 10 you can get a certain advantages if you opt to use your Microsoft login. However, if you have something Unixoid (e.g. NAS4Free) for your file server you will quickly notice you need to remind it of your user name. And no, solution is not as simple as renaming your user to your e-mail address since at character (@) cannot be used.

What needs to be done instead is to create a simple mapping file (I named mine samba.map):

anita = anita@medo64.com
anita = anita
josip = josip@medo64.com
josip = josip

In that file you map user name received over network to the Unix user. Notice that multiple different names can be mapped to the same user.

Last step is getting Samba to actually use that file. How is that configured really varies with your system. For NAS4Free, you want to visit Services -> CIFS/SMB -> Settings and into Auxiliary parameters add path to the given mapping:

username map = /mnt/Config/samba.map

Now you can use your Windows 10 user e-mail to your heart’s desire.

[2018-07-22: NAS4Free has been renamed to XigmaNAS as of July 2018]

I've Got a Pebble in My Shoe

A month or so ago a new Pebble Time firmware came to the legacy Pebble devices - in my case the Pebble Steel. For something that is such a big change, installation process went better then expected. Only slightly annoying thing was installing new application on my phone but everything was smooth sailing from there. Until I started using it.

First, the good stuff. Application/watchface selection interface changed a bit to reflect possibility of having an infinite number of applications running. Yes, unlike the old firmware, the new one allows for dynamic swaps.

The new timeline interface was a pretty big change for me as I extensively used watchface swapping and now the same buttons brought different behavior. While I cannot say I am a big fan of the new interface, speaking with other people I will chalk this change to the improvement category. For myself, I still might not be using it much but at least I don’t actively hate it.

The bad stuff is that now you cannot use any application without your mobile phone. Before you had 8 applications but they were all available to you even if phone was dead. Yes, some of those applications might have had issues but standalone stuff worked (e.g. Authenticator). With the new firmware application is loaded only once you access it. If phone is dead, so are your applications. Yes, you might get some use of last running application but that is simply not enough. And lets me not get started about the time needed to enter the applications - it got much longer.

While slowness of the application access I can grudgingly understand, I cannot understand the freaking animation that take ages. And these animations are used liberally within the new timeline interface. Yes, at some places they might be needed to cover for bluetooth latency, but that just means application design is close to wrong if you need to chit-chat between phone and watch that much.

And forget about having multiple watchfaces if your mobile phone is dead. You will stay with whatever was last loaded. While I don’t change my watchface often under normal circumstances, I do so while traveling. As my travels are usually cross-atlantic, this also means I keep my phone turned off most of the time. Not being able to select between my standard watchface and one set at the destination’s timezone is annoying. More so because that used to work just fine with old firmware.

And don’t tell me this has to be like that due to the new interface. Even the first Pebble allowed for 8 applications in its memory. With Pebble Steel memory got doubled (while number of application slots remained the same). Even if we assume doubling of needs, we still could have at least 4 static application slots for the most important stuff (configurable).

And yes, even changing the menu order requires mobile phone as the new firmware removed on-watch menu editing too. Frankly, outside of slow and over-animated timeline interface, I cannot really think of the single thing new firmware actually improved. They just slashed mini features left and right.

I view this new firmware as a step backward whenever you need to use your Pebble as an independent device. Pebble used to shine when paired with mobile phone but it worked nicely even without it. New firmware ensures you need to have your phone turned on and next to you at all times. And even under the best of circumstances, the animations are going to seep the life out of you.

It might seem this text is harsh but I don’t think so. When compared to the other smart watches, Pebble excelled at being a comfortable thing you could use for prolonged amount of time (5 day battery) and not being dependent on a phone to work. With the new update only the long battery life remained. Yes, I am still fond of my Steel and I will keep it for a while longer. However, if it was to die today, I don’t think my next watch would be a Pebble.