Thursday, 27 December 2012

IE7 and contentEditable

IE7 and contentEditable

Interestingly (I'm playing it rather loose and free with the term 'interestingly' here) I found that removing the contentEditable attribute from some elements cause them to become editable in IE7. The senario is this, HTML comes in, you don't know if it contains contentEditable attributes, but if it does you want to remove them. Run a function on the HTML to remove attributes. This was being done in jQuery.

$("*").removeAttr("contenteditable");

The effect of the above was some elements became editable in IE7, also list-items where missing their markers (common IE behaviour if contentEditable is true) running a function to set the attribute to false...

var els = document.getElementsByTagName("*");
for (var i = 0; i < els.length;i++){
    els[i].contentEditable = false;
}

... this will stop the content from being editable in IE7 but wouldn't fix the missing bullet markers. I still can't find a fix for this, so resorted to cleaning the HTML and stripping out the contentEditable attributes on the server before sending the HTML down to the client. (You can always rely on IE to give you something to do! : )

Also, interestingly *cough*, an embedded browser in a .NET app will use the oldest version of IE loaded on the machine, rather than the newest. So if your client is using IE9, it's still quite likely that they have something like IE7 in your .NET app. Worth setting the metadata X-UA-Compatible to IE=edge, this seems to have the effect to force the system to use the latest installed version of IE.

<meta http-equiv="X-UA-Compatible" content="IE=edge" />
As the above may cause validation errors, you might want to put this in your apache config instead...

Header set X-UA-Compatible "IE=edge"

Where ever you set this header, remember where it is, I have a nasty feeling it'll need editing at short notice at some point in the future!




Monday, 17 December 2012

Brr, it's cold in here...

It was the Crisis Mid-winder swim on Saturday which involves a quick dip in Brockwell lido. The water was crystal clear, blue and a sharp 4 deg C.



Creating an Ubuntu 12 launcher for Chrome to use a proxy-server.

To create a new launcher...
  1. Type 'menu' into the Dash dialogue (alt + F2) this should bring up the Main Menu manager
  2. Select Internet from Menus
  3. Highlight Chromium Web Browser and select Properties, leave that open so you can duplicate it 
  4. Create a new menu item and duplicate the existing menu item, call it something sensible though
  5. Add what ever options you require and close


That should be it, now you can search for your launcher in Dash. You'll need to close any open chrome browsers before launching a new one. Using this method means you don't need to change your proxy settings globally and you can set up a load of links using different proxies to run as and when needed.

Saturday, 24 November 2012

Quote of the day...

Angry work colleague...   "THAT'S WHY I HATE WINDOWS!"
Me... "Why?"
Angry work colleague...   "BECAUSE IT'S SHIT!"

Well thought out, considered opinion!

On an XSLT related issue, I had to count the number of items starting with a given letter or number for an A to Z. We can find all the items starting with any given character using starts-with(). In the cace of counting elements which start with a diget we need to do it slightly differently...

<xsl:param name="lcase">abcdefghijklmnopqrstuvwxyz</xsl:param>
<xsl:param name="ucase">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:param>
<xsl:param name="digits">1234567890</xsl:param>

<!-- return the number of books whose name starts with any given letter -->
<xsl:template name="alphabet_counter">
        <xsl:param name="letter" />
        <xsl:value-of select="count(/books/book[starts-with(translate(name,$lcase,$ucase), translate($letter,$lcase,$ucase))])"></xsl:value-of>
</xsl:template>

<!-- return the number of books whose name starts with a number -->
<xsl:template name="int_counter">
        <xsl:value-of select="count(/books/book[contains($digits, substring(name, 1, 1) ) ])"></xsl:value-of>
</xsl:template>

Saturday, 10 November 2012

Add Open terminal here to IntelliJ

Tip of the day, add "Open terminal here" to context menu in IntelliJ (11.1) running on Ubuntu (12).

If like me, your missing the option to open a terminal from the context menu, this can be added quickly by adding an external tool;

  1. File > Settings > External tools
  2. Add, opens an add/edit tool form
  3. Put in a suitable name, deselect the Synchron... and Open console checkboxes
  4. Select where you want it to show up in the 'Show in' section
  5. In the 'Tool Settings' section, add "gnome-terminal" as the Program and "$FileDir$" as the Working Directory
  6. Click OK 
That's it, you should now have the option in your right click context menu. Simples.

In Mac OS it's a little different, try putting "open" as the Program and $FileDir$ -a Terminal as the Parameters, worked for me on OSx 10.9.2



Wednesday, 31 October 2012

mac mini, how do I xxxx thee? Let me count the ways...

In case, like me, you put a CD/DVD into your mac mini and it doesn't appear on the desk top, to eject follow this simple set of instructions...
  1. Search internet for help
  2. Try opening itunes to see if you can eject from there
  3. Try opening a terminal and typing "drutil tray eject"
  4. Try restarting computer holding down the mouse button
  5. Try the above another couple of times, just in case
  6. Try restarting the computer holding down the option key (I might be wrong but I think the 'option' key is the one with 'alt' written on it) when you see the startup selection screen, press eject key on the keyboard (if you have one)
  7. Repeat the above a couple of times 
  8. Try restarting the computer holding down the key combination... Command-Option-O-F (the command key, might be the one with the apple logo on it)
  9. Try the above a couple of times, try holding down the keys, try repeatedly pressing them, if you ever see a command prompt on the screen you've found the Open Firmware prompt, try typing in "eject cd"
  10. Try restarting your computer and doing nothing at all for 15 mins, you never know, magic might happen, it might just eject itself
  11. Admit defeat, there is no software related way of getting your CD back.
  12. Unplug the computer, leave it for a coule of mins, turn it over and using a kitchen knife pry the casing away from the base
  13. Ease the casing off the computer, the CD housing is at the top, remove the four screws holding the top of the CD case in place and slide out your CD
  14. Replace the screws 
  15. Replace the casing 
  16. Plug in everything and turn back on, job done, I can now return the CD to the library  
  17. At this point I'm not sure if i should put an unwanted disk into the mac, to ensure I never put something I actually need in there again. Maybe something that humanity would be better off without, like Sex in the City 2?


Saturday, 27 October 2012

11.9 °

After a number of years of hardly going swimming at all, I started going to Brockwell lido at the end of the summer. It's unheated and starting to get quite cold, it's been around 13 to 14 degrees, but this morning it was a crisp 11.9°c (34°f). Luckily the Gym/Spa has a open weekend so after the pool you can sit in the spa and recover! Recommend : )
Apart from that its been ISO-9001 this week, happy to say that we passed with flying colours! Go team Map : )

