Monday, May 25, 2009

I had a dream.

I had the weirdest dream this morning, it could've been straight from a novel or a movie. Here's a quick overview of what happened:

There's a family, Father, Mother and son (all unnamed) living in Russia, not necessarily today, or maybe just a country with an oppressive regime. At some point the Mother and child end up fleeing, I'm not sure what happened to the Father. The Mother ends up in Korea and the child in New Zealand.

A significant amount of time passes, during which I don't know what happened, then the Father and the child are reunited in back at their old home. (Perhaps the Father had been there the whole time). They get along relatively well, but things are a little strained. Then the Father gets a new job working for the government who he detests, but he loves the job. So every morning he considers not going, but every morning he still goes, and comes back satisfied.

Now, one day he gets some award, probably as whatever he was working on gets completed, or is successful, I don't know. Soon the mother is back there too. Things are very strained as apparently the Father had raped the Mother to have their child.

The mother and son are talking one day about fleeing again, this time as a family, but the regime hears about it, and they are forced to flee straight away.

The dream ended with the three of them in a car on the run.

Pretty crazy, huh? I hope I didn't forget any of the more important details.

In fact, this dream occurred in the 10 minutes between when I hit snooze on my alarm, and it went off for the second time.

I've been thinking if I ever write a book (or a movie) this might be a cool idea. Take what you will from that.

Sunday, May 24, 2009

Life is a game

Just a thought that I had in the shower this morning and stuck a little bit. I'm not saying I'm totally behind this, but just thought it was interesting.

Firstly, the point of a game is to have fun. Some people say it is to win, but simply put, they're wrong. Winning is just an added bonus. Thus, if life is a game, the point to life is to have the most fun possible. This leads to a number of things, like keeping yourself in a good condition to be able to have fun in the future. Having more fun now, but in such a way as to reduce the amount of fun you can have in the future, may lead to having less fun overall.

Taking drinking as an example. Lots of people say it is fun to drink, to get wasted, to get off your face. However, this can adversely affect your future potential for having fun - you could get alcohol poisoning, injure yourself, drink and drive and have an accident, all manner of things. Though these aren't the norm, the norm is you're fine. Say 1 time out of 100 you get wasted something bad happens, ranging from the fairly bad to death. If you only get wasted once, your chances are good, but say you do it every weekend for two years, approximately 100 times, then you've got a 63% chance that at least once something bad will happen. 3 years, 78%, 4 years, 87% and 10 years 99%. Now, these bad things can clearly reduce your potential to have fun in the future, so moderating the amount you drink looks like a good idea, statistically.

The same argument can be made for a plethora of other things that people see as 'fun' such as taking drugs, kayaking down a river, having sex, tramping, etcetera. However, you can't just eliminate everything that has any potential chance of something bad happening, as then the amount of fun you'll have overall would also be reduced. So if you see life as a game, you've got to find the balance for what is the right level of risk to take in order to be likely to get the most fun overall. Then there is the luck factor, there are some people that do ridiculously dangerous things all their lives and nothing bad seems to come to them, while there are others who get messed up after the first attempt.

Just something to think about.

Saturday, May 23, 2009

Fragile Base Class Problem - Not Quite

I have never encountered the fragile base class problem when programming, but I encountered something remarkably close when I was writing code for our comp sci group project today.

I was extending the DefaultMutableTreeNode class. It has two remove methods, remove(int childIndex) and remove(MutableTreeNode node) for removing children from this node. I was overriding these two methods as I was keeping a separate map of the nodes, my remove(int childIndex) method found what node was at childIndex, and them called remove(thatNode).

Now, my remove(MutableTreeNode node) method would remove the node from my map, and then call the superclass' remove method. The superclass' remove method must have been (confirmed by looking at the java souce code) calling remove(int childIndex), which I had overriden, so my version got called, which called my other remove method, which called the superclasses remove method - loop until the stack overflowed. Was pretty easy to see that this was happening from the stack trace.

Now, the fragile base class problem is when changed a base class causes a derived class to break, where this is slightly different in that the implementation of the base class caused the derived class to break. Now, if the DefaultMutableTreeNode class were changed so that the remove(int childIndex) called the remove(MutableTreeNode node), then I would suffer the fragile base class problem.

Oh the joys of programming.

Crazy Double Chat

