Archive for the 'Knowledge Base' Category

November 29th, 2015
6:06 pm
Upgrade to WordPress 4.3.1

Posted under Wordpress

This was pretty straightforward, and involved the following:-

  1. Backup the site
  2. Upgraded all widgets/plugins to the latest versions, from within the plugins page in the WP admin.
  3. Perform the upgrade from within the WP admin dashboard
  4. The Folding Categories widget I was using is no longer maintained/compatible so it was removed.
  5. The existing standard archive widget was removed as it is static only and I wanted a collapsible one
  6. I installed the Collapsing Categories Widget – this was done directly by searching from the plugins page and installing automatically. No manual copying of files etc. was needed. The widget was excellent and works well with the existing customised salient theme
  7. I customised the widget as required – key points e.g. for the knowledge base widget were to tick “Expanding shows: Just Sub-categories”, to auto expand the Knowledge Base category, to exclude the Uncategorized and Library categories, and in advanced options to untick “Show top level categories”. The style was set to the default of “Kubrick”.
  8. In addition, I edited the collapsCatStyles.php file from the plugins page for the widget, and changed the rule for “li.collapsing.categories .sym” to use a font size of 1.0em for the arrow pointer as the default of 1.1em was rather too large.
  9. I installed the Collapsing Archives Widget – This is a companion widget very similar to the above Collapsing Archives Widget and with similar settings, also coded by Rob Felty. I used similar settings for this widget, and also edited collapsArchStyles.php, changing the rule for “li.collapsing.archives .sym” to also use a font size of 1.0em as again the default of 1.2em was too large and also different to the Collapsing Categories Widget.
  10. I had to re-enable the existing Flexi pages widget – it was not broken but for some reason the upgrade disabled it.
  11. Finally took a post backup of the site again.

I also performed exactly the same steps on the site for 2intandem.net which uses the same theme etc.

No Comments »

March 13th, 2014
12:20 pm
Enabling Wake On Lan to pass through a Draytek Vigor 2920n Firewall

Posted under Library

The information on this is firmware version dependent and not all correct.

However, This post appears to have the correct update for the telnet wol command which is needed to make it work.

The correct options for wol to enable wol from the wan are

wol fromWan any

wol fromWan off

wol fromWan on

In my case the correct one is the any option, wol fromWan any. My surmisal is that this is doing a similar thing to setting up a static ARP entry as I did on the Netscreen, as normally arp translation would require the target machine to be awake to reply to the arp request, which of course it is not.

Note that this post appears to have incorrect information in my case that did not work.

This post is mostly correct, but the above wol command was definitely needed as well or it would not work – I checked this by using wol fromWan off and it stopped working again. In my version, I defined a MAC binding of 10.0.0.253 to ff-ff-ff-ff-ff-ff, i.e. used a spare unused address near the top of the subnet.

In the post, he defined an open port, whereas I used a port redirection as initially I tried a different public port (2007), but changed back to port 7 when I discovered that the port number was not an issue. The key thing here in my case was to map the WAN address in use to the above IP address just bound, using the desired port, and making sure it is a UDP mapping or it will not work.

This finally allowed it to work via the WAN, but noting that initially Panther would not wake due to another reason but Meerkat did successfully, which misled me for a while!

No Comments »

October 21st, 2013
3:55 pm
Translating a string Enum value into an Enum given an Enum class object

Posted under Java

You can translate a string Enum into its corresponding Enum using the Enum in this way :-

 

//Assuming Fields is the target Enum
String fieldName = “myField”;
Fields field = Fields.valueOf(fieldName);

 

However this can also be done if you are given a class object of the Enum:-

 

//Assuming fieldClass is a class object for the Fields Enum
String fieldName = “myField”;
Fields field = Enum.valueOf(fieldClass, fieldName);

No Comments »

December 30th, 2012
6:39 pm
Imedia Embedded Linux – Backup using tar

Posted under Linux
Tags , ,

This article here discusses how to perform Linux backups and restores using tar ( I have also saved a pdf of the post in the Linux section of the repository).