Sunday, 21 October 2012

The Bree Louise

The Bree Louise pub at Euston is a place I've walked past many a time, but never ventured into. Normally I'm heading for Diwana around the corner in Drummond St. a veggie restaurant from the era when veggie resturants where few and far between.  The other day I was heading for the Bree Louise to meet a friend, who as it turned out didn't show up while I was there. I did find a spaniard and an american to talk to though, so not all was lost! And the pub, a dusty, old-school pub with fantastic selection of ales. recommend : )

I finally decided enough was enough today and I'd put my mind to getting Tomcat debugging to work in IntelliJ, something I've always meant to do, just never got round to.

Firstly I needed need to get Tomcat Server to show up in Run/Debug Configurations and Application servers to show up in Settings > IDE Settings . It wasn't there so I went to Settings > Pluggins and and enabled Tomcat integration. After the IDE restarted I added my Tomcat to the Applications Servers section by opening Settings > Application Servers > Add, it asked me for my Tomcat home and base directories ("tomcat home" where the bin is and "tomcat base" is where the "webapps" directory is, on my deployment the conf director was in base location and IntelliJ was expecting it to be in home, so I had to symlink it in).

Then selected the Run/Debug Configurations menu, clicked Add, selected Tomcat server (local in my case), give it a name and leave the defaults as they are.

I needed to create an artifact in Project Structure to link to my tomcat webapp. This was a simple task of choosing Add >Web Application Exploded an adding the source folders.

I needed to tweak some stuff to get tomcat to play nicely, IntelliJ wanted to start tomcat by running ./catalina.sh run, starting tomcat this way was giving me Tomcat – Java.Lang.OutOfMemoryError: PermGen Space error, in the end I added this to the catalina.sh file
JAVA_OPTS="-Xms536m -Xmx1024m -XX:PermSize=256m 
-XX:MaxPermSize=256m $JAVA_OPTS"
probably not the best way of doing things, but it did sort out my start up issues!
All this required a lot of starting tomcat, a quick way to find tomcat process id in order to kill it (presuming your running on 8080)
$ sudo netstat -lpn |grep :8080
tcp6  0  0   :::8080    :::*   LISTEN   6447/java
$ kill 6447 
or  $ kill -9 [proc id] if your hard core!

