Showing posts with label development. Show all posts
Showing posts with label development. Show all posts

Wednesday, May 7, 2014

Apache CORS Headers

It is possible to add multiple domains by using the following:
Header set Access-Control-Allow-Origin "http://domain1.com"
Header add Access-Control-Allow-Origin "http://domain2.net"
Header add Access-Control-Allow-Origin "http://domain3.org"
However, it doesn't work entirely as expected and it also exposes all your API clients to anyone interested. Not a big deal, but why expose more info than necessary?

So, to only have valid requests return one single domain (the accepted Origin) we can configure Apache to dynamically check and return only one permitted domain:
SetEnvIf Origin "(http|https)://(domain1.com|domain2.net|domain3.org)$" RequestOrigin=$0
Header always set Access-Control-Allow-Origin %{RequestOrigin}e env=RequestOrigin
This will return http://domain2.net if the request has an Origin of http://domain2.net. If the request has an origin that isn't matched by the regular expression in the SetEnvIf command, then it will not return any Access-Control-Allow-Origin header at all!

Some other headers I always include:
Header set Access-Control-Allow-Methods 'GET,PUT,POST,DELETE,OPTIONS'
Header set Access-Control-Allow-Credentials true

Monday, December 23, 2013

Regular Expressions

To match a floating point value in a substring I currently use the following regular expression:

(\d+(?:\.\d+)?(?:[eE][-+]?[0-9]+)?)

This matches:

  • 123
  • 123.4
  • 123.4E3
  • 123.4e-4
  • etc...


Does anyone have a better expression that matches example strings?
Please post in the comments below, thanks.

Thursday, March 21, 2013

AO Item Assistant v1.1.5

A new version of Item Assistant has just been released which should fix the major issues introduced with the "big AO server merge". It also cleans up and removes support for multiple dimensions and the player-shop monitor since these features are obsolete.

For those that play on both "live" and "test live" I recommend having two separate installs of AOIA, one for each dimension. Even with the old multi-dimensional support, it was never meant to support "test live" as one of the dimensions. (Due to, amongst other things, the difference in the AO Item database.)

I also want to give a big "THANK YOU!" to the AO community for all the feedback, testing and suggestions that just keep on coming in.

(For those that have been testing intermittent versions, this is essentially the same as v1.1.4.24.)


AOIA Homepage
v1.1.5 download

Saturday, December 15, 2012

Item Assistant 1.1.4

I have finally gotten around to updating AO Item Assistant to support v18.5 of the AO client properly. A bit late, I know, sorry about that.


Changelog:
  • Fixed issue with connecting to the AO client after the 18.5 patch.
  • Fixed parsing of the AO DB to handle the updates of the 18.5 patch.
Happy Holidays and an educational New Year!

Downloads here!

Wednesday, September 26, 2012

SublimeText2 - A small tip

It can be difficult to find the correct internal name of a command when you want to add a keyboard shortcut to it in SublimeText2. Wouldn't it be neat if you could show all the commands you trigger in a window somewhere? Well, it turns out it is really simple:
  • Open the console
  • Type the command
    • sublime.log_commands(True)
  • Go do stuff in the editor or menus and see commands roll by. 
When you have the command name it is quite easy to add that to your personalized key-bindings from the Preferences menu.

i.e. my current personalizations:
[
   { "keys": ["ctrl+keypad_divide"], "command": "toggle_comment", "args": { "block": false } },
   { "keys": ["ctrl+shift+7"], "command": "toggle_comment", "args": { "block": false } },
   { "keys": ["ctrl+d"], "command": "reindent" },
   { "keys": ["shift+ctrl+s"], "command": "save_all" },
   { "keys": ["ctrl+d"], "command": "find_under_expand" }
]


Saturday, September 10, 2011

Item Assistant v1.0

I would like to thank everyone for all the feedback, encouragement and gentle nudges I have received over the last 18 months or so. It has been a long while since I released an update to Item Assistant, and I apologize for that, but now the wait is over.

v1.0 is here!

Major changes this release include the new Summary View and an installer to supplement the regular zip archive distribution.

