Thursday, 20 May 2010

Fixing annoying Australia-centric google results: &gl=

Google seems to prefer giving me Australian results to some of my searches. This is often useful, but sometimes it's annoying.

It looks like adding "&gl=" to the request disables this feature.

Judging by my quick experiments (see below) it's using gl=au by default.













http://www.google.com.au/search?q=university australian results
http://www.google.com.au/search?q=university&gl= world results
http://www.google.com.au/search?q=university&gl=au australian results (same as australian results above)
http://www.google.com.au/search?q=university&gl=uk uk results


The following searches, however, seemed to have only minor variations, with no obvious country biases:

http://www.google.com.au/search?q=smtp+server+component
http://www.google.com.au/search?q=smtp+server+component&gl=
http://www.google.com.au/search?q=smtp+server+component&gl=au
http://www.google.com.au/search?q=smtp+server+component&gl=uk


The effects of the GL parameter seem to be different from using the

* The web
* Pages from Australia

options sometimes available on the left of a google search.

Also note, something I've done (I suspect clicking on the "The web" link) has changed the results I'm now getting for the GL-less seaches.

Oh, I found out about the parameter from http://www.searchmasters.co.nz/articles/204/country-bias-in-google-search-results/

Thursday, 6 May 2010

finding <? that aren't <?php

I'm using this pattern (in vim) to find "<?" that aren't "<?php":

\(<?\)\@<=\(php\)\@!

it uses zero-width look behind for the "<?" and zero width negative look ahead for the "php".

And using grep (in perl mode):

grep -P "\<\?(?!php)" -r .


Test cases:

YES <?
NO <?php
YES <?=
YES <? asdf
YES <?adsf
NO asdg



And a quick shell script for fixing a file (I say "quick" because it doesn't always work - e.g. if you have "<?/* comment */?>" it doesn't put in the extra whitespace you need after the "<?php"):

sed 's/<?=/MAGICaaxo3ohW/' | sed 's/<?php/<?/g' | sed 's/<?/<?php/g' | sed 's/MAGICaaxo3ohW/<?php echo/'

Thursday, 29 April 2010

ggplot2 background colour

changing the background colour of a ggplot - run this, then rerun plot

> th = theme_bw()
> th$panel.background
theme_rect(fill = "white", colour = NA)
> th$panel.background = theme_rect(fill = "black", colour = NA)
> theme_set(th)

Thursday, 15 April 2010

Zend Soap Client exception

If Zend_Soap_Client is giving you an "Invalid SOAP request" and you don't know why, try adding "$client->setSoapVersion(SOAP_1_1);".

The error I was getting:

[SoapFault]
Invalid SOAP request
stack trace

* at ()
in C:\xampplite\php\PEAR\Zend\Soap\Client.php line 1113 ...
1110. $this->_preProcessArguments($arguments),
1111. null, /* Options are already set to the SOAP client object */
1112. (count($soapHeaders) > 0)? $soapHeaders : null,
1113. $this->_soapOutputHeaders);
1114.
1115. // Reset non-permanent input headers
1116. $this->_soapInputHeaders = array();


Thanks to Mark Steudel's comment at the zend soap client page

Friday, 19 March 2010

Drupal and php snippets

useful link: http://drupal.org/handbook/customization/php-snippets

to get php in blocks, enable the Php Filter in the modules section.

I've managed to break a site (so that nothing renders because of a php error in a block) and fix it by posting a page that I already had open with that block being edited.

I haven't had to work out how to perform such a fix without that lucky open page (yet).

Monday, 8 February 2010

Drupal, Zen, Nice Menus

If you're using trying to use Nice Menus to make a Zen subtheme for Drupal, you might need to remove the "overflow: hidden" from the navbar block in layout.css if you're having trouble with your menus not working or only partly showing up.

Here's a quote from layout.css (the comment is not mine):

#navbar
{
overflow: hidden;
/* May need to be removed if using
a dynamic drop-down menu */
}


Monday, 1 February 2010

Fragments of CSS


a:hover {color: green; text-shadow: #FF0000 1px 1px 3px}