10/28/2012

Treeview and storage

Posted by – October 28, 2012

I‘ve not written a while about programming, let alone anything about that mailing program, RoundAbout. Today’s subject is the Windows TreeView control and its data section, the TreeNodes. As you probably know, a TreeView shows data in an hierarchical way, allowing users to ‘expand’ or ‘close’ so-called TreeNodes, so to expose or hide data they do and don’t want to see. TreeNodes in the Windows world can have user-data attached to it and often, developers will use this to store program specific information. I believe in .Net, this data propery is called ‘Tag’: in the Delphi world, it was called plainly ‘Data’. So code-wise this could look like this:


var Node: TTreeNode;
/* FolderData is a pointer to a record */
Node := TreeView.Items.AddChild(Node, FolderData^.Name);
/* Attach the FolderData to the current node */
Node.Data := FolderData;

Early in the process of development, it was noticed that any font or even layout changes caused severe crashes in the TreeView: The TreeView in RoundAbout holds account and message/mail folder information via each TreeNode’s Data member. After a long investigation, I noticed that this was caused by the Delphi TreeView control itself: whenever a window anywhere was refreshed, Windows would send a message to the TreeView control to refresh and recreate itself. Let me say that again: whenever a font was changed in RoundAbout, this would trigger any TreeView to recreate itself. I think this issue was resolved in later versions of Delphi, but I decided to create my own control (PMTreeView, code here) to preserve the data with the following premises:

  1. Override CreateWnd and DestroyWnd
  2. Upon destruction of the treeview window, save the data for the nodes to a memorystream.
  3. Upon creation of the treeview window, (if available) load the node data from the memorystream.
  4. Trigger an event to notify the developer that the Data structure has changed for further activities.

As I mentioned earlier, I believe in subsequent Delphi versions, Borland fixed this in their own TreeView controls. However, for a piece of code that I debugged and coded in a night or so, my own PMTreeView control wasn’t too bad of an implementation.

10/27/2012

Seagate open thyself

Posted by – October 27, 2012

A year ago or so, I bought a 500 gig Seagate GoFlex portable harddrive. Unfortunately, I dropped it and started to have troubles with it. Initially, I thought the drive was just failing on me but upon thorough investigation I found out that actually the USB connector on the drive was broken. I recall that when I ‘unboxed’ the drive, I already had second thoughts about the cable and connector: I thought it looked suspiciously fragile.

I could go into a rant about everything fragile nowadays, but, here’s the thing: this drive contains a lot of data. I don’t want to lose my data. Why not just break it open and put it into one of those hd/custom enclosures: you know you can buy these at your local Staples for 20 dollars or so. Actually, opening the Seagate enclosure wasn’t too hard: first of all, there’s a plastic enclosing around the connector portion which you can slide out (use a bit of force..). Next, just push two or three flat screws into the rim and wiggle them until the top part lets go. Inside the shell, you can now take out the 2.5″ drive (you would need to screw off the aluminium cover) and put it into your custom enclosure.

I guess the moral is to stay clear from fragile connectors and plugs and all that stuff. On the other hand, a drive is just a drive. However, I fear the day, harddrive makers start to use propriety hd interfaces.

More images below the fold.

More…

10/26/2012

Dragons and Laptops

Posted by – October 26, 2012

What is funnier than ‘America’s Funniest Home Video Show’? Why, items that are wrongly priced on on-line shopping sites! I mean, a 10,000 dollar laptop that features a second generation i3 processor, a tame Radeon processor and yes, 6 GB of RAM. Surely, that RAM is solid gold. No?

A month or so ago, I finished watching all seasons of the show ‘A Game of Thrones’ (HBO Canada), an award-winning TV series based on George R. R. Martin’s Fantasy books ‘Songs of fire and ice’. I was advised it was pretty good, and sure, it was pretty good. The show is known as the most downloaded show on the Internet as HBO had refused to sell the show on DVD (or something to that matter: I can’t remember the details).

I had already started on George R. R. Martin’s books on July the 6th and as you may have noticed from the books-library, I finished the current known last entry of the series, “A dance of dragons”, just a week or so ago. All the titles in the series are long and, while at times slow to develop, fairly good reads. The major question is that Martin still has two titles to write and looking at the pace of the HBO series, I fear that the show is catching up with the books before Martin can officially finish them.

10/16/2012

XCOM: Enemy Unknown

Posted by – October 16, 2012

I have never played the original XCOM game (nee UFO: Enemy Unknown), back in the mid 90s. The famous turn-based-squad Microprose game obviously took the gaming world by surprise and people have been talking now for ages to recreate the experience of XCOM. Open-source? Check. Check. Check. What can you say?