I wanted to at least backup my system so that I had all the custom configuration and shell scripts backed up.

I was not looking to do a full restore – if I lost the system I would reinstall from CD and then probably pull from the backup piecemeal manually as required.

As an Imedia system is so small (mine is only 2GB), I backed up to a FAT32 flash drive and then archived the backup elsewhere. Imedia does a good job of handling USB drives, but will need FAT32 rather than NTFS.

tar appears to do a pretty good job of backups – symbolic links are handled correctly by default (it backs up the links rather than following to the files), and permissions etc. are backed up as per the above article.

The following example shows my backup script, generated with the help of the above article:-

#!/bin/bash

if [ -z $1 ]; then read -p "Enter Backup Name:" name;     else name=$1; fi
if [ -z $2 ]; then read -p "Enter output directory:" dir; else dir=$2; fi

file="${name}_`date +%Y-%m-%d_%H-%M-%S`"
if [[ $dir != */ ]]; then dir=$dir/; fi
file=$dir$file

echo Backup: $name started at: `date +"%d-%m-%Y %H:%M:%S"` > $file.log
echo Output File: $file.tar.gz >> $file.log
echo >> $file.log

tar -cvpzf $file.tar.gz --exclude=$file.* --exclude=/proc --exclude=/lost+found --exclude=/sys \
    --exclude=/mnt --exclude=/media --exclude=/dev --exclude=/var --exclude=/tmp / >> $file.log 2>&1

echo >> $file.log
echo Backup: $name completed at: `date +"%d-%m-%Y %H:%M:%S"` >> $file.log

No Comments »

May 15th, 2012
7:22 pm
Oracle XE 11g R2 installation issue on Windows 7 64 bit

Posted under Oracle
Tags , , ,

During installation, I received the following error message:-

“The installer is unable to instantiate the file …{…}\KEY_XE.REG”

The installation was mostly correct but I was unable to access the getting started/home page.

This post here details a workaround for the issue but this did not  work for me.

In the end, I recreated the Get_Started.url file under (in my case) E:\oraclexe\app\oracle\product\11.2.0\server.

This contained a parameter placeholder for the HTTP port, and I just edited the correct port in directly. Note that for some reason it was not possible to change the existing shortcut. I had to delete it and create a new one of the same name, which then worked fine.

Whilst doing this, I also changed the HTTP port that the web interface listens on. This is done by running a stored procedure, and is detailed in both this post and also this alternative post. Both posts detail the same method.

Note also for XE 11g R2 that the getting started page (which corresponds to the old 10g home page) no longer has the means to create schemas or to run sql queries. Schemas/users can be created via SQLplus, or via TOAD or SQLDeveloper.

Note that TOAD 8 is not compatible with 11g. The latest free TOAD now lasts for a year and is excellent with plenty of functionality, albeit with an occasional nag/advert for the paid version. The paid version is around $800 for a seat which is very high for a SQL development tool, even if it is a good one. Note that the free TOAD is available from Toad World here, but is not available from the main Quest Software site – this appears to be a marketing decision to keep the free version out of sight from people who may be persuaded to part with money for the paid one. I should not complain too much as they are after all providing an excellent free tool.

No Comments »

May 15th, 2012
6:58 pm
Automatically disabling Sleep during Acronis True Image Home Backups

Posted under Windows 7
Tags , , ,

Previously this had been an issue as the PC would sleep during the validation of a Backup, so I manually switched to an Always On power plan.

With the current PC build I was using, the PC would hang and not shut down cleanly if it was put into sleep and woken whilst an eSATA drive was attached to the 2-port STARTECH card I was using. Providing the PC did not sleep, all was fine.

I therefore looked for a means of automatically switching to always on for Backup runs. Rather than switch back to the normal power plan automatically after the backup, I elected to leave Always On set and switch back to normal on every startup. This way, I would be sure that if I still had the eSATA drive connected after a backup, the pc would not sleep.

This Acronis forum post which refers to this instructional pdf detail a workaround to the problem, which involves coding a batch file to switch power plans, and calling it as a pre/post custom command in Acronis in the backup settings.

