Monday, April 18, 2011

Underoath

I sometimes forget how much I love listening to Underoath. They're such a great band, particularly their last three albums (Define the Great Line, Lost In The Sound of Separation, and Ø (Disambiguation)). Sometimes it can be a bit heavy, and I'm not in the mood for it, but so often it just fits perfectly. Good music, good lyrics (even if they can be hard to interpret at times).

I can just sit and listen for ages. Or I sit and listen with the lyrics in front of me (Ctrl+T in banshee), and finally learn what they're actually saying. They usually speak of the troubles of life, particularly life as a Christian, in a world where it can be hard.

For instance, the song I'm listening to now, A Fault Line, A Fault of Mine has the verse:

I was lying when I said, I was looking up
I was too scared to show what I am
Bear with me, bear with me, this is all I have left
This might be more than a simple conversation

Which is exactly how I feel at times. I find it encouraging, and it's really helped me through some times when I haven't been feeling myself. Give them a listen, you might enjoy it (or get a headache).

Saturday, April 16, 2011

gnome terminal unlimited scrollback

A recent, and very handy feature that came out in gnome terminal (my currently preferred terminal program, basically because I use gnome), was unlimited scrollback. I thought I'd try it for a while, to see if it would have any negative effects on performance (particularly memory use), as it'd be a useful thing to have, as there have been a number of times I've lost output that I would've liked to have kept off the top of the buffer.

The first thing I did was to fill the terminal with a whole lot of output, to see what would happen. My preferred way of doing this was simply $ base64 < /dev/urandom, which avoids the problem of strange things happening due to the non-printable characters. After running that for a while, I didn't notice the memory usage increasing, but also couldn't find any new large files in my home directory, or /tmp. Which left me a little confused.

They're probably using some kind of fancy compression was my next thought (despite random data being impossible to compress). So I changed my command to run as $ base64 < /dev/urandom | tee tmp to make a temporary file of the output as well as spitting it out. Compressing that with xz, bzip2 and gz all shrunk it to about 70% of the file size (remember, it's base64 encoded random data, so we can actually compress it). As a sidenote, the compressed base64 random data was about 5% larger than just the pure random data - which itself can't be compressed. So this led me to think that they couldn't be compressing it all away to virtually nothing, it's got to be somewhere. (Meanwhile, I left the command running, filling up my terminal).

My next port of call was to have a look at the source code. So I git cloned the gnome-terminal repo, which it turns out uses another gnome library, vte, which I also cloned. I could find where the setting was defined, and it turns out "unlimited" just means there are a max G_MAXLONG in the buffer (which is effectively infinite). I also found mention in a comment that it was saving it to disk, but I couldn't find where it was saving the data.

But then I saw the light. I could just look at what files gnome-terminal had open, so lsof to the rescue. Then I found it was being sneaky, it had a number of files called /tmp/vteXYZ1tv open, but it had already deleted them. Thus you can't see them when browsing, and they will be removed when the program closes. This makes sense, it means that when the process is closed, it doesn't matter how (at least I think), the space of the files can be reclaimed, i.e. we won't get leftover files on a program crash, or a kill -9. They can be restored though, my way (there are probably others), was to do a ls -l /proc/<gnome-terminal pid>/fd to see what they point to. Then you can cat these to make a new file. These are just a verbatim copy of the terminal output. No compression. No nothing. As it turns out, one of my terminal history's was almost 900 MB! But that was only after random data being spat out very quickly for quite a while, unlikely to happen in ordinary usage. For the foreseeable future though, I think I'll keep this option checked, as I can live with a bit of disk usage for the handiness.

Monday, December 13, 2010

Biscuit denser than a neutron star

Over lunch, a couple of friends and I happened to be talking about biscuits, among other things. As we all know, a biscuit tends to absorb water from its surroundings, as it is generally drier than them. Now if we place a biscuit next to the ocean, it would slowly absorb all the water out of the worlds oceans, while maintaining the same volume (yes, we knew that this is completely impossible).

Now lets throw some numbers in. According to wolfram alpha, the volume of the world's oceans is 1.3 x 10^21 L, for an approximate mass of 1.3 x 10^21 kg. Biscuits vary in size, but we took ours to be a cylinder of radius 3 cm, and height 0.5 cm, for an approximate volume of pi x 3^2 x .5 = 14 cm^3 = 1.4 x 10^-5 m^3. Thus the density of the biscuit (as the mass of the biscuit is negligible compared to the water) is about 10^26 kg m^-3. For a comparison, this is much denser than the density of a neutron star, which is typically 8 x 10^16 to 2 x 10^18 kg m^-3 (this agrees with the value of 2 x 10^17 that I calculated in an assignment not so long ago), which, according to wikipedia is "approximately equivalent to the mass of the entire human population compressed to the size of a sugar cube."

