Ext JS 6 Formulae to Combine Date and Time fields

My brother has been on my case to blog something about web development; he blogs at the drop of a hat whereas my offerings are usually spread years apart. I develop using Ext JS for a living (among other things) and its lack of a combined date/time field is very annoying. Previously I would copy the time onto the selected date before saving the record, but that’s a bit nasty. So I’ve written some ViewModel formulae to do it instantly.

Here is the result:

Specifying the date first will default to 9:00 AM, and specifying a time first (without having entered a date already) will default to the current day. I am using the ViewModel.links property to create a new DateAndTime model instance (which I’ve named ‘rec’). The Date and Time fields are bound to ‘{Date}’ and ‘{Time}’ and the get and set methods on their respective formulae take care of changing the shared datetime field on the model. There is a display field bound to the ‘{DateAndTime}’ formula which shows the current value the moment it changes.

It’s quite likely that anybody not versed in the many intricacies of Ext JS won’t have a clue what I’m talking about here. This post is not for you :-) But it might help some poor sod dealing with the inconvenience of not having one field to take care of both the date and the time in Ext JS. Perhaps an override might be better but I try to come up with solutions that don’t involve any extra jiggery pokery (I also use Sencha Architect, where it’s very easy to see what I’ve done if I happen to work on my old code one day; it does happen from time to time!).

Desert Colour Scheme for NetBeans

Eyeball a white screen whilst programming for too long and your eyes are going to hurt, so a sympathetic colour scheme is essential. My favourite scheme, or at least the one I became used to when I used gedit a fair bit, is called Desert (no longer available, so here’s my copy), which is based on the Desert scheme for vim. Lately I’ve been using Geany to take advantage of a few more features, so here are of the relevant files from my “~/.config/geany/filedefs” directory which I modified to implement the same colours.

However, this Christmas I intend to read Programming Clojure, a book I bought just over a year ago! And since I haven’t been able to cope with emacs or vim, I was forced to once and for all put in the time to implement the Desert colour scheme in NetBeans. The process was quite laborious, so hopefully this will be useful to those who find the default offerings a little meagre.

Here’s a sample of the colour scheme, showing defpackage.clj from the clojure examples in the book. I have also configured these same colours for other file formats I use often, such as PHP, HTML, JS, CSS, SQL, and knocked up the others as best I could in the time available. NetBeans sure doesn’t make this easy, but you gets what you pays for :-)

(picture: preview showing desert colour scheme

Download: Desert Colour Scheme for NetBeans 59.3 KB (created with 6.9.1)

To install, open NetBeans, go to Tools > Options, then click on Fonts & Colors, then click the Import button at the bottom and browse to the file downloaded above. Enjoy!

Two years using Linux and I’m in computing heaven

This morning I wanted to scan an image, so I fired up Simple Scan in Ubuntu and clicked the scan button (by the way, using my cheap CanoScan LiDE 20 for which there was no 64-bit Windows 7 support for quite some time – now supported with a 10 MB driver/software download – but which Ubuntu supports out-of-the-box with no effort on my part). As soon as I see the picture on screen I decide to see if I can just stop it there and save what I want. Lo and behold, it doesn’t complain, I crop the image and click save, and it just saves without having to scan the image again like most dumb-ass commercial scanning packages. Very impressed.

I then decide that the image is a little too big, and not wanting to fire up The GIMP like I have been doing until now, I decide to search for a better way. A short Google search later and I find the nautilus-image-converter add-on to Ubuntu’s file manager. A mere 30 KB download using the Synaptic Package Manager (Add/Remove Programs on steroids for you Windows slaves) and a re-login later and I’m resizing images with ease.

If you search for “free image resizer windows 7” you get quite a lot and the only link I could safely say is free of viruses and spyware is Google Picasa, but since it appears in the Ads section, anybody with half a brain should be wary these days (except Google in this case). Search for any Windows software and you’re more likely to get spyware than not. Being a Linux user I don’t have that problem because my software only comes from a trusted source, and not the likes of FileHippo.com or soft32.com.

I started using Linux seriously exactly two years ago when I happily took the buggy Windows Vista off my media centre PC and installed Mythbuntu 8.10. At the time I had to tinker a little to get my remote control working and a few other things but since installing 10.10 last weekend, I found it was an absolute cinch! By default it installed Samba and configured the same shares I did two years ago, there was an option for my remote control, and it looks more polished than before. The only thing I did as before was enable low noise amplification on my TV card. And since the transmitted digital TV guide in Australia is pretty decent now, I don’t even need to install Shepherd, which has served me very well. The new version of MythTV even comes with a Python script that automatically downloads matching artwork for my favourite TV recordings such as The Colbert Report and The Daily Show with Jon Stewart. My brother has been complaining about his unstable Windows 7 Media Center install (six months old). I might have to burn him an ISO of Mythbuntu. So, I wouldn’t even go back to Windows Media Center now if Microsoft paid me!

In the past I have said some very unpleasant things about PHP but now it’s all I use. It’s true that its function names are all over the place and everything is in the global namespace, but it’s just so darn convenient and widespread. Much like VB was looked down upon in the Windows world as a toy language, it didn’t change the fact that it made people’s lives easy and therefore became very popular. As far as languages go I’d really like to find the time to read the dead-tree edition of Programming Clojure that I bought (under the influence of the proselytisation of a better programmer than myself), but at the end of the day it’s all about results, and with PHP I’m more productive. Now I’m mixing PHP on the server with Ext JS on the client thanks to another good book, Learning Ext JS. I can’t see me installing a Windows Server at home any time soon.

If an operating system requires me to install anti-virus software then I’m going somewhere else. Using a virus scanner gives you a false sense of security and doesn’t do much except drastically slow down your computer. One of the best articles I’ve ever read on why Windows sucks big time is The Six Dumbest Ideas in Computer Security. Windows commits most of the sins mentioned and even with things like User Account Control I still wouldn’t use Windows 7 at home. You would have to pry Linux from my cold, dead, hands if anybody wanted me to stop using it :-)

