Saturday, October 03, 2009

Lost your ethernet cards on your VM?

This tip may help you.

We use virtualization A LOT on our environments, as a symbol of trust to this concept we only have half of our web production servers as real machines, the other half is virtualized.

A common issue we found is that after installing SP2 on a Windows 2003 Ent/Standard installation or simply after installing certain security updates on Windows 2003 Ent/Standard R2 installations we lost sometimes the ethernet cards of the Virtual Machines (VM).

Well, the solution is quite simple, this problem usually only happens when you have not installed the client VMware tools, after installing them and restarting the Virtual machine you will be back in business.

Strange? yup. Drove me nuts a couple of times.

Tuesday, September 29, 2009

Squeezing a Cabinet file.

As part of our applications automatic update process we transfer a CAB file to the client side that contains the required updates.

Lately we've being using certain components that are increasing the "weight" of our applications to the point that it is becoming a bit slow to transfer these cab files. The immediate solution to this situation was to review the compression rate of the CAB files to compensate for the additional weight of the applications.

The interesting part of this "simple" procedure was to look at the command line help of the makecab.exe, around four lines and none of them telling us what we could do to help us on this topic. Nothing that some searching and reading can not fix, so if anyone ever has the need of adjusting its CAB compression ratio here it is the solution:

The CAB format allows you to use three compression methods: Deflate, Quantum and LZX. Obviously we pick the always effective LZX algorithm, which you can enable by using this command:

MAKECAB.exe /D CompressionType=LZX /D CompressionMemory=21 /L ..\Output File1 File2.CAB

Where File1 is the file you want to compress and File2.cab is the resulting file. "/L" indicates an output directory. CompressionMemory is the level of compression under the algorithm in question, 21 seems to be the highest.

Monday, September 28, 2009

There is a business opportunity EVERYWHERE.

It is a matter of "simply" finding them.