The Summary View shows credits and levels of your characters, while the installer takes care of some of the most common problems people have installing the application.

In addition to new features, a lot of work have gone into trying to make the application more robust to handle the different usage scenarios.

From the change log:
  • Fixed bug 2947010. Generating the script with items for ingame display now use the correct linebreak tag.
  • Fixed bug 2802231 in the find panel and in the PB filter panel. Toon list is now reloaded as it is opened. 
  • The window location is now recorded and restored to/from the conf file. 
  • Opening an item using Xyphos.com will now also supply the QL of the item so the stats are shown correctly. 
  • Improved ripping of items database so it supports newer version of AO.
  • New Summary View shows levels and amount of credits for all registered toons. 
  • Created a basic installer.

Enjoy!

Tuesday, May 10, 2011

.Net Clipboard and the OutOfMemoryException.

I recently had a weird bug that manifested as a first-chance OutOfMemoryException inside Windows.Forms when using the clipboard. At first it doesn't appear to do any harm, except the clipboard did not return the expected data. Unfortunately it had a slight side effect: Any later call using OLE/COM would crash and burn. Bummer!

Some hours debugging later, and it was apparent that the crash was happening consistently by just letting the application idle after putting something on the clipboard. Apparently there was something wrong in the idle mechanism that updates the paste-command button... but what?

So I went surfing teh intarweb! And found this MSDN page from Microsoft explaining how to use the clipboard from a .Net application. Then I noticed this:
To access data from the Clipboard by using versions earlier than .NET Framework 2.0, use the GetDataObject method and call the methods of the returned IDataObject. To determine whether a particular format is available in the returned object, for example, call theGetDataPresent method.
That looked familiar, and indeed the code was using the old way of accessing the clipboard, by first using GetDataObject() and then using GetData() on the result.
Now the page didn't say anything about this way of doing things being deprecated, but I still got that nagging sensation that this was an important clue.

So I set down and create two simple test applications that did the same thing, only each using a different variation of the clipboard API. The applications were simple: put something on the clipboard, and repeatedly try and read it back in a loop.

The result was that using the new (and preferred?) way of clipboard access had no problems. I ran it through a loop of million clipboard accesses without a hiccup. On the other hand, the application using the old variation of the API had a very familiar problem. After some iterations it started throwing the familiar first-chance OutOfMemoryException. What more, the clipboard data stopped being available for the test application. Very similar indeed to the problem in the main application!

A few repeat runs, trying stuff like forced garbage collection (which did not help at all, except the performance went down the drain) a clear pattern emerged: My test application would stop working after 65525 invocations of GetData(). The 65526th time and onward it would just silently fail with the OutOfMemoryException in the debugger output.

65526 is pretty darn close to the magical 0xFFFF 16 bit limit, so allowing for some initialization and general overhead, it seems clear that the old variation of the clipboard API (pre v2.0) is leaking a handler, global resource or otherwise doesn't free up some counter internally.

If you are lucky enough to be able to use the newer version of the .Net API I suggest you do so, and remove any code using the old API, since its quite simply broken!

Monday, August 30, 2010

SVN Trouble

After upgrading to the latest TortoiseSVN I started getting trouble committing changes back to the server with the following error:
'\' is not a working copy.

Downloading and testing the latest SVN command-line client yielded much the same results, only with some different messages.

After much googling I got a sneaky suspicion that there was an issue with my working-copy actually being on the root of a drive; in my case U:.

Checking everything out again, but this time at U:\wc worked perfectly.

Versions used:
  • TortoiseSVN 1.6.10, Build 19898 - 64 Bit
  • Subversion 1.6.12

To sum it up: Don't upgrade if you have your working copy at the root of a drive and it is currently working!

Tuesday, January 26, 2010

Item Assistant v0.9.7

Item Assistant version 0.9.7 has just been released to the public. This is a pure bugfix release that hopefully fixes some compatibility problems on Windows Vista and Windows 7.

Also included is a bugfix from Darkbane relating to the recording of org contracts.

From the changelog:

  • Fixed org city output for CharacterParser integration. Does not dump contract message on zone since it doesn't contain anything useful anyway.
  • Includes UAC manifest in EXE file. Hopefully this should make some compatibility problems with Vista and 7 go away.

