5 O’Clock – Sunset in December
Taken at Chester University around dusk, I made this in Photoshop last year. The full size version is available at deviantArt.
Taken at Chester University around dusk, I made this in Photoshop last year. The full size version is available at deviantArt.
If you have hosting with Dreamhost or any other host which gives you a shell account, you can install your own custom version of PHP. I needed to compile PHP with GMP support for the OpenID login plugin for WordPress, so I spent the whole day tweaking trying to get everything working. There's a page on Dreamhost's Wiki which has a script, but it still took me hours to get right. I've written a quick guide to help avoid the mistakes which slowed me down.
Options +ExecCGI AddHandler php-cgi .php Action php-cgi /cgi-bin/php.cgi
If you have problems installing, the Dreamhost forums might be a good place to ask for help.
Two pretty useful Java methods. They're both related to JTrees, but should have been included as built in methods really.
The first returns a treepath given an object. Once you have a JTree, you may need to get the path to the node that contains that object (to scroll the JTree to that object for example). It's a recursive function so it doesn't matter how many levels your JTree contains.
private TreePath getPathToNode(DefaultMutableTreeNode node, Object obj) { System.out.println("Looking for "+obj.toString()+" in "+node.toString()); if(node.toString().equals(obj.toString())) { return new TreePath(node.getPath()); } else { for(Enumeration theChildren = node.children(); theChildren.hasMoreElements();) { DefaultMutableTreeNode thisNode = (DefaultMutableTreeNode)theChildren.nextElement(); if(thisNode.toString().equals(obj.toString())) { System.out.println("Found node at "+new TreePath(thisNode.getPath())); return new TreePath(thisNode.getPath()); } else if(thisNode.getChildCount()>0) { for(Enumeration grandChildren = thisNode.children(); grandChildren.hasMoreElements();) { DefaultMutableTreeNode grandChild = (DefaultMutableTreeNode)grandChildren.nextElement(); TreePath n = getPathToNode(grandChild, obj); if(n != null) { return n; // if the call returns anything but null, we've found the node } } } } System.out.println("Node not found"); return null; } }
The second returns a DefaultMutableTreeNode given an object. It recursively searches the JTree until it finds the object matching the one you pass to it, then returns the node containing that object.
private DefaultMutableTreeNode getNodeFromName(DefaultMutableTreeNode node, Object obj) { // Used to scroll the JTree to the current account for(Enumeration theChildren = node.children(); theChildren.hasMoreElements();) { DefaultMutableTreeNode thisNode = (DefaultMutableTreeNode)theChildren.nextElement(); if(thisNode.toString().equals(obj.toString())) { return thisNode; } else { if(thisNode.getChildCount()>0) { for(Enumeration grandChildren = thisNode.children(); grandChildren.hasMoreElements();) { DefaultMutableTreeNode grandChild = (DefaultMutableTreeNode)grandChildren.nextElement(); DefaultMutableTreeNode n = getNodeFromName(grandChild, obj); if(n != null) { return n; // if the call returns anything but null, we've found the node } } } } } System.out.println("Node not found"); return null; }