logo

ShrimpWorks

// why am I so n00b?

titleNew phone

date 8 Jul 2005

So I got myself a shiny new samsung D500 phone!

Since WP supports posting by email and this phone can send them, I thought I would mess around a bit with the concept.

Here’s a rather bad photo taken out my office window…

Lost in time

Since I’m bored at the moment, I might as well post some code :D

PHP has 2 nice functions, explode() which breaks a string into an array using a separator, and implode() which takes an array and glues it back into a single string using a separator. I use it regularly, so eventually ended up needing one for Delphi too.

I cannot take full credit for the Explode function however, I found it somewhere and can’t for the life of me remember where that might be. It is somewhat modified from the original though…

Also note that these work with TStrings, rather than arrays.

function Explode(const str: string; const separator: string): TStrings;
var
  n: integer;
  p, q, s: PChar;
  item: string;
begin
  Result := TStringList.Create;
  try
    p := PChar(str);
    s := PChar(separator);
    n := Length(separator);
    repeat
      q := StrPos(p, s);
      if q = nil then q := StrScan(p, #0);
      SetString(item, p, q - p);
      Result.Add(item);
      p := q + n;
    until q^ = #0;
  except
    item := '';
    Result.Free;
    raise;
  end;
end;
function Implode(const Strings: TStrings; const separator: string): String;
var
  i: Integer;
begin
  Result := Strings[0];
  for i := 1 to Strings.Count - 1 do
    Result := Result + separator + Strings[i];
end;

Wordpress lets you write email messages to a specific email address and
it’ll periodically check for new messages, and post them to the blog!

Cool beans!

MMMMMMMMM

This game (demo at the moment) is really sucking up all my evenings :D. The gameplay is absolutely brilliant. The whole Squad story is just ownage when playing with a decent bunch of players. Just a pity squads can only be 6 people big.

I can actually fly planes too. Managed to shoot down a helicopter and a plane last night (though the plane kill took about 5 minutes of frantic flying from my victim). Though there’s always someone else behind me waiting for me to fly straight for a half second too long :(.

If you like team games, with a rather unrealistic, yet somehow realistic feel, get this when it comes out on the 28th (South African release apparently).

Ok so this is a little trick I picked up a few years ago when I developed the first version of ECheck and I started learning the POP3 protocol. It’s come in very handy when I’m away from my email client and don’t want to receive email anywhere and fragment my mailbox by spreading it across a few machines.

Firstly, this’ll work on both Linux and Windows systems, with no extra software needed (assuming most Linux distros come with a Telnet client by default).

It’s a pretty useful thing everyone with an email account should know ;-).

Firstly, open a command prompt, and execute the following:

$ telnet <your.mail.server> 110

would obviously be replaced by the address (IP or hostname) of your POP3 server.

If you connect, you should be presented with a welcome message and a “+OK” message. You then enter the following commands to log in, replacing the contents of the "" with your details:

user <your@username>   pass <password>

After which, you should be greeted by another “+OK” assuming you managed to log in. If you make a typo, just send the line with the type

  • you usually cannot backspace and correct mistakes. Issue the correct command again.

Now that you’re in, let’s see your messages. To see how many messages and how big each of your messages is, send the following:

list

Once again a “+OK” line should be shown, followed by a very simple list of message IDs and file sizes (in bytes). Let’s preview a message, shall we?

top <id> <lines>

The headers for message , followed by up to number of lines from the message will be spammed to your console. You can find both the “Subject:” and “From:” header lines to decipher who the message is from and what it’s about. Of course you can also read the body…

Hmm? This message is junk mail or spam? Want to delete it before it hits your inbox?

dele <id>

… will delete the message with ID . It’s important to note that the message IDs are maintained - so if you delete message 1, message 2 will not fall into 1’s place. It’ll remain 2 for the remainder of the session.

If you’ve deleted the wrong message, all it not lost. You can ‘reset’ the mailbox status to how it was when you first connected:

rset

And once you’re done mucking around, disconnect nicely:

quit

It’s also worth noting that the commands are all case-insensitive, though I’m sure the ‘correct’ way of doing it would be to use all caps for commands, the server doesn’t seem to mind either way.

Have fun…

I haven’t really seen a lot of news about the OpenOffice.org 2 Beta release. It seems to me like a pretty important thing :P.

Anyway I popped by the OO site recently and grabbed the beta (which is actually version 1.9.79). Anyway, first thing to note is the loading time has unfortunately not really changed much since the 1.1 range. Next thing you’ll notice is the look. It looks a few million times better than previous versions, and actually looks like a native Windows application now. The toolbar icons all look much clearer - I never really liked the previous version’s icons much at all, they were all very unclear as to what they did.

Next up, Calc now supports 64000 rows!! This was my biggest gripe with previous versions - they were limited to 32000 before, which pissed me off no end when trying to work with large chunks of data. For me, this is the biggest improvement I could have hoped for :). I also found defining custom number and date formats somewhat easier than before.

I can’t say I’ve used Writer all that much, so I can’t comment too much on that, but I did note that the Print Preview has been properly overhauled. The Print Preview seemed to have been an issue when trying to convert people :).

I can’t say I care much for the new Open Document Formats, since most of my work requires me to use Excel and Word files, so I just write to those formats whenever I save. Lets see if MS will start to support the format in Office now that it’s been recognised and approved as a standard.

Overall, I guess the real version 2 can only get better :).

I’ve been adding some nifty things to my PHP project at work (cellphone starter pack invoicing, usage tracking [big bro is watching you earn him money every time you use your pre-paid airtime :P], etc). It’s got a lot of pretty nice features. Using client-side JavaScript, it actually pretty much behaves as a normal desktop application, only it lags like hell when you visit other pages (slow web server :P).

