guyblade.com #/


PSN
Gamercard


2008 Jul 30 namine


Guy Blade Guy Blade---03:59:00


And yet, it moves
So, apparently there was an earthquake about 30 miles southeast of JPL today. It was relatively minor in my office--it just seemed like someone was shaking the cubicle wall really hard. Luckily, there was no damage to anything at work (at least not anything that I work with) or at my apartment. I was slightly worried that it might have been strong enough to tip over one of my bookcases, but there was nothing out of place in my apartment when I got home.

Published by XPost


Permalink to this post     Com/0


2008 Jul 27 celes


Guy Blade Guy Blade---12:52:00


Coming Soon...


Published by XPost


Permalink to this post     Com/0


2008 Jul 17 tifa


Guy Blade Guy Blade---06:52:00


Lovelace would be disgusted
Ada is a badly designed language and its designers should feel bad.

I say this for several reasons which I will soon impart to you.

1. How many types are too many? Basically, Ada allows you to define all sorts of types. You can define a type which is all positive integers. You can define a type which is all real numbers between 2 and 3. You can define a type which only represents a valid number of seconds to occur in a day. At first, this sounds like a great idea because it forces you to make sure that all of your numeric values are legitimate and verifies them at runtime. The downside is that you have to cast every single time you move from one to another. It doesn't matter if two different types are both defined to be all positive numbers representable with an unsigned 32 bit integer, you still have to explicitly cast. This becomes even worse if you're doing such simple things as adding, where if you're adding two different kinds of numeric types, you'll have to cast one into the other. Also, if you're using the built-in functions for doing things like converting an integer into a string, you have to know the exact type that you're using or else you won't know what function to call, and loathe to you who would try to use the wrong one.

2. What's that about interfaces? So, sometimes you have to deal with binary interfaces. In my case, I'm reading satellite data which is in a fixed (and not going to change) format. Ada does, luckily, provide something similar to C structs called records which you can theoretically use to read such binary data in fixed structs. Unfortunately, the language (or at least the gnat implementation) made an idiotic design decision: if you're packing a record, the compiler can feel free to rearrange the elements of the record (see 8 in link). Now, that just isn't going to work when the layout of the data has been pre-defined. When I say that the record is an int32, a uint8, and then an int32, it isn't ok to put the uint8 at the end to keep alignment easy!

3. Shift what now? So, you can't use a record to just read the data in straight. What do you do instead? You use an array of bytes (Unsigned_8s in Ada parlance) which is the same size as the record that you're trying to read and then reconstruct them into the various types that you need. Sounds like no problem to me, just a bunch of shifting and ORing then some type fiddling to make everybody happy. Unfortunately, however, Ada only provides bit shifting operators for "modular" (i.e., unsigned) types. Also, due to the crazy type system mentioned in part one, you can't force a negative integer value which you've constructed in say a Unsigned_32 into an Integer_32 by using the casting operations. Clearly, that wouldn't make sense because the "negative" value in the Uint32 is larger than the maximum value of the Int32! How do you get around this impasse? By doing two's complement calculations on your own, of course! This, along with my complaints in part 1, make the code to convert 4 bytes into a 32 bit integer something like 10 lines long instead of being more like the one line long piece of C code that I use to process other data plus it has lots of wonderful constants like 16#80000000# (which is the bitmask for seeing if the MSB is set) and 16#7FFFFFFF# (the negation of that for anding out the other part).

4. What do you mean it doesn't matter? Ada is a case insensitive language. I don't think this is inherently a bad design decision, but it has, in the code base that I'm working with, led to the brilliant decision to use ALL UPPERCASE to refer to all non-built-in types, functions, and variables.

5. I would kill for fprintf. Ada's options for writing numbers to text files are rather sparse. You can use Type'Image(variable) to produce a string which contains the value in a fixed format (integers would match the regex /(-| )\d+/; floats would match the regex /(-| )\d+\.\d+E(\+|-)\d+/). This has the downside of producing very ugly floating point numbers every positive number is have a space at the front of it. It's pretty easy to remove, but I shouldn't have to. The other method is to create an instance of the Ada.Text_IO.Integer_IO or Ada.Text_IO.Float_IO classes. Of course, these classes can't be instantiated directly, you have to extend them so that they apply to a specific type of integer or float and won't work on any other types (see part 1 again). That's one extended class for each type or a whole lot of casting. Good luck trying to use integer/float IO at the same time as doing regular "text" IO. I wasn't able to ever get it working right. I'm sure there is a way; I'm also sure that it is bad and that it should feel bad.



