Dave Harris

General ramlings about Java

DNS-323 Setup November 22, 2010

Filed under: DNS-323 — daveharris @ 12:09 pm

This is a list of steps and resources used to set up my Dlink DNS-323 RevB

Phase 1: Upgrade firmware

Upgrade to the latest firmware

Alternatively, use the custom alt-f firmware.

Phase 2: Correctly format 4k drives

Western Digital 4k sector drives (EARS) are not correctly formatted by the DNS-323, and the partitions must be setup manually to align with the cylinder boundaries.

Phase 3: FFP

Phase 3.1: Standard FFP

Install Fonz Fun_plug (FFP) and enable ssh.  Then setup additional packages and install bash, dnsmasq, screen, sudo and vim ffp packages

Advantage: Installs ssh, telnet, bash and other useful tools

Disadvantage: Files stored on / ramdisk so have to replace modified config files each reboot.  Also there is still git package

Phase 3.2: Optware

Install optware which allows many more packages to be installed, which allows git installation

Disadvantage: Still have to workaround ramdisk issues and fragments package management – some built-in, some in ffp, some in optware

Phase 4: Debian chroot

Phase 4.1: Debian Etch

Download and install Debian Etch chroot.

Follow the upgrade path:

  • Upgrade via apt-get to Debian Lenny.
  • Install samba, using the standard smb.conf as a base.
  • Create standard user account, lockdown ssh access

Advantage: No more ramdisk issues, more control over package management and running a real linux distro

Disadvantage: Running an old version of Debian (stable) which is arm, not the newer armel architecture

Phase 5: Alt-f Replacement Firmware

Debian Squeeze (debian-testing) is available only in the newer ‘armel’ architecture, not in the older ‘arm’ architecture.  The default firmware is arm and therefore cannot run squeeze.  Alt-f is an alternative custom firmware which is running on the ‘armel’ architecture as well as supporting some things that the default does not, such as ext4.  It can be run ontop of the default firmware, but that has the same problems ramdisk problems as before.  It an replace the default firmware by flashing the device but that seems a little dangerous and with limited benefit.  This may be required is Lenny is no longer supported.

Phase 5.1: Debian Squeeze Chroot

Download, create and install Debian Squeeze chroot.

Advantage: A newer version (unstable) of Debian.

 

How To Replace a Default Windows Driver February 13, 2010

Filed under: How-to,Windows — daveharris @ 12:04 pm

I had a problem where the network card driver in Windows 7 was faulty.  It is a known issue with the Asus on-board ethernet card.  The fix was to install the Vista driver, but doing that is easier said than done.

I first tried to just install the driver over the top of the old one which looks like it worked but didn’t replace it.  I then tried to un-install the driver via the Device Manager.  You then have to reboot for it to take effect, but on boot Windows detects the hardware and installs the same driver again!!!

To get around this you need to turn off hardware detection.  You may also need to allow unsigned drivers (a new requirement in Windows 7, not Vista).  Both of these are set via Group Policy.

Click Start -> Run -> gpedit.msc (and push Shift + Enter to run as admin)
Navigate to Computer Configuration -> Administrative Templates -> System -> Device Installation -> Device Installation Restrictions
Set ‘Prevent installation of devices not described by other policy settings’ to ‘Enabled’
Set ‘Allow administrators to override Device Installation Restriction policies’ to ‘Enabled’

Then go to the Device Manager (<Right Click> Computer -> Manage -> System Tools -> Device Manager) and un-install the driver.  Then reboot.  The driver should not be installed by Windows.  Go to the Device Manager again and it will be listed under unrecognised device or something.  Now right click on the device and then ‘Install Driver’ and give it the proper device driver.

 

How to automatically connect to Windows Share from a Mac at boot/wake January 12, 2010

Filed under: How-to,Mac — daveharris @ 9:47 pm

My current HTPC setup includes a Mac Mini sitting under a 40″ LCD flatscreen running Boxee.  All my media is sitting on a Windows 7 machine, with standard windows shares setup.  My MacMini doesn’t have any mouse or keyboard, so everything needs to be done via the apple remote.  When not in use the MacMini sleeps so things to come up correctly when waking.