If there is a need, there is an opportunity. Native cross platform? for me opportunity! 64 bits? semi-opportunity, for some it is very needed, for some others is just a way of showing management that our cool language and IDE supports the latest trends and we are as "fast" as any managed 64 bits and actually "faster" because we are native. (You must understand that's for management, so, save all the technical no no argument, that is why is on quotations.)

The latest example of a good opportunity, and someone going after it is this website that Eko Indriyawan one of our community members post on the Delphi forums.

It looks legit and actually from a technical point of view gets me thinking on the implementation they used to build it. I'm pretty sure tons of spamming companies will give it a try. It will mean a quick cash flow for the creators which probably will die soon after, but will get someone making good money for a bit.

ahh so nice, the beautiful process of finding opportunities keeps going...

Monday, August 31, 2009

DevExpress now officially supporting Delphi 2010.

Well, they were quick to deliver and now it is official. DevExpress is supporting Delphi 2010 and it is available for download to all their license holders.

The new Express Install, v1.46 includes full support for Delphi 2010 and C++ Builder 2010 to the following VCL components:

ExpressQuantumGrid v6
ExpressQuantumTreeList v5
ExpressVerticalGrid
ExpressPivotGrid v2
ExpressScheduler v3
ExpressBars v6 and Docking Library
ExpressNavBar v2
ExpressEditors Library
ExpressSkins Library
ExpressSpreadSheet
ExpressLayout Control
ExpressPageControl
ExpressDBTree
ExpressFlowChart
ExpressOrgChart
ExpressSpellChecker
ExpressPrinting System v3

Very good news indeed, Enjoy!

Thursday, May 14, 2009

Follow Delphi Live!

If you were one of the unlucky (like me) that could not assist to Delphi Live, follow the instant updates from lots of Delphi developers that are having a great time at it, this is the link at Twitter.

Nick Hodges is coming up next with an update on the Delphi Roadmap, so, what can be more exciting than that!


GOGO Delphi!

Monday, April 06, 2009

Time for new looks...

Well,

Lately we've seen a lot of websites changing their look to get into the web 2.0 fashion, and my favorite resource center for all Delphi related data is no exception. The ultra fast and cool, Delphi made FullTextSearch.com (Tamarack) has a new address and look in http://www.codenewsfast.com/ under the umbrella of HREF Tools.

Congratulations, can't wait to see the benefits of migrating to Delphi 2009 in the months to come!.

If you were not using this full text search engine for the Delphi and C++ Builder community and third party newsgroups, it is time you do it. Go and check it out!.

Tuesday, March 24, 2009

The future in our fingertips...

So, we loved the BlackBerry and what they did with that little ball on their keypad. Then Apple came and show us how amazing it is to use our fingertips on screen touch technology, in the meanwhile Microsoft amazed us with their Microsoft Surface, but what is next?

After I saw this video, I just laughed and enjoyed the fact that we live in very exciting times, StarTrek, StarWars and more getting closer to our time. Once reality came back to my senses, I went back to my Delphi 2009 and kept working on creating the coolest systems I can, with the language I love.

Enjoy these times and enjoy life.

Tuesday, September 02, 2008

Credit Card number validator for Delphi

We are implementing parts of a global electronic payment solution and one of the mandatory features was to verify credit card numbers. This is done using the Luhn algorithm. I was expecting to find a wide variety of implementations on our sexy Delphi language but to my surprise there were very few hits on my search.

So, for others that may needed, I'm including this small routine that validates the credit card number (not the card secure code, nor the expiration date). There are several implementations on the web that based on the card prefix digits you can determine the kind of card you are looking at (VISA, MC, Dinners, etc.) That kind of inferences are not reliable for a global solution so the decision was made to drop that auto detection.

function ValidateCreditCardNumber(CreditCardNumber:string):boolean;

Const
DigitsAllowed = ['0'..'9'];
MaxCCSize = 19;
MinCCSize = 13;

var
i : integer;
CleanCardNumber: string;
digit: Integer;
CheckSum: Integer; { Holds the value of the operation }
Flag: Boolean; { used to indicate when ready }
Counter: Integer; { index counter }
PartNumber: string; { used to extract each digit of number }
Number: Integer; { used to convert each digit to integer}


Begin
CleanCardNumber:='';
digit:=0;

// Remove any non numeric value
for I := 1 to Length(CreditCardNumber) do
Begin
if CreditCardNumber[i] in DigitsAllowed then
CleanCardNumber:= CleanCardNumber + CreditCardNumber[i];
End;

// Check for valid card length number
if (Length(CleanCardNumber)MaxCCSize) then
Begin
Result:= False;
Exit;
End;

// get the starting value for our counter
Counter := Length(CleanCardNumber);
CheckSum := 0;
PartNumber := '';
Number := 0;
Flag := false;

while (Counter >= 1) do
begin
// get the current digit
PartNumber := Copy(CleanCardNumber, Counter, 1);
Number := StrToInt(PartNumber); // convert to integer
if (Flag) then // only do every other digit
begin
Number := Number * 2;
if (Number >= 10) then
Number := Number - 9;
end;
CheckSum := CheckSum + Number;

Flag := not (Flag);

Counter := Counter - 1;
end;

result := ((CheckSum mod 10) = 0);

End;

This implementation is based on a 1996 VB Code migration from Shawn Wilson.

Thursday, July 17, 2008

Tiburón swimming in Lake Ontario.

For the first time, a Tiburón was found last night swimming around the North York Public Library and people is wondering if they are coming out from Lake Ontario.

But, such a thing seems to be untrue. All points out that our visitor came from Silicon Valley.

Yup!, we had the pleasure to listen to no other than legend CodeGear developer David Intersimone and Anders Ohlsson (geesh, hope i got his lastname right). They gave us a good talk about CodeGear, Embarcadero and tour of Tiburón, called now officialy "Delphi 2009".

The highly expected Unicode support is everywhere and it seems that the guys put lots of effort on achieving a high degree of backwards compatibility, which is as usual, a fantastic tradition that thankfully Delphi has never lost.

Lots of new classes to help us on this transition, some new enhancements to the VCL (some cool new components there) which you probably already saw on all the blog posts that CodeGear is generating now.

BUT, now lets talk about those hidden gems that we could see while they were demoing stuff, for example, a new little category to the component tool palette, something called "Ribbon Components", yup, they didn't mention it, they didn't demo them, but it was there. So, no NDA violation here, nor there, merely healthy speculation.

Also I noticed two more categories, and I am extremely happy about them, because it means that we are finally getting some love on the middle tier area. It seems to be part of the announced improvements to DataSnap, a "Data Snap Client" and "Data Snap Server" categories, instead of the typical single "DataSnap" group. What is in there, no idea, but hey, i like the hint.


Anyway, it was a great time, a great experience, Delphi is getting better. The guys seemed to be pump about the future, and so are we.


Oh, and did I mention that we are hiring? :)


