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?!




 

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)