Before coming up with a solution that worked, I tried a few other options;

Q. Doesn’t Boxee have a built-in Windows Share (Samba) client?

A. Well, yes technically it does.  However in practice I found it to be pretty unreliable.  Some shares would connect fine while some wouldn’t, then the next day those that worked yesterday wouldn’t connect.  I wasn’t able to find any log file to say what the problem was.  Also another problem is that when you started Boxee it would connect, but it would take a while (~30 secs) before the media would show up as available.  Not a big issue but annoying when I want to watch something now!

Cateat: This was with the Boxee Alpha, I am currently using the beta which is much improved so these issues may be addressed.  Let me know in the comments, I would like to hear!

Q. Why don’t you use the standard Windows share mounting in Finder?

A. The problem with this is that this only works for as long as you are logged in.  I can do a ‘Reconnect at Login’ by adding the mounted Volume to Login Items, but this has issues as well.  When the machine wakes from sleep, the volume says it’s connected by there are no items in the volume.  Funny I know….

Cateat: This was with Mac OSX 10.5 Leopard so these issues may be addressed in 10.6 Snow Leopard.  Let me know in the comments, I would like to hear!

Q. OK smartie-pants, how did you make this work then?

A. I’m glad you asked!  I used the power of autofs.  Autofs is a way of mounting local and remote filesystems, and is used by OSX already.  The setup is quite simple, but will require sudo/root access and simple use of command line tools.

  1. Create and edit a new file: sudo nano /etc/auto_smb
  2. Add an entry (one per line) to this file in the format

    -fstype=smbfs ://:@/

    Replace the with the your details, for example my line is

    Photos -fstype=smbfs ://dave:secretPassword@windows/Photos

  3. Save & quit (Ctrl+x) and run ‘chmod 700 /etc/auto_smb’ to keep your password safe
  4. Now edit the master autofs configuration file:

    sudo nano /etc/auto_master

  5. Add a line that says:

    /Volumes auto_smb

    (You can set the first word to be whereever you want to volume mounted, but /Volumes is the default place in OSX)

  6. To force refresh run: sudo automount -vc
  7. Done!

This solution fulfils all my requirements and has been working great for 6+ months.  It doesn’t matter what order I turn on my machines, the autofs daemon will see if the network is up and then mount the shares as soon as it can.  It doesn’t seem to sit there trying non-stop to mount the share if unavailable either, so it seems quite lightweight.

Occasionally I do get the annoying ‘Shares are unavailable’ window, but not usually.  If anyone has a solution for hiding this window I would love to hear it!  It floats above all other windows including Boxee.  I am ok with writing my password in the file as it just my local home network, I assume there are ways around this but I haven’t bothered to investigate it.

If you have similar setup or need help setting this up on your machine, let me know in the comments ;)

Happy Sharing

 

How to access the Spring WebFlow from Spring MVC September 1, 2009

Filed under: How-to,Spring — daveharris @ 5:09 pm

I recently came across a problem in a Spring Webflow based application where I needed to have one page as a standard Spring MVC page. I needed to write a PDF file to the actual http response and I’m not allowed to do that in WebFlow.

So I defined a standard Spring MVC Controller and URL Mapper to complement my existing Flow Controller:

<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
  <property name="mappings">
    <props>
      <prop key="/index.htm">/index.htm</prop>
      <prop key="/pdf.htm">PDFPageController</prop>
    </props>
  </property>
</bean>

<bean id="PDFPageController" class="controller.mvc.PDFPageController" />

<bean name="/index.htm" class="org.springframework.webflow.executor.mvc.FlowController">
<property name="flowExecutor" ref="flowExecutor" />
<property name="defaultFlowId" value="main" />
</bean>

Then inside the MVC Controller (which extends AbstractController), define a method called accessFlowScope like below:

