Tom's Blog


Array split into groups of specific length in JavaScript


In this post, I am sharing a few methods of converting a one-dimensional array into a two-dimensional array with a specific number of items in second level arrays.

Disable title and subtitle in Highcharts


In this post, I am sharing wow to disable title and subtitle with Highcharts JavaScript chart library.

Column or tooltip label change in Highcharts


Highcharts library allows for a high number of customizations. One of the most common customizations problems is to change tooltip or a column label. In this post, I am sharing a quick way of changing column or tooltip label in Highcharts.

Customization of title and subtitle in Highcharts


In this post, I am sharing how to customize title and subtitle in Highcharts JavaScript chart library.

String split into n-character long tokens


In this post, I am sharing how to split a string into tokens which are of N characters in length. That might be very handy when it comes to number formatting e.g. Separate a number in decimal format with thousands delimiter, from 1233232 to 1,233,232 Separate a number in binary format every fourth digit (a single byte), from 1011010010101001 to 1011 0100 1010 1001 Separate a number in hexadecimal format every second character, from 0xfab22883b0ada0 to 0xfa b2 28 83 b0 ad a0 For that purpose we can use the following regular expression .

Number formatting in JavaScript


There are many different ways of printing an integer with a comma as a thousands separators in JavaScript.

Useful things spring expression language SpEL


In this post, I would like to share several useful things about Spring Expression Language which can help you with Spring framework configuration. Spring XML wiring style is sufficient in most cases. Sometimes, however, you need to perform wiring that is much more difficult or sometimes even impossible without writing extra Java code, e.g., convert a string value to the upper case, calculate a numeric value, etc.

Character set conversion on Linux / Mac OS


The easiest way to convert characters set on Linux or Mac OS systems is to use iconv program. The iconv program converts text from one encoding to another encoding.

Thymeleaf HTML element replacement


When building HTML templates with Thymeleaf template engine, you may end up with a situation where an HTML element needs to have the text coming from localization resources, but also it needs to have some additional child elements which can’t be replaced during template rendering. One of the examples could be Bootstrap and its page header.

WebStorm IDE & Java SE 1.6 on Mac OS


In this post I am sharing how to setup WebStorm IDE with legacy Java SE 1.6 on Mac OS.

Sails v0.10 middleware customization


In this post, I would like to share how to customize Express server in Sails version 0.10.

Heroku Dyno instance identifier


In this post, I am sharing how to identify a Heroku dynos from within your application. In many cases, well-written cloud applications do not need to know what Heroku dyno is handling a request. However, sometimes that knowledge is essential.

Remove decimals from currency in AngularJS


AngularJS provides currency formatting filter which converts numbers into locale specific currency string e.g. 123.50 number converts to $123.00 for en-US locale or 123,50 € for fr-FR locale. But what to do if I would like to perform currency formatting without the decimal (cent) part, e.g. $123 or 123 €?

Session cookie expiration in Sails


When you generate new Sails application, session use transient (aka session) cookies. In most cases, web browsers usually delete transient cookies when the user closes the browser. As the cookie is deleted, users session is terminated. In some cases, this is desired behavior, but sometimes it is required that session expires within a specific time of application inactivity.

Java 8: conversion between new and old time API


Among plenty of improvements, Java 8 came with an entirely new API for dates, times, instants, and durations (java.time package). However, there are thousands of projects that use the legacy java.util.Date for date and time presentation purpose. As Oracle did not provide any direct way of converting between java.time and java.util.Date class, I would like to share with you some ways of doing so. The conversion itself is not very complicated; however, it might be a bit confusing as we are converting between java.util.Date, which stores time zone information, and java.time.LocalDateTime / java.time.LocalDate which do not store time zone details at all.

Platform-dependent newline character in Java


In many situations, you may need to use platform-dependent newline character in Java. There are several ways you can get that value, depending on the Java version you are using.

Security scheme in JIRA


In this post, I would like to share a way of applying a security scheme to a JIRA project using SQL. In many cases, you will not have to do that as JIRA administration console works perfectly fine in that respect. However, in my case, I needed to apply a security scheme to an existing project which had over 110,000 issues. I eventually managed to do that via JIRA administration console but in order to achieve that I had to add extra GB’s of RAM to my system (it may not be possible in many cases, especially if JIRA runs on 32-bit system) and the process itself was very time consuming, it took around 30+ hours. Application of a security scheme via SQL was a way quicker and completed in about 30 min.

Maven fix to use default Java version on Mac OS X


Recently I installed Maven 3.2.1 on Mac OS X and discovered that Maven did not use my default Java version (set to 1.7). Instead, it was using Java version 1.6. The java -version command was giving following output: java version "1.7.0_51" Java(TM) SE Runtime Environment (build 1.7.0_51-b13) Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)

Filters in controllers in AngularJS


In this post, I am sharing how to use a filter in a controller in AngularJS. A straightforward way of injecting a filter is to inject dependency with the name composed of the filter name and the Filter suffix: <filterName>Filter. E.g., the dependency customFilter injects custom filter. The injected component is a filter function. Note that you can use this approach to inject filter also to services and directives.