Divis Blog

Just another geeks blog.

Various javascript libraries

clock March 10, 2008 22:04 by author Divi

In the last few days I got the time to read some magazines I neglected for the last 1-2 weeks. While I read them, I found some very interesting JS libraries:

 

Bevel-JS

Link: http://www.netzgesta.de/bevel/

A cool script, which enables you to modify images via javascript.

image

In the foreground, you can see the image which can be found in the example directory of the library, while in the background there're the modified images with applied image filters. Both included JS files only have an altogether size of 48kb.

 

Flot-JS

Link: http://code.google.com/p/flot/

The following code is from the example directory:

$(function () {

var d1 = [];

for (var i = 0; i < 14; i += 0.5)

d1.push([i, Math.sin(i)]);

var d2 = [[0, 3], [4, 8], [8, 5], [9, 13]];

// a null signifies separate line segments

var d3 = [[0, 12], [7, 12], null, [7, 2.5], [12, 2.5]];

$.plot($("#placeholder"), [ d1, d2, d3 ]);

});

What looks a little bit mathematical is just the description of several graphs, which look as following:

image 

This is just a simple version of what the flot-library offers. Another slightly more complex version, which consists of several different graph types can also be found in the example dir:

image

To say it with the words of a colleague of mine: "I won't need that more than once a year - but then it could be realy useful."

One nice thing about these diagrams is: The library offers methods to retrieve the values at the current cursor position and also a way to zoom the displayed diagram.

 

Ext-JS

Link: http://extjs.com

The ExtJS seems to offer some very nice controls. A screenshot of the API-Documentation of the frameworks demonstrates some of the controls, which are also used on their own page:

image

As you can see in the tree on the left-hand side, there're some very useful controls, which can be found in almost all applications. E.g.: Grid, Menu, Tree.

For the lazy guys: There're also some video tutorials available on the page ;-)

 

zXml

Link: http://nczonline.net/downloads/

If you click on the link above, you'll be redirected to a page, where you can find many nice JS-libraries. E.g. one extension extends the JS-arrays with the method "clone".

But the class I've been interested in most, offers an browser independent interface to handle XML. The JS file is only 14kb in size and offers to write code like the following:

//create a DOM document

var oXml = zXmlDom.createDocument();

//fill it with some XML

oXml.loadXML("<root><child index=\"1\"/><child index=\"2\"/> <child index=\"1\"/><child index=\"3\"/></root>");

//look around

alert("Root is: " + oXml.documentElement.tagName);

alert("First child is: " + oXml.documentElement.firstChild.tagName);

As you can see, you're able to use the usual terms like firstChild or tagName to work with the various elements and their values.

 

Dojo-Offline-Toolkit

Link: http://dojotoolkit.org/offline

The "entwickler"-magazine (edition: march/april) wrote an article about the usage of the dojo-offline-toolkit in cooperation with Google-Gears. Google-Gears offers a SQLite database and a proxy server to store dynamic content on the client to display it controlled when it's needed.

The dojo-offline toolkit doesn't add new functionality to Google-Gears, but offers some methods to ease the work with Gears. Some of the methods are the "Dojo-Storage" which can persist objects, methods to execute sql and some to download resources from the given page (called 'slurp').

 

Only for the completeness of this page are here some further links to frameworks I know:

- Prototype

- Script.Aculo.Us

- Moo-Ajax und Moo-FX

- JQuery

- ASP.Net Ajax

All of these are great frameworks which don't only focus on ajax but also add perfect effects for your page. However I assume that these frameworks are much more common and don't need any explanation here.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Free pdf-printer from Bullzip

clock February 22, 2008 19:25 by author Divi

During the last days I've been asked several times for the possibility to convert, as easy as possible, any Word-files into pdfs. Usually one of the following things crossed my mind instantly:

- OpenOffice offers the option to save files as pdfs.

- The Office 2007 plugin "Save as PDF" (naturally requires Office 2007)