private void accessFlowScope(HttpServletRequest request, HttpServletResponse response) {
  // Gain access to the Spring Web Flow context
  FlowController controller = (FlowController)getApplicationContext().getBean("/pdf.htm");
  FlowExecutionRepository repository = ((FlowExecutorImpl)controller.getFlowExecutor()).getExecutionRepository();
  FlowExecutorArgumentHandler handler = controller.getArgumentHandler();
  ExternalContext externalContext = new ServletExternalContext(getServletContext(), request, response);

  // Make sure we have a flow execution key.
  if (handler.isFlowExecutionKeyPresent(externalContext)) {
    try {
      // Get access to the variable stored in the context.
      ExternalContextHolder.setExternalContext(externalContext);
      FlowExecutionKey flowExecutionKey = repository.parseFlowExecutionKey(handler.extractFlowExecutionKey(externalContext));
      FlowExecution flowExecution = repository.getFlowExecution(flowExecutionKey);
      Object variableInFlowScopeObject = flowExecution.getActiveSession().getScope().get("variableInFlowScope");
    }
    catch(Exception ex) {
      logger.error("Error when accessing flow scope from MVC", ex);
    }
    finally {
      ExternalContextHolder.setExternalContext(null);
    }

  }
  else {
    logger.error("Handler did not have flow execution key present");
  }
}

This can then be called from your handleRequestInternal method of the MVC controller:

public ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)

All that is required now is to call from the Webflow view jsp into the MVC controller. I had to do a horrible iframe like so:

<iframe id="pdf-view" src="pdf.htm?_flowExecutionKey=${flowExecutionKey}" height="100%" width="50%">
  I'm sorry, iframes are not supported by your browser, upgrade to <a href="http://getfirefox.com">Firefox</a>
</iframe>

Now you can pull out whatever values you require from the many scopes (request, flash, flow, conversation) and use them in your MVC controller to do stuff.

NB: All the code is used pretty much verbatim from http://www.ervacon.com/products/swf/tips/tip1.html, but it doesn’t say to add the flowExecutionKey onto the URL, which is the part I was missing and thiking that it wasn’t working correctly.

 

SVN Dump Parts of a Repository August 5, 2008

Filed under: How-to — daveharris @ 5:02 pm

Today at work at Fronde I needed to create a dump of a ‘project’ inside a repository.  Our SVN setup is to have one repo per team and then within there have a folder for each client/project.  In this case I was providing the backup to a client so it was vital that I gave them just their code and not the whole repo.

So my SVN repo was like this:

/
  teamA
    clientA
    clientB
  teamB
    clientC

To dump the clientA history into a portable, re-creatable format, I used svnadmin dump, like this:

svnadmin dump [path to repo] > repo.dump

Which creates a dump of the entire repository into a file called repo.dump.  This took about 10 mins with 1000 versions and used 100% CPU so it would be best to perform this outside of normal work hours.  You have been warned!

I then used svndumpfilter (tutorial) to filter just for the ClientA folder (see folder tree above):

svndumpfilter include clientA < repo.dump > clientA.dump

If you have nested repositories, then it breaks with a syntax error.  To get around this you need to run the dump multiple times using the ‘exclude’ directive until you have what you want:

svndumpfilter exclude clientB < repo.dump >> clientA.dump
svndumpfilter exclude clientC < repo.dump >> clientA.dump

This didn’t take very long and at the end I had a full svn repository that could be re-created anywhere.  To prove the point I installed SVN on my mac and created the repository.  I then loaded the dump file into it and it worked beautifully ;)

svnadmin create /Users/Dave/ClientA
svnadmin load /Users/Dave/ClientA < ClientA.bak
mkdir /Users/Dave/ClientA-checkout
svn co file:///Users/Dave/ClientA clientA-checkout/

Now that you have checked it, you can delete the whole repo backup file (mine was massive) Repo.svn-dump in my case.

Easy as pie once you know how.  The fact that you can’t specify the filter at dump-time is non-intutative, clunky and frankly a waste of space.  However if you only need to do it once it works and produces a very nice result.  Open Source and Open Standards FTW ;)

 

MySQL Backup Script May 29, 2008

Filed under: *nix,How-to — daveharris @ 12:53 pm

This is a convienct place for me to put stuff that I (or you!) may need in the future. While working at Fronde I wrote this little backup script for the wiki we were using. It is meant to be run on a cron job daily. It makes daily backups and every Friday copies that backup to elsewhere (preferably off disk or off site) and deletes that past week’s daily backups. Before I get flamed in the comments I know that there is AutoMySQLBackup but that is huge and very complicated and I wanted to write it myself! :P

