Saturday, October 4, 2008

How to umount when the device is busy

What a silly problem and what a simple solution! Thanks to the author, here it is:

It happens all the time doesn’t it? You need to unmount a CD or you want to pack away the external drive but when you try to umount it you get the dreaded “device is busy” message. Wouldn’t it be great if Linux actually told you what was keeping the drive busy? Here we are in 2008, I’m using Ubuntu Gutsy, and that message hasn’t changed in all the years I’ve used Linux.

# umount /media/disk/
umount: /media/disk: device is busy
umount: /media/disk: device is busy

First thing you’ll do will probably be to close down all your terminals and xterms but here’s a better way. You can use the fuser command to find out which process was keeping the device busy:

# fuser -m /dev/sdc1
/dev/sdc1: 538
# ps auxw|grep 538
donncha 538 0.4 2.7 219212 56792 ? SLl Feb11 11:25 rhythmbox

Rhythmbox is the culprit! Close that down and umount the drive. Problem solved!

Tuesday, September 9, 2008

Another good game for Linux

A game I played and actually finished, it was relatively short, though it offered a lot of fun... and another version is in the works for 2009.

Eschalon: Book 1 is a classical turn-based roleplaying game. There are tense moments, but I didn't click myself to death. Another good thing is the openness of the world; you can go anywhere at any time, few parts are inaccessible (which doesn't mean it is safe). Worth trying out.


Things to do:
- generating of content is based on the characters level at the moment of opening of the container... note to self, if I play it another time, I should leave a couple of chests etc. unopened in the 'easy' parts, for massive profit later on
- one thing that seems to work well with all monsters is to walk in a line for some time, then change direction; they will lose a move and I will get a head start. Ideal for an archer if he has the space and needs to run around to avoid the nastier critters.
- setting off traps by shooting them with arrows is a great perk
- never really got into alchemy and making potions; but it got much easier with two rings of the right kind when enchanting items becomes possible

Monsters I really disliked:
- Acid Grubs - destroying equipment scares the pack rat out of you; and maybe it was just an illusion, but they always seemed to follow the character even if he ran half a map away. Nasty things, one nice location to dispose of them is the Giant Village.
- Raptors - they seemed a bit out of place; but a good combat challenge, just don't let them surround you. Separate and kill; there is one place where you can crush them in their gardens.
- overall bad: being attacked from several sides. Even the weakest critters gave me a hard time

Annoying/boring parts:
- picking a lock, and breaking your last lockpick, when you would have to travel far for another; this is where I save/loaded the most
- diseases are very ugly, not to mention of being cursed - are there any ways of overcoming them besides the expensive potions or spells? Perhaps food could give an increased chance of defeating a disease.
- getting entangled in trees while 'w'alking
- looking for a basic ingredient for a looong time... nobody had it, and even restocked shops just seemed to avoid it. Darn.

Misc:
- reuse of some characters once their quests are complete would be nice - for example the old man with a boat could take you somewhere
- how about bolt spells that would hit several monsters in a row
- I went through the 70 pound quest, but the guy kept offering it to me... bug?
- the carried weight was not recalculated after arrows were dropped from quiver (noticed it when overencumbered)
- poltergeists not able to pass through walls or doors - good for the game, allowing them to do that would do more for realism and make them scarier


In general, I have to commend the balanced play; once I learned the basics, I was rarely challenged for life, (mostly with important monsters or when I got reckless); but also rarely able to just breeze through a map and waltz through lesser opponents. I also never had huge amounts of money, that you ordinarily expect from these games. Great work done here.

It was relatively short, which is really good with my lack of time. :)

New Life on the Blog

Was it really a year without a single post?

Well, now I have a few things to post here, so I guess I will. Any updates to follow may be very irregular, beware.

Wednesday, June 6, 2007

Those trivial differences between Explorer and Firefox

(...and likely between many other browsers.)

I've just accidentaly noticed a little detail in the CSS:

Styles commented out with a double slash - // - are ignored by Firefox, but not by Explorer, which processes them. Styles hidden in /* */ are really hidden as they should be.

I wonder what the standards say on this. :)

---

Update on the onmousemove event: now I found out to be blamed is the image I have in the background. Under Explorer, if the mouse hovers over it, it will be the target for mouse events, even if there is a span hovering above it - Firefox uses the span. The visible borders always capture events (entertainingly enough, once you "grab" the border and start moving/resizing the span, Explorer accepts mouse events from all over the place... so there is obviously a bug.)

Now if you actually make the span contain something, Explorer will immediately consider the span as being more than just a few lines, and dutifully notes the events in the span. Duh.

An easy way to place something into a span that shall be completely transparent (what we work with is behind it), is to set the opacity on 1%, plus some background color. A small opacity won't be really noticed. (Unless you want to have visible borders on that span, which I wanted.)

Though I can't escape the thought that the browsers may be processing this information somewhere... calculating the effect anyway. Some other 'empty' effect would be nice.

Saturday, June 2, 2007

JavaScript Image Editor... sort of

At work, I am just making a sort of image editor in JavaScript. (What? Yes, really. In JavaScript.)