- The Acrobat Distiller (Part of the commercial Acrobat from Adobe)

 

From time to time I made myself some trouble searching for an up-to-date version of some tools, that might could help me, but most of the time I recommended, to the guys that haven't had Office 2007 installed, to download and install OpenOffice.

 

Since today I would recommend, to the guys without Office 2007, because I like its plugin, to download the "PDF Printer" from Bullzip. The PDF-Printer ist free and requires only the installation of "Ghostscript". Both downloads can be found on the download-page of Bullzip:

 

Bullzip

After the installation, there's a new printer placed in your system control panel. If you select that device and print your document, a dialog appears, which asks you for the target file location. After you selected the destination, everything will happen automatically.

Currently rated 3.0 by 5 people

  • Currently 3/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Missing Silverlight Assemblies

clock February 10, 2008 23:46 by author Divi

Today I tried for the first time to create a Silverlight 1.1 (respectively 2.0) project. But even during the first try to compile the project, I got lots and lots of errors, saying that there was a namespace missing. The namespace I read at most was: "System.Windows".

In the silverlight board I found several other guys, which encountered the same problem as I had and couldn't solve it, even if the un- and reinstalled Silverlight and event the whole Visual Studio ... Obviously they made the same fault as I did :-D

If you create a silverlight project it looks as follows:

image

If you're also having corrupted references for the assemblies "agclr", "system.silverlight" and "system.Xml.core", you probably made a fault during the installation of Silverlight 1.1.

After I downloaded all tools I found on the Silverlight-page, I had to confess to myself, that I've had ignored one download ... It was the "Silverlight 1.1 Alpha Refresh" runtime. I thought that everything I needed was in the SDKs - that's a wrong conclusion!

If you install the VS-tools, you just get the TEMPLATES, which are telling VS how to handle that Silverlight stuff. The assemblies themselfes are in the browser plugin...

The alert I was shown was: "Please close all browser windows first and uninstall Silverlight". For sure I didn't want to uninstall Silverlight - and that was my fault. Obviously you have to uninstall any Silverlight plugins to install the current version.

Meanwhile everything works fine (and great!)

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Sitecore Xpress released

clock February 7, 2008 23:13 by author Divi

Today it was the time I waited for. Almost as on christmas I was glad that as I entered the page of "Sitecore Xpress", there was no longer the teaser saying "Coming to a server near you...", but a nice looking download page. For sure I logged in instantly and downloaded it. Small 250MB, which needed less than 10 minutes on their way to my desktop ... the license code on the other hand took his time ... I got it at 4pm - But the waiting was worth it. Now I can finally play around with it on VISTA...

image

The commercial Sitecore (recently called "Sitecore red") had some problems with IIS on Vista ... But I think that will be also fixed on the next version, which I await shortly.

In any way - it's nice to simply ignore the small error message on the beginning (saying the IIS would not run) and just start installing it and - who would have believed - after some minutes - a browser window opened, the page appeared and it simply works. This is how it looks on my screen: 

image

That cheered my heart.

 

But what the hell is Sitecore? Sitecore is a highly developed CMS - the best I've ever seen. You almost have the like on your own desktop, if you're welcomed directly after the login with the following screen:

image

(Yes - that's a screenshot of the current version) ... so just don't wonder if the windows need a little bit longer on the first opening... .Net has to compile the libraries for the first run.

As you can see on the screenshot, the interface looks almost like an Windows-desktop ... and also the "Content Editor" corresponds to the layout of the Windows-Explorer. As a Windows user you shouldn't have any problems to find your way through the system:

image

 

So if you would gladly try that CMS, which is normally for commercial use only and which is also used in enterprise solutions: Download Sitecore Xpress in any case! It's free and you won't ever have the same kind of fun with any other CMS ;-).

 

Links

Sitecore Website

Sitecore Xpress Website (DOWNLOAD)

