Archive for March, 2009

ASP.Net, XML, XSL-Transform

Monday, March 23rd, 2009

Here is a quick way to use ASP.Net to show some XML documents. One will find information such as Reponse.Write and stuff like that. Those information are for older version of ASP.Net when the xmlDocument was not implemented yet. So here is what one need:

In the aspx page, use the xmlDocument control:

<asp:Xml ID=”xmlDoc” runat=”server”></asp:Xml>

In the code page, use the following code in the page_load section:

if (File.Exists(Server.MapPath(e.Filename))){

xmlDoc.DocumentSource = Server.MapPath(e.Filename);
xmlDoc.TransformSource = Server.MapPath(“SC-SD-Transform.xsl”);
}

And it should be working fine now. You can also use events and such if you would rather not put it in the page_load section.

Shaman King

Sunday, March 22nd, 2009

The manga Shaman King was stopped in April 2008. However it restarted in march 2009!

If you don’t know about Shaman King, it is the story of people who can see spirits and interact with them. Every 500 years a fight occurs among all the Shamans to decide on their King. The king being the shaman that can interact with the great spirit, the one to which every soul on earth goes back to when their body dies.

If you want to read it online you can always go to: http://www.onemanga.com/Shaman_King/

Have fun!

ASP.NET & GridViews

Sunday, March 22nd, 2009

New POC i need to do at work again. Again using ASP.NET, C# because I can’t get the web admin to actually install the PHP extensions I would like to use (such as the ones for PDO).

Gridviews have to be use, so I get to coding them and coding the associated SQL Procedures. And then I got the usual errors when trying to update an element in one of my gridviews. The error is because the SelectParameters names and the UpdateParameters names did not match.

GridView Select & Update parameters needs to have the same names! (Well at least that solved the problem)

PHP PDO & Apache mod_rewrite configuration…

Friday, March 13th, 2009

This is just a small post since it only concerns a few stupid thing I did.

For a while I had been trying to get PDO (it is an extension that provides some nice functionalites to connect to databases) to work with mysql. In the php documentation they inform that you need the php_pdo_mysql.dll library to be available and loaded. I went in the library folder and found a php_mysql.dll file… Thinking that maybe since the time the documentation had been written, the file had been renamed and i vainly tried to get PDO working… lost like an hour or so… Well the thing is you really have 2 mysql files, one that is used by PDO and one that is used by the standard mysql commands!

As for the apache story, to enable the pretty prints for the urls on this blog I had to configure mod_rewrite. Not being an expert or anything a while back I had setup some virtual hosts and some directories. So to allow mod_rewrite, i go in my virtual host and modify it accordingly… forgetting that I had a directory section in the file that was superseeding the directives I was giving in the virtual host directory section… So when you try to install mod_rewrite on Apache and you are running virtual hosts, don’t forget to also check your directory directives!

And since I tend to forget this kind of things since I am not an everyday user it is blogged!

Subversion Hooks on Windows

Wednesday, March 11th, 2009

Context

A few weeks back i decided to make a web site to manage RPG games for people who cannot meet IRL at the request of some friends.

At first, since I was the only one doing any work on the site I did not really care about versionning the code. However came a time where I ended up asking a friend who can do graphics for help in doing the design and layout of the page. After exluding the HTML code from the PHP code in pretty much everywhere came the problem with 2 people working on the same files without versionning… After 2 or 3 incidents I just decided to use my svn server to version the files for the web site.

However, when you version your code it is not automatically published and you have to use post-commit hooks. And because you do not want your website to hold the svn administration folders you cannot make the website on the web server a checkout folder. Thus you need to rely on svn export.

Configuration

The server is setup with SVN loaded into Apache and both SVN server and Apache server running as services under the account ‘local system’ on a Windows machine. Apache was running with the ‘Local System’ account.

Problem

Thus i started implementing my post commit hook to export the website after each commit. And it did not work.

Resolution

Solving this issue took me quite some time from getting help on IRC or from Google. It also happened because I am not well versed in the technology I use here. Here is the list of thing I tried:

  • Providing a username and password to the svn export command. Unsuccessful (still do not know why).
  • Making the repository readable for everyone. Unsuccessful (I guess it is still linked to point 1).
  • Launching Apache manually. Successful… but not really efficient (due to the use I do of the server (lots of tests)).

Conclusion

To finally get this to work I did the following:

  • Create a user for Apache.
  • Launch a command prompt running as Apache
  • Run the svn export command, svn asked me for a user / password and I provided svn with that information.

And that seems to have done it.

And for information here is the command i used in the post commit hook file (post-commit.bat):

svn export –force reporitoryURL websiteFolderPATH

I however still have unresolved issues:

  • How the heck do I provide a username / password to svn through a command prompt ? (Error: ~ file path not found)
  • Why allowing read access to the repository did not solve the problem ? (Is the local system account unable to access the repository url?) (Do I need to provide the –non-interactive switch?)

Once I have a bit of time I’ll try one of the few things that need to be tried and update / comment this post.

Another experiment after that

Because I also have a subversion repository on my laptop to version the file I work on (I hate having the same files with a version extension, it is just cluttering the folders) and I wanted to backup my versionned files automatically to a network share, once again I had to implement post-commit hooks.

However this time, SVN runs standalone without being integrated into Apache. And this time the export had to be done on a network share mapped on my computer. Because subversion removes all the pathing information before running hooks you have to provide the full network path or remap the drive to your computer before running the export and you also need to have write access for the SVN account to that share (or run the command as another user (no idea how to do that yet))

In the hope that it will help someone, someday.

Chryzo