So Firaxis (Of Civ fame), just released their interpretation of the famous XCOM game, XCOM: Enemy Unknown and too much critical acclaim, with a current average rating of 89. Many reviewers praise the difficulty of the game, paired with high levels or re-playability. And to be honest, 20 hours in, it is good, with some side remarks.

First of all, the game is using the Unreal engine and thru the first gameplay, I think the game scales fairly well. I’m running it on a high-end computer, but I think I would have been able to play it on my older P7350 machine. Secondly, the game is unmistakenly hard and unpredictable at times, even on the Normal level. The premise is this: you lead and train a team of combat personnel in a varying (but fixed amount) of missions. Successful missions in regions will lower ‘panic rates’. If panic rates are going through the roof, countries can and will withdraw support for your XCOM organization. What makes things worse is that some missions (Abduction missions, typically) will require you to make decisions WHICH region is going to be the focus of attention. I’ve not even talked yet about the tech-tree. Sadly, the tech-tree is not really dynamic and neither are the maps.

Here is where the problems start with XCOM: The tech-tree and the non-dynamic maps. The tech-tree sort of give you options to focus on: it’s far from indepth and generally speaking, if you keep your focus on researching armor, you should be able to keep up with the scaling of the game’s AI (yes, it will get harder gradually). Secondly, the maps don’t seem to be random enough for me. There may be like 50 or so unique maps, and sure, aliens look like they’re placed randomly on the map, but after 10 or so missions, the maps look the same.

That doesn’t mean it’s no fun: listen, this is a turn-based strategy game with the focus on (tadaa) strategy. Every mission is a careful exercise of slowly moving your forces tile by tile, turn by turn and attack by attack. Early in-game, you learn fast to adopt to the strategy of the AI: move your troops out of harm’s way because, that’s what the AI does as well. I don’t really care about how Firaxis has set up the financial part (yep, you need money to keep your organization running) nor do I care about the ‘scanning’ and ‘flight combat’ portions of the game. Both remind me strongly of the Mass Effect approach: they add no real value to the game.

So, to summarize, XCOM can be frustrating and rewarding at the same time. During the 20+ missions I played, it’s extremely exciting to finish a mission without any casualties. However, more often you lose extremely valuable team members. That’s just another reason to do better do the next time. Highly recommended. See images underneath.

10/21/2012: I finished the game in Normal difficulty mode. It’s pretty much an unforgiven game, that requires you to use every weapon and defensive tool in your arsenal (reddit on difficulty of the game). The very last battle, the Temple ship assault, I managed to finish by using three psi-enabled soldiers. Tip: smoke grenades and rush your assault team as close as you can to the Uber Ethereal. If you can, mind control one of the Mutants as that will distract one Ethereal (there are two of them). Let your sniper keep the other Mutant at bay. Do not (NOT) kludge together.

10/12/2012: Only 14.5% of Steam players beat the game on any difficulty. That is not a lot.

More…

10/14/2012

Unity dialogs wars

Posted by – October 14, 2012

