Gangmax Blog

自由之思想,独立之精神

Java Lambda Type Inference

| Comments

I see code like this:

Service.java
1
2
3
4
5
6
7
8
9
@Override
public void log(Request request) {
    // ...
}

@Override
public void submit(Request request) {
    Utils.submit(request, request -> log(request));
}

Here is the code in “Utils.java”:

Utils.java
1
2
3
4
public static void submit(Request request, Consumer<Request> comsumer) {
    // Do something.
    comsumer.accept(request);
}

“request -> log(request)” is a lambda expression, but how does it become a “Consumer”?

Git: Syncing a Fork

| Comments

Sync a fork of a repository to keep it up-to-date with the upstream repository. From here. This is useful when you forked a repository in GitHub and want to get the latest changes made after the fork from the original repository to your repository.

Gitstats

| Comments

GitStats is a statistics generator for git repositories. It examines the repository and produces some interesting statistics from the history of it.

From here and here.

Launch Sublime Text From Command Line on Mac

| Comments

From here.

What you need to do is to create a symbolic link:

1
2
3
4
# Run the following command to craete the symbolic link:
ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/sublime
# Run it.
sublime ~/Documents/test.txt