Clear the Secure Enclave if you sell or give away a MacBook Pro with Touch Bar

November 18th, 2017 | #apple #macos

TIL Apple recommends you to clear the Secure Enclave before you sell or give away a MacBook Pro with Touch Bar.

Read more

Passing Default group to form(...) in Play 2.6.x when using group constraints in forms

November 17th, 2017 | #java #playframework

TIL if you pass custom groups to the form(...) method in Play 2.6.x, you also have to pass the group javax.validation.groups.Default explicitly—if you want any of its fields taken into account during the validation process of a form.

Form<FooForm> form = formFactory().form(FooForm.class, Default.class, FooCheck.class).bindFromRequest();
Read more

Do not commit sensitive data to public repositories

November 15th, 2017 | #git #github

Stupid title, right? You probably think it is obvious to not commit sensitive data to public repositories. Well, it is obvious—sort of.

Read more

Make Google Chrome warn you before quitting on Mac

November 13th, 2017 | #chrome #macos

TIL Google Chrome can warn you before quitting (on Mac).

Read more

HashSet in Java is backed by a HashMap instance

November 12th, 2017 | #java

TIL that a HashSet in Java is backed by a HashMap instance.

/**
 * Constructs a new, empty set; the backing <tt>HashMap</tt> instance has
 * default initial capacity (16) and load factor (0.75).
 */
public HashSet() {
    map = new HashMap<>();
}
Read more

Effectively final variables in Java

November 10th, 2017 | #java

TIL what effectively final variables in Java are.

A variable or parameter whose value is never changed after it is initialized is effectively final.
The Java™ Tutorials: Local Classes

Read more

Optimise local repositories with Git Garbage Collection

November 9th, 2017 | #git

TIL how to optimise local repositories with Git Garbage Collection.

$ git gc
Counting objects: 1278, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (1068/1068), done.
Writing objects: 100% (1278/1278), done.
Total 1278 (delta 234), reused 1096 (delta 102)
Read more

Delete local branches that are merged into HEAD and deleted on remote

November 8th, 2017 | #git #bash

TIL how to delete local branches that are merged into HEAD and deleted on remote.

git branch -r | awk '{print $1}' | egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk '{print $1}' | xargs git branch -d
Read more

Prevent Google Analytics from making requests to stats.g.doubleclick.net

November 7th, 2017 | #googleanalytics #csp

TIL why Google Analytics makes requests to stats.g.doubleclick.net and how to prevent Google Analytics from making these requests.

Read more

Use Scala match expression in Play Scala template

November 6th, 2017 | #scala #playframework #html

TIL how to use Scala match expression in a Play Scala template.

@badgeColor(subscription: String) = {
    @subscription match {
        case "Authorised" => { primary }
        case "Pending" => { secondary }
        case "Confirmed" | "Paid out" => { success }
        case "Failed" | "Cancelled" => { danger }
        case "Expired" => { warning }
        case "Charged back" => { info }
        case _ => { @* applies also if "Open" *@ light }
    }
}
Read more

tonnygaric.com 1.0.0 released

November 5th, 2017 | #tonnygaric.com

Saturday 28th October I came up with the spontaneous idea to start a blog. I immediately started to write down what I would need to go live the next day. After going live on Sunday 29th October, it was only about improvements, like making the response time shorter and being mobile-first. After 9 days of development in the evening, after finishing work and studying, I can finally say: tonnygaric.com 1.0.0 is here!

Read more

Create a seconds countdown in 6 lines of JavaScript

November 4th, 2017 | #javascript #html

TIL how to create a seconds countdown in just 6 lines of JavaScript.

var seconds = document.getElementById("countdown").textContent;
var countdown = setInterval(function() {
    seconds--;
    document.getElementById("countdown").textContent = seconds;
    if (seconds <= 0) clearInterval(countdown);
}, 1000);
Read more

In Java 6 == 24

November 3rd, 2017 | #java

TIL that in Java 6 == 24. Let's see how and why.

Read more

How to run JShell on Mac OS X when Java 8 and Java 9 are installed

November 2nd, 2017 | #java #bash #macos

TIL how to run JShell on Mac OS X when both Java 8 and Java 9 are installed. JShell is one of the new features in Java 9. It is a REPL (Read Evaluate Print Loop) for Java, which evaluates declarations, statements, and expressions as they are entered and immediately shows the results.

Read more

Escape single quotes when using Java MessageFormat

November 2nd, 2017 | #java

If you are using Java MessageFormat, you will possibly encounter the issue that single quotes are not rendered.

/* string used in code */
"Hello, it's me!"

/* output */
"Hello, its me!"
Read more

Keep track of datetime an entity was last modified with Ebean in Play

October 31st, 2017 | #ebean #playframework #java #sql

TIL that Ebean helps you to keep track of the datetime an entity was last modified. I wanted to implement a column last_modified_at, when a colleague showed me this commit. You simply can add a timestamp property to a model with the annotation @WhenModified. Ebean will set the timestamp to the datetime when the entitiy was last modified.

Read more

Use PHP header() function to send HTTP headers to client

October 30th, 2017 | #php #http #html

TIL the header() function in PHP that sends raw HTTP headers to a client.

<?php
    header("X-Content-Type-Options: nosniff");
    header("X-Frame-Options: DENY");
?>
<!doctype html>
<html lang="en">
Read more

Chrome Dev Tools: dark theme

October 29th, 2017 | #chrome

TIL the dark theme of Google Chrome Developer Tools. Open Dev Tools, go to Settings, under Appearance you should see a Theme: select box. Here you are able to toggle between dark and light.

Read more

Hello, World!

October 28th, 2017 | #tonnygaric.com

Hi, I am Tonny. Born (in '98) in Nijmegen, The Netherlands. Currently working full-time as a Junior Software Engineer at Service2Fruit and part-time studying Information and Computer Science at Open University.

Read more

© 2017 Tonny Garić | With from Nijmegen, The Netherlands