Of course it is not supposed to be a real image 'editor', it shall merely serve for 'cutting out' a fitting part of an existing image, then pass the parameters to another program on the server, which will do the cutting itself.

That's it, not very complicated, right?

Well, not with JavaScript. Moving a single layer (the selection over an image) and especially resizing it is quite tricky. Let's see a few hurdles:

- already getting the coordinates of something on a page isn't easy. Luckily there are well-tested functions to be found outside! I've got one from Quirksmode (a good resource to remember for web development, btw). The coordinates of a mouse are then simple.

- it got a bit more complicated, once I've started using absolute positioning, to actually have control over the 'editor'. In the end, I have used a separate object, that remembered the position and sizes of the resizing area; with every move or resize it was updated, its values used to change the resize layer.

- once you use the onmouseover event, your CPU load goes up, and if you fool around a little (moving the layer wildly around), it may jump up to 100%. I may not care, but this thing should eventually be used by the customers, who might not like the load. Also, if you try debugging (and you will need it), which you have to do in some textbox, everything will go _much_ slower. Be prepared for that.

- the actual calculations for moving and resizing something are so easy to break, and so hard to get right. Especially if you want the dingus to be resizable from all sides - up or down, left or right, doesn't matter. I have seen only one script that actually did this, and it worked in a horribly complicated way, with neat design but very ugly code. (Will add link to it.)

- additional fun was our special condition: we wanted the resulting image to be of a certain size in the end; what we selected could also have any size, but we could enlarge it or make smaller. But what I had to maintain, was the width-to-height ratio.


Developing at two browsers at once gets annoying; I rather kept testing with Firefox (blesseth be Firebug!) until it was somewhat stable, and then tried it with Explorer. Glad that you asked, there were some differences:

- the worst were the different names of the JavaScript objects that were desperately needed. How do you find out where the mouse came from or went to? I know it now (at least for the two browsers), but it took some annoying experimenting.

- Firefox apparently waited, until the image was loaded; Explorer didn't, and kept executing the code after the loading was requested - so an onload function had to be implemented for the image, that did all the initialization. But that was actually an improvement.

- pretty bad was Explorer's treatment of the mouseDown event. What worked well with Firefox, failed there. Turns out that it somehow refuses to fire the event, if the layer has only a border defined, and nothing else. But as soon as a background color is set, it works! That of course sucks, as the image in the background had to be visible. In the end, I have set up a large transparency for the resizing layer, and had both things... well, it isn't perfect. I'd like the border to be completely visible, and the transparency/opaqueness to be very gentle, so most of the picture stays visible. Still some work to do with this... or somehow bypass it. Duh.


Well, that's how it is starting, and much is to be done (the closing functionality that tests if the selection is correctly positioned isn't yet complete, so it can be broken), but the basics already work! Guess I will post some image a maybe even some of the code so it is clear what it actually does, and how.

Monday, May 28, 2007

A Linux game that looks actually fine

For the record: burning works flawlessly now with Feisty. At least something works as it should. Yay!

---

Speaking of Linux games, there is a neat one that brought me actually some fun: Globulation 2. It is a strategy, still in development and therefore with quite a few imperfections, but it runs smoothly even on my piece. It's still an alpha, so that can be excused for now.

Some good:
- it has a good unit management system; you don't actually select the units and send them to do something, you order what-is-to-be-done-where, and any free globs (that's the units) of a given type will hurry to the place to do their job. The ultimate top view above the many faceless units you command.
- the units do all the stuff on their own, and once you make sure your base is well equipped and supplied, you can concentrate on the strategy and don't loose time with micro-management.
- the whole look is kind of neat, with the globs and their buildings

Some bad:
- as mentioned, it is in development, so there are some things that seem unfinished
- the music becomes annoying pretty fast, to be turned off after a few minutes

Monday, May 21, 2007

Development new and old

My laptop is really the genuine article. I have considered playing some neat-looking game for Linux (and there's very few of them, let me tell you), but it didn't do much in the way of playing. It seemed to require 3D hardware support. Doesn't sound like anything unusual nowadays (my gaming tastes are hopelessly backwards). So... does my lovely laptop support that?

Well it does... but not for Linux. After spending another couple hours of looking for drivers and success reports, I actually found a petition to AMD for making drivers for ATI Radeon XPress 200M - just my brand.

Not that I would be using it that much, but it's kind of disheartening. Ah, whatever.

For the record, the game that interested me, was SCOURGE. Could be fun. :(

---

Some good news in turn: on my work computer, I worried about the sound under Linux. Well, nothing to worry, the default ALSA driver worked perfectly (I don't have speakers yet so it's headphones-only).

Anyway, there is sound! Go MP3s!

---

USB is fun, especially under Linux. I didn't use 'em much after upgrading on Feisty, but at some point I tried my USB key. Didn't work.

As the ancient tradition commands, I googled, and found some reports on USB devices being destroyed by the Linux kernel (what?!?). Luckily it turned out to be not my case, What was my case, was a broken new driver, which excluded some devices (like my newer 1GB USB key), but recognized others (like my older 256MB key, and my DVD burner). Of course, I could have only one at a time. There is more in comments on this...

...but isn't THAT fun?