Posts

Geek quotes

This one is probably my favourite: "There are 10 types of people in the world, those who understand binary and those who don't". Here is one I came up with myself some years ago and used to use in my newsgroup signature: "Blessed are the geek, for they shall public class GeekEarth : Earth".

Derived properties that you don't want cached

I'm rewriting a Win32 application using ECO. One of the things this application allows the user to do is to specify their preferred unit of measurement for height, distance, depth, weight, and speed. To achieve this I have an ECO class ApplicationSettings which is a singleton which identifies the units to use. I then have 2 properties for each value.... InternalLandingDistance DisplayLandingDistance The idea is that I should never expose Internal* properties in the GUI but display their corresponding Display* property instead. The Display* property will read/write the Internal* property and perform some kind of conversion on it. If I always store my values using the unit with the highest accuracy (Distance = feet, Depth = millimetres, Weight = Pounds, Speed = KPH) then I just need to convert them by the correct factor when reading/writing from the Display* properties. This isn't rocket science, obviously I can just implement these as reverse derived attributes right? The pr

Mr thicko thicky thickpants

Well, I feel stupid. Worse than that, I generally feel very thick. Especially yesterday! So, what happened yesterday? I went to Bletchley Park . What a brilliant place! Walking around what was for approximately 50 years one of the biggest secrets of WWII was really quite strange. The stuff these people did was simply amazing! One guy managed to figure out the inner workings of a machine none of them had ever seen just by looking at two *almost* identical messages enciphered using the same machine configuration. The second message was 5 characters shorter than the first because the operator repeated the message but decided to abbreviate some of the words to save some time. This was all they needed. Not only was the functionality of the machine divined but what seems to be the world's first (semi) programmable computer was then designed + built to decipher messages received by wireless and then transcribed to punch holes. This thing has a optical reader that works at 5,

RetrieveChanges(out ignoredChanges)

Here's another quick blog about a new ECO IV feature. I asked for this during development because I had a particular problem I had to solve. My new application has a class named "PlannedCall". When the user logs in they see a list of planned calls that are A: Active B: Not already actioned C: Assigned to the current user, or not assigned to anyone D: EarliestCallTime <= Today + 1 As time goes on there will be a lot of instances of this class in my DB, so obviously I want to use the OclPSHandle to select my objects otherwise I will end up with a whole load of objects in memory that I do not need. However, when another user actions the planned call the Actioned property becomes true. If I use an ExpressionHandle then this planned call would disappear from the presented list, but with OclPSHandle it will not. This is where the new feature comes in! When you call PersistenceService.RetrieveChanges a collection of DBChange will be sent to the client from the server. T

ECO IV

CodeGear are letting some people blog about features in the next release of Delphi (Highlander) before it has even been released. How cool is that? A lot less secrecy, what a great move! Sooooo. How about I spill some beans about ECO IV? Maybe I can find a thing or two to mention :-) I'll just throw together something unplanned, so expect a weird mixture of stuff in no logical order whatsoever! Well, first of all , you're going to get a whole load of source code. I mean *lots* of it! There's a new service called the ICacheContentService . Let's say you know for a fact that there is an object in the DB with the ECO_ID 1234 and it is a Customer. Instead of loading that object into the cache with an OclPS evaluation you can simply use this service to register it in the cache. I've found this really useful in an app I am writing where I use SQL to find customers matching a certain sales criteria. I then create an IObjectList of these customers by injecting the

More secure passwords

Storing a plain-text password in a DB leaves your system open to abuse from anybody with access to the tables (sys admin for example). Here is the technique I recently used. Instead of storing the password itself I store a hash of the password, and a random "salt" that was used to create the hash to make it less predictable. [UmlTaggedValue("Eco.Length", "255")] private string PasswordHash { get { ... } set { ... } } [UmlTaggedValue("Eco.AllowNULL", "True")] [UmlTaggedValue("Eco.Length", "40")] private string PasswordSalt { get { ... } set { ... } } As you can see I do not store the password, just a hash + salt, both of which are private. Here are the methods used to set the values of these properties. public void SetPassword(string newPassword) { if (newPassword == null) throw new ArgumentNullException("password"); if (newPassword.Length < 6) throw new

Printing bitmaps using CPCL

I've had no end of grief trying to print a PCX to a Zebra Printer using the CPCL printer language. Silly me, didn't notice the EG command (expanded graphics) so there was no need to convert my BMP to a PCX and then struggle with binary data. I still had a bit of grief working out how to print using the EG command because the documentation is quite frankly crap. The expected command format is EG {WidthInBytes} {HeightInPixels} {XPos} {YPos} {Data}\r\n The printer expects a 1 bit pixel matrix. So if pixel(0, 0) is set you will set "80" in the data. If pixel(0, 0) is set and pixel (7, 0) is also set you would sent "81". Basically what you need to do is to read each set of 8 horizontal pixels and then use bit operations to create a byte value 0..255, and then output this as hex 00..FF. Here's the routine :-) public void DrawBitmap(Bitmap bmp, int xPosition, int yPosition) { if (bmp == null) throw new ArgumentNullException("bmp");