Dokumentacija o mrežnom protokolu i datotečnom formatu za fiskalnu blagajnu

Dokumentacija se, zanimljivo, ne nalazi na FINAinom webu o fiskalizaciji, nego na webu porezne uprave.

Zato jer, je li, logično je da se koristi PKI arhitektura FINAe i podnose zahtjevi FINAi i zatim sve submita poreznoj upravi.

Dakle, file format za XML datoteku, postupak potpisivanja (hura, signing) i network protokol. Hura – here’s to reading massive amounts of boring stuff! Hura za nove poreze, hura za FINA-u i hura za vrle nam ministre…

Bulk uploading of Google Apps accounts via CSV using Apple Numbers

I’m using Apple Numbers on a Mac with Croatian locale. This means CSV files not only don’t have a BOM (byte order mark) which Google Apps requires, but its CSV files are not actually comma-separated, but semicolon-separated. (Croats use decimal comma instead of decimal point, so any CSV files generated by spreadsheets can’t use commas. Weird, yep, my dear US reader.)

So… follow Google’s instructions in building the CSV file, and then process it with the following commands in Vim.

:set bomb
:%s/;/,/g
:wq

You’re welcome.

Mini-review: Windows 8, after a while

I don’t use Windows daily, but I’ve got a bit of experience with Windows 8 nonetheless now. So, a small update.

1. Freezes don’t occur after I got several hundred megabytes of updates. I did not try the suggestion in an Ars Technica comment which claims…

This is the “dynamic tick” issue. Install the latest updates through Windows Update to fix itor disable dynamic ticking.

Run Command Prompt as Administrator and type this:

bcdedit /set disabledynamictick yes

and then reboot.

2. Lock screen is cool.
3. Couldn’t get Apple multitouch touchpad to work yet.
4. TeamViewer 8 now supports sending multitouch gestures from iPad to Windows, so I played a bit with that. Neat; I can imagine this being cool on a tablet. But no way these gestures will be tolerable on a desktop.
5. Desktop removal was done only partially. I really wish I could make Metro a secondary UI at this point; Explorer improvements are fantastic, and Metro is only a toy.
6. Xbox Games app is still useless to me.
7. Store app is useless to me, but at least I found out how Updates are done. A small link appears in top right.
8. I like the fact that I could theoretically write a Metro/WinRT app in pure C. I don’t like the fact that the signature requirement and different formats make it nearly impossible to use MinGW for that.

Anyway, I’m not as angry as I was after an hour of use, especially since the system does not randomly restart for me. In fact, I’m not angry at all; I’m more disappointed, considering that this would’ve been an awesome upgrade from Win7 were it not for a silly potentially unreadable theme in desktop (and removal of Windows Classic theme!), and were it not for the Metro being forcefully shoved at everyone, yet being inaccessible to developers who don’t want to ship through Windows Store. Metro may be cool in some uses, but should not have been forced upon every single desktop user who wants Windows 8 just for better performance and better Explorer.

Windows 8 mini-review: My first hour

An hour of primarily disappointment and three total machine lockups.

Tons of stuff that looked like a good idea turned out to be a disaster. Let’s list some stuff. All this on Macbook, unibody late-09. I point out once again: this is after an hour of playing, without studying anything or doing any reading.

