22nd Aug 2009

Mobile web-site resuce – SSH from iPhone

Posted in Server stuff and installs, Web Development at 11:01 pm by admin

This weekend I got a chance, or rather was forced, to try out the SSH client I’ve had sat on my iPhone for the last few months.
I got an email from my boss who had just been tipped off about problem with our <a href=”http://www.sphinxsearch.com”>Sphinx</a> configuration. The usually very helpful stemming that Sphinx performs on search queries was causing “Live music” and “DJ music” events to come up when a user searched for “musicals”.
At this point I was in a cafe on Broadway Market with a coffee eyeing up the ample selection of vegan cakes. Getting to the point I whipped out my iPhone and logged into our webserver using <a href=”http://jbrink.net/touchterm/”>Touchterm</a>. I was relatively easily able to edit the Sphinx config file with vim (the command line editor that’s better than emacs), restart the server and reindex all our events, I later realised that changing the stemming config only requires a restart of searchd to take effect.
Thanks to the convenient shortcut overlays I could access the crtl, esc and arrow keys and also perform key shortcuts like ctrl+a to get to the start of the command because I forgot to type sudo.
Now I’m totally told I’m going to shell out a &pound;2.99 quid for the pro version.

This weekend I got a chance, or rather was forced, to try out the SSH client I’ve had sat on my iPhone for the last few months.

I got an email from my boss who had just been tipped off about problem with our Sphinx configuration. The usually very helpful stemming that Sphinx performs on search queries was causing “Live music” and “DJ music” events to come up when a user searched for “musicals”.

At this point I was in a cafe on Broadway Market with a coffee eyeing up the ample selection of vegan cakes. Getting to the point I whipped out my iPhone and logged into our webserver using Touchterm. I was relatively easily able to edit the Sphinx config file with vim (the command line editor that’s better than emacs), restart the server and reindex all our events, I later realised that changing the stemming config only requires a restart of searchd to take effect.

Thanks to the convenient shortcut overlays I could access the crtl, esc and arrow keys and also perform key shortcuts like ctrl+a to get to the start of the command because I forgot to type sudo.

Now I’m totally sold I’m going to shell out a £2.99 quid for the pro version.

30th Aug 2008

Installing Ferret on a PowerPC Mac

Posted in Server stuff and installs at 2:45 am by admin

I am (still) a proud owner of an Apple PowerBook, and it’s only now that in this overwhelmingly x86 world that things are starting to get a little awkward. I dual boot Ubuntu and OS X and as many people know running powerpc linux is full of unexpected trouble and disappointments.

Anyway so I was trying to install ferret (a ruby based full text search engine) through ruby gems (I’m using 1.0.1) and ran into a puzzling issue. It should have been as simple first install the rubygem, then the rails plug-in,

> sudo gem install ferret

> ruby script/plugin install svn://projects.jkraemer.net/acts_as_ferret/tags/ stable/acts_as_ferret 

However the powerpc world is as cruel as it is neglected. Though this command seems to result in success when you try and use the library with your rails app or whatever you will encounter an error when starting the server, something like

Failed to load /usr/local/lib/ruby/gems/1.8/gems/ferret-0.11.6/lib/ferret_ext.bundle (LoadError)

The reason for this is the Makefile that comes with this rubygem has the processor type hardcoded as i386, that’s intel x86 processors. 

The solution: fix the makefile and compile it for your processor in a few easy steps.

Open your terminal and find your gems directory, mine is /usr/local/lib/ruby/gems/1.8/gems/ yours may vary due to 1.8, installation and ruby version.

> cd usr/local/lib/ruby/gems/1.8/gems/ 

Next Dig a little deeper into the ferret gem’s directory (assuming we have the same version it should be something like …

>cd ferret-0.11.6/ext

Delete all the existing binaries, they are of no use to you.

> sudo rm *.o ferret_ext.bundle

Fix that make file. Use your favourite text editor which must be vi right?

> sudo vim Makefile

With the file open type

:%s/i386/ppc

to globally replace i386 with ppc. Next type

:wq

to save and exit. Use something less trciky like textmate, BBEdit or pico if you’re not familiar with vi. On the other hand you could learn to use it before you bring shame upon yourself and your family.

Now we’re ready to recompile the thing, pretty simple!

> sudo make 

This will compile all those little c files in there and create a new ferret_ext.bundle, for some reason this doesn’t really live here so last thing is to move to the right place

> sudo cp ferret_ext.budle ../lib

All done. Start your rails app and go.

01st Aug 2008

Opera and Safari will cache content with a query string

Posted in Front End at 2:22 pm by admin

I was doing some checking up on our HTTP expiry headers that we were sending down dynamically with our product image caching script after it was reported by YSlow that they were not doing their job properly. Another concern I had is that I was under the impression that Opera and Safari do not cache content that has a query string.

Some browser cache mythbusting ensued.

A quick google search revealed only a few references to this phenomenon posted on out dated forum threads. After browsing our development version of our site with Opera 9 and Safari 3.1.2 and tailing the apache access log it was clear that this is not at all true. Given the correct expiry and cache control headers both Opera and Safari will cache content with a query string.

While a most of people completely ignore proper management of their users’ browser caches others make wild assumptions and generalisations about the behaviour of these strange beasts. They all behave slightly differently and the only way to know for sure if a particular browser is caching your content is to open your access log and check. One trick I have used in the past is to put sleep(5), or your language’s equivalent somewhere in the script execution, but this can get tiresome!

Hitting refresh in most browsers certainly all the ones I tried on my mac will re-request most if not all content regardless and also emptying your cache, clearing your private data or whatever does not always do as is promised. A quick tip to finish make sure your test browsing is clicking through links and not hitting refresh, or your tests wont be accurate.