As you may, or may not know, I use Emesene in the place of MSN messenger or Windows Live or whatever it's called nowadays as I use Linux, and the MS variant doesn't run on Linux (it may do under WINE, but I wouldn't use it anyway as Emesene meets my needs). While it does strange things from time to time - like not display a line I just typed in the window at my end, but will at their end, something that happened today really took the cake.

I was chatting with a friend of mine today (about out comp sci group project). Then a new conversation was started with her and another member of our group (3 way conversation). I left the previous window open, as you do. Some of us have dinner, and for various other reasons, no chat takes place for a few hours, in which I leave these windows open.

Now, it comes to the point where I want to ask a question, to the second person. So I go to the 3 way conversation and ask if she's still there. As soon as I do this, that conversation changes to a 2 way conversation as if she had gone offline, even though she was still online. Then the first person replies "...? wrong person?" Which I thought was odd as surely she would've realised it was the group conversation.

Then I realise, that the "...? wrong person?" also appeared in the first, 2 way chat, between her and myself. And every line she wrote from then appeared in both conversations, and she was receiving the messages I typed into the boxes on both chats.

The net effect was I had two chat windows talking to her one, her lines went to both of my windows, but my lines in either window went to her one window. Pretty cool huh? Though useless and crazy nonetheless.

Wednesday, May 20, 2009

Stab proof sheep, and the opposite of strange

Today was a good day for the random anecdotes, I'll recount a few of the more amusing ones now.

According to one of my physics lecturers, citing wikipedia [confirmed], using a small fraction of niobium in a steel alloy makes it much stronger (I think he said 10x).

According to another guy in the same class, there are new stab/bullet/everything proof vests being developed using merino wool and other things. Apparently they can only sew this very slowly to avoid wrecking the needles. This has important connotations. Firstly, NZ, with it's high number of sheep has the potential to become an economic powerhouse because of this. The second, and potentially more deadly, is that how long will it be before we get stab proof sheep? You thought those sheep were so cute, well, I for one welcome our new woolly overlords.

Next, have you heard of the new search engine-style thing, Wolfram|Alpha? Well, at our youth group planning meeting tonight, it came up in conversation, and apparently it can tell you how many fish are in the ocean. I just tried this, and it states \inline 2 \times 10^9 metric tons. It also lists all the approximations it made along the way. This wasn't quite what I was expecting, as it didn't tell you the actual number of fish, and more importantly, it misspelt tonne. I then asked for the average weight of a fish, which failed so I see why it can't answer.

The other thing I tried in it previously, was to ask how many basketballs would fit in the ocean, which failed. Trying to find the fault, I asked what the volume of a basketball was, which failed, though it did manage to answer the much more difficult, "What is the volume of the ocean?" Ah well, give it time and it's sure to be able to answer a whole lot more trivial questions.

Lastly, I got this somewhat cryptic text message today, "Oposite spin to strange?" Your job is to answer it (I texted back the answer as soon as I read the message, was part of a pub quiz apparently). Hint: Subatomic particles.

I hope you found those as amusing as I did.

Musicals

So, last Friday night, there was a musicals night at Kohanga. I'm not normally a big fan of musicals, so when I was invited I didn't know if I was going to go or not. I ended up inviting a couple other people, so then I sort of had to go, because it'd be a little stink if I invited them, they showed up, but I wasn't there myself.

After a thoroughly democratic voting procedure conducted via email, the three musicals selected were Singing in the Rain, Grease and The Phantom of the Opera. I hadn't seen the former or the latter, but I had heard good things about them so was looking forward to them (I had actually voted for these two).

Due to some DVD zoning issues on people's laptops, we weren't able to watch Singing in the Rain first, so Grease it was. It was alright - well to be correct - what we watched of it was alright. But the video store that it was rented from had stuck this clear plastic sticker thing on top with their advertising, bar code, and can't walk out of the store with it things. However, as the DVD was evidently a bit old and knackered, this was coming off, and bubbles and things has formed under the surface so it would skip badly every now and again, and eventually froze - during the Grease Lightning bit.

Then out of the cold, dark night an apparition appeared, an apparition bearing a DVD player and a much nicer sound system. With this we managed to watch Singing in the Rain (and later The Phantom of the Opera). I thoroughly enjoyed these two, and it was really interesting watching them in succession because they are such different films.

Singing in the Rain was brilliant, so funny, and not a soppy love story as it would likely have become were it filmed in the last 10 years or so. I loved Cosmo, the way he was the guy behind the scenes, the guy out of the glory, but still loving every minute of it, and couldn't be happier with life. And these three lines deserve a mention:

Cosmo Brown: Talking pictures, that means I'm out of a job. At last I can start suffering and write that symphony.
R.F. Simpson: You're not out of job, we're putting you in as head of our new music department.
Cosmo Brown: Oh, thanks, R.F.! At last I can stop suffering and write that symphony.
[Courtesy of www.imdb.com as I wanted to get them right rather than rely on my memory]

Now The Phantom of the Opera was a whole different kettle of fish. Firstly, it was turned up rather loud which made it oh so much more impressive. I loved the contrast between the light voice of Raoul and the darker, almost rocky voice of the Phantom. Also I loved the scene where the Phantom takes Christine down to his lair for the first time (in the movie at least), and the candles came up out of the water! Looking on wikipedia [so it must be true] they apparently got this effect not from CGI, but using special candles that ignite when they come out of water. How awesome is that!

Anyways, I'm going to be a lot more open to seeing musicals now thanks to this great experience.

Sunday, May 17, 2009

Looking at things now, compared with then

Do you ever look at something a while after you did it, and realised that it wasn't actually what you perceived it to be then? I don't know if this happens to you, but it happens to me all the time.

The example that made me think of this, was earlier today I was writing a lab report for the NMR lab I did just over a week ago. In one of the experiments you had to choose the right capacitor value so the amplification would be as centred on the frequency of resonance as possible. You can forget all that if you want to as you don't need it for what follows. On the day, we chose 11 nF as that looked the best (I specifically remember thinking this). But when I was writing the report, 11.1 nF was clearly better. In my report I had to write, "On the day, the 11 nF run looked the best so that was what was used for the remainder of the experiments, but looking at it now, the 11.1 nF one looks marginally better."

It happens to me all the time. I'll have a maths problem in my assignment that I'll puzzle over for ages and not get it. Then look at it later and it'll all be clear. Or similarly, I'll give a long, complicated proof or example, then look at it later and think of a much simpler version. There are all sorts of things like this. (Though on second thoughts, these two can be explained by me thinking over in the time in between.)

For good measure, I'll throw in those times when something seems like a good idea when you do it, but you look back and think, "Why did I do that? That was stupid."

I've rambled enough now, I think.

Saturday, May 16, 2009

The joys of the train (in NZ at least)

I remember a couple of weeks ago, I was catching the train home from university, and when I got to the station, the LCD stated that the train was running up to 5 minutes late. I didn't think that was too bad, it's pretty normal for the trains to be running a few minutes late.

After I had been waiting at the platform a few minutes, there was an announcement apologising for these still "up to" 5 minute delays. At that point it was already 3 minutes after the train was meant to have departed. As I listened to the announcement, I remember saying, "up to" in a sarcastic tone and a guy standing beside me agreed that the use of those words was probably not wholly accurate.

A few minutes later, now almost ten minutes after the train was meant to have departed, another announcement comes, now the train is "about" 10 minutes late. Lo and behold, only 2-3 minutes after this announcement the train arrives!

What I object to about this whole thing is not the fact that the train was running late, that happens, and we have a rather run down rail service, thanks to that almighty cure-all known as privatisation, but that's another whole story, but instead the way they stated the lateness. Surely they would have known that the train was likely to be more than 5 minutes late, so why use the specific term, "up to"? Surely it would have been more accurate if they had stated "about" at first. Ah well, the state of people's England is ever improving.

My amazing coding discovery

I just discovered that in C and Java (and presumably other languages as well), the following is perfectly valid syntax:
var1 = var2 = var3 = something;
To, as is reasonably obvious, the value of the three variables to something. Which (to me) is a whole lot nicer than doing the same over three lines, as I've always been a big fan of not using extra lines unnecessarily. This goes up there with my other favourite space saving technique, the ternary operator which takes the form:
var = boolean ? someValue : someOtherValue;
Where if the boolean evaluates to being true, var will be set to someValue and if it is false, someOtherValue. You've done on one line what would've taken four with if/else statements! I've even been tempted to use nested ternary operators sometimes, but this quickly becomes illegible, which ain't the best.

Anyways, back to the = = = thing, I actually first found that out in a physics lab a couple of weeks back, when I had to set three registers to the same value on the microcontroller to set up three timers I think it was. Though I was having issues at that point so I think I just changed it back to make sure it'd work. I then had the perfect situation to use it on our group project, and it worked fine, so I'm never going to look back. I haven't learned such a trivial yet handy language feature like that in a while so it felt like when I had just learnt about var++ and var *= something and the like.

And, three quarters of the way through writing my first blog post I change from using the nice (but laggy - being google probably lots of javascript) rich text editor I've gone to using the plain html - go figure.