1. Three complete machine lockups. Unacceptable. I’m typing this from Ubuntu 12.04, fastest booting OS on my machine.
2. Boot not much faster. My time to desktop, uh, I mean Steam, isn’t much faster. Reports of speedups may have been exaggerated.
3. Microsoft account required to read Gmail?! Seriously, wtf.
4. Games app not updated out of the box. You get a big banner that you must must must update via Windows Store app. It’s clickable, except nothing happens.
5. Touchpad doesn’t work. I get it, I have Apple drivers for it which may be broken. But if they don’t work, don’t completely disable the device — it’s moronic. You don’t need a driver because it is also representing itself as a mouse, not just a touchpad.
6. WPA2 Enterprise settings finally at sane defaults. Something good at least. They could have turned on ‘authenticate as user’ by default, too, though.
7. Whoever designed charms opening method needs to be shot. Point to up right, then wait, then click on an option? Seriously?
8. Extra options by right clicking. Seriously?! Apps have hidden interface — and I’m supposed to just GUESS it’s opened by rightclick? I wouldn’t mind if it didn’t go against every convention on every other OS, including Windows 8 itself: charms are opened one way, additional app options another. Why not make me point into another corner, at least, to be consistent!?
9. Windows Store app doesn’t come with obvious Update button. The only way I found to open the update screen is to open Games app and get that app to open Windows Store app to see 14 updates available.
10. Services blow. More than once an app started doing something online (with an annoying oversized “I’m working” bar instead of their equally annoying excuse for a spinner) and never finished. Including the Windows Store app doing updates.
11. Calendar app doesn’t support multiple calendars per account. And it’s even documented in the FAQ for the Calendar app with my precise use case: Gmail account with multiple calendars, including shared ones. Jeebus. This from the company that makes Outlook.
12. Tiles are oversized, live tiles are annoying. Some tiles are live, some are not. Most that ship are completely useless to me, for example the stock ticker tile. So they add to the noise. I saw an option that appears to allow me to turn tiles off, but having some tiles live and some not makes me yell and scream at the choice of the default ones. Most of default ones that are live are the ones that are useless to me.
13. Microsoft account required for Mail app. Did I say this? If I did, I’ll say it again.
14. Messaging app doesn’t come with XMPP. Facebook supports XMPP, Windows Live Messenger supports XMPP, Google Talk supports XMPP. Instead they opt for supporting one Facebook account and one Windows Live account — the one you used for login. Doesn’t matter that I actually have two old unused, but contact filled accounts which I may want to put into good use again (and which happen to be linked with the current account); I can’t, because I switched to a new account and a new address. WTF.
15. No Twitter support out of the box. Windows 8 is the only current desktop OS coming without at least the ability to send tweets, if not read them. Ubuntu comes with Gwibber and integration into menu bar, and OS X comes with integration into notification center.
16. Everything is in alt-tab. Metro apps, Win32 apps, it doesn’t matter. Everything is mixed. And if an app starts launching and you alt-tab, apparently you canceled the launch and made it shut down. If it completes the launch, it’ll stay active. If not, not. At least that’s the impression I have.
17. Apps launch slowly. Shouldn’t use of Metro and .Net and whatever not made launches snappier?
18. Tiles are, in practice, ginormous and ugly. Oh, I said that already. But I didn’t say that some are tiny, and some are big, and that I’m totally confused by the way they’re supposed to be ordered.
19. CONTACTS TILE IS ANIMATED. (!!) First, I have NO idea why I’d want to watch my contacts’ photos. Second, don’t animate that. I do need an addressbook, but I don’t need it to blow up contacts’ avatars into my face by default.
20. Mail app is best made of the default ones. And that doesn’t mean much.
21. I need quick access to settings, especially during setup, but also later! Mac’s even got a standardized shortcut for that: command+comma. While I’m setting up the system, I don’t want to always go through annoying procedure with charms.
22. Expose! If you guys already bothered to make all these fullscreen apps and all cutesy and what not, and if you mapped command+tab to something more sane than what you did in Windows 7, then you could have also implemented Expose so I can actually see all the apps that I’m running. Their content would even be easily visible in tile-sized thumbnails, considering what font size you guys picked…
23. HORIZONTAL M*F* SCROLLING. (Say that in your best Samuel L Jackson voice, please.) I find horizontal scrolling HIGHLY irritating. I think it even stops scrolling if you point it over some widgets while not over others, so you have to ‘evade’ the deadzones? I may be wrong on this one. And I surely ain’t rebootin’ into Windows so it can freeze on me once again.
24. Did I mention how the Games app doesn’t work out of the box? And how the Store app has hidden the Update button somewhere I couldn’t find it?
25. ARGH! And argh! No “sideloading” of Metro apps! Argh! They renamed plain-old installation into sideloading, as if it were something despicable and not-recommended! And then they blocked it!
26. Whoever came up with the idea that Store app needs no search box because you can open the Search charm needs to be outcast from the user interface design community for the rest of their life. They thought you can replace all search functionality with a hidden, hard to reach button that’s reachable only via a gesture that needs a delay. I didn’t think of hitting Ctrl+f because I saw no search box. Perhaps it works, perhaps it doesn’t. I’m not rebooting to check.
27. During install you are ‘encouraged’ to connect to WLAN… but lack enough options. Metro interface itself lacks enough WLAN configuration options; you have to drop back into desktop to configure the details, because improved defaults for connecting to a WPA2 Enterprise network are just that: improved. What if they don’t work? Well, no manual configuration for you. What’s worse, during setup, the network I tried to connect to didn’t appear even after refreshing the list. New networks appeared, but not the one I needed. Cute. So I skipped connecting, hopefully not missing an opportunity for more joy.
28. I could probably come up with a dozen more things, but it’s 1am.