Something that reminded me of the issues regarding Unity new ‘touch-based devices desktop paradigm’ that I noticed earlier, which I was going to mention in the previous posting: When you copy (cut/move) a large set of files, Nautilus will show you the ‘Copy File Dialog’ box. If you minimize this box, you will not be able to re-open ever therefore sort of leaving the user in the dark when the copy operation has finished. In Unity, all minimized windows go to the ‘Unity bar’ (no, NOT that kind of bar). Minimized modal dialogs that are part of applications however, do not. You cannot even re-open this box thru the ALT+TAB switch windows method. Sadly, this is a bug reported in earlier versions of Unity and it seems like it is still hanging around on (bug #887821).

In Gnome 3, they solved this slightly more elegant: Modal windows are treated the same as general system notifications and you should see it fly by in your message event ‘log’ (so to say). Switching to this dialog, however, can be achieved by using ALT-TAB and selecting the Nautilus icon. Not ideal, but definitely some Gnome developer was paying attention to properly implementing modal dialogs.

It would be interesting to see how Microsoft is solving modal dialogs in Windows 8/Metro.

Update 10/21/2012: Looks like the modal dialog issues have been fixed in Ubuntu 12.10 in an overhauled Windows switching system that actually looks pretty(see image screenshot).

10/13/2012

Madness du Systeme Linuxi

Posted by – October 13, 2012

The previous posting was actually supposed to be detailing the conversion of my DV-5 to Linux, a process that I have done so many times that I can do this with my eyes closed. Sort of. It took a bit longer as I decided to check out OpenSuse and Linux Mint first. Either Linux flavours I disliked from the get-go: OpenSuse is driven by KDE 4, which I really like, except for that it reminds me these days of Lego in both a good and bad way. Mint is where I expect desktop-Gnome 3 to go: only, it behaves very unpredictable. For example, UI elements like menus in NetBeans didn’t work at all. Also, random crashes occurred too many times.

So, back to Unity, which, as you probably already knew, I hate. For now, I can tolerate it: however, in my mind, while I appreciate that the Ubuntu-crew is concentrating on a UI that can work with touchbased devices, it would have been so nice if they had provided users with a good UI choice.

I am pining for both KDE4 and Mint tho. Or, maybe, just maybe, I really should go back to Debian, which to my surpise is now up to version 6. Same apt, same tools and same architecture.

Activities in Linux

Posted by – October 13, 2012

Now that I’ve finally moved on to bigger hardware, I can officially retire my 2008 DV-5 1157-CA (this link doesn’t exist anymore). It has served me well, while costing me two harddrives, because, well, it obviously lost one fan at one time resulting in overheating. As you know, the number one killer of harddrives is heat.

While we’re at it: I’ve decided to steer away from major brand laptops like HP and Toshiba: I have had both brands and have seen the quality dwindle down. Current models look ugly and are extremely fragile. I don’t mean that you should be able to drop a laptop from 20 feet or so.

My favourite part of the DV-5 was the fact that it could play recent games fairly well (see category) because of the size of the video ram: For a general all-purpose laptop in 2008, 512 MB was a lot. Additionally, the laptop is not extremely hard to take apart: heck, at one time, HP’s site had elaborate instructions how to do it yourself and where to order spare parts from. Maybe that’s all we need from laptop manufacturers: sell laptops that one can repair and upgrade yourself.

For now, the DV-5 is running the latest Ubuntu flavour.

09/30/2012

A beach runs here

Posted by – September 30, 2012

Summer’s been over now 10 or so days and looking outside, it feels like Fall (or Autumn) snapped in here before we could even think of typical Fall things, like seeing the leafs colour and/or raking them up. I believe our trees started shedding their leafs early, only because of the extremely hot temperatures back in July.

That said, this Summer we actually managed to ‘hit the road’ for a change and visit the amazing places that NB has to offer: Saint Martins, Saint Andrews and which ever places are in between these towns. The most remarkable place we ended up visiting was New River beach park: We happened to swing by it (accidentally) at low and high tide.

At one time, a while ago on this blog I complained about the fact that, when living in NS, that there were so many NB tourism commercials. Now that I’ve been living here for over 4 years, there are indeed many reasons why you’d want to check out NB during the Summer season.

09/03/2012

Curiosity

Posted by – September 3, 2012

Four weeksago or so, NASA’s JPL successfully landed the rover “Curiosity” (wikipedia) on Mars. The landing was probably one of the most watched (and celebrated) events on the Internet, witness the many gifs of cheering NASA people (Happy NASA guy and Happy NASA people) and the pop-rock-star treatment of the NASA engineers at Reddit (“We’re engineers and scientists on the Mars rover mission”).

As any major news event that at one time broke the Internets, news and interest in the Curiosity rover is slowly dwindling down. However, great photos and mission details are posted on Curiosity’s main site at NASA (MSL website). My favourite one is the movie about the landing (taken from images from the one of the rover’s cameras), which thanks to the Internet, was then made into a HD 25 fps movie, which you can watch right on Youtube. If you like hi-res images of anything but Mars, go here.

I’ve always been a proponent of unmanned flight as I’ve mentioned in earlier posts years ago. The risk of losing a rover is worth less than the risk of losing people in extremely dangerous environments.

NASA’s MSL project is supposed to last a year. No doubt, the rover will keep trucking for a long time after that.

08/04/2012

Summer respite and yards

Posted by – August 4, 2012

We seem to be slightly going back to normal temperatures here in SJ: that is, cooler temperatures particularly in the morning. You might say that this Summer was one of the warmest: Even Accuweather seems to be suggesting the very same. If I recall correctly, we had 2 weeks of scorching temperatures and even now, I don’t think we’re totally out of troubles yet. But yeah, the temperature changes in the morning (and the dew and our famous fog at that) are refreshing. One could say, I’m almost ready for Winter.

So, the state of the yard is so – so: This was the first year, I’ve seen brown grass patches around the yard. Partially, I blame myself for rigorously cutting the grass too low. There seems to be a good part to the story tho: We cut some of the banks and weeds so low that the wild berry bushes and thistles have been thriving which in turn attracted a lot more ‘good’ insects (bees and monarchs) to our backyard. I believe last year I mentioned I would never take down thistles as they literally serve as ‘lunch rooms’ for foraging working bees. This year the same holds true.

07/15/2012

Another slight of Postgres

Posted by – July 15, 2012

Back almost 10 years ago, as mentioned probably a-many times, I exclusively used Debian to deploy Postgres database servers. That was mainly, because (officially) there were no Windows versions out yet, well, except for an older 7.2 version. My main interaction therefore was with bash and the postgres commandline tools (psql). I’ve not had a need to install postgres on a Linux machine since a while ago (2007?), so I was sort of surprised that 9.1 one was the most stable version. I barely touched the 8 series because, as you probably know, back in the days Debian Sarge only supported version 7.4.

I was not surprised I was still able to use psql’s commandline tools: heck, I was surprised that I still remember which command options to use to clear buffers and what not. If you do a combined Windows/Linux development, you don’t need pgadmin: as a matter of fact, I barely used it because (and even now), I find the program’s UI underwhelming.

The underwhelmingness (is that a word?) of pgadmin, was actually the sole reason to start up a SourceForge project to write a Delphi tool to set things right. I ended up abandoning the idea and focused on a tool to export data forth and back using plain ODBC connections. This initially evolved in a tool called ‘Helios’, written in Delphi, which then became HelioSQL when I rewrote this for .Net.

The only reason why I bring this up is to highlight that – while I already had extensive knowledge of Sybase (yay) and SQLserver – my heart was so close to postgres, that I used a similar naming convention for my database query tool.

Add. 1: There used to be a joke in the postgres mailing-lists on how to pronounce ‘PostgreSQL’. There were people who thought the unfortunate naming was the main cause of PostgreSQL’s low adoption rate. Everybody I ran into, just called PostgreSQL ‘Postgres’. The same idea is true for ‘HelioSQL’. I wouldn’t dare to claim that ‘Helios’ low adaption rate is because of its silly name.

Add. 2: A thing that blew me away was that I could run psql on both Windows and Unix platforms. This is where SQLServer is missing out: as far as I know there are no unix tools available that provide connectivity to SQLserver (well, I’m discounting ODBC for UNIX).

07/14/2012

A slight return to Postgres

Posted by – July 14, 2012

Years ago, I used to set up postgres on Debian servers. For a couple of test, I had to install Postgres somewhere: Installing on Windows is generally a breeze, but not needing the third-party tools, I decided to go back to Linux and install the database server on my Ubuntu box. While I didn’t have issues with importing test data/databases, there were minor things that had me briefly stumped. So, to install Postgres on Ubuntu and other Debian flavours, here we go:

  1. First install postgres by entering ‘apt-get install postgresql’ in a bash-session/terminal
  2. We need to properly initialize it and I would recommend to add your login user to Postgres: sudo -u postgres createuser -D -P arthur
  3. Optionally, create a new database: sudo -u postgres createdatabase -O username whateveryouhavefordatabasename
  4. Open up pg_hba.cfg (sudo vi /etc/postgresql/9.1/main/pg_hba.conf).
  5. Change the following lines properly (use trust):
    # IPv4 local connections:
    host all all 127.0.0.1/32 trust
    host all all 192.168.2.0/24 trust

  6. Open up postgresql.conf and set listen_addresses = ‘*’ properly (* means that postgres will listen to all ip-address as defined in networking)
  7. Restart postgresql
  8. Connect to postgres using the psql client: psql -U arthur -h localhost -d whichever database

The official postgres site has demo databases (or rather links to them): they are around this url

Debris

Posted by – July 14, 2012

One of the more fascinating subjects that seem to occupy the news is the tsunami debris field that has slowly descended on western parts of Canada. Earlier this year, a Japanese HD motorcycle that washed up in Canada made the headlines after news reporters managed to find the owner of it, who had apparently barely managed to survive the disaster.

According to latest estimations, the field contains 1.5 million tons of debris, which has BC authorities pondering what to do with the problem:

“Stuff has been coming across the Pacific forever but to see the start of 3 million tonnes of debris washed off the land and head across the ocean towards us was something I never thought I would see. There’s a wait-and-see approach and most people want to take some action. But it’s a very huge job and we haven’t seen anything yet coming from the government on plans on how to be ready for it and what we’re going to do when the debris hits.”

The US’s NOAA has an extensive site dedicated to the problem (here), which includes an interesting infographic about the field itself and where most of the debris might land (using current and wind models). While the NOAA infographic doesn’t mention any possible findings of human remains, a US oceanographer expects that people might find sneakers with bones in them:

“We’re expecting 100 sneakers with bones in them,” Curt Ebbesmeyer told a tsunami symposium Monday, “DNA may identify people missing since the March 2011 tsunami. That may be the only remains that a Japanese family is ever going to have of their people that were lost. We’re dealing with things that are of extreme sensitivity. Emotional content is just enormous. So be respectful”

Ebbesmeyer, who is the co-creator of the “Ocean Surface Current Simulator computer model”, expects the amount of debris to peak in October of this year.