Saturday, August 02, 2014

HTTP User agent string

When designing web pages we have to be careful of various browsers different ways of interpreting the specification. Traditionally developers read the HTTP_USER_AGENT when the user connects to the server and then send that user content that matches the browsers ability to display. Over the years things have gotten better, Internet Explorer is moving to be standards compliant and thats a good thing.

This recent article points out that Microsoft are putting the words "like Gecko" in its user agent string, so that web servers send them content that is meant for the Firefox browser. Rather than content that was designed for older versions of Internet Explorer. This of course is wrong, claiming to be something you're not could cause other bugs, Microsoft have weighed up the balance of cost/benefits and decided to go ahead. Fair enough, but what is the real solution?

Well whenever you have to do something its best to look around to see what others are doing. If you look over at the OpenGL graphics extensions you see that, whilst the specification has a version number with a set of features, as a programmer I can check to see if a particular extension is actually implemented before I try and use it.

This coupled with a version number could help developers build standards compliant sites but also future proofing them. That way as a browser evolves it gets to either implement its own specific extensions or standards compliant. Everybody using the standards compliant should expect the same on all platforms.

Tuesday, June 24, 2014

The living wage failure

There has been growing talk of paying a living wage:

The concept irks me, businesses voluntarily paying good wages is like businesses volunteering to pay tax. Many millionaires have stated they don't mind paying more tax, just they don't want to pay more then their peers.

The living wage is the same problem, you've either got to make it the national minimum wage or not bother.

Personally I would prefer to see the wage increased so we can do away with Working Tax Credit which is at the end of the day a benefit from the state to the shareholders of low paying companies.

Saturday, April 12, 2014

USB Wakeup

Further to my earlier post on this, I tried setting up a udev rule so I created the following in /etc/udev/rules.d/90-hid-wakeup-enable.rules

# USB hub
SUBSYSTEM=="usb", ATTRS{idVendor}=="1a40", ATTRS{idProduct}=="0101" RUN+="/bin/sh -c 'echo enabled > /sys$env{DEVPATH}/../../power/wakeup'"
SUBSYSTEM=="usb", ATTRS{idVendor}=="8087", ATTRS{idProduct}=="0024" RUN+="/bin/sh -c 'echo enabled > /sys$env{DEVPATH}/../../power/wakeup'"
SUBSYSTEM=="usb", ATTRS{idVendor}=="1d6b", ATTRS{idProduct}=="0002" RUN+="/bin/sh -c 'echo enabled > /sys$env{DEVPATH}/../../power/wakeup'"
SUBSYSTEM=="usb", ATTRS{idVendor}=="1d6b", ATTRS{idProduct}=="0003" RUN+="/bin/sh -c 'echo enabled > /sys$env{DEVPATH}/../../power/wakeup'"
# logitech keyboard
SUBSYSTEM=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c52b" RUN+="/bin/sh -c 'echo enabled > /sys$env{DEVPATH}/../../power/wakeup'"

Which enabled most of the device tree for wake up but for some strange reason when I checked on the status it will still reporting one as disabled:

[[email protected] ~]# find /sys/devices/pci0000\:00/0000\:00\:1a.0/usb1 -iname wakeup -exec cat {} \; 

Ok, so who was the odd one out:

[[email protected] ~]# find /sys/devices/pci0000\:00/0000\:00\:1a.0/usb1 -iname wakeup

A quick enable:

echo enabled > /sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.6/1-1.6.2/power/wakeup

And the keyboard is once again resuming...

Monday, January 20, 2014

Windows Server and the Task Scheduler Error Code 0x3

Wow, so again this is me documenting a problem I've had. Recently I was asked to diagnose a problem with a Windows Server 2008 on which its scheduled tasks were failing with the helpful error 0x3.

So what does 0x3 mean? Well according to Microsoft it means:

"The system cannot find the path specified."


Given that the paths were there and that up until midnight the tasks were running fine this lead to a problem. So I checked the following:

1, Can I run the task manually?
2, Can I run the task in the "Only if user is logged on" mode
3, Has the anti-virus done something?
4, Is there anything in any of the event logs for the last 24 hours that relates to this?

Nothing appeared to offer a reason for the failure. I ended up doing the thing I hate the most and that was scheduling a reboot. Once the server came back up the tasks sprang into life. If anybody knows what happened, please let me know.

Sunday, December 29, 2013

IDE's and speed

I am a big fan of the the command line and keyboard shortcuts, however the one thing I've never managed to  do it move away from a graphical development environment. Eclipse, Visual Studio, Notepad++ and in the last few years QtCreator have all delivered exactly what I needed. However I always felt they might not help me work at my best, I always ran compiles via the command prompt and always had a strong grasp of scripting and the ability to reproduce my steps for a build machine.