Some things are so horribly limited, so horribly underthought (or perhaps overthought by wanna-be-clever strategists) that I can’t imagine myself even contemplating switching to Windows 8 for productivity if, for any reason, I couldn’t use OS X anymore.

If I ever have to go anywhere but Mac, I’m going to Ubuntu. And I suspect that for my minimal gaming needs I’ll upgrade back to Windows 7. Some text I read implied that I’d need a developer license to even start writing Metro apps (hint: not needed even for writing iPhone apps in Simulator), and at the moment I’m unwilling to contemplate joining any such dev program and even less forking over cash for it. If I’m wrong on this one, sorry, I can’t be bothered to Google this at 1am.

I’m even extremely happy and pleased that I didn’t have to buy Windows 8, instead getting it via university’s membership in DreamSpark.

It’s 1am, and maybe I’m just tired. These are just first impressions. If I force myself to use the OS enough, maybe it’ll grow on me. Maybe Microsoft will turn Metro apps into something more than a pile of colored underpowered pieces of… joy. In the meantime, I’m just writing down my first, early impressions. If they change, I’ll write a small follow-up. And I sure hope that I’m just sleepy, grumpy and over-irritated right now. Because otherwise, this is a flop of epic proportions.

iPhone 5 is a transition device

So you’re Apple.

And not the magical, mythical, always inspired Apple. You’re Apple that has been a market leader for a while, and is now being overtaken by new devices. You’re the Apple that is clinging to a philosophy that has served you well: don’t make your customers inconvenienced, and keep backward compatibility as long as possible. Change stuff when needed, and do so gradually.

Try not to break stuff

Developers often get this treatment from Apple. You are gradually eased out of your old practices and “encouraged” to adopt new ones. There are rarely any sudden changes. Even UDID was not suddenly thrown out from the OS; it was first deprecated, and then thrown out of iOS6 after months and months of easing developers into new practices. I can’t really remember significant mistreatments of developers, aside from weird App Store rejections and insistence on quite limiting sandboxing model. (Even there, line had to be drawn somewhere in order to make everyone happier and enforce better development practices.)

Aside from developers, Apple also doesn’t want end users, its primary customer base, to be inconvenienced. iOS 6 broke several things in several apps I work on when I first launched them in the Simulator, and I completely understand what went wrong and that most of what Apple changed is for the better. (I’m unsure how is force-crashing the app when no auto-rotation target is successfully calculated counts as a change for the better, though.)

However, in order not to break existing apps, Apple seems to have employed the model from OS X where the behaviors occasionally change based on the SDK the app was built on. I’m pretty convinced that several classes that ship in UIKit are loaded differently based on whether or not iOS 6 SDK was used in compiling the apps.

Don’t reject change

However, there’s a thing that Apple does that is also easy to notice: they are not resistant to change. Microsoft has tried very hard to keep backward compatibility as far back into the history as possible. Apple has taken many opportunities to shed itself of legacy code and practices. Mac OS to Mac OS X was a chance to throw away some legacy Macintosh Toolkit practices and establish Carbon as a nearly-Toolkit-but-not-quite replacement, with somewhat better structured code. PowerPC to Intel transition was a chance to break some code, but not a lot. Intel to Intel 64-bit was a chance to throw away most of Carbon and to introduce a new, but incompatible, runtime for Objective-C that is extended to this day without breaking existing apps. (One of major things this new runtime brought was non-fragile ABI, which basically means Apple can add stuff into Objective-C classes without breaking stuff.)