German Sitecore Solution Partner "netzkern GmbH"

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Center content on page

clock January 31, 2008 10:47 by author Divi

One day after another I'm having the problem of centering content in the middle of a web-page.

My default way was to enclose the whole page in <center>-tags and put matching content into it - but there're some problems with that.

But from time to time there has been some kind of solution using the "margin"-style-property. The problem: Sometimes it worked - but sometimes it didn't - here it is how you have to do it:

margin:0 auto

With this combination you tell the page "take care of the distance of the content on the left and the right side, so that they match each other.".

Explanation: The first value combines the properties margin-top and -bottom, while the second value combines the -left and -right values.

To get that working there's only one very important thing you have to remember. If you use only this property, the browser will take ALL THE PLACE IT GETS - and that means that it will just fill the whole page with the content and say "ok - space filled - no margin needed". To prevent this you have to set a specific width for the content of the page:

width: Xpx (X = numeric value for the content width)

If you use both style-properties in the tag of the main-content element, it will center automatically (no matter how wide the window is).

 

AutoMargin

 

Hint: If you're working with the <center>-tag - that also works great - you only have to align the content manually again (e.g. if you don't want the text to be centered, you have to say "text-align:left".

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


CryptographicException

clock January 21, 2008 18:34 by author Divi

Because I hit that error today for the second time (the first time appeared some weeks ago), I thought I just should write it down to not forget it again:

If you get the error messages "Bad Key" or "Invalid handle" in relation to any kind of "System.Security.Cryptography.CryptographicException", you should at first check the write/read-permission of the private-key-file of the certificate - and in the second step, if it contains all required values for our intention (Because you can't do everything with every certificate).

 

My problem: I tried to use an X.509 certificate to sign a Saml-token. Foolishly there were errors on several places, which a catch-block (in combination with a not working logger) hid, so that I needed a lot of time to search for the reason.

Both errors appeared while serializing the token.

 

Two problems and their solution:

Problem 1 - "Invalid handle": This error appeared, if the script couldn't access the private-key file of the certificate. The user "NETWORK SERVICE" needs at least read-permission for this file.

How can I find the private-key file? There's a nice tool collection, created by Microsoft, called the WSE "Web Service Enhancements"... the version, which is, I guess, the current one, is 3.0 - even if most of the results show 2.0, if you search for them with Google.

This collection contains a tool named "WSE X.509 Certificate Tool", with which you can simply select the right values in the two dropdown lists and open a filtered list of all found certificates by hitting the button. As soon as you open a certificate, you can see all information about it. This is the view of one of my test-certificates, which I created myself.

image

At the bottom of the window, you can find a button labeled "View Private Key File Properties". If you click that button, it displays the normal Windows-file dialog for the specified private-key file. In the tab "Security" you can now set the permissions for that file (in our case "NETWORK SERVICE"). As soon as the script is able to read the file, the "invalid handle" message disappears. 

 

Problem 2 - "Bad key": Who is able to read, has an advantage (german saying):

image

As soon as the one input field (Image 1) is replaced with three single input fields (Image 2), the description text on the right changes. It sais: "If the extension is not present, three values will be shown[...]". If I would have read that the first time I tried it, I would have saved much time, because the certificate I bough simply hasn't had the so callend "Subject Key Identifier", which is required for signing the token. As soon as the certificate contains the SKI, you won't get the error message anymore.

 

You can find the WSE tools on the Microsoft-download-page.

 

One last hint I got for you: If you want to check your software against certificates, you can create your own certificates, containing all combinations of rights. There's a nice tool from EldoS which is called "Crypto4™ PKI". It's commercial, but a 30-day trial version can also create nice certificates (for a specific time) ;-).

Currently rated 3.5 by 2 people

  • Currently 3.5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Kane and Lynch installer

clock January 20, 2008 15:00 by author Divi