Editors like vi and Emacs always seemed non-intuitive to me, holding legacy with keyboard sequences such as :w! always grated at me.

So for 2014 one of my new years resolutions will be to find the right text editor for me, starting with the one I use the most nano. I've found some cool syntax highlighting and I've just got to find function lookup or code completion to make it ideal.

Saturday, December 07, 2013

One of my new years resolutions - done

So one of this years New Years resolutions was to be an open source developer. As part of that I am spending time writing software, today I created a tool which I know I'll use myself:

Offline Sitemap generator:

Its a small command line utility that allows me to create a sitemap file for my websites. Sitemaps files are used by search engines to know what pages they need to look at. With the advent of access to content delivery networks (CDN) such as Rackspaces Cloud files, it means I can quickly and cheaply use a distributed network of servers to deploy my websites.

If anybody wants installers, then let me know. It should run on Windows, Mac and Linux.

Wednesday, November 20, 2013

KDE and the Windows key

By default the KDE Application launcher doesn't have its pop-up mapped to the windows key like Windows or Gnome does. This was a a constant pain because I am so used to just hitting that key. I understand that KDE wanted to use the key as a modifier like the CTRL and ALT keys but I already have those two modifiers. So I found this:

Basically I'll repeat the important bit it here in case it gets lost to time:

"unless you configure the Win key, it acts as a Meta modifier by default, and cannot be used as a shortcut. To change this, create a file ~/.xmodmap and put the following in the file:
keycode 115 = F14
This makes your system think the Win key is actually the F14 key. Note: different keyboards sometimes have different key maps for the Win key (i.e. on my Thinkpad, the keycode for the Win key is 133). You can use the application "xev" from the terminal to determine which keycode applies to your keyboard.
You can modify the file
and add the command
if [ -f $HOME/.xmodmap ]; then
/usr/bin/xmodmap $HOME/.xmodmap
to the bottom of the file, which should load your .Xmodmap on startup.
  • Note: you should do the .Xmodmap creation and the Xsession modification and then logout/login (or run /usr/bin/xmodmap $HOME/.xmodmap) before attempting to modify the shortcut key."
By Wesley Burr

Sunday, November 17, 2013

How do I enabled wake from sleep with my Logitech keyboard and mouse?

I recently switched from Ubuntu Linux to Fedora Linux on my main desktop. However in so doing you often lose some of the little custom settings that you configured over the years. For the most part the desktop was back up and running within a few hours, however the resume from sleep when I touch the keyboard was not working. I remembered I had done something to convince Ubuntu to work however I could not remember what. Until now...

So a quick look at what was and what wasn't enabled:
[[email protected] ~]$ cat /proc/acpi/wakeup
Device  S-state   Status   Sysfs node
SMB0      S4    *disabled  pci:0000:00:01.1
USB0      S4    *enabled   pci:0000:00:02.0
USB2      S4    *enabled   pci:0000:00:02.1
US15      S4    *enabled   pci:0000:00:04.0
US12      S4    *enabled   pci:0000:00:04.1
NMAC      S5    *disabled  pci:0000:00:0a.0
P0P1      S4    *disabled  pci:0000:00:08.0
HDAC      S4    *disabled  pci:0000:00:07.0
MXR0      S4    *disabled  pci:0000:00:10.0
BR11      S4    *disabled
BR12      S4    *disabled  pci:0000:00:12.0
BR13      S4    *disabled  pci:0000:00:13.0
BR14      S4    *disabled
BR15      S4    *disabled
BR16      S4    *disabled
BR17      S4    *disabled
Not much to tell me there other than that USB hubs are enabled:
[[email protected] ~]$ lsusb
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 004: ID 046d:c52b Logitech, Inc. Unifying Receiver
Bus 001 Device 003: ID 1a40:0101 Terminus Technology Inc. Hub
Bus 001 Device 002: ID 1a40:0101 Terminus Technology Inc. Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Ah, getting warmer. The device is on bus 1 and device 4.