Apple has recently deprecated development for armv6 devices, and with Xcode 4.5 and iOS 6 decided to completely do away with support for it. This is surely inconveniencing some developers who, like me, up until then used iPhone or iPhone 3G as their main iOS device, and inconveniencing users who are no longer going to be able to get new versions of apps. And unless they backed up the .ipa files, they won’t be able to install versions that did support their device.

They are not afraid to change stuff. They are careful to ease developers in. And the myth that Apple magically “knows” what users want has been dispelled recently. And of course, it’s only logical that Apple, its engineers, as well as its management, do live in the same world that we do.

They see what people want because they observe. They may end up deciding on price point based on profit margins, profit now instead of profit later, and they may end up on deciding what goes into the device based on what can they can realistically construct best. But they definitely, definitely do watch what people want.

People want bigger devices

Remember 2007 and 2008, even 2009? Remember how people complained about iPhone’s size?

Jump to 2011 and 2012. iPad has come, other tablets have come, and people have seen that they, in reality, want bigger devices. Something rare has happened: Apple has missed what people want. (G4 Cube was another instance, and their insane prices in ‘less wealthy’ countries may be other instances.)

A controversial subject in ‘certain’ countries in the world, evolution theory, does in fact work. Perhaps we cannot go to the past to see that Earth was, in fact, inhabited by life forms that changed in response to environmental changes and that mutated; perhaps denialists can produce odd explanations for the abundance of evidence we have in favor of evolution theory.

But ‘genetic algorithms‘ definitely do show that mutation, recombination, and overall improvement in small steps by extolling beneficial adaptation, ignoring harmless ones, and shunning the harmful ones actually does work.

Android has flooded the market and evolved.

Adaptation

With Android, there were a lot of mutations. It has started with a poor product, and slowly grown. Various screen sizes, various input devices, various launchers, using stock versus using modified OS — all these things were mixed, matched, recombined, changed, and in the end we got devices like Galaxy S3 and Galaxy Note.

I have not owned an Android device, nor do I foresee that in the nearby future I will. I have played only a little while with several tablets, and my sister has an Android phone. I’m utterly unimpressed by the environment itself. I’m occasionally impressed by what openness has allowed, while at the same time unimpressed by flooded Android Market Google Play, with applications not being vetted, with applications that suspiciously request far more permissions that they need, with abhorrent and unnecessary NFC…

Yet a good point is being made.

All these changes, mutations, mixes and matches have produced several outstanding devices, and widened our horizons.

Android may be an initially stolen (and an initially poorly stolen, at that) product. What amounts to industrial espionage by a certain former board member at Apple has produced a vibrant smartphone market that even Apple will learn from. Notification Center is one example where Android took the lead, where a developer for jailbroken iOS systems has created a Notification Center, and where he ended up being hired to replicate it at Apple in an even better way than he did on jailbroken 4.x systems.

(Note that iOS itself has taken a lot of, shall we say, ‘hints’ from the old Palm OS, from Pocket PC and Windows Mobile — primarily packing a lot of UI ideas into a highly animated and fluent, NeXT-related UNIX-based operating system.)

What’s the future bringing? Screen size changes!

Apple has done a great thing for developers when the retina screen came out. The change was so radical that they needed all developers to upscale apps to 2x their size. So they did the same thing Palm did and that sometimes Microsoft did: they simply said that a pixel is not a pixel is not a pixel, but that a pixel is instead a ‘point’. They did something different, too: they simply said that the upscaling will be solely at 2x rate, not 1.5x, not 2.5x. They also made use of sub-‘point’ precision easy (albeit occasionally inconsistent, if you dig deep enough — for example, CATiledLayer does some weird stuff).

However, it turns out that people also want screens of different sizes, aspect ratios et al. It turns out that even people who are hard-core Apple fanboys clamor for a bigger iPhone for easier reading, even though they immediately say that a bigger size would “not fit the hand as well as the current size”. (And I don’t agree, considering that — surprise, surprise! — people have different hand sizes, hence the current size does not fit as well.)

How would you bring different screen sizes?

So on OS X, developers have been trained for a long time to use the “struts and springs” model to make the user interface elements (views, we call ’em) respond to size of their parent view. For example, when a window resizes, many sub-elements resize as well.

iOS also has the struts-and-springs model available. Either in Interface Builder or manually via the -setAutoresizingMask: method, developer can quite easily make the UI resizable.

