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

Xamarin View Fails To Bind To Model

MvxBind:Warning: 9.81 Unable to bind: source property source not found Property:SomeObject on null-object

One of the causes of the above error is mixing up the order of base.OnCreate and SetContentView calls in the Views OnCreate method.

Below is an example of the correct order.

protected override void OnCreate(Bundle bundle)
{
    base.OnCreate(bundle);
    SetContentView(Resource.Layout.MyLayout);
}
Posted in Programming | Tagged , | Leave a comment

5 Minute NLog Wrapper: Limiting The Number Of Emails Sent

If you’re using an Email target to send notifications when an error occurs, it may be useful to limit the frequency of those emails. One way of achieving this is to wrap your target that sends email in a Wrapper target. This custom target will intercept calls to the Email target and, based on the time since the last email was sent, either pass on the log event to the wrapped target or swallow it.

[Target("FrequencyWrapper", IsWrapper = true)]
public class NLogFrequencyWrapper : WrapperTargetBase
{
    private DateTime _lastLogEventOccurredAt = DateTime.MinValue;
 
    protected override void Write(AsyncLogEventInfo logEvent)
    {
        if ((DateTime.Now - _lastLogEventOccurredAt).TotalMinutes >= MinLogIntervalInMinutes)
        {
            _lastLogEventOccurredAt = DateTime.Now;
            this.WrappedTarget.WriteAsyncLogEvent(logEvent);
        }
        else
        {
            logEvent.Continuation(null);
        }
    }
 
    [DefaultValue(30)]
    public int MinLogIntervalInMinutes { get; set; }
}
<extensions>
  <add assembly="MyAssembly"/>
</extensions>
 
<target name="limitedEmail" type="FrequencyWrapper" minLogIntervalInMinutes="40">
  <target name="email" xsi:type="Mail"
      ...
  />
</target>
Posted in Programming | Tagged , | 3 Comments

JEE7 Launch with Arun Gupta

The Jozi JUG is hosting Arun Gupta on 26 August for the launch of JEE7. You can RSVP on Meetup. See you there!

Arun Gupta will be flying in (not to Waterkloof) to give a presentation to the Jozi JUG on all the new goodness in JEE7. It’s not often we get international speakers, let alone of this caliber, so this one is not to be missed!

About the speaker:
Arun Gupta is a Java EE & GlassFish Evangelist working at Oracle. Arun has over 14 years of experience in software industry working in various distributed computing technologies, Java(TM) platform, and several web-related technologies. In his current role, he works very closely to create and foster the community around Java EE & GlassFish and related technologies.

To find out more about Arun, head over to https://blogs.oracle.com/arungupta/

Duke says... thumbs up to Arun!

Duke says... thumbs up to Arun!

Posted in Uncategorized | Leave a comment