Anyway, I can’t claim I’ve written all the snazzy features myself unfortunately. Due to time and pressure I’ve been relying on good old Open Source to help me out. There’s actually a helluva lot of stuff out there to make things easier for just about anything you need to do…

  • ADOdb - http://adodb.sourceforge.net/

    Obviously the first thing to get going on any database-aware application, is to actually interact with the database. PHP has an Interbase module, with a whole bunch of Interbase functions. These all work fine, and there’s really no problem with them. ADOdb however makes working with SQL databases so much easier. No need to remember PHP’s randomly named module functions, and it gives you access to a huge assortment of database drivers (of corse all dependent on normal PHP modules). It’s even available for Python now!

  • Smarty - http://smarty.php.net/

    Next you’d presumably like a fancy presentation for your application. You have three options here - painfully output every single line of HTML manually through your code, create yourself a template engine/language, or use Smarty. Smarty is a Template Engine, which lets you define “.tpl” files which are bascally just HTML files with a couple of variable placeholders and smarty function calls. But it’s not just the simplicity of creating a Smarty instance, assigning variables to it, and then just calling display(), it’s the functions you can put into your template files. Looping through customer listings, building tables or drop lists, check lists, etc, etc, etc. One of the most useful things I’ve found is the ability to define your own smarty functions, allowing you to add custom functionality to your templates and the output they generate.

  • PHP pdf / PDFClass - http://ros.co.nz/pdf/

    One of the requirements of this project was that reports had to be generated in user and printer friendly PDF format. At first I looked into the option of having Smarty generate tabular reports, and get an HTML to PDF processor (there are several PHP options available) to turn my HTML into the PDFs required. Unfortunately, for the most part, these converters are heavily buggy, and didn’t give me very much control at all over the output (ok, I had full control over the output, but things like page headers and footers, page numbering, etc, etc are required for nice reports). Anyway, so I set about using PHP’s PDF functions. Unfortunately, that turned out rather risky across different versions of PHP, and was generally a pain to work with. Enter this package. It doesn’t require any of PHP’s PDF modules, so it’s free from cross-version and cross-platform bugs and stuff. It also has a bunch of nice functions for headers, footers, tables, etc. It also provides the option to save the output to disk, output direct to browser, or plop the output into memory where I can play with it. I’ve built a very nice reporting class around this package.

  • Code 3 of 9 Barcode Generator - http://www.sid6581.net/cs/php-scripts/barcode/

    Another requirement of the system is the ability to group multiple items into a single item. From the code side of things, it’s fairly simple, but to users, trying to manage these million boxes of starter packs and remembering or creating their own codes for these boxes would obviously be rather difficult. Anyway, I though it’d be nice to offer a barcode people can print and stick to the boxes. Enter this little script. Couldn’t be easier to use, and with the help of a little Javascript, users can even scale the barcodes up and down (by dynamically reloading the image, not just changing the dimensions and possibly corrupting it) before printing.

  • PHPMailer - http://phpmailer.sourceforge.net/

    I’m using this for sending my PDF reports via email. It allows you to easily attach files, or file content (so I don’t need to save the PDF’s to temp files before attaching, just attach the output directly from script). Also supports SMTP, so no need to rely on PHP’s mail configuration.

I’m also using a nifty little ZIP lib that allows me to zip my in-memory PDF reports, and send them direct to the browser for downloadable reports (since a normal PDF will open in the browser). Unfortunately there’s no readme or author URL in the source :)

I did get it from PHPClasses.org though, which has quickly become by first stop for anything I need in a hurry that I couldn’t be bothered, or don’t have time to write myself. Nice rating system and “top 10"s filter out the good stuff instantly, making finding stuff really simple. I highly recommend it to any PHP developers.

titleNew Toy

date 13 May 2005

So I went and bought myself a brand spanking new laptop last week :D.

It’s an HP Compaq NC8230 featuring the works - Intel Centrino CPU, ATI X600 ‘mini’ PCI-Express with it’s own 64MB RAM (don’t you just hate ‘shared video RAM?’), 15.4" widescreen display (with ambient light sensor to adjust brightness dynamically! Ooooooh, aaaah), only a 40GB HDD still, wifi, bluetooth, smart card reader stuffies, Win XP Pro SP2, etc etc etc.

All very nice :)

I went and got myself a virus on the day I unpacked it though… So much for the pre-installed Norton AntiVirus. Dumped Norton and tried out the home edition of avast! Anti Virus, which saved me rather smartly. Seems much nicer than the good old AVG system.

Anyway, it’s not as pretty as my old one (nx9010), but after a week using it at work, it actually feels more comfortable despite it’s more rigid, rectangular appearance.

Overall I’m very impressed :-).

Well because I’m apparently not doing any work here… I’m being trekked off to JHB yet again. No idea when I’m even getting back. Lovely 3 days notice I’m given too.

Seems whenever things in my life start settling down and I actually start getting things done, this shit pops up…

Hrm, I just remembered I was supposed to do some work for an old client this weekend too… LOLOLOL…… :-(

Dunno if anyone would have noticed but the site was blinking on and off last week, with dynamic DNS issues.

I’ve been using an application which runs as a service on my Windows machine, but it seems to often give up if it can’t get a new IP or the update fails, and sometimes it just doesn’t bother even trying :-).

Anyway I slapped up a quick Python script to be run from a cron job at 5 minute intervals to check a website which provides my IP (like http://checkip.dyndns.org), grab the first IP it finds, and updates my ZoneEdit account with the new IP.

Seems to have been running reliably the past few days now.

I’ve dumped it on the Files page if anyone would like to give it a go. It’s set up for ZoneEdit, but I’m sure it’s easy to adapt to other services as well.