Anyway, debugging is now working, I haven't explored all the options but did check the "persist sessions" checkbox which means you can pick up where you left off between restarts which is magic! And, hot swapping seems to work (on occasion).

Why didn't I get this sorted ages ago?!




Saturday, 13 October 2012

Veg dumplings

Itsu round just the corner from work in Fetter lane do very fine veg dumplings, i'm not normally a one for the chains, but have to say... yum.

I was struggling for a while, trying to copy an action in PhotoShop (CS3), it turns out all you need to do is drag it onto the "Create new action" icon and boom!

Another thing that turns out to be quite easy is formatting a date from a string in jsp, in the example below the "published" variable is a string, the pattern attribute on the parseDate tag must match the format of your string, after that you have a date object variable which you can format using the formatDate tag.

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>


<c:set var="published" value="2012-10-01 12:24:09.263" />

<fmt:parseDate 
    value="${published}" 
    pattern="yyyy-MM-dd HH:mm:ss" 
    var="publishedDate"/>

<p>Published: 
<fmt:formatDate 
    value="${publishedDate}" 
    type="date"
    dateStyle="full"/>
</p>

checkout http://www.tutorialspoint.com/jsp/jstl_format_formatdate_tag.htm for more info on what the type and dateStyle attributes do.

Saturday, 6 October 2012

What I learned this week; Ganache

What I learned this week; Ganache

It is possible to ruin a ganache, you stir it like crazy when it still hot! Since I was stuck with it, not having any more cream, I mixed it with a hand blender when it was just getting cool. It didn't have the glossy sheen it should, but made an acceptable covering for the cake.

Also, having had some IE7 problems when loading YUI3 at the bottom of the page I've gone and stuck one in the document head for older versions of IE.

<!--[if lte IE 7]>
    <script 
        type="text/javascript" 
        src="/lib/yui/${yuiVersion}/build/yui/yui-min.js"></script>
<![endif]-->

On a related point, it seems that in IE9 borer-radius is supported, but not in conjunction with a gradient filter, at least not on what I was doing, so decided that I'd rather have the rounded corners than the gradient.

<!--[if IE 9]>
  <style type="text/css">
    #divContainer div.topbar {
        border-radius:10px 10px 0 0;
        filter:progid:DXImageTransform.Microsoft.gradient(enabled = false);
    }
  </style>
<![endif]-->

Saturday, 29 September 2012

What I learned this week; yui3 src

What I learned this week;

Most importantly, keep a supply of something edible, and more substantial than miso soup, at work!

Also, to setup yui3 from src branch in GitHub and download, then follow these steps.... (if you already have git-core and node installed, just run the last 5 or so commands)

$ apt-get install g++ curl libssl-dev apache2-utils then 
$ apt-get install git-core
$ git clone git://github.com/ry/node.git
$ mkdir ~/nodejs && cd $_
$ wget -N http://nodejs.org/dist/node-latest.tar.gz
$ tar xzvf node-latest.tar.gz && cd `ls -rd node-v*`
$ ./configure
$ make install
$ cd /to/your/yui3/
$ npm install
$ npm -g install selleck
$ cd src
$ selleck --server

All being well you should now have a server running on localhost:3000. To update the build folder cd into the individual src folder and run $ shifter, or cd yui3/src and run $ shifter --walk to do the entire thing.

Monday, 9 July 2012

left:-99999999px

*.accessibilityHeader {
   left:-99999999px;
   position:absolute;
}
I put the above in a style sheet the other day and only just noticed that there where no horizontal scroll bars appearing in FireFox.  Fortunately, it didn't take too long to find, apparently it's too big a number, what's up with that!??!

Monday, 20 February 2012

Escaping quotes in XSLT for text used in JavaScript or JSON

XSLT template for formatting javascript safe strings by escaping double quote char " i.e. &quot; or &#34; with escaped version \"

Tuesday, 31 January 2012

IE7 and hasLayout


All these years I've assumed that {zoom:100%;} and {height:1%;} where essentially the same, forcing an element to have layout (hasLayout property). After a very unproductive morning, being made to look foolish by IE7, I finally in desperation changed the zoom directive to height and my clear float hack started working. Note to self, go round the country and personally upgrade all IE6/7 versions to IE9!
 

Note: the opinions on this page don't represent that of my employer in anyway. And, actually only vaguely represent my opinions on the date of publication. (Unlike Ms T, I am very much for turning)