After I've heard of "Kane and Lynch" (and just wanted some dark humor), I thought: "Hey - you could try the demo, which is laying around on your desktop for the last days." ... I really had to smile a little bit, as the installer looked as follows:

 

KaneAndLynchInstaller

 

Obviously there was missing a localisation file I thought and tried to click through the well-known mechanics. Unfortunately this try also failed, after I selected the path to install, because there appears an error message, which closes the wizard. Unfortunately I couldn't read anything so I was not able to install that game.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Outlook-Odyssey

clock January 19, 2008 17:11 by author Divi

As I already told you some days ago, I've bought the Office package. Full of anticipation to not get my mails anymore through the web interface but to just open my Outlook, I opened it and selected "Exchange" as mail server type. Obviously the biggest fault I could do :-D 

After I entered all required information for connecting to our Exchange server, my Outlook told me that they couldn't be verified ... Pity ;-) ... but the best joke came after that: Our admin had a good advice for me: First create another account and then set up the Exchange account manually in the configuration menu ... said - tried - failed.

The problem: Outlook offered the following options after reopening it:

1.) Enter valid account information for the Exchange (see above: that didn't work)

2.) Cancel

So I clicked "Cancel" to enter an alternative mailing server as primary account ... but ... hmm ... obviously the "Cancel" button forced Outlook not to go back one step to choose another server but to close ... Hard luck. Outlook wanted me to enter valid data for an Exchange accoutn and NOTHING ELSE!

 

So I thought: There must be any way out and started searching my registry for the name of the Exchange server. I found it on two places. One of them was the browser history (from the web interface) - the other one was at:

HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\<username>\13dbb0c8aa05101a9bb000aa002fc45a

First first try was, who'd have guessed, to clear that value... didn't work. So I simply deleted the whole key ... FAULT :-D!

After I started Outlook again, I got the following miraculous message:

MessagingServiceError

