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



 

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)