Wednesday, April 30, 2008

How to create a Web Server Control in ASP.Net with Delphi 2007

We were presented with the challenge of creating our own server controls. After some research on the web, we found very few examples regarding how to do this, even less if they are specifically targeted to Delphi.Net 2007.

So, in order to help the next fellow Delphi developer that is presented with similar situations, it is our objective to publish small articles on every new item that we face in our development process as a contribution to the new Spirit of Delphi that is growing in the community.

Special thanks to Feryal Badili for putting this article together. :)

Here is the step-by-step instruction on how to create a simple server control in Delphi 2007.

Well, there are two ways to create web components in Delphi:
1) You can go to 'File-New-Other-Delphi for .NET Projects' and choose 'Web Control Library'.
2) OR, you can go to 'File-New-Other-Delphi for .NET Projects' and choose 'Package'. Then in project manager panel, right click on 'Contains' folder and select 'Add new-Other-Delphi for .NET Projects-New ASP.NET Files' and select 'Web Custom Control'. You may want to use this approach if you would like to have multiple controls in the same package.

The general recommendation is to use the first method to create a web custom control for the first time, it is a lot easier in the long run, believe me.

Delphi will generate the source code for a very simple web control. Let's just try to understand it:

The default name for the file is 'WebControl1.pas' . It is a Delphi unit file and the unit name is really your namespace. You need to remember that because you're going to need it later when you are using the control in your web page!

Under 'Type' section of the code, you will see the following lines:

[DefaultProperty('Text'), ToolboxData('<{0}:MyWebControl1 runat=server>')] MyWebControl1 = class(System.Web.UI.WebControls.WebControl)

Well, what does it mean?
Your class MyWebControl1 is derived from System.Web.UI.WebControls.WebControl.

If your control renders a user interface (UI) element or any other visible element on the client, you should derive your control from System.Web.UI.WebControls.WebControl (or a derived class).

If your control renders an element that is not visible in the client browser, such as a hidden element or a meta element, derive your control from System.Web.UI.Control. The WebControl class derives from Control and adds style-related properties such as Font, Forecolor, and BackColor.

In addition, a control that derives from WebControl participates in the themes features of ASP.NET without any extra work on your part. If your control extends the functionality of an existing control, such as the Button, Label, or Image controls, you can derive from that control.
If you are going to have multiple visual controls in your server component and you wish to inherit the basic functionality of the parent controls, you need to derive your class from CompositeControl class:
MyWebControl1 = class(System.Web.UI.WebControls.CompositeControl)
To learn more about composite controls, see:
http://msdn2.microsoft.com/en-us/library/3257x3ea(VS.80).aspx

The code inside brackets that is generated on top of your class definition is attributes that apply to your class. To learn more about these attributes, see the following link:
http://msdn2.microsoft.com/en-us/library/ms178658(VS.80).aspx

The code generated by Delphi adds a property called 'Text' to your component . Since this property is published, you will be able to see it in the "IntelliSense" or "Code Completion" and object inspector when you use this component in a web page.