Another year another operating system (openSUSE defeats Mandriva)

About this time last year I decided that Linux simply wasn’t good enough and returned to Windows XP. A week later I discovered that Mandriva was actually up to scratch, and so I ditched Windows and moved completely across to Linux. Since then I’ve upgraded from Mandriva 2008.0 to 2008.1 which worked rather smoothly, and when 2009.0 came out I actually made the switch to the 64-bit version without too much fuss as well. So, 2008 really was the year of Linux on the desktop for me.

However, recently I’ve actually started to do more with Mandriva than just replacing a day-to-day operating system. I’ve decided to start learning MySQL and PHP to actually get some first-hand knowledge of what I have long regarded as bug-ridden ghettos. And this is where my problems with Mandriva started to well up. I went looking for a decent editor but Quanta (or kdewebdev) seemed not to be in Mandriva’s repository. The kdewebdev4 package contained no files but depended on various and sundry utility programs. It turns out there is no qt4 version of Quanta and you have to install the qt3 version, which complains about an unsatisfied dependency (which is actually there, you just have to select it yourself). On the server-side of package mismanagement, Apache doesn’t depend on a Multi Processing Module (MPM) in drakconf (a trick for newcomers: installing Apache on Mandriva doesn’t actually give you a working web server unless you have prior knowledge and know that you also need to choose an MPM).

To top it off I think Mandriva probably made KDE 4 their default KDE version too soon. Not being able to use one’s desktop like a folder was very annoying, and creating icons manually that showed an ugly strip of buttons on mouse hover also irritated me. KMess also crashed rather too frequently (it was 2.0.0 I guess, but still… if it was buggy it should have been held back) and little things were just getting to me. It wasn’t so bad that I could have switched back to Windows (XP or Vista) but it was enough for me to want something better. Given that Mandriva fired one of their most valuable employees recently, I think the writing is on the wall for that distro, sadly.

Having said some rather unpleasant things about openSUSE 10.3 it doesn’t sound likely that I’d be checking it out again, but openSUSE seems to have a larger community and when the chips are down, having more people on IRC to help out counts for something. There’s also my cute SUSE plush gecko with fridge magnets for feet (given to me by a colleague several years ago) beckoning me to try it again. So, here’s a summary of my experiences with openSUSE 11.1 so far:

The good

  • The installer was very impressive. Given that I didn’t want to trash my former home partition I was pleased to see that openSUSE selected it by default and opted not to format it.
  • KDE uses Plain Desktop by default but that’s easily fixed with Folder View (which openSUSE have backported from the still-in-progress development version of KDE 4.2). Mandriva will “feel” much when they get this functionality.
  • I was initially let down to see that KMess isn’t provided by openSUSE but when I found that Pidgin 2.5.1 now supports the MSN “status message” feature, I was able to cope (not seeing the silly slogans of one’s friends can be isolating).
  • The desktop effects in KDE 4 seem to be better integrated with openSUSE than in Mandriva and worked with my bog-standard ATI x300 video card (albeit not dazzlingly fast). I miss the Compiz shortcut of Ctrl Alt MouseMove to spin the desktop cube around, however I leave this turned off anyway, and only turn it on to show off the power of Linux to somebody.
  • The YaST Control Center seems nicer than the Mandriva Control Center, though not by any order of magnitude. I will say that the Hardware > Mouse Model section is apparently for show only.
  • The KDE wallet is not as annoying in openSUSE compared to Mandriva. Wallet-aware applications obey my wishes to store passwords in plain text, whereas Mandriva’s wallet would not shut up about it, and was most insistent.