So, there you have it. What's denser than a neutron star? A biscuit (containing all the world's oceans).

Thursday, July 8, 2010

Sound arguments require basic logic

Sound arguments require basic logic. Sounds obvious, right? But it seems that some people just don't understand this. Or maybe they understand basic logic incorrectly. Anywho, when someone structures an argument in such a way that it doesn't actually prove the point they were trying to argue, I find it mildly amusing. It happens often too. I'm going to go on to describe one example of this that I encountered recently.

So, a little while ago, I went to a talk entitled, "Is religion inherently violent?". I don't care where you stand on this issue, it is just to illustrate my point. The speaker went on to demonstrate that violence exists outside of religion with a variety of examples, particularly from the 20th century. She also put forward one way that violence would develop in any group of people, religious or otherwise.

You see what she did? The issue itself wasn't addressed at all. By showing that violence exists outside of religion, you're not saying anything about whether or not religion is inherently violent. What she wanted to prove was that religion does not imply violence, but what was shown was that violence can result outside religion.

On the other hand, if you couldn't show that there was violence outside of religion, and there existed some violence, that would be a proof that all violence comes from religion. Not a proof that religion is inherently violent as there could still be some religions that don't cause violence. I can see how people can get confused, but it's not too hard really, if you just think about it.

Lastly, I'm not saying the talk was bad, she did bring forward an interesting point. I'm just saying that she didn't prove the argument the talk was supposed to be based on.

Wednesday, June 30, 2010

A proof that there is no onto homomorphism from S_5 to S_4

Warning: contains maths, algebra even.

This is probably one of the most satisfying proofs that I've ever come up with (or at least remember coming up with). This is partly due to the fact it is non trivial, and partly due to the amount of time it took to come up with it.

Anyway, here's how it goes:

Suppose there is an onto homomorphism \(\varphi\) from \(S_5\) to \(S_4\).

By the first isomorphism theorem, \(S_4 \cong \, ^{S_5}\!/_{\mathrm{ker} \varphi}\), so \(\left| \mathrm{ker} \varphi \right| = \frac{\left| S_5 \right|}{\left| S_4 \right|} = 5\).

As this is prime, \(\mathrm{ker} \varphi\) is cyclic.

Let \(x\) be an element that generates \(\mathrm{ker} \varphi\). \(x\) is an even permutation as \(x^5 = 1_{\mathrm{ker} \varphi}\), so \(\mathrm{sgn}(x)^5 = 1\) and \(\mathrm{sgn}(x) = 1\).

Therefore all elements of \(\mathrm{ker} \varphi\) are even, so \(\mathrm{ker} \varphi \subseteq A_5\), the alternating group.

But \(\mathrm{ker} \varphi \lhd S_5\), so \(\mathrm{ker} \varphi \lhd A_5\), which is a contradiction as \(A_5\) is simple.

So there does not exist such a homomorphism.

Sure, I assumed that \(A_5\) was simple, but we all know that, right?

Tuesday, November 24, 2009

Coding in my spare time now feels so blah

So I started work at my job for the Summer just over two weeks ago, which is great, I'm really enjoying it, but it has almost completely removed my motivation in my spare time. When I'm working all day coding, I really can't be bothered to do more at home, well at the moment at least. Though I have been quite busy lately and that could've been contributing to it.

Having used python almost exclusively at work so far, I'm really enjoying it, it seems to be a really nice programming language, and if I do go back to working on my project, I'll be sorely tempted to start again in python. Though I don't really know how to use its gui libraries, and I doubt I'll get any chance at that at work.

The other thing I find really annoying is that after getting used to my large, wide screen monitor at work, it's really frustrating to use eclipse with my small laptop screen. Though that's a fairly minor thing really.

Tuesday, November 3, 2009

Dimetric Land Rendering

So I got started on my game, I'm calling it BMAC (Build me a city). I've been playing around with the dimetric rendering (sort of like isometric, except instead of all 3 angles between the axes being the same, 2 are the same, and the third is different). I've got it to the point where with a grid of tiles, each with an elevation, it's drawing a fairly nice landscape. Without further ado I present to you my test picture.

As you can see, it's not quite perfect, some of those little moundy things should really merge with their neighbours, and at the top of the hill in the bottom two lines stick out a bit which is odd, but I plan on doing them soon.

That was quite a bit of effort, and quite a bit of drawing pictures to see how it should look. I plan on making it so it can draw from 4 directions looking down at it, but have only down one of these so far, the rest will come.

That's around 500 lines of code or so, which is less than I thought it'd be, but I suppose once I get all the special cases and directions and things that'll increase significantly. I'm quite chuffed though, I thought that would take much longer.