Except many people never bothered more than absolutely necessary; for example, due to designing without navbar when the navbar could actually appear in runtime. They never had to, because — due to inflexibility of the window — they never had to play with multiple screen sizes. One of the only two places where the screen size changed radically were the transition to iPad, which in itself required a radically different user interface model (and use of different nib-files was VERY encouraged).

The other place where window and view sizes varied was the very, VERY underused TV-out display support for every UIWindow — which existed since iOS 3.2.

Training developers to use autoresizing masks

So if you ever wanted to train people to use autoresizing masks in preparation for a variable screen size, how would you approach the problem, Apple-style?

Obviously, you first need to deprecate the old-style development; that is, iOS app development with minimal autoresizing support. If you can’t actually force devs to use it (and with autoresizing masks, you can’t), then nudge them in the right direction.

One way is to explore what else is blocking good use of autoresizing and make sure you fix that problem. In case you can’t actually fix the problem elegantly, still provide the solution as a way to nudge developers to notice you really, really want to emphasize autoresizing.

Final step involves actual introduction of a device that uses a radically different screen size, without inconveniencing users by blocking operation of old apps.

What are the first two steps?

First step involved release of iPhone 5. This was a definite wake-up call that you really, really need to iron out those few places where you managed to mess up autoresizing. You don’t need to fix anything on the x axis, but y axis is fair game. On launch day of iPhone 5, you realized that the rumors were true, and whatever stuff you read about Apple never changing the resolution except by scaling by powers of two were — wrong. You, the dev, now needed to adapt to everything other platforms already had to do: resolutions change, and not just by scaling in powers of two. DPI (or, perhaps, PPP or pixels per ‘point’) do change in powers-of-two, but not the resolutions. In fact, you realize that you were groomed for the resolution staying fixed at 480×320 points, but that suddenly that’s no longer true.

Now you are not in the world of 480×320, but in the world of 586×320, and your every assumption is fair game.

However, if you don’t ship that one file called Default-568h.png (or, as Apple nudges you to call it, Default-568h@2x.png), you’re getting a pass. We won’t screw your app over just yet. This is just an introduction… but you’d better adapt! You don’t want black bars on top and bottom of user’s device. And think wider* too: iPad users get the black box around the iPhone apps as well as lower resolution of the app. Don’t you think iPhone 5 users deserve better, just like iPad users?

* See what I did there?

What’s the second step? Something called “automatic layout” being force-fed upon developers by default in Xcode 4.5. No matter that it’s as usable as a brick — it is quite powerful, and if the dev takes the time to correctly build the UI using automatic layout, then the localization becomes quite better. It’s completely unusable in the current state, though, so I suspect a lot of devs (especially those who don’t widely localize their apps) will stick with the old-but-reliable struts-and-springs model.

As I said, the second step may not involve creation of something usable. It does involve nudging devs in the right direction.

Future devices

So the third step is, of course, wholehearted acceptance of what Apple already knows, but developers may only suspect: variable resolution displays.

Apple has heard folks who clamor about Galaxy Note’s size. Apple has realized that there’s a sweet spot between iPhone and iPad screen sizes.

iPad mini is a further proof that Apple is willing to play with screen sizes. It didn’t play with the resolution yet, but I feel it’s only a matter of time before Apple releases a non-4:3 iPad. Perhaps with a built in phone.

Perhaps a phone which can also run UIUserInterfaceIdiomPad applications adapted for the new resolution?

Maybe we’ll also see a Default.png mini-revolution, where we will specify to Apple how they should resize the Default.png image, or allow devs to run some very simple Core Graphics code upon app installation in order to draw the image, instead of shipping various images for various resolutions and orientations? For a completely universal app in complete compliance with best practices for Default.png, an app that is iPhone 5 and iPad 3-aware which still supports iPhone 3GS — you have to ship no less than 5 images. If my prediction comes true, it’s only going to get worse.

I have absolutely no idea how Android solves the problem, nor am I really interested.

How hard is it to adapt?

I don’t think that adapting will be too hard. What one must take into account is that, all of a sudden, we will have to make wider use of resizable-image-with-cap-insets support introduced in iOS 5, and enhanced in iOS 6. I suspect Interface Builder will be enhanced in order to permit easier creation of such images (which currently have to be constructed in source code). Aside from ‘just’ skinning buttons, although even that was avoidable by having the app’s artist export each and every button with static text already painted on it, we’ll find out that suddenly there are a lot more backgrounds we have to skin, including the table view backgrounds.

