Simon Holywell

Posts tagged computing

Sun + Oracle Deal Closed

You may have noticed that the Oracle logo has begun to appear across all the Sun websites, which is a visible indication that the Oracle buy out of Sun is now complete.  In the spring of last year the deal was announced and many people were very worried about Oracle’s intentions for Sun’s open source projects – most notably MySQL.  Many seemed to consider MySQL a competitor for Oracle’s 11g database software and therefore Oracle would be looking to reduce development investment to stifle the perceived competition.  This is something that both Larry Ellison and the audience at the Oracle + Sun close presentation found laughable.

Larry Ellison has also written a short open letter to Sun’s customers, which highlights Oracle’s intended investment in the future.


Open Letter to Sun Customers

Open Letter to Sun Customers


So we can all rest easily now!

Agavi Form Population Filter

Attaching the population filter without using form IDs (suitable where the current form is on the same page as the URL in forms action parameter)

http://gist.github.com/294742

Use form ids to link the pre-population to a particular form

http://gist.github.com/294743

The above hints were created with help from IRC.

Netbeans and Remote XDebug

To get Netbeans to listen for browser initiated debug sessions please consider the following steps:

  1. Go to Project Properties > Run Configuration > Advanced > Debug URL and choose the Do not open a web browser.  Save.  (you may like to setup Path Mapping, but it works for me without it)
  2. In the projects listing right click on your intended project and choose Debug, which will start Netbeans listening for connections.
  3. In your web browser you can now access your website http://www.example.org?XDEBUG_SESSION_START=netbeans-xdebug
  4. You will now see the debug information appear in the debug log area of Netbeans.

(Para-phrased and expanded upon an answer on StackOverflow)

Agavi PHP Framework Resources

Agavi Framework Logo

Agavi Framework

Bitextender backed Agavi is a very secure and helpful open source (LGPL) MVC framework with the core development being headed by David Zülke (Wombert) and Felix Gilcher (certainly in the IRC channel!). It can take some time to get the hang of the framework so I have put together all the resources I use or have used to help you get started.

Documentation Resources:

Support Resources:

jQuery and iFrames

I worked on a project while ago that required the use of iFrames to create “AJAX” file uploads.  It took me a little while but I finally worked out how to get the contents of an iFrame using jQuery.  To get the contents of an iFrame we need to wait until the iFramed content has finished loading as well.

http://gist.github.com/294740

Opera Mini 5 Beta

Opera has released a new version of their free mobile browser Mini for beta testing.  Head on over to mini.opera.com to download it or if you are reading this from your mobile the direct link to the beta is m.opera.com/next.  The new version is much improved in many areas.  The first thing you will notice is a new sleeker user interface and a “Speed Dial” interface when it first loads up.  My favourite is the addition of tabbed browsing and a neat little password manager.

I have been using it on my Symbian based phone during the train journeys to work and its great.

Opera Mini 5 Beta Reviewers Guide

jQuery Using and Manipulating Select Lists

JQuery is a fantastic tool but sometimes its functionality can be obscure or doing it one way might not work in a certain browser (MSIE6 anybody!).  I have often found myself trying to remember the best way to work with HTML select lists so I am compiling this list of hints for future use and I hope that you find it useful.  All the examples below are written where this represents the select element of the select list.

First up getting the selected value from a select list is as simple as using the jQuery shortcut $(this).val();.  Simple isn’t it!  Setting the selected item is just as easy too…

jQuery has a nice shortcut for setting the selectedIndex/value of an HTML select list and its syntax is as so $(this).val('value');.

Finding an option in a select list by its value works out to be something like this $('option[value="value-to-search-for"]', this);.

Often I need to be able to reset the select list to its initial state when clearing/resetting a form for the next submission.  There is a jQuery shortcut for this which is $(this).val('');, but it does not work in IE for whatever reason so I devised $(this).val($('option:first', this).val());.  This basically sets the select lists value equal to the first option in the list.

The next item on the list is resetting the select list to a blank option, which is easy with the following syntax $(this).val(null);.

Now to add an option into a select list with jQuery $(this).append('<option value="Option Value">Option Name</option>'); and to remove an option from the list by value $('option[value="value-to-search-for"]', this).remove();.

The aforementioned tips and some extras are included in a syntax highlighted manner below for your perusal.

http://gist.github.com/294741

Moving to git and setting up InDefero as a web frontend

git Logo

Most of our development is done on Vista desktops (although I also run Ubuntu of course) and we wanted a web interface for easy browsing of code so I needed to use a pervasive and well supported VCS. After much hunting around and looking at Bazaar, Mercurial and git I decided to go with the latter due to its support in the community.  There are still some reservations I have against git, which work well for Linux kernal development but not our day to day web development – the major one being that subversion would allow you to commit and update on a file by file basis where as git versions the entire repository at once as far as I am aware.

Anyway now I have an Ubuntu server that I am using for storing the repositories and as a pretty frontend I have installed InDefero which also allows us to manage tickets.  InDefero is much like the code.google.com forge to manage and look at it so it is very simple.  I like Trac but I was not happy with the existing integrations with git.

It was not all plain sailing with the InDefero install as I had to make some very minor changes in the git plugin’s core code (the git plugin comes as part of InDefero and does not need to be installed seperately).  Basically the plugin was creating new repositories with very strict permissions which meant that the neither my backup user nor the apache process user could access them.  What this meant from the frontend was that the repository statistics (disk usage) were not displayed because it could not stat the directories and my back up process could not open them to make backups.

