Sunday, August 3, 2014

Web Workers in practice - Integration (HTML5)

Intro

Couple of years ago, web workers (along with other HTML5 stuff) suddenly became popular. On the  spike of their popularity, many tutorials were written. However, the moment of popularity was very brief, mainly because, well, you don't need this in your regular JS application. The common use case - blocked UI because of long-running script - is rather rare if you use modern browser with fast JS engine.
Have you really seen something like that recently?
In lots of tutorials all the workers did was passing messages to main script, where it was printed to console or put in some DOM element, which doesn't give you any feeling of concurrency at all.
More advanced ones included prime number sequence generation, which was more like it, as this is a really long operation, especially when you generate a long sequence :)
In this tutorial I'll try to show another example how web workers could be useful in practice - in other math problem.


Saturday, July 26, 2014

About Windows Phone 8.1 usability

This is interesting. While it's obvious that WP UI was designed with attention to details, some of the user experience is not pleasant at all. For example:

1. When you start using your phone, you can't update or install any app, unless you set the correct date. Technically, it fails when you try to create Outlook account (or "live id", whatever), which will be bound to the phone. Problem is that error message is extremely cryptic, stating only that update/install failed and providing error number. Googling up the error number revealed no specific details (at least to me). So I had to google once more, why the phone update could fail which gave me the page with possible problems, mentioning the need for correct time. My guess is that it reaches out to MS server to "activate" the phone. Anyway, it was quite unpleasant.

 2. Windows store app. I think it's not obvious that app updates are in downloads section. It took some time for me to figure it out.

3. Setting time by scrolling the rectangles with numbers is a bad idea IMO :) It may seem good to designers, but I'd prefer to type the numbers.

4. No changelogs in most of app updates. I mean those pre-installed apps like "News", "Weather" and Nokia stuff.

But all in all I can't say that I'm too disappointed. It runs rather smooth, and rectangle UI, while new to me, is an interesting concept.

Thursday, April 10, 2014

Programming Pocketbook - jumpstart script

As you may know, it's possible to build apps for some older Pocketbook models, that run Linux. There are 2 SDKs for that, that I'm aware of - official and unofficial one, the latter being much more popular. Unfortunately that SDK comes with no templates. So to start development from scratch, you have to manually create a bunch of file yourself, like the makefile and the source code file, which is not fine in the XXI century. To automate the process, I created this small shell script, which creates them for you, using a name you specify:
#!/bin/bash

echo "Input project name:"

read proj_name

mkdir $proj_name
mk_file_name=$proj_name".mk"
c_file_name=$proj_name".c"
master_makefile_name="Makefile"

cd $proj_name
echo "SOURCES += "$proj_name".c" > $mk_file_name

echo "OUT = "$proj_name > $master_makefile_name
echo "include /usr/local/pocketbook/common.mk" >> $master_makefile_name

echo -e "#include \"inkview.h\"\n\nint main(int argc, char **argv)\n{\nreturn 0;\n}" > $c_file_name
Hope it hepls you too.

Saturday, March 8, 2014

Running old ASP app on Windows 7 - 401.3 unauthorized problem

There's a great article here about how to run and debug that 'classic' ASP site of yours, if you happen to have one. However, if you make just the steps from article, you'll probably end up with "HTTP Error 401.3 - Unauthorized" error. The solution is simple and found on serverfault - you just have to grant the IUSR user at least a Read&Execute access to your website's folder. Just like that:
Hope I saved you some googling.

Sunday, March 2, 2014

ASP.NET web forms captcha

The whole purpose of this post is to show how simple it is to introduce some custom handler in ASP.NET (that old one, which's still used though). Reading the preparation book to TS 70-515 exam, I found handlers' examples there very impractical, so I decided to get more or less real case, where custom handlers are of use - captcha. To free UI thread, handler will be asynchronous.

Saturday, March 1, 2014

Changing desktop icon fonts in xfce

You may have noticed, that desktop icon fonts that are by default in Linux Mint xfce/Xubuntu distros are awful. It’s just plain black, which means that putting any dark wallpaper will render your icon labels unreadable.
Seriously, guys! Desktop font should be light gray with a dark gray shadow, as it is in LM Mate, LM Gnome, Windows or any other OS. Usability designers have discovered this long ago, just copy this solution as many have done before you.
Fortunately, I googled up this xfce forum thread, where guy is adviced how to change the desktop fonts in xfce.
The only difference is that you have to edit the .gtkrc-xfce file, not .gtkrc-2.0, as the latter contains only include ".gtkrc-xfce" line.
So,you may copy-paste the code below to your ~/.gtkrc-xfce and relog with the current user so that changes are applied.
style "xfdesktop-icon-view" {
    XfdesktopIconView::label-alpha = 0
    XfdesktopIconView::shadow-x-offset = 1
    XfdesktopIconView::shadow-y-offset = 1
    XfdesktopIconView::shadow-color = "#101010"
    XfdesktopIconView::selected-shadow-x-offset = 1
    XfdesktopIconView::selected-shadow-y-offset = 1
    XfdesktopIconView::selected-shadow-color = "#101010"
 
    fg[NORMAL] = "#fefefe"
    fg[SELECTED] = "#fefefe"
    fg[ACTIVE] = "#fefefe"
}
widget_class "*XfdesktopIconView*" style "xfdesktop-icon-view"
If you want to change font as well, for example to ‘Verdana’, just add font_name="Verdana" line somewhere within the braces.
P.S. I think this is quite a good example of why the Linux desktop lags behind the Windows and OSX.

Displaying quotation marks in CSV opened by Excel

I love CSV. Easy to serialize, easy to read, great choice for some basic reports. Good news is, it can be opened by MS Excel, so office folks can use it. Bad news is that Excel (at least 2007 one, which’s still widely used) parses CSV in a weird way.
So, how wrapping quotation marks are handled:

1. Single quotation marks around value have no effect –
"test"
is displayed as
test
.
2. Double quotation marks add some ‘cool’ quotation marks in the end of the string – so
""test""
becomes
test""
.
3. Tripple quotation marks actually give those bloody single quotation marks around value –
"""test"""
becomes
"test"

Note, that this applies only to quot. marks that ‘wrap’ the value, i.e. are at the start and the end of value. Quot. marks in the middle of value are displayed ‘as-is’, e.g.
test "that" string
is displayed as
test "that" string
(identical).
I’m not that sure I want to know of reasons why it’s made so.