The next bit required a big of detective work but it boils down to this change in the operating system and to how USB works. So now I know that I cannot just enable the USB hub, I've actually got to enable the device and the hub will send it on.
[[email protected] ~]$ ls -al /sys/bus/usb/devices/
total 0
drwxr-xr-x. 2 root root 0 Nov 16 17:42 .
drwxr-xr-x. 4 root root 0 Nov 16 17:42 ..
lrwxrwxrwx. 1 root root 0 Nov 16 17:42 1-0:1.0 -> ../../../devices/pci0000:00/0000:00:02.1/usb1/1-0:1.0                                                        
lrwxrwxrwx. 1 root root 0 Nov 16 17:42 1-1 -> ../../../devices/pci0000:00/0000:00:02.1/usb1/1-1                                                                
lrwxrwxrwx. 1 root root 0 Nov 16 17:42 1-1:1.0 -> ../../../devices/pci0000:00/0000:00:02.1/usb1/1-1/1-1:1.0
lrwxrwxrwx. 1 root root 0 Nov 16 17:43 1-1.4 -> ../../../devices/pci0000:00/0000:00:02.1/usb1/1-1/1-1.4                                                        
lrwxrwxrwx. 1 root root 0 Nov 16 17:42 1-1.4:1.0 -> ../../../devices/pci0000:00/0000:00:02.1/usb1/1-1/1-1.4/1-1.4:1.0
lrwxrwxrwx. 1 root root 0 Nov 16 17:43 1-1.4.2 -> ../../../devices/pci0000:00/0000:00:02.1/usb1/1-1/1-1.4/1-1.4.2
lrwxrwxrwx. 1 root root 0 Nov 16 17:43 1-1.4.2:1.0 -> ../../../devices/pci0000:00/0000:00:02.1/usb1/1-1/1-1.4/1-1.4.2/1-1.4.2:1.0
lrwxrwxrwx. 1 root root 0 Nov 16 17:43 1-1.4.2:1.1 -> ../../../devices/pci0000:00/0000:00:02.1/usb1/1-1/1-1.4/1-1.4.2/1-1.4.2:1.1
lrwxrwxrwx. 1 root root 0 Nov 16 17:43 1-1.4.2:1.2 -> ../../../devices/pci0000:00/0000:00:02.1/usb1/1-1/1-1.4/1-1.4.2/1-1.4.2:1.2
lrwxrwxrwx. 1 root root 0 Nov 16 17:42 2-0:1.0 -> ../../../devices/pci0000:00/0000:00:04.1/usb2/2-0:1.0                                                        
lrwxrwxrwx. 1 root root 0 Nov 16 17:42 3-0:1.0 -> ../../../devices/pci0000:00/0000:00:02.0/usb3/3-0:1.0                                                        
lrwxrwxrwx. 1 root root 0 Nov 16 17:42 4-0:1.0 -> ../../../devices/pci0000:00/0000:00:04.0/usb4/4-0:1.0                                                        
lrwxrwxrwx. 1 root root 0 Nov 16 17:42 usb1 -> ../../../devices/pci0000:00/0000:00:02.1/usb1                                                                  
lrwxrwxrwx. 1 root root 0 Nov 16 17:42 usb2 -> ../../../devices/pci0000:00/0000:00:04.1/usb2                                                                  
lrwxrwxrwx. 1 root root 0 Nov 16 17:42 usb3 -> ../../../devices/pci0000:00/0000:00:02.0/usb3                                                                  
lrwxrwxrwx. 1 root root 0 Nov 16 17:42 usb4 -> ../../../devices/pci0000:00/0000:00:04.0/usb4                                                             
Now all that might look like gibberish but if you follow the links "->" you'll see numbers relating to a device, so I go on the hunt for more information by listing the folders:
[[email protected] ~]$ ls /sys/bus/usb/devices/1-1/
1-1:1.0              bDeviceSubClass     descriptors  ltm_capable  speed
1-1.4                bmAttributes        dev          maxchild     subsystem
authorized           bMaxPacketSize0     devnum       port         uevent
avoid_reset_quirk    bMaxPower           devpath      power        urbnum
bcdDevice            bNumConfigurations  driver       product      version
bConfigurationValue  bNumInterfaces      ep_00        quirks
bDeviceClass         busnum              idProduct    removable
bDeviceProtocol      configuration       idVendor     remove
[[email protected] ~]$ ls /sys/bus/usb/devices/1-1/1-1.4
1-1.4:1.0            bDeviceSubClass     descriptors  ltm_capable  speed
1-1.4.2              bmAttributes        dev          maxchild     subsystem
authorized           bMaxPacketSize0     devnum       port         uevent
avoid_reset_quirk    bMaxPower           devpath      power        urbnum
bcdDevice            bNumConfigurations  driver       product      version
bConfigurationValue  bNumInterfaces      ep_00        quirks
bDeviceClass         busnum              idProduct    removable
bDeviceProtocol      configuration       idVendor     remove
[[email protected] ~]$ ls /sys/bus/usb/devices/1-1/1-1.4/1-1.4
1-1.4:1.0/ 1-1.4.2/   
[[email protected] ~]$ ls /sys/bus/usb/devices/1-1/1-1.4/1-1.4.2/
1-1.4.2:1.0          bDeviceProtocol     configuration  idVendor      removable
1-1.4.2:1.1          bDeviceSubClass     descriptors    ltm_capable   remove
1-1.4.2:1.2          bmAttributes        dev            manufacturer  speed
authorized           bMaxPacketSize0     devnum         maxchild      subsystem
avoid_reset_quirk    bMaxPower           devpath        port          uevent
bcdDevice            bNumConfigurations  driver         power         urbnum
bConfigurationValue  bNumInterfaces      ep_00          product       version
bDeviceClass         busnum              idProduct      quirks
Ah, some manufacturer information.
[[email protected] ~]$ cat /sys/bus/usb/devices/1-1/1-1.4/1-1.4.2/manufacturer
Looks like I found my wireless receiver, a quick look at the product:
[[email protected] phil]# cat /sys/bus/usb/devices/1-1/1-1.4/1-1.4.2/product
USB Receiver
And yes that what I am after, next to check its current power wakeup:
[[email protected] ~]$ cat /sys/bus/usb/devices/1-1/1-1.4/1-1.4.2/power/wakeup    
Bingo! So I tried the standard enable:
[[email protected] ~]$ sudo echo enabled > /sys/bus/usb/devices/1-1/1-1.4/1-1.4.2/power/wakeup                                                                    
bash: /sys/bus/usb/devices/1-1/1-1.4/1-1.4.2/power/wakeup: Permission denied
Bummer....Lets try is a super user:
[[email protected] ~]$ su                                                        
[[email protected] phil]# echo enabled > /sys/bus/usb/devices/1-1/1-1.4/1-1.4.2/power/wakeup
And to check the change applied:
[[email protected] phil]# cat /sys/bus/usb/devices/1-1/1-1.4/1-1.4.2/power/wakeup
Excellent!!! However that change isn't permanent, its just for the lifetime of this kernel boot. So I had to put that line in to the standard /etc/rc.local file. That way it gets applied each boot. 