#!/bin/bash
# Wiki Database backup script

# Set up the variables
DB_USERNAME="username"
DB_PASSWORD="password"
DB_HOST="localhost"
DB_NAME="wikidb"
BACKUP_DIR="~/wiki_backups"
ARCHIVE_DIR="~/wiki_backups/archive"
DATE=$(date '+%Y-%m-%d')
OUTPUT_FILENAME="${BACKUP_DIR}/wiki_${DATE}.sql"
ERROR_FILENAME="${BACKUP_DIR}/error_log_${DATE}.txt"
ARCHIVE_FILENAME="${ARCHIVE_DIR}/wiki_${DATE}.sql"
MYSQLDUMP="/usr/local/mysql/bin/mysqldump"

# Dump the wiki db to a file
${MYSQLDUMP} -ac --add-drop-table -u ${DB_USERNAME} --password=${DB_PASSWORD} \
    -h ${DB_HOST} -r ${OUTPUT_FILENAME} ${DB_NAME} &> ${ERROR_FILENAME} 

# If there are errors, then do stuff here...
STATUS_CODE="$?"
if [ ${STATUS_CODE} = 2 ]; then

fi

# If the error log is empty, delete it
numLines=$(cat ${ERROR_FILENAME} | wc -l | sed 's/\ //g')
if [ ${numLines} = 0 ]; then
  rm ${ERROR_FILENAME}
fi

