Your dungeon is full of yogurt.

Archive for the ‘Coding’ Category

Progress report

Posted by: Daniel on Thursday, January 10th, 2008 at 6:53 pm.

Current Mood:Here bugs… emoticon Here bugs…

Progress continues… (esp for the benefit of Cew :P)

  • Harmony:
    • Session manager now should have basic functionality working nicely, just awaiting some feedback on further upgrades.
    • The Security control panel is working, although a couple of it’s features aren’t fully wired in yet.
    • The Time control panel is also working nicely. The core now has timezones and smart date handling.
    • The bbcode system has had a major rework, providing greater flexibility and resilience … not to mention it should be faster.
    • The foundations of the new quicklink is in place and being used by the Time control panel.
    • Hopefully more updates on the control panel will be following soon.
  • The dynamic images code has also seen some updates…
    • In it’s first steps from prototype to service, the whole setup has now moved to it’s own subdomain.
    • The runescape comparator now displays your progress through the level and indicates which skills have had recent xp gains
  • After much consideration, I’ve decided the theme on Make it Funky needs further tweaking… some details about it have been annoying me.

That seems to be all I can think of for now heh.

How to Fizzbuzz…

Posted by: Daniel on Monday, June 4th, 2007 at 11:44 pm.
Categories: Coding, From Paws.

Okie, so it’s simple enough… right?

Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.

Lets do this in C… Your first thought might look something like:


for (int i = 1,int y=0;i <= 100;i++)
{
if (i % 3) { printf("Fizz"); y = 1; }
if (i % 5) { printf("Buzz"); y = 1; }
if (y == 0) { printf("%d\n", i); } else { printf("\n"); y = 0; }
}

which is ok, but not entirely efficent… so:


for (int i = 1,int y=0;i <= 100;i++)
{
switch (i %15)
{
case 0: printf ("Fizzbuzz\n"); break;
case 3:
case 6:
case 9:
case 12: printf("Fizz\n"); break;
case 5:
case 10: printf("Buzz\n"); break;
default: printf("%d\n", i); break;
}
}

Or perhaps we’d like to show proper form…


int i,j;
int f = 3;
int b = 5;
int fb = f*b;
char **a = malloc(sizeof(char*)*fb);
//
memset(a, 0, sizeof(char*)*fb);
a[0] = strdup(”Fizzbuzz”);
//
for (i = 1;i < b;i++)
a[i*f] = strdup(”Fizz”);
//
for (i = 1;i < f;i++)
a[i*b] = strdup(”Buzz”);
//
for (i = 1; i <= 100; i++)
{
j = i % fb;
if (a[j]) printf(”%s\n”, a[j]);
else printf(”%d\n”, i);
}

Fun?
(the comments are to try and make wordpresses stupid parser make properly formed xhtml)
Now which of the three are actually the correct answer … well that I’ll leave as an exercise for the reader.

Trac … why not to bother…

Posted by: Daniel on Thursday, May 17th, 2007 at 3:39 am.
Categories: Coding, From Paws, Rants.

Current Mood:Angry emoticon Angry

Okie, trac, on the face of it, looks really nice…

Bug tracking, milestone management, wiki, repository integration … all nice and shiny.

Only it has issues.

First I was having hassle with getting the right permissions.
Then it was a bork in one of the dependencies.
Now it’s a bork in another dependency (note that these are all dependencies marked as stable)

Well over 6 hours of work and still not working bug free is too much.  Trac gets zapped… lets see if Mantis handles any better.

Incidentally … Wordpress 2.2 is out … shiny!

Limitations breed creativity

Posted by: Daniel on Saturday, March 10th, 2007 at 11:09 pm.

This is an interesting concept, but one that can be demonstrated fairly simply.

At the moment I’m working on the market interface. Part of the funky of this system is that a lot of the interaction is done via click and drag (trust me, it’s pretty funky). Unfortunately for my sanity the java packaged drag and drop api’s (AWT and Swing flavours) are rather broken, and somewhat over complicated.

Since the simpliest test case I could find (copied from the documentation) totally failed on my dev system, I had a pretty solid limitation. As a result I’ve had to sit down and implement my own drag and drop handling code, and, although I’ve not actually finished it yet, the end product looks to be far better in the long run than the equivalent concoction using java api code, not only is the total code generated much less, but it is far more flexible for my purpose.

That of course leads me to note that if the original attempts had worked, I would probably have cobbled something together from the ancient AWT drag and drop code and spent ages muttering how it never works quite as well as I’d like. I certainly wouldn’t have arrived at this solution nearly as quickly.

Ergo, the more arbitary limitations present on a task, the more creative and original the end product is likely to become.
While it can be argued that this isn’t necessarily a good thing, certainly it can produce some awful results, it has to be better than repeating the same “obvious” performance every time.
This idea extends rather nicely to just about everything we do in life. One of my recent pictures had me wanting to take a picture of a lily without all the clutter in the background. Two pieces of black card later I had the picture I wanted, and it looks much better for it.
When driving any distance the obvious choice is the fastest route (usually along the nearest motorway) … Perhaps the journey might be more interesting if you plan before hand to avoid motorways, or find a place to stop every hour?

Perhaps that’s something to try the next time you have a task that could be somewhat dull or tedious?
Find a more creative solution with random restrictions. Might not make it easier or quicker, but it will certainly be more entertaining ;)