(You don't have the current version of the Microsoft Exchange-Message service. Please Create an profile first.)

Hmm ... ok - attempt failed - it was late - I haven't had a backup ... so: repair Outlook ... didn't work - deinstall Outlook and install it again - also didn't work ...

Slowly I got a little bit frustrated... Last try: Got the "work"-laptop and searched the key on it (To go the save way I deleted the whole <username>-key and replaced it with the information from the laptop) ... And when I just were destroying my new system, I also copied the whole profile-directory from the Vista directory:

DRIVE:\USER\<username>\AppData\Local\Microsoft\Outlook

En voila - my Outlook started the first time - the Exchange was already configured and all of my mails were already available (only the mails from the shared folders were missing) - and now I can finally write my mails at home :-D. 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Adding MessageInspectors

clock January 17, 2008 01:46 by author Divi

After some time ago noone could explain to me at tutorials.de how to log incoming and outgoing messages in WCF, I thought I should tell share my knowledge about that with you:

WCF offers a configuration for MessageLogging by default. These are the so called "Diagnostics" and absolutely sufficient if you're really just trying to log something. The related article about that you can find at the MSDN.

Unfortunately the logging can't be configured as detailed as I needed it at that time. My task was to store the sent message related to an object, to check wheter the preprocessing wrapper does its job.

After some searching I found the way of the "Extensions". And that works as follows:

You can set the endpoint in the configuration and attach an Endpoint-Behavior::

<endpoint address="ADDRESS" binding="basicHttpBinding" behaviorConfiguration="AttachClientInspector" contract="CONTRACT" />

Therefore a "Behavior" named "AttachClientInspector" needs to be created (Of course you can chose the name yourself). This one would look somewhat look like this:

<endpointBehaviors>
  <behavior name="AttachClientInspector">
    <ClientInspector />
  </behavior>
</endpointBehaviors>

If you're using Visual Studio 2005, just don't wonder why the "ClientInspector"-Tag is beeing marked with the description "...invalid child element". That's just because the VS2005 doesn't recognize the Extension itself. And that's the next step you have to do. The config section "System.ServiceModel" allows subsections named "Bindings", "Behaviors" and "Extensions". Here you can add your "BehaviorExtension":

<behaviorExtensions>
  <add name="ClientInspector " type="CLASSNAME, ASSEMBLYNAME, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</behaviorExtensions>

Of course the CLASSNAME has to point on a specific class, which is qualified for inspecting the message. To make sure that the class is accepted for this, you have to derive it from "System.ServiceModel.Configuration.BehaviorExtensionElement" AND implement "System.ServiceModel.Description.IEndpointBehavior". You have to derive from BehaviorExtensionElement, to use the class as an extension for the behavior. It requires the allocation of BehaviorType, where you can just return the current class via typeof and the method CreateBehavior, where you just have to return an instance of the current class.

public override Type BehaviorType
{
    get { return typeof(CLASSNAME); }
}

protected override object CreateBehavior()
{
    return new CLASSNAME();
}

On the other hand IEndpointBehavior provides the methods which are called, when the extension is executed at runtime. The interesting method for us should be: "ApplyClientBehavior". This method has a parameter "clientRuntime" of the same-named type. Here you can now attach the inspector as follows:

clientRuntime.MessageInspectors.Add(new CUSTOMINSPECTOR());

So... that's the key thing, to call our inspector as soon as the Endpoint is beeing used. Now there's only missing the implementation of the inspector itself. Therefore you have to create a class named CUSTOMINSPECTOR (the uppercase words are just placeholders to demonstrate the relations) and derive it from the type "System.ServiceModel.Dispatcher.IClientMessageInspector". This interface adds two methods. AfterReceiveReply and BeforeSendRequest. The second one awaits a return value of the type "object"... simply write "return null;" into this method and everything works fine.

If you now hit the compile button, everything should build without any problems. Now we have to add the implementation of the inspector. Therefore both methods have parameters of the type "System.ServiceModel.Channels.Message". In these parameters there's the real message contained.

If you're now trying to use that object, I guess it won't last a long time until you're getting stressed up, because the message-object is getting invalid, as soon as you read any information out of it. Cool, isn't it? ;-)

But you can solve that problem also very easily, because the message-objects contain a method called "CreateBufferedCopy". By calling that method you can create a "buffered copy" of the current message-object:

MessageBuffer bufferedMessage = request.CreateBufferedCopy(request.ToString().Length);

(Here's the message-object "request". In the "AfterReceiveReply" the object is called "reply".)

 

You can modify the "buffered copy" as often as you want and create a message object again after your analysis has finished:

 

request = bufferedMessage.CreateMessage();

(And as already told - again: The parameter of the reply-method is "reply". The object which is filled here, has to be the same as passed to the current method.)

 

All you have to know about it is - you've got several ways to analyze the content of the message:

1.) You can create a XPathNavigator with the method "CreateNavigator" out of the "bufferedMessage", with which you can analyze the xml itself. Over that you can access the content at any part of the XPathNavigator via its property "InnerXML". This one contains the content of the current node as a plaintext-string.

2.) You can also, as already said before, use ToString on the request object, which will return the content of the message (The envelope).

I wish a lot of fun with that and hope I could help you!

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Strange problems with the BlogEngine

clock January 12, 2008 00:53 by author Divi

In any way there're some strange problems with the BlogEngine at the moment ... I already got used to edit them again, as soon as I published them from the live-writer, to remove the "tags:" writing,  but there seems to be also a problem with the IDs, because from time to time the entries seem to be duplicated... Or - much worse: I just got home and the newest entry was gone.

Fortunately the Live-Writer had cached a copy of the entry, so it saved me the time for writing it again.

I'll keep track of that ...

[UPDATE 20.01.2008] It simply seems to be the LiveWriter, because everytime I post anything - and even if i'm instantly changing the page after the post, there're two entries created. I've posted an issue about that on Codeplex.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5