Saturday, January 16, 2010

AO Item Assistant v0.9.6

I have just released v0.9.6 of AO Item Assistant. This release is mainly a bugfix release and fixes some critical stability and compatibility issues.

Also included are patches from Darkbane to make the application output files that can be used by his tools.

Output of the files can be controlled by the Record Stats button on the toolbar.

Here is the official changelog:

  • Changed link to AO Mainframe.
  • Updated SQLite to version 3.6.22 to resolve some issues.
  • Fixed database parser bugs. The symptom was that the application was unable to track certain items.
  • Application now outputs files that can be opened with the CharacterParser application.

Friday, July 3, 2009

The Problem Child

Getting the latest release of Item Assistant out the door has been problematic to say the least. The first published binary labeled v0.9.4 proved to be flawed in more ways than one.

After FunCom released the 18.1 patch to Anarchy Online, I had to completely re-implement the database extraction code. Before it was using an existing DLL by Faircom called CTreeStd.dll. Unfortunately the age of that DLL was showing and FunCom decided (wisely IMHO) it was time to move to something that supported a database size larger than 2 GB.

Re-implementing it wasn't really that hard, as I originally based it on mapped_file_source from the boost iostreams library, to map each of the data-files into memory at a turn, and extracting all relevant information. This turned out to be a shortlived solution, as bug reports started flooding in from Windows XP users. Apparently there are limitations in the older Windows kernel that prevent me from mapping a 1 GB file into memory at one go. So I went back to the drawing board, and implemented it all again, this time using the more classic approach of the std::ifstream. Since the "random" access I cause isn't really that random (I read all items in the sequence they are stored in the file) there was no noticable performance difference between the two solutions on my PC.

So just to sum up, here is the list of what has changed between v0.9.3 and the current v0.9.5:

  • Added support for the new database in v18.1.
  • The application is no longer using the registry to store its settings. Settings are stored in the ItemAssistant.conf file.
  • Enhanced item listing so the container column shows if an item is equipped, and at which tab-panel it is.
  • Added baloon warning popup when application is started after the AO client was started since this may lead to the database being out of sync.
  • Improved statusbar for the Inventory view.
  • The application will now remember which dimension you chose last time you changed dimension in either the find panel or the pattern matcher.
  • Added "Copy Item Name(s)" to the item context menu.
  • Bug Fix: Fixed weird encoding of ampersands in backpack names.
  • Bug Fix: Exporting all items from a toon should not put multiple quotes around the backpack names any more.
  • Bug Fix: Fixed buffer overflow with long backpack names.

Monday, May 11, 2009

TeamCity, Ant & DITA

Over the last few days I have been trying to get a CI server (aka build server) up and running. After trying out both CruiseControl and CruiseControl.NET I landed on TeamCity since it is a bit simpler with a decent web GUI as well as being somewhat familiar from my work.

You can download TeamCity and try it out for yourself since they offer a free edition that supports up to 20 build configurations and 3 build agents.

One of the tasks I wished to accomplish in by CI server was to build the online help files (HTML) as well as the user manual (PDF). Having all the source material in DITA formatted XML files makes that pretty easy from the command line using the DITA Open Toolkit full easy install distribution. Getting it to run automatically from TeamCity proved to cost me some gray hairs though.

So as a note-to-self here is a short checklist of what to do after TeamCity has been installed:
  1. Download DITA and unzip it. (Ex in: C:\DITA-OT1.4.3)
  2. Create a new build configuration for you project, and set "Ant" as the "Build runner".
  3. "Ant Home" should be the ant folder in your DITA installation. (Ex: c:\DITA-OT1.4.3\tools\ant\)
  4. In "Additional Ant Command Line Options" input the classpath and any options for Ant or the DITA toolchain it spawns.
  5. Add DITA_DIR environment variable to the build configuration and set it to the folder you unzipped DITA to in step 1.
  6. Create a build.xml file for your targets and point TeamCity at it.
