Grails Bootstrap Form Field Error Template

Define a Grails template in /layouts/_formFieldError.gsp
<div class="form-group has-error">
<g:hasErrors bean="${fieldModel}" field="${fieldName}">
<div class="errors">
<g:eachError bean="${fieldModel}" field="${fieldName}">
<span class="help-block"><g:message error="${it}"/></span>
</g:eachError>
</div>
</g:hasErrors>
</div>

Usage
<g:render template="/layouts/formFieldError" model="[fieldModel: myModelObject, fieldName: 'myFieldName']" />

Posted in Programming | Tagged , , | Leave a comment

Making Sure Our Technical Communities Are Safe Spaces For All

The number of technical user groups in South Africa has grown and we’ve now got several vibrant communities. Which is awesome!

If we want to make sure our communities continue to be as awesome and welcoming as they are, we need to take steps to ensure our events and on-line spaces stay safe. The easiest of which is the implementation and enforcement of an anti-harassment policy.

How easy is it? You can lift, almost word for word, a policy from the Geek Feminism Wiki. We’ve done so at the Jozi JUG.

If your group hasn’t instituted an anti-harassment policy, email the organizers and let them know they need one and where to get it!

Duke gives the thumbs up to safe communities

Duke gives the thumbs up to safe communities

Posted in Event, Programming | Leave a comment

August Jozi JUG – Docker and MongoDB

Want to learn all about Docker? Then come to the August Jozi JUG! RSVP and details on Meetup.

Docker

Docker

New to Java and keen on learning about MongoDB? The Next Gen talk is just for you! RSVP and details on Meetup.

MongoDB

MongoDB

 

Posted in Event | Tagged , | Leave a comment

June Jozi JUG – Javascript, Nashorn and Project Avatar

The June Jozi JUG will take place on 30 June at BBD from 18:00. So come through for great presentations as well as free food and drink. To RSVP please go to the groups Meetup page.

Next Gen : The Jozi JUG Code Dojo Second Kata

The Jozi JUG code dojo’s second white belt kata will be explained.

The Dojo is a totally free place where new Java developers in South Africa can learn modern techniques of the Java ecosystem.

The kata includes explaining the code of the first kata, modifying the program and pushing the code to github.

Come on over!

Come on over!

History of JavaScript and new exciting features of Nashorn and Project Avatar

JavaScript is all the rage! If you have not heard of node-this-node-that there where have you been?

Not to want to miss all the attention, Oracle has put its brightest minds in upgrading Java’s JavaScript engines with 95% Java-To-Node compatibility.

Join Rory as we discover the history of JavaScript and the new exciting features of Nashorn and “Project Avatar”

See you there!

Posted in Uncategorized | Leave a comment

My Latest Venture – Space For Africa

What do you do if you’re an entrepreneur, design professional or the like without permanent offices but a coffee shop just won’t do for your next meeting? You go to Space for Africa where you can:

Find meeting rooms, private offices, co-workspaces and more to book by the hour. All in real time.

And what do you do if you want to earn money from your unused meeting rooms or office space? You register with Space for Africa.

It’s my latest venture and I look forward to sharing it with you!

Is this where you'll give your next presentation?

Is this where you’ll give your next presentation?

Posted in Business | Leave a comment

AngularJS – Format Cents As Monetary Unit (Dollars, Rand etc)

1. Create a filter

app.filter('MonetaryUnit', function () {
    return function (amount) {
        return (amount / 100).toFixed(2);
    }
});

2. Apply filter to field

{{someField | MonetaryUnit}}

For example, if someField has a value of “2000” it will render as “20.00”.

Posted in Programming | Tagged | Leave a comment

May Jozi JUG – Code Dojo and Open Source Contributions

The Jozi JUG is hosting their May event on Monday the 26th. There will be two tracks on the evening, so there’s something for everyone. What are you waiting for? RSVP today!

A big thank to Oracle for hosting and sponsoring the evening. The JUG wouldn’t be the success it is without their continued support.

Next Gen : The Jozi JUG Code Dojo
The Jozi JUG is introducing a new format to improve beginner Java skills and inspire a love for technology in South Africa.