But I’m almost sure that this revolution will happen.

If anything, Scott Forstall leaving Apple is probably going to make this easier. Who knows — perhaps he was one of the people pushing for never changing the UI resolution, based on his judgement of appropriateness of the platform for withstanding such a change. Perhaps he didn’t even care, and the decision was made by another manager or engineer.

Whatever the case — the point of this entire rant is that varying screen resolutions are coming. Perhaps not as wildly as was the case with Android, but we will see them change. We may even see a sort of convergence of iPhone and iPad, with iPad pushing out the iPod touch from the game.

It would be in line with lineup simplification that Apple likes to do every couple of years. So just as the Mac Pro is probably about to die, perhaps iPod touch will die, too.

A possible future lineup?

Professional Consumer
Mobile iPhone iPad
Desktop iMac Mac mini
Portable MacBook Pro MacBook Air
TV Apple TV HD Apple TV

What do you think?

Installing IMAP extension for PHP on Mountain Lion

Based on Dao Hoang Son’s tutorial (itself based on Dan Spencer’s Lion tutorial), as well as a few corrections of my own, I came up with the following script. It fetches and installs University of Washington’s IMAP library, then the PCRE – Perl Compatible Regular Expressions library, and finally the PHP IMAP extension itself.

Please study the script yourself before running it, or run it line by line. It performs no error checking, meaning it might totally wreck your machine — and I’m not responsible if it does. Keep a Time Machine backup around and unplugged from the computer, in case it does.

The script wasn’t yet tested in its complete form; it’s an approximate transcript of commands I ran in shell. But since I’ll keep it around in case I ever need to re-run it, I’m fairly certain it works.

UPDATE December 24th 2012 – Merry Christmas! I’ve applied corrections based on Mehmet’s comment. He also comments you need to install autoconf before running the script (so phpize can work). I already had it installed.

Filesizes for stuff I downloaded: 1.990.304 – imap-2007f.tar.gz, 1.539.766 – pcre-8.20.tar.gz, 12.926.535 – PHP-5.3.15.tar.gz

#!/bin/bash
BUILDDIR=/tmp/phpimapmountainlion

mkdir "$BUILDDIR"
echo " "
echo "= FETCHING AND INSTALLING IMAP"
echo " "
cd "$BUILDDIR"
wget -c ftp://ftp.cac.washington.edu/imap/imap-2007f.tar.gz
rm -rf imap-2007f
tar xvvfz imap-2007f.tar.gz
cd imap-2007f
make osx EXTRACFLAGS="-arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp"
sudo mkdir -p /usr/local/imap-2007f/include
sudo cp c-client/*.h /usr/local/imap-2007f/include
sudo mkdir -p /usr/local/imap-2007f/lib
sudo cp c-client/c-client.a /usr/local/imap-2007f/lib/libc-client.a

echo " "
echo "= FETCHING AND INSTALLING PCRE"
echo " "
cd "$BUILDDIR"
wget "http://sourceforge.net/projects/pcre/files/pcre/8.20/pcre-8.20.tar.gz"
rm -rf pcre-8.20
tar xvvfz pcre-8.20.tar.gz
cd pcre-8.20
./configure --prefix=/usr/local
make
sudo make install

echo " "
echo "= FETCHING AND INSTALLING PHP-IMAP"
echo " "
cd "$BUILDDIR"
PHPVERSION=`php --version|head -n1|cut -f 2 -d ' '`
##git clone -b "PHP-$PHPVERSION" https://github.com/php/php-src.git php-src
wget --no-check-certificate -c https://github.com/php/php-src/tarball/PHP-5.3.15 -O PHP-5.3.15.tar.gz
tar xvvfz PHP-5.3.15.tar.gz
cd `ls |grep php-php-src-|head -n1`
cd ext/imap
phpize
./configure --with-imap=/usr/local/imap-2007f --with-kerberos --with-imap-ssl
make
sudo cp modules/imap.so /usr/lib/php/extensions/no-debug-non-zts-20090626/