In addition, as I wanted to set the plan back to normal at boot time, I used the technique from this StackOverflow post which worked correctly. Originally I had tried using a scheduled task triggered at boot time, but it refused to run and did not give a reason why.

My registry settings file, batch files, and vbs script are listed below for reference. Note that the GUIDS correspond to the particular power plans, and are unique for each one and different for each pc – see the above pdf for details of how to list the power plans with their corresponding GUIDs.

This fixed the problem, but I remain unimpressed that Acronis does not handle this automatically or have a setting for it in a backup definition. You can tell it to prevent sleep for scheduled backup runs, but not for manually initiated ones.

 

SetPowerPlanNormal.reg

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
"SetPowerPlanNormal"="wscript.exe \"C:\\System Management\\RunInvisibleBatchFile.vbs\" \"C:\\System Management\\SetPowerPlanNormal.bat\""

RunInvisibleBatchFile.vbs

CreateObject("Wscript.Shell").Run """" & WScript.Arguments(0) & """", 0, False

SetPowerPlanNormal.bat

:: Change Power Plan to Normal.
::
@ECHO OFF
POWERCFG -SETACTIVE ccaec46d-cbf8-42af-9e8f-ab66182942f7
::
@EXIT

SetPowerPlanAlwaysOn.bat

:: Change Power Plan to AlwaysOn.
::
@ECHO OFF
POWERCFG -SETACTIVE 499ab33e-0735-4605-8ccc-98211478164b
::
@EXIT

No Comments »

May 5th, 2012
1:30 pm
Sage Instant Accounts V11 install hangs on Windows 7 64bit

Posted under Sage Accounts
Tags , , , ,

Update 15/5/2012

Further to the issues below, whilst I could run Sage satisfactorily for the most part, some features still needed ODBC to be working, such as Invoice preview and VAT return printing.

After a couple of attempts I was able to setup ODBC after the event by running E:\Salient Soft\Accounts\Sage\Instant Accounts\ODBC32\Disk1\Setup.exe. This allowed ODBC setup/install even after Sage had been installed.

Sage was happy even though there was no mention of the ODBC driver or connection for Sage under Administrative Tools/Data Sources (ODBC). The real underlying issue was not discovered, but the problem was finally resolved.

I was then able to successfully print a VAT return and preview invoices, which previously had failed.

 

Original Post

This was a reinstall using a fresh windows install, but the same location for Sage on a data disk. The following issues were hit:-

  1. On install, it hung at the point where it said “Setup is configuring the ODBC”
  2. I tried installing from a shortcut to the CD, with administrator mode set and Windows XP compatibility of various flavours, but the same error persisted.
  3. I then tried removing the “ODBC files” option from the (custom) install. This changed the problem – the install now hung at the point where it said “configuring MIS files”.
  4. I then did another custom install removing everything that I did not need, including ODBC, MIS support, E-Banking, web/email templates etc.
  5. This time, the install finished successfully. Furthermore, Sage ran fine even though I had not told it to “configure the ODBC”.

Note that it is possible that the previous duff installs did configure ODBC and that the final install was dependant on the previous ones to work. This should be borne in mind if trying again. However, all the installed files for Sage were all there anyway as this was a reinstall – I was only doing it to install the windows/registry settings/shortcuts etc. that Sage needed.

I did not try a new install to a new directory as I did not need to – this may have worked, but I cannot say. If so, it may be possible to import or copy the old company data into a new install. A quick look at the menus and a quick google did not reveal any obvious way to do this, but a judicios copy may work.

Note also that this issue did not occur the first time I installed on Windows 7 64. This first time was also an install over an existing Sage installation copied from Windows XP.

No Comments »

March 29th, 2012
1:33 pm
CVS error on commit: “added independently by second party”

Posted under CVS
Tags , , , ,

I received this error whilst performing a commit via Eclipse:-

The server reported an error while performing the "cvs add" command. cvs server: xxx added independently by second party