# If today is Friday, put a weekly backup in archives and delete daily backups
if [ $(date +%A) = "Friday" ]; then
  cp -f ${OUTPUT_FILENAME} ${ARCHIVE_FILENAME}
  rm ${BACKUP_DIR}/*.sql
  #echo $(cat ${BACKUP_DIR}/wiki_${DATE}.sql)
fi
 

Home Sweet Home May 18, 2008

Filed under: San Francisco — daveharris @ 12:44 pm

Well I arrived safe and sound in Wellington this morning.  It was nice to hear kiwi accents again!  It was also nice to go through NZ customs without having to take my shoes off!!!

I had a fantastic time but it is always nice to get home.  Unfortunately I left in 30 degree heat and arrived in Auckland at 5am at 7 degrees, ouch!

Unfortunately I couldn’t get an iPhone as they were all sold out from the Market St Apple Store and the online store.  The 3G iPhone must be just around the corner…  The consensus is that it will be announced that the keynote of WWDC which starts early June (at the Moscone Centre!).

I’m not really looking forward to going to work tomorrow… Speaking of which I should pimp Fronde.  If you want application development, visit http://www.fronde.com

I have added more photos to the Yosemite and Cycling albums also

Thanks for all your comments and I will see most of you soon…

 

Two hot days May 18, 2008

Filed under: San Francisco — daveharris @ 12:35 pm

The last two days in San Fran were unbearably hot, upwards of 36 degrees!!  On Thursday I took a nice ride on a catamaran.  The photos are here.  That made the heat bearable, but typically there wasn’t really enough wind!!  No one knew what to do with themselves so most were lying under trees in the park…

On Friday I took the tram on the steepest line, California Street.  I then had a look around Chinatown.  SF has the biggest Chinatown outside of China itself.  There were heaps of little stores selling all sorts of things, I could even buy a Samurai sword, I was kinda tempted.  Everything was really cheap, about half price of the other stores on Fisherman’s Wharf!  I then went up to the famous Castro district which is famous for being the gay and lesbian capital of the world.  The day before, California made it legal for same sex couples to marry (to much opposition) and so the streets were decorated and people were still celebrating.  But it was again about 35 degrees so it was too hot to do anything.  It seemed that most people were sitting under the trees in Union Square, or shopping in the air conditioned boutiques!  The photos are here.

I flew out Friday night SF time…

 

Yosemite May 16, 2008

Filed under: San Francisco — daveharris @ 5:34 am

So after yesterday’s exploits on the bike, I really didn’t feel like getting up at 6am to go to Yosemite, but I knew that I would be thankful later!

We left at about 7.30am and arrived at Yosemite at 1.30pm, a long trip. We parked pretty much right under the falls and stepping out of the a/c couch, the heat hit like it does getting off the plane in Singapore or something. It hit 32 degrees there because it is more inland, it would’ve got much higher but we were at 5000 feet above sea level! I can’t describe in words how awe inspiring this place is, my photos definately can’t do it justice but here they are. I took about 200 photos, so these are just a sample.

Nothing can do this place justice. The height of El Capitan is just astonishing, and people actually climb up there (the shortest time is 4 days!). We stopped and looked at some smaller waterfalls up close on the way and then a good viewing spot for El Capitan and Bridalveil Falls. We had 3 hours on our own after we arrived and I spent most of that at the largest Yosemite Falls. There was a track to the top that took 3 hours that I wanted to do but didn’t have enough time or energy after yesterday! They have a free shuttle service to take you around the park and the visitor centre had a good video. I couldn’t resist some professional photography so got a large postcard of the falls.

They are going a lot of work on the road and so we were stuck in traffic for about an hour or so. Thankfully we had air conditioning. The driver could tell we weren’t getting anywhere fast se he took us up to Inspiration Point where you can see all the major attractions. He said that it was probably the most photographed spot in the US if not the world.

As it happened there was a kiwi couple on the tour also (yes, its a very small world) so we took each others photos so there are more of me this time ;)

I got back to the hotel at about 10.30pm so it was a very very long and hot day. As we crossed the Oakland bridge at about 10pm, it was still 28 degrees!!!!

So it is now Thursday morning and I finally have internet access so I can post this and the photos. It is meant to reach about 35 degrees here today. It is very hot already so I am doing to find a tree at Fisherman’s Park and get some reading done and then go on the yacht this afternoon. I need a break, its been a very busy few days!

Well last full day in SF, and its a hot one! ;)

 

Biking to Sausilito (and beyond) May 16, 2008

Filed under: San Francisco — daveharris @ 5:11 am

This morning the weather forecast said that a heat wave was coming so I had to shuffle my plans around. I was planning to go to Yosemite on Wednesday and then do the biking on Thursday but it is meant to be 30+ degrees on Thursday so I went today instead.

As I said before, there are many people that ride to Sausiltio and catch the ferry back to San Fran. I thought that was winmping out a little to be honest, and I was going for a ride not to see Sausilito. I managed to find a place that hired out road racing bikes so there I was riding down Fisherman’s Wharf (on the (my) wrong side of the road) headed for the GG bridge. Photos are here. I looked at the map and found that Sausilito was only 13km but Tiburon was another 13km round the coast. There was a ferry headed back from there if I felt tired, but I wanted to ride there and back. Even though the heat wave hadn’t officially started yet, the temperatures were easily hitting 28 as I rode into Tiburon, completely wasted. I wasn’t sure exaclty where I was going and was following the cycle way hoping I would make it.

Speaking of cycleways, they are everywhere here and really well used. They are nice and smooth too which is a change from the roads which are even worse than ours. And I was riding this awesome racing bike so I felt every single bump!

Anyway, I eventually arrived at Tiburon and found a sleepy Italian town just waking up at 1pm. I found this awesome Italian panini place and after cooling down I decided that catching the ferry back was wimping out and I had like 6 hours to make it back. The temperature got even hotter though, one side said it was 33 (of course everything is in Farenheit so 101 degrees doesnt really mean anything to me, but 90 is 30 and HOT!). I did contemplate getting the ferry from Sausilito, but I only needed to cross the bridge and I was basically there. Being the stubourn rider (thanks Dad!) I rode on and up the massive hill to the bridge. I was about ready to collapse when the freezing (and I mean freezing) wind off the sea arrived at the entrance to the bridge. So that is why I look so wasted here. I got back in plenty of time and bought a tshirt saying I had ridden across the GG bridge! I had a speedo too (but it was all in miles was was kinda useless) and my total was 42 miles (68km) .. so thats why I was so tired. Not sure where the 13 + 13km came from (yes that was km’s not miles)

I got a pizza from this awesome little places up the road called Uncle Vito’s and ate it all in one sitting and was almost too tired to sleep. I think I overdid it … ooops! ;)

Photos are here

 

 
Follow

Get every new post delivered to your Inbox.