Those who are familiar with MySQL may be used to terminating a query with ‘\G’ to have the client output the query results vertically with each column/value pair a line at a time. There is in a equivalent in PostgreSQL too. The psql client uses ‘\x’ to toggle vertical output, and ‘\g’ to send the current buffer to the server for processing. To get the same effect in psql as ‘\G’ in MySQL, just end your query with ‘\x\g\x’.
After a little hard work, I’m releasing my attempt to address the shortfall in accurate UK geocoding services. Courtesy of open data provided by Ordnance Survey Open Click-Point, some sed, SQLite, PHP and YQL I’ve produced a REST API, and a YQL datatable. I’ve also written a more thorough account of this by way of documenation.
So, you need to take a copy of a subversion working copy, but it has local changes that you also need to copy. This precludes the use of `svn export` since the local changes won’t be included. One option is to do an `svn export` anyway, and then `cp -ra` the local changes. Another solution is to use a find command that excludes subversion metadata, and then copy the resulting files:
`find . -path ‘*/.svn’ -prune -o -type f -print`
I did something similar some time ago, but forgot the command, so here it is for posterity.
I decided some time ago that I wasn’t happy with the way this site looked. Unfortunately I haven’t had much time to do anything about it. I’ve finally got around to making some changes, the most important of which you may notice is the minimalist design. I don’t know if I plan to change this any time in the future, but for now it will do.
I’ve also tried to pull in some data from other services I use (perhaps not as frequently as I would like) such as Twitter, Facebook and Flickr. To that end, my recent Twitter tweets are now displayed, together with my Facebook status. I’ve also pulled in some random images from my public Flickr collection.
Another aide memoire, but again may be useful to some. I’d like the ability to work from home on some web development projects I’m doing at work. Getting the code locally is not a problem thanks to Subversion over ssh However viewing the results can be tricky when you consider that the development server is behind the work network. The answer is SSH tunneling.
Let’s say you can access SERVER_A directly over ssh The service you want to access is on SERVER_B which you can’t access directly via SSH from your local machine. However, you can access SERVER_B from SERVER_A. I’ll assume that you want to access the service locally on port 12345, and that the remove port is port 80. The following command will allow you to access a service on SERVER_B from your local machine.
ssh -Nf -L 12345:SERVER_B:80 username@SERVER_A
The ‘-Nf’ switch says don’t execute a command with this ssh session, and run this ssh process in the background. The first port is the port you want to use locally; the first server is the usually inaccessible remote server you want access to; and the third port is the remote port you want to use. The final argument gives the login to the remotely accessible server you have ssh access to directly.
One caveat to this is if you are trying to access a web site that is defined using Apache virtual hosts. With this command alone, requesting localhost:12345 in Firefox would only direct you to the site that is listening remotely for requests that match ‘localhost’. If you would ordinarily access this site using mysite.server_b, then you need to use that as the address in Firefox on your local machine. Therefore, this needs to be added in /etc/hosts. With that done, you should be able to request mysite.server_b:12345 in Firefox and be directed to the remote “virtual host” site.
Recently I had cause to report on the usage staff at work made of the corporate intranet. This would ordinarily be a simple enough task if the logs were plain standard Apache logs. However, I was dealing with Oracle9iAS, a very different beast indeed. Oracle9iAS is built on top of a customised version of Apache and incorporates a caching proxy server, the so-called Webcache; an implementation of J2EE called OC4J (Oracle Containers for Java) and various other bells and whistles, making it something of a behamoth. [Read more]
As you can see from my previous post, my first attempt at writing a WordPress Plugin was a success. This plugin is very simple and allows the user to embed a YouTube video into their post. The main function calls a callback function that replaces every occurrence of the tag ["youtube" video_id] (minus quotes) with a flash video corresponding to the video_id parameter.
Just paste the code below into a file called ‘youtube.php’ in your wp-content/plugins directory. You should then be able to activate it via the Plugins admin option. Once activated, you can place a YouTube video in your post by going to code-view and inserting ["youtube" video_id] (minus the quotes). The video_id parameter is the ‘v’ parameter in a YouTube URL. In the example below, the URL is http://www.youtube.com/watch?v=lL4L4Uv5rf0. Therefore, the video_id parameter should be lL4L4Uv5rf0. In the code below, you will need to remove the quotes around the word “youtube” in the regex on line 5, I had to put these in to display the code without it interpreting the tag… it’s a work in progress!
My work has recently taken a departure from the usual web development as I’ve been “borrowed” by the other development team to help out with a Java project. Now, my Java is reasonable sound but yesterday I came across a curious situation involving passing about the current object.
In common with a lot of languages, the current object is represented by the ‘this’ keyword. I wanted to pass ‘this’ to a static method of another class. Of course, I can’t refer to the object as ‘this’ in the static method context as that would be ambiguous insofar as it could refer to the class with the static method I’m working with. This pattern is often used with callbacks where for example you might want to register a class with a particular listener objcet. To avoid confusion, I named the actual parameter in the static method
that
I assumed that I would reference the fields and methods of the object using
that.someMethod()
rather than
this.someMethod()
This is where the fun begins. Let’s call the original object
SomeObject theObject
and I want to call the static method
SomeClass.doStaticMethod(SomeObject that)
I would call that method, from within theObject, using
SomeClass.doStaticMethod(this)
When in theObject, I have access to private fields and methods since private fields and methods are within scope. I assumed the same would be true when I passed “theObject” as “this” to “SomeClass.doStaticMethod(SomeObject that)”. However, when I actually try to access private fields such as “that.privateField”, it would appear that I no longer have access. I could create appropriate accessor methods, but that would defeat the idea of encapsulation.
Does anyone have any ideas? Am I missing some fundamental (and so obvious I missed it) rule of scope or object passing?
I’ve finally found time to start investigating some other PHP frameworks, and after some brief research I decided to start off with Symfony. All is going well and so far I’m impressed with what Symfony can do compared with CakePHP… with a few exceptions.
I initially tried following the My First Project tutorial, but hit problems pretty quickly. It would seem that there was a problem with the PHP SQLite extension. The phpinfo() function verified that SQLite was indeed installed, but I couldn’t get any further on that trail. After reading a number of forum posts on the issue, it became apparent I should recompile Apache and PHP. I’m still not that confident with Linux to do that so I left it at that.
Then I followed the Askeet tutorial with more success as this tutorial uses MySQL rather than SQLite. However, I can’t get the URL rewriting to work as it should. I’ve checked my Apache configuration, the .htacces file and still no luck. If I load http://<project>/question I get a 404 error. If I load http://<project>/index.php/question or http://<project>/frontend_dev.php/question all is well. I’ll press on with this tutorial until I hit a road block, but this is really bugging me. Again, a few forum posts suggest recompiling Apache and PHP. However, the extensions that should be included in the new build are already present according to phpinfo().
I’m currently running Fedora 7 which installs Apache and PHP in its own odd way. Perhaps I should start from scratch by removing Apache and PHP with yum and compiling both from source. Although as I said I’m kind of reluctant to do that. If anyone has any ideas – let me know!