The Jozi JUG code dojo will be announced and the first white belt course will be explained.
(100% for free, no catch!)

Karate Kid - http://springfieldpunx.blogspot.com/2010/03/wax-on-wax-off.html

Karate Kid – http://springfieldpunx.blogspot.com/2010/03/wax-on-wax-off.html

Open Source Contributions
There will be three lighting talks from members about their open source contributions:
OASIS Open and B2B Messaging – Theo Kramer
Introduction to Dipforge – Brett Chaldecott
Spring Data RDF – Corneil du Plessis

Mr Miyagi - http://springfieldpunx.blogspot.com/2010/03/wax-on-wax-off.html

Mr Miyagi – http://springfieldpunx.blogspot.com/2010/03/wax-on-wax-off.html

Posted in IT, Programming | Leave a comment

IT Cuties and Code Babes – Why Oh Why?

An acquaintance of mine posted a link to the IT Cuties site. The description is “Programming tutorials hosted by cute girls”. Not women, but girls.

This led me to discover the even more explicit Code Babes where you can learn to code while “checkin’ out babes”. You can go from virgin to advanced in the subject matter. Yeah, subtle.

Source - http://knowyourmeme.com/memes/facepalm

Source – http://knowyourmeme.com/memes/facepalm

Most programmers are male and we’ve managed to entrench sexist behaviour into our culture. The above sites are clear examples of that sexist drivel. If you care about our industry at all, please don’t support the behaviour and call it out when you see it.

Handy tip – If you link to a site and don’t want that to help it’s page rankings, be sure to include nofollow in your links.

Posted in IT | Tagged | 2 Comments

HMAC SHA512 in Java

When doing some research on authentication tokens I came across the post Don’t Hash Secrets and learn’t of a few new things, one of which was HMAC: Hash-based message authentication code.

I use Google Guava for some utility functions, but it doesn’t have a built in HMAC function. The code below still uses Guava for BaseEncoding.

private static final String DEFAULT_ENCODING = "UTF-8";
private static final String HMAC_SHA512 = "HmacSHA512";
 
public static byte[] hmacSha512(String value, String key){
    try {
        SecretKeySpec keySpec = new SecretKeySpec(
                key.getBytes(DEFAULT_ENCODING),
                HMAC_SHA512);
 
        Mac mac = Mac.getInstance(HMAC_SHA512);
        mac.init(keySpec);
        return mac.doFinal(value.getBytes(DEFAULT_ENCODING));
 
    } catch (NoSuchAlgorithmException e) {
        throw new RuntimeException(e);
    } catch (InvalidKeyException e) {
        throw new RuntimeException(e);
    } catch (UnsupportedEncodingException e) {
        throw new RuntimeException(e);
    }
}
 
public static String asHex(byte[] bytes){
    return BaseEncoding.base16().lowerCase().encode(bytes);
}

I used the HMAC Generator / Tester Tool to generate test data.

Posted in Programming | Tagged , , , | Leave a comment

Submit HTML form using AngularJS

The payment gateway I’m integrating with requires a post from a form to navigate to their payment page. Some of the information I need to post is dependent on the results from a call to my back end server.

My first attempt was to invoke my controller from a regular JavaScript function called in onsubmit. However, as all $http calls in AngularJS are asynchronous there was no way to wait for the result of my back end server call before either allowing or blocking submission of the form.

The approach that worked was to create the form without an action or method. When the ‘submit’ button is clicked, the controller function (createPaymentAndNavigate) is called. This does the call to the back end, in the success callback sets the action and method on the form, and then submits the form.

HTML

<form id="bookingForm" name="bookingForm" novalidate >
...
<button class="btn btn-success btn-lg pull-right" ng-click="createPaymentAndNavigate(bookingForm.$valid)">Payment</button>
...
</form>

Success callback in AngularJS controller

var bookingForm = document.getElementById('bookingForm')
bookingForm.action = "https://www.example.com/xyz/process.trans";
bookingForm.method = "POST";
bookingForm.submit();
Posted in Programming | Tagged , | Leave a comment