This problem is caused by the use of permissions setting in a PHP mkdir() command in the src/IDF/Plugin/SyncGit/Serve.php on lines 94 and 193.  You will want to increase the file permission octal just enough for your other users to gain access.  It is also worth mentioning that on line 111 there is a umask() command which you might also wish to tweak to improve your access.  Also don’t forget to update all $pluf_path values in the files in the scripts directory.  The rest of the way you should be fine just following the included documentation in doc/syncgit.mdtext

So far I am enjoying using InDefero though I think I will need to hack it so that when you add a new repository/project all the users names are placed in the project members as default to save vast amounts of copying and pasting.  Our development team is not large enough to warrant only giving certain people access to certain repositories/projects.

[UPDATE] I have made a small (and nasty) hack to the source of InDefero to cause the members text area when creating a new project to be pre-filled with my member’s names.  This involved changing /src/IDF/Form/Admin/ProjectCreate.php on line 107 by setting the array element initial to the value you want to appear in the text area.

For our desktop access to git we are using msysGit, PuTTY Plink and TortoiseGit.  This combination is working well for us so far and means that even non-technical users can begin versioning their documents and push them to a central repository for backup purposes.

Handy Linux Commands

I use most of these commands every day to simplify my terminal interactions with an Ubuntu development box.  This is more of a personal reference but thought I would share incase you find it useful.

Task Command
Get all users on the system

for user in `getent passwd | cut -d: -f1`; do id $user; done

Delete all .svn or any file name by replacing .svn in the command with your filename find ./ -name ".svn" | xargs rm -Rf
Look for enabled modules or particular environment settings in PHP

php -r 'phpinfo();' | grep 'searchkeyword'

for example php -r 'phpinfo();' | grep 'json' to find out if JSON is installed and what version of the module is available

Push a line of text into a file

to reset file content to ‘text to push’ – echo 'text to push' > /etc/file
to append to file content ‘text to push’ – echo 'text to push' >> /etc/file

Create an empty file touch filename.ext
Watch a file on the command line.  Useful for viewing logs whilst debugging. tail -f /var/log/filename.ext
use control + c to break
Break the current command Use the keyboard combination control + c
Access to MySQL Converting Microsoft Access MDB Into CSV Or MySQL In Linux

Samba File Share Over SSH Tunnel

Sometimes you need to be able to access a remote Samba server in a secure manner from a Windows machine.  This is a relatively simple procedure on an XP SP3 machine like mine linking into an Ubuntu server pre setup with Samba file sharing.

Windows is a little bit annoying as it binds all filesharing operations to port 139 so you cannot have more than one filesharing system in operation at once.  If you were to tunnel directly across to your Samba server it would bang heads with the Windows filesharing layer.  You could just disable file sharing in Windows but that is an in elegant method and you may need access to both Windows and remote Samba shares.  So we will need to setup a new loopback adapter with a local ip address that we can tunnel Samba request through thus allowing Windows filesharing to operate normally along side Samba.  This effectively makes Windows think that it is accessing Samba shares on a seperate machine whereas a tunnel usually acts as a port on the local machine.

Add the Loopback Adapter to the Windows client machine

  1. Open up the Add Hardware control panel (Start > Control Panel > Add Hardware)
  2. Click next and wait for the annoying wizard to finish hunting around your system
  3. Choose ‘Yes, I have already connected the hardware’
  4. Then scroll to the bottom of the ‘Installed hardware’ list box and choose ‘Add new hardware device’
  5. Now choose ‘Install the hardware that I manually select from a list (Advanced)’
  6. Select  ‘Network adapters’
  7. Under ‘Manufacturer’ you want ‘Microsoft’
  8. For ‘Network Adapter’ choose ‘Microsoft Loopback Adapter’
  9. You may have a to wait a little while for the adapter to be fully installed

Set the Loopback Adapters Configuration

  1. Pull up the adapters properties dialogue (Start > Control Panel > Network Connections and then right click on the adapter and choose properties)
  2. Disable ‘File and Printer Sharing for Microsoft Networks’
  3. Highlight ‘Internet Protocol (TCP/IP)’ and click the ‘Properties’ button
    1. Choose ‘Use the following IP address’
      1. Enter ‘10.0.0.1′ for ‘IP address’
      2. Enter ‘255.255.255.0′ for ‘Subnet mask’
    2. Click the ‘Advanced’ button and on the ‘WINS’ tab
      1. Enable ‘Enable LMHOSTS Lookup’
      2. Check ‘Disable NetBIOS over TCP/IP’
  4. You will now need to restart you computer even though Windows does not prompt for this step

Configure the SSH Tunnel

  1. On your PuTTY session configuration dialogue choose Connection > SSH > Tunnels
  2. Check/enable ‘Local ports accept connections from other hosts’
  3. In ‘Source port’ enter ‘10.0.0.1:139′
  4. In ‘Destination’ enter ‘localhost:139′ (127.0.0.1:139 did not work for me)

Test and Map the Connection

In the Run command console (Start > Run) enter ‘\10.0.0.1′ and you should be presented with file explorer window containing the contents of your Samba share.

So if that worked we are ready to roll, but you can give your Samba share ’server’ a more friendly name by opening ‘C:WINDOWSsystem32driversetchosts’ in your favourite editor (Vim in my case).  Scroll to the bottom and enter the following ‘10.0.0.1    samba’.  You can now access ‘//samba’ in the same way we did above via the Run dialogue.  If you have assigned the loopback device to a different subnet then you will need use the lmhosts file in the same directory instead – please see Microsoft KB Article Q105997.

Now you can Map the Samba share like any other by using the ‘Tools’ menu in a Windows file explorer window.  In the ‘Folder’ input enter ‘\samba’ or for a home directory called simon ‘\sambasimon’ (you must have enabled home directory sharing in your Samba smb.conf (/etc/samba/smb.conf)).