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; }
I'm still getting to grips with Java, but there a few functions I miss coming from PHP. in_array lacks a Java equivalent, as does the implode function. Here are the equvalent methods in Java:
implode()
public static String implode(String[] ary, String delim) { String out = ""; for(int i=0; i<ary.length; i++) { if(i!=0) { out += delim; } out += ary[i]; } return out; }
in_array()
public static boolean in_array(DefaultListModel haystack, String needle) { for(int i=0;i<haystack.size();i++) { if(haystack.get(i).toString().equals(needle)) { return true; } } return false; }
Until SQL server 2008's released, there’s no easy way to page reults or only show the first n results. I searched around for a while until I found this on MSDN.
SELECT TOP limitnumber FROM ( SELECT TOP (limitnumber/ offset) * limitnumber) * FROM tablename AS T1 WHERE clauses ORDER BY sortfield DESC) AS T2 ORDER BY sortfield ASC;
The LIMIT and OFFSET values are the same as in PostgreSQL or MySQL. limitnumber is the number to show per page, and offset is the starting row.
I bought a shiny new iPod touch, and after unlocking it to install custom applications, I soon filled the 300Mb applications partition. If you need more than 300Mb for apps (which you more than likely will if you install more than a couple), you can create a sym link to the music partition.
[Via: MacRumours]
I've been working on adding support for Microsoft SQL Server to iZeit, and there are a few things I've noticed. Firstly, whereas you can addin multiple rows in MySQL or Postgres by using
INSERT INTO tablename (field1,field2,field3) VALUES (r1c1, r1c2, r1c3), (r2c1,r2c2,r2c3)
MSSQL fails and throws an error. Instead, you have to use UNION ALL, which I always thought was more resource intensive.
INSERT INTO tablename (field1,field2,field3) SELECT (r1c1, r1c2, r1c3) UNION ALL SELECT (r2c1,r2c2,r2c3)
The second major annoyance is that MSSQL doesn't like ORDER BY clauses with text fields. Understandably you can't sort a field containing an image, but why can't it sort a text field alphabetically? One thing I still haven't found a workaround for is the LIMIT and OFFSET clauses, which MSSQL doesn't support.
Britons are now sending more then 4 billion texts weekly. That's more than were sent in the whole of 1999 and 25% more than one year ago. In September, 4.8 billion texts were sent, about 4,000 per second!
That’s some furious texting. People would be better off with Blackberrys though…
Scientists have devised a new currency to be used in space. The Quid 'coins' are made from a polymer which unlike credit cards or regular coins, have no sharp edges which could damage space suits.
The Quid is expected to be used in the upcoming inflatable space hotel and aboard Virgin's SpaceShipTwo.
The current exchange rate is about 1 Quid to £6.25.
Nothing makes you feel more like a telly-addict than when someone makes a geeky reference to a Sci-fi show and everyone knows exactly what they mean. This site has a list of Simpsons scenes and which films they came from. It looks like Matt Groening's even more of a telly-addict than me.
Source [Via: nodomain.cc]