The not-so-good

  • The back and forward buttons on my mouse only work with Firefox and do nothing in Dolphin. I’ve read far and wide on the topic and got nowhere using evdev in xorg.conf, and only managed to disable these buttons in Firefox or maintain the status quo using xmodmap. I may have to bite the bullet and compile imwheel myself (since there’s no package for it, grrr!) but for now I just don’t have the time or the patience. I can’t believe that in 2009 and with version 11.1 of an operating system that mouse support is still so pathetic! This is one area where Mandriva was better.
  • IP details are configurable by default in the Network Manager applet in the panel, but since I logged on as a test user first, and configured my IP there, then logged in as the username I intended to keep, I was puzzled when the network seemed to go down. It seems that IP addressing is user-specific, which is quite bizarre. Going into YaST > Network Devices > Network Settings allows you to use global settings thankfully, but this section of YaST is a tad disorganised in my humble opinion and could be tidied up.
  • VLC is not available in the standard openSUSE repositories. I found this quite surprising since VLC is an exemplary open source project, but apparently there are some patent issues, and configuring the Packman repository got me this (as well as Audacious – even this is now apparently an enemy of open source. Amazing.)
  • The obligatory sound problems surfaced when trying the Packman-packaged version of Songbird 1.0.0 – it simply showed some stream error message and couldn’t play a thing. Weirdly enough, the version I downloaded myself from Mandriva in a tarball works fine. A packaged-for-openSUSE program can’t even play sound, but a harmless tarball-version works perfectly.
  • K3b said it couldn’t detect my burner, and I found that running a “chmod o+rw on /dev/sr0” meant that K3b could both detect it and burn a DVD successfully. A forum post later reveals that I have to add my user account to the “disk” group, which is just plain silly as far as I’m concerned. An ordinary user is going to expect to be able to use their burner as burner, and any arguments that could support such stupidity will not be entered into :-) I’ll assume this just slipped under the radar and will be fixed eventually.
  • There seems to be two places for configuring monitor power management in the KDE 4 System Settings: 1) in General > Display > Power Control and 2) in Advanced > Power Management. No matter what I choose in either of these areas (even customising the “Performance” profile in the advanced section), my common-enough Dell 2407WFP never goes to sleep, so I have to turn it off if I’m going to be away from the screen for any length of time.
  • There is no package for gkrellm themes. No biggie, really, but Mandriva has them :-)

Even though I cited one more not-so-good aspect to openSUSE than good, I am very impressed with it. It seems much more polished than Mandriva, thanks to the Folder View support in KDE 4 as well as the installer and YaST overall. If openSUSE could find some way to improve mouse support then I’ll even pay for my next version or donate or whatever is the done thing to show one’s appreciation. Like most distros, it’s always the video, sound, and peripherals that are still the major issues, so I hope for some improvement in this area overall (particularly getting rid of all those sound systems). But I’m not going to back to Windows. No way!

Mandriva 2008: The perfect distro for KDE + Compiz

My attempts at switching to Linux since Christmas have been finicky and largely unsuccessful… until today when I installed the x86_64 free DVD version of Mandriva 2008. The things this distro configures perfectly and without effort, all out of the box, are endless. If you prefer KDE and want a bit of eye-candy with Compiz, look no further than Mandriva.

What worked out of the box:

  • It detected my ATI Radeon X300 video card which proved to be a right pain in the you-know-what with virtually ever other distro except PCLinuxOS (which is based on Mandriva anyway, so it’s no wonder);
  • My 21″ IBM CRT monitor was correctly identified and a decent refresh rate was automatically chosen;
  • The back and forward buttons on both of my Evoluent vertical mice worked without me having to tinker with xorg.conf (which I just couldn’t get working in any other distro, even after reading the various HOWTOs available on the subject);
  • Double-clicking in the top-left icon of the title-bar (the “control menu box” in Windows-speak) was configured to close the window by default – I didn’t have to go fiddling to get that working (I don’t even know where the option is, so this was a nice touch);
  • Getting Compiz to work was as simple as ticking the box, allowing it to install a few packages, logging off and logging on again – far easier than the likes of Linux Mint or the dreaded openSUSE in that regard;
  • Mandriva must install some pretty decent fonts by default because everything is looking nice and crisp and legible – no need for msttcorefonts;
  • The language and dictionary was set correctly to English (UK) in Open Office, which is as it should be since that’s the language I chose during the install (I can’t say the same for Kubuntu where I had to install myspell-en-au and openoffice.org-thesaurus-en-au myself).

What didn’t work out of the box:

  • To be fair, I have to report that it wouldn’t allow me to write to my NTFS partitions by default, however, given that previous Linux evaluations have taught me the “ntfs-3g” package is required, I won’t be having any trouble now;
  • It would be nice to have English (Australian) as a language but English (UK) is the mother-tongue, after all, and is more compatible with Australian English than American with all it’s freaky spellings, so I’m not too peeved about that.

So, in short, if you prefer KDE but want wobbly windows, a rotating 3D cube of virtual desktops, and other eye-candy, you can’t beat the Mandriva 2008 free DVD. Given that I couldn’t get the Mandriva 2008 KDE One CD to even load X, I assumed that this free DVD probably wouldn’t let me have any eyecandy, but I couldn’t be more wrong. It seems that by sticking to 100% free software as configured by Mandriva results in the perfect combination of KDE customisability and Compiz droolworthyness :-) It doesn’t get any easier than this and, being 64-bits, it’s as fast as lightning on my Q6600, too!