As you can see, this property also has some attributes:
Bindable: set it to true if your property can be data bound.
Category: In object inspector, this property will appear under the category(group) that you define.
DefaultValue: Obviously, this is the default value of your property.

You need to define these attributes for each and every property that you want to publish for your component. Also pay attention to the field definition for your property.

Next step is to add your own child controls and render the server control. In order to do that, you need to implement the following procedures:

procedure CreateChildControls(); override; procedure RenderContents(Output: HtmlTextWriter); override;

Here is an example of simple server control that includes only one control (TextBox) and adds one property named 'ShowTime' to the control.

You can use this component in both Visual studio or Delphi .NET.

unit WebControl1;
// To create a more advanced Web Control that supports live data at
// design time, see instructions in the readme file located in the
// 'BDS\5.0\Source\DotNet\dbwebcontrols' directory
//

interface

uses
system.web,
System.Web.UI,
System.Web.UI.WebControls,
System.ComponentModel,
system.Drawing,
System.Data,
system.security.Permissions;

type
///
/// Summary description for the component
///


[
AspNetHostingPermission(SecurityAction.Demand,
Level = AspNetHostingPermissionLevel.Minimal),
AspNetHostingPermission(SecurityAction.InheritanceDemand,
Level=AspNetHostingPermissionLevel.Minimal),
DefaultProperty('ShowTime'),
ToolboxData('<{0}:OpenItems runat=server>')
]
OpenItems = class(System.Web.UI.WebControls.CompositeControl)
strict private
IsError : boolean;

msgBox : textBox;
FShowTime: boolean;

strict protected
procedure RecreateChildControls(); override;
protected
procedure RenderContents(Output: HtmlTextWriter); override;
procedure CreateChildControls(); override;
public
constructor Create;
published
[Bindable(false),
Category('Behavior'),
DefaultValue(false),
Description('Show the Date and Time')
]
property ShowTime : boolean read FShowTime write FShowTime;
end;

implementation
uses SysUtils;

///
/// Define a public parameterless constructor needed by web controls.
///

constructor OpenItems.Create;
begin
inherited;
isError := false;
end;

procedure OpenItems.RecreateChildControls();
begin
try
EnsureChildControls();
except
IsError := false;
end;
end;

procedure OpenItems.CreateChildControls();

begin
try

Controls.Clear();

// Create a text box
msgBox := TextBox.Create;

if ShowTime then
msgBox.Text := DateTimeToStr(Now)
else
msgBox.Text := DateToStr(Now);

msgBox.BorderStyle := System.Web.UI.WebControls.BorderStyle(1); // Sets border style to 'None'
msgBox.ForeColor := System.Drawing.Color.get_Red;
msgBox.Style.Item['position'] := 'reletive';
self.Controls.Add(msgBox);
except
IsError := false;
end;

end;

///
/// Render this control to the output parameter specified, preserving
/// cosmetic attribute output generation inherited from standard
/// WebControl.
///

///


{$REGION 'Render override'}
procedure OpenItems.RenderContents(Output: HtmlTextWriter);
begin

if not IsError then
begin
// There was no error so far, render all components
try
AddAttributesToRender(output);

Output.AddAttribute(HtmlTextWriterAttribute.Cellpadding,'1', false);

Output.RenderBeginTag(HtmlTextWriterTag.Table);
// The table will be very useful when you have multiple visual controls
// included in your component

Output.RenderBeginTag(HtmlTextWriterTag.Tr);
Output.RenderBeginTag(HtmlTextWriterTag.Td);
msgBox.RenderControl(output);
Output.RenderEndTag(); // end td
Output.RenderEndTag(); // end tr

Output.RenderEndTag();

except
// An error happened, just show a message
Output.Write(' '+ 'Unable to create the components');
end;

end else begin
// An error happened, just show a message
Output.Write(' '+ 'Unable to create the components');
end;

end;

{$ENDREGION}

end.


A painless self-hosted Git service

Remember how a part of my NAS setup was to host my own Git server? Well that forced me to review options and I stumble into Gitea .  A extr...