Note!
Setting the CLASSPATH environment variable had NO effect, neither had adding -classpath to the JVM command line options. Only adding it as a -cp option to the Ant command line did the trick. I did not find any mention of this in either DITA documentation or TeamCity documentation.
It might be obvious for someone more familiar with Ant, but for me it was a big hurdle I only discovered while (desperately) searching trought the Ant plugin configuration on my TeamCity server.

Saturday, April 25, 2009

Item Assistant Speedup

Ripping the AODB in Item Assistant have been greatly sped up in a recent subversion commit (#310) bringing the time it takes to rip the AODB down from 2:42 to about 1:25 (on my setup). Users with SSD drives are probably not getting a big boost, but you are all spoiled anyway :P

The code change simply tell SQLite to use a memory based journal while ripping, instead of the default file based journal by running the following command on the database:

PRAGMA journal_mode=MEMORY

The program is now probably using more memory while ripping, but since most people can spare 50-100 MB I don't think it will be a problem.

Tuesday, March 31, 2009

New Anarchy Online Item Database

A new item database for Anarchy Online has made it to the public. Still being developed, but is is already working quite nicely.

URL: http://www.xyphos.com

It is still missing things like item interpolation, but I'm guessing its not too far off into the future before its in there as well. Until then I will have to settle for Auno's site for that piece of functionality.

AO Item Assistant has been updated with support for the new site. I haven't removed the references to AOMainframe yet, but that project looks too dead to be resurrected. :(

Wednesday, March 4, 2009

Certified ScrumMaster

I have just completed a 2 day training to become a Certified Scrum Master. I attended Mike Cohn's course in Oslo and it was a very interesting experience. Although we have been using Scrum in our organization for some time now, it was very educational! Mike really knows what he is talking about!

Mike Cohn's blog.

The course I attended was organized by programutvikling.no.

Update: And now I even have a nice certificate on my office wall. :)

Monday, February 23, 2009

Item Assistant - Startup Issue

Some people are experiencing problems starting version 0.9.2 (and possibly earlier version of the 0.9 branch). It shows up as a Windows error message telling you the application failed to start because the configuration is wrong. Well.. what configuration? AOIA doesn't have a configuration!!

So after a bit of googling and reading up on side-by-side assemblies, it turns out the solution is pretty simple. To run it you need the Visual Studio 9.0 CRT DLLs installed on your system. If you don't have Visual Studio you can just grab the redist package from Microsoft and install that.

Future snapshots of the application will probably have the missing DLLs bundled in the ZIP file as a "private" assembly, like in this CodeProject article about Visual Studio 2005.

Friday, February 20, 2009

Item Assistant v0.9.2

I just uploaded a new snapshot of Item Assistant to the sourceforge page. This is the official v0.9.2 release.

You can see the forum for the official release notes.

This version has been tested with the recently released patch of Anarchy Online (v18.0.0) also know as "The Legacy of the Xan" booster pack.

For downloading go here.

Thursday, January 29, 2009

Cool Open Source Site

I stumbled over a cool site for open-source software development today. It has the wierd url ohloh.net and appears to be a social networking site based on open-source development.

Anyway, somebody had already registered my pet project, Item Assistant, and I diligently grabbed it and started to fill in details like SVN repository URLs etc. It then started generating some useful and interesting statistics about the project.

Anyway, its cool and you can check it out right here!

Item Assistant Inventory View Revamped!

Over the last weeks I have been refactoring the inventory view of Anarchy Online Item Assistant (AOIA) to a more traditional MVC pattern. I took the inspiration from the work I did with the identify view and made it a bit more general so it can be used to display an item-list of any search I create.

The main benefit, besides cleaner code, is that the inventory view now has a column that tells you where the backpack that has the item is located as well.

Sunday, January 11, 2009

Item Assistant Identify View

More updates to AOIA.

I have added a new view that lets you quickly locate items in your inventory that are convertable into a different item type.

In the list on the left you choose the target item, while on the right it will determine the un-converted items you have that match your selection and where they are located.



The list of items that are convertable and what they convert into, is manually entered by the developers into the database. There is currently no way for me to extract all tradeskill processes (I don't even know if they exist in the AO database at all or only exists serverside? Anyone?)