Sunday, June 23, 2013

Failed to open VDPAU backend in Chromium or Chrome

This morning I finally set down to figure out something that has been bugging me for nearly a year.

Using Chromium on my ubuntu PC I would get a long pause when starting Chromium before a webpage would show, then after about 3 minutes the browser would work and continue as normal. For ages I thought it was this error:

[6684:6705:0623/] Failed to get name owner. Got org.freedesktop.DBus.Error.NameHasNoOwner: Could not get owner of name 'org.chromium.Mtpd': no such name
[6684:6705:0623/] Failed to get name owner. Got org.freedesktop.DBus.Error.NameHasNoOwner: Could not get owner of name 'org.chromium.Mtpd': no such name
[6684:6684:0623/] Failed to call method: org.chromium.Mtpd.EnumerateStorages: object_path= /org/chromium/Mtpd: org.freedesktop.DBus.Error.ServiceUnknown: The name org.chromium.Mtpd was not provided by any .service files

It said error (instead of a warning) so I assumed it was the cause of the problem. However after looking over the message I got after the browser sprung to life I saw this:

Failed to open VDPAU backend cannot open shared object file: No such file or directory


Turns out Chromium is trying to load a video driver for a graphics card I replaced nearly a year ago...

Removing all references to libvpdau from my system using synaptic cured the problem. Woohoo!

This has been a public service announcement.

Thursday, May 16, 2013

Don't call me stupid

These days advice on energy is everywhere. However it is unfortunate that it's exactly the same advice wherever you turn. My energy company just emailed to remind me:

1, "Turn the heating down" - Thanks but given the number of times I've heard this my thermostat is now in negative numbers...

2, "Switch off equipment, don't let it standby, leaving equipment on standby costs the UK almost £1 billion a year" - Given that there are 25million homes in the uk then we can assume that's costing me £40 a year or 77 pence a week to have my items on standby or 10 pence per day to have devices at my beck and call. Which isn't really much of a saving. Especially when you factor in that most standby stuff is actually in businesses not at home...

3, "Insulation" - Durrrr. Insulation is cheap, EVERYBODY has already done it. I have never seen a house without loft insulation and only those homes that cannot have cavity wall don't have it these days.

4, "Use energy saving light bulbs" - Since incandescent bulbs were phased out last year, this is really stupid. Like telling someone "Hay, only buy the light bulbs that you are allowed to buy"

5, "Wash at 30 degrees Celsius" - This is really stupid advice, if you do this with anything other than lightly dirty clothes, they come out all smelling bad and with marks on. Forcing you to wash again.

Energy saving is only a part of the solution, the real thing that needs to happen is investment in new cheap, carbon free energy source. However that would require more work than the marketing department sending out a useless email...