The error related to some test database scripts in the project. I searched for solutions to this, and found some comments about tagging the files as merged, but this was not really any help.

In the end, I examined the files using TortoiseCVS, and noted that the offending files were not flagged as being under source control – they did not have any icon decoration on them.

In the end the following steps solved the problem:-

  1. I made sure I had copies of them elsewhere, and then deleted them from the (TortoiseCVS managed) directory under the eclipse project.
  2. I then did an Update with TortoiseCVS – this reloaded the latest versions from CVS, and this time they were correctly icon-decorated as managed.
  3. I then copied the new versions in to replace these. When I did this, the new versions were correctly decorated in red as updated versions but known to CVS/Tortoise.
  4. I then did a commit with Eclipse, and this now proceeded without error.
  5. Finally to be safe, I did a file compare to check that the correct latest versions were in place.

This solved the problem. It appeared that somehow I had lost the required CVS metadata such that the files did not appear to be CVS managed. Tortoise was very helpful here – if you see files with no icon decoration, this is immediately suspicious.

No Comments »

February 27th, 2012
9:32 am
Passing the “this” reference for a subclass from a self-referential generic superclass

Posted under Java
Tags , , ,

Update 7/12/22

Previously I have implemented a composite iterator for iterating a tree of tags from a search on a PropertyTree implementation. Note that in this case, the abstract base class for the composites was a TagTree, and the concrete subclasses were a TagList and a Tag. As a Tag did not need a list, the list of children was in the concrete TagList and not the TagTree. Therefore, the TagTree did not need to have generic references to self referential subtypes in the way the example below does – in fact it did not need to be generic at all. Therefore it did not suffer this problem. For further clarity see the example below from Angelika Langer here. In her code, the list is in the abstract superclass which is why it suffers the problem below and potentially needs the infamous getThis trick per below.

Original Post

Some generic classes are recursively self-referential, such as in the following abstract class statement for a tree node :-

public abstract class Node <N extends Node<N>>  {

}

In this situation it is sometimes necessary for example to pass a reference to this from the superclass to a specific subclass which expects an argument of type N :-

public void methodA(N node) {
//do something with the passed node
}

public void methodB(N node) {
node.methodA(this); // error – incompatible types
}

In the above fragment, the error is because this in the superclass has a type of Node<N> which does not match N.

Another related use case is where a fluent API returns a ‘this’ reference from each of the fluent methods. If for example a fluent method in an abstract base class needs to return a ‘this’, as above the reference needs to be for the concrete subclass so the same problem occurs.

The topic is discussed in detail in Java Generics and Collections, section 9.4 on the Strategy pattern. The section from the book may be viewed online at Flylib here.

Angelika Langer also discusses it in more detail her Generics FAQ here

In the above case, the problem can be solved with the so-called getThis trick. An abstract getThis method is defined in the superclass, and implemented in each subclass:-

Superclass

protected abstract N getThis();

Subclass

protected Subtype getThis() {return this}; // where Subtype is the concrete subtype of N

Now the superclass can obtain a type correct reference to this and pass it without error:-

public void methodB(N node) {
node.methodA(getThis()); // this time it works
}

As Angelika Langer points out in her examples, there can be other ways around this kind of problem depending on the situation, but sometimes you do need the getThis trick.

No Comments »

February 21st, 2012
3:57 pm
CDI Interceptors not called on local call to service layer EJB method

Posted under CDI
Tags , ,

When a service layer EJB method is called locally from within the same class, any CDI interceptors on the method are not invoked. This is standard CDI behaviour, as interceptors are only designed to be called when a method is called from an external client.

I hit this issue when my OptimisticLockInterceptor (which converts OptimisticLockException to ChangeCollisionException) was not being called, and OptimisticLockExceptions where being propagated all the way up to the view layer -  Mantis issue 120 details this.

The solution to this is to ensure that any required interceptors are annotated on methods at the point of call from an external client. If they then call another EJB method locally, any interceptors on the second method will not be called, but this is not a problem if the first method is correctly annotated. If the second method is also used externally, then its interceptors will be correctly invoked.

No Comments »