Archive for the ‘Development’ Category

EasyMYP version 2.6 - Release

Wednesday, August 19th, 2009

EasyMYP version 2.6 is released!

It adds / improves the following list of features:

  • Dirties up the code a bit more due to it being beta and having new functionalities
  • A tree view is now available to peak into the archives
  • You can extract anything you want from the tree view by using a simple right click
  • Drag & Drop files in the application to load them, no need to go through the menu anymore!
  • Drag & Drop items from the archive tree to the file system tree!
  • Huge speed increase in lots of places
  • Multi threaded the extraction of files in order to separate read and write operations
  • Last but not least: Persistent options!

Still learning loads of stuff when working on functionalities for this application, so keep them coming!
The application can be found at: EasyMYP on GoogleCode

EasyMYP version 2.6

Tuesday, July 7th, 2009

EasyMYP version 2.6 Beta is up and about!

It adds / improves the following list of features:

  • Dirties up the code a bit more due to it being beta and having new functionalities
  • A tree view is now available to peak into the archives
  • You can extract anything you want from the tree view by using a simple right click
  • Huge speed increase in lots of places
  • Multi threaded the extraction of files in order to separate read and write operations
  • Last but not least: Persistent options!

Still learning loads of stuff when working on functionalities for this application, so keep them coming!
The application can be found at: EasyMYP on GoogleCode

LUA: Classes and Instanciations

Monday, April 27th, 2009

If, like me, you tend to be a bottom up learner you usually never read the manuals except when you need to. And this is, for once, one of these times. Only reading the class parts of the manuals/wikis (IE: http://lua-users.org/wiki/SimpleLuaClasses and http://www.lua.org/pil/16.1.html ) is actually not really enough to be able to make classes always work as you want them to.
If you also tend to adapt examples to your requirements (no need to reinvent the wheel), here it might actually go wrong. In the examples given in the two previous link, the writers tended to forget about the differences between metatables and tables completely confounding me :).
In the example below:

function Account:new (o)
o = o or {} — create object if user does not provide one
setmetatable(o, self)
self.__index = self
return o
end

self equals Account and the metatable of Account is also Account which creates an infinite loop which needs to be treated if you try to save / dump the instanced variables.
To solve this, use instead the following syntax:

function Account:new (o)
o = o or {} — create object if user does not provide one
setmetatable(o, {__index = self})
return o
end

When you retrieve the saved variables don’t forget to set the metatables to what they should be too :)

And if I am totally wrong in what I just posted, I ll be glad to be corrected. I really do have a hard time with the Lua OOP model, guess I still have lots to read / learn.

Wordpress Xslt Processor plugin - follow up

Saturday, April 18th, 2009

So, a user of the plugin asked me on how to make the plugin also have parameters for the xsl file. And I ended up coding it because it seemed simpler that way.

This this post servers as much as a test bed as a presentation of the different kind of options one can use:

So lets start with the most basic way to use this plugin:

Use:

[XmlProcessor wp-content/plugins/CPT_XslProcessor/example]

Result

Author: Chryzo, Hakre E-mail: You may not view this section
Parameter test: You have to override this parameter

or:

[XmlProcessor xml=”wp-content/plugins/CPT_XslProcessor/example.xml” xslt=”wp-content/plugins/CPT_XslProcessor/example.xsl”]

Result:

Author: Chryzo, Hakre E-mail: You may not view this section
Parameter test: You have to override this parameter

Now, lets say you want to add options to the xsl file:

Use:

[XmlProcessor wp-content/plugins/CPT_XslProcessor/example params=”default_param=this is the replaced default parameter”]

Result:

Author: Chryzo, Hakre E-mail: You may not view this section
Parameter test: this is the replaced default parameter

or:

[XmlProcessor xml=”xml_filepath” xslt=”xslt_filepath” params=”default_param=this is the replaced default parameter”]

Result:

Author: Chryzo, Hakre E-mail: You may not view this section
Parameter test: this is the replaced default parameter

And that should actually be working now :)

LUA and overloading

Tuesday, April 7th, 2009

I am coding some mod in LUA for some game and I hit a snag and it actually took me quite some time to solve it due to several functionalities not available through LUA to control some of the interface elements and thus transformed the snag into lots of small snags to get what I wanted to work.

But the last snag I hit, after clearing the others, was really annoying, in the API there was a function like: removeSmthg(ID) but also removeSmthg(NAME). And being unfamiliar with the language as always I forgot that LUA doesn’t handle type-based function overloading, so only one of the function actually worked… the one I was not using. Once I found that out, it ended up being quite easy to actually do what I wanted at the start.

And because it is blogged, I should remember it next time!

WordPress Xslt Processor plugin development

Sunday, April 5th, 2009

Need

If any of you actually read my about me page, you know that this blog ended up being more than foreseen. Thus I required to have more liberty in some of the things i wanted to do.

Typically you may have a resume in a pdf or document format. How do I include such a document inside the theme of WordPress ? How do I include content from a webservice / an xml document in WordPress?

To answer part of this need, I made a request on the wordpress forum to no avail and I ended up coding it. Fortunately the WordPress API is very well made though the documentation is a bit lacking in some places. In WordPress you can have:

First I tried using filters but due to the encoding and escaping done by wordpress my regular expressions would not work. I loaded my prefered IRC client and connected to the #wordpress channel on freenode. Lots of help and advice there and information too. Taking their advice into account I used Shortcode which actually remove all the requirements for parsing the code yourself. WordPress provides the Shortcode API for that.

What about the Plugin ?

The plugin that I am now using takes an XML and XSLT files, process it and output to the window. For an example of how to use it see my “resume” pages.

If you want to use this plugin, you can find the latest version on WordPress: XslProcessor

(At the time of this note, the code is not yet uploaded. Approval from WordPress has not yet been received)

Hope you find it as usefull as I do.

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.

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