You can use reserved identifiers as variable names in C Sharp

December 8th, 2017 | #csharp

TIL you can use reserved identifiers in C# if you use @ as a prefix.

Read more

Mark up matching text when using grep

December 8th, 2017 | #terminal

TIL you can mark up matching text when using grep.

grep --color "pattern_to_match" filename.txt
Read more

Time To Live is hop limit in practise (and in IPv6)

December 4th, 2017 | #networking

TIL Time To Live is, in practise, a hop limit and will be renamed in IPv6.

Read more

Command nohup invokes a utility immune to hangups

December 3rd, 2017 | #terminal

TIL nohup invokes a utility immune to hangups.

nohup [--] utility [arguments]
Read more

Commands whatis and apropos

November 30th, 2017 | #terminal

TIL about the commands whatis and apropos.

$ apropos converter
pdb2mdb(1)               - Program Database to Mono Debugging Symbol converter
CPAN::Meta::Converter(3pm) - Convert CPAN distribution metadata structures
native2ascii(1)          - native to ASCII converter
$ whatis rm
rm(1), unlink(1)         - remove directory entries
git-rm(1)                - Remove files from the working tree and from the index
Read more

Null coalescing operator in C Sharp, PHP, Bash and SQL

November 27th, 2017 | #csharp #php #terminal #sql

TIL about the null coalescing operator in C#, PHP, Bash and SQL. In general, the null coalescing operator returns the result of its first operand—if it exists and is not null.

string siteName = suppliedName ?? "Default Name";

/* is logically equivalent to*/

string siteName = suppliedName != null ? suppliedName : "Default Name";
Read more

Filter by tags in Kirby

November 26th, 2017 | #kirby #php #tonnygaric.com

Since a few days I have made it possible to filter my blogposts by tags. I found it very easy to implement tags in Kirby. In this blogposts I will show you how.

Read more

Compare enums with == instead of equals() in Java

November 22nd, 2017 | #java

TIL you should compare enums with == instead of equals() in Java.

a == SomeEnum.ENUM_VALUE
/* instead of */
a.equals(SomeEnum.ENUM_VALUE)
Read more

Command man prints “gimme gimme gimme” at 00:30

November 22nd, 2017 | #terminal

TIL why the command man print gimme gimme gimme at 00:30. When you run man at 00:30 without specifying the page or with -w, it outputs gimme gimme gimme to stderr.

$ man -w
gimme gimme gimme
/usr/local/share/man:/usr/share/man:/usr/man
Read more

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

November 18th, 2017 | #apple #macos #terminal

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 #terminal

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


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