Saturday, 24 July 2010

Building VLC on Ubuntu

Exciting apt command:
apt-get build-dep vlc
downloads vlc's dependencies for me. From VLC's UnixComplie page.

Still doesn't compile. OK, new plan:
update-manager -d
alpha FTW.

Wednesday, 9 June 2010

RMySQL and mysql connector odbc 5.1.6

I think installing mysql-connector-odbc-5.1.6-win32.msi upset RMySQL.

In R, running
library("RMySQL")
gave me
... Error in if (utils::file_test("-d", MySQLhome)) break : ...

Setting MYSQL_HOME to C:\PROGRA~1\MySQL\MYSQLS~1.0
fixed the problem (using XP's System, Advanced, Environment Variables, System Variables).

References:
https://stat.ethz.ch/pipermail/r-sig-db/2009q2/000648.html
http://biostat.mc.vanderbilt.edu/wiki/Main/RMySQL

Edit:
Except that only lets me load the library, connecting doesn't work now. Gave it the mysqllib.dll that comes with HeidiSQL, that'll work until mysql-5.1.47-win32.msi finishes downloading (copied the dll into a dir called "bin", set MYSQL_HOME to dir that bin dir was in).

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).