Published by XPost


Permalink to this post     Com/0


2008 Jul 14 yuffie


Guy Blade Guy Blade---13:15:00


Alternate Plan
A couple of weeks ago, my iPod was stolen. This has led to me using WMHD as a music source at work. Unfortunately, my music tastes and what is available on WMHD do not coincide well. As such, my answer thus far has been to set up an icecast stream so that I can listen to my music from work. It turns out that mpd makes a very good source for icecast and can do all the nifty things necessary to make a decent little remote music player.

The only problems that I've had so far are difficulties set up any sort of security on the stream. Icecast (at least the svn trunk) supports streaming over SSL, but there is essentially zero documentation. Also, icecast only supports two kinds of authentication: htpasswd which is essentially identical to apache's htpassword auth, and "url" auth which sends a command to a remote http(s) machine and greps the output for a given magic string to authenticate a user. The problem with the htpasswd is that it is a pain in the ass to configure and the "url" auth doesn't play nice with using a self-signed SSL certificate (fails to authenticate without explaination) or provide a method for ignoring the self-signedness.

Obviously, I don't want to run an open music stream over the internet, so I'm going to have to figure something out. The obvious answer would be to enable ipsec and only allow it to work over ipsec, unfortunately, ipsec connections aren't allowed through my firewall at work.

Published by XPost


Permalink to this post     Com/0


2008 Jul 11 terra


Guy Blade Guy Blade---07:22:00


Your statement has been added to the record
So, a while back, I threw together a quick commenting tool for use on guyblade.com and andersonhighschool.com. At some point, it became spammy and I just disabled it. Based on the dates of posts, this was like two years ago. I was reminded that this page existed by looking at my awstats and seeing that, dispite the fact that it was impossible to actually post to the comment page, it was being spammed to the tune of a few hundred hits a month.

My response was, of course, to try to re-enable it with some sort of security. My first attempt was a brain-dead captcha made using PHP's gd library. Apparently, spammers have prebuilt libraries for solving any captcha using the built-in fonts in PHP's gd build as I had several hundred spam posts by the time I checked again.

My second attempt (the current one) is to present an equality of the form "x * y + z = t" wherein one of x, y, z or t is missing and all are non-negative integers. The user is prompted to solve for the missing value. Although it is also brain-dead simple, I hope that it is not in the pre-built captcha solving libraries. If it is, I may be forced to make people solve simple definite integrals over polynomials and/or evaluate simple derivatives at points on polynomials.

I suppose this could have the side effect of preventing some people from being able to comment on my posts @ guyblade.com, but I think it will be ok.

Published by XPost


Permalink to this post     Com/0


2008 Jul 10 peach


Guy Blade Guy Blade---17:51:00


The bullets go up
So, a few days ago, I rediscovered the game Tyrian. It was a vertical scrolling shooter made in the mid-90s that was exceptionally good for its time and has managed to age very well. What caused me to rediscover it was finding (through stumbleupon) that the game's engine has now been open-sourced and released for free through the OpenTyrian project. This is especially nice because the game now will run more or less flawlessly under linux without any special emulation required. I highly recommend it to any fans of the scrolling-shooter genre.

Published by XPost


Permalink to this post     Com/3


2008 Jul 02 rinoa


Guy Blade Guy Blade---06:12:00


Things that suck.
1. Finding out right as you're getting ready to leave work that something absolutely has to get done before you leave.
2. It taking an hour.
3. Horses going down the wrong side of the street, toward you, while you're on a bike.
4. Blowing a breaker when the breakerbox is outside, downstairs, behind the building, in a dark alley at night.
5. Your iPod getting stolen. Again.
6. Vacuum cleaners.
7. Wasting a DVD trying to burn YellowDog for the PS3 with a bad image.
8. Trying to install Ubuntu on the PS3 and it refusing to ever load X.
9. Rent going up by $100.
10. Being on call for jury duty.


Published by XPost


Permalink to this post     Com/0

Archive
Copyright 2002-2024 Blade Libergnosis//Powered By Blogger