Écrit le 9 mars 2020 par Jeremy Howard and Rachel Thomas
Traduction en français par Patrick Jayet et deepl.com.
Article original.

Nous sommes des data scientists, c’est-à-dire que notre travail consiste à comprendre comment analyser et interpréter les données. Lorsque nous analysons les données relatives au COVID-19, nous sommes très…

On my trip to Berlin for the Scala Days conference, I used Passbook for the first time to store my boarding pass. I thought it would be interesting to share this first paperless boarding experience with you.

When I did the check-in on Swiss’ website the day before my flight…

I have stumbled upon a weirdness regarding the behavior of readLine in Scala (at least with my current basic understanding of the language).

The following snippet is supposed to read three times a line from standard in. But it reads 3 times the same line (the first).

[code]
(1 to 3) foreach {
val line = Console.readLine
i => println(line)
}
[/code]

while the following snippet (very similar) behaves as expected (reading the three first line from stdin):

[code]
(1 to 3) foreach {
i => println(Console.readLine)
}
[/code]

Any idea why?

Java quiz of the day (easy): what gives

Object[] a = new Integer[]{};
List<Object> b = new ArrayList<Integer>();

Response: we get an exception on the second line:

Type mismatch: cannot convert from ArrayList<Integer> to List<Object>

Arrays and Generics are not consistent. While for arrays, an array of some type is…

What gives:

Integer a = 100, b = 100;
Integer c = 200, d = 200;
System.out.println( (a == b) == (c == d) ); // A

Response: counter intuitively, the program prints ‘false’ out. Integer in Java is a non-native class, where ‘==’ means ‘reference equality’ (two variables are reference equal if they are pointing to the same object). From there we would expect the expression of line (A) to be reduced to ‘false == false’, but it is slightly more complicated: the Integer class has the particularity that all Integer (like Short) in the range [-128, 127] are shared. This means the two variables ‘a’ and ‘b’ are actually pointing to the same shared object. Hence the expression of line (A) is in fact reduced to ‘true == false’.

What gives

Double a = null;
Double b = a == null ? a : 1.0;

Response: as strange as it can seem at first look, b is not equal to null after the second statement, but the code produces a NullPointerException.

The reason for that is the type of the second expression (double) inside the ternery operator. The first expression ‘a’ of type Double is unboxed to double (calling doubleValue() on ‘a’ which is null), causing the NPE.

You can find a discussion about that here.

I was just checking which commands are supporting sparse files. I post hereafter a short overview of what I found out (working on Linux).

  • Create a sparse file of 20 GiB:
    dd if=/dev/zero of=foo bs=1 count=1 seek=20G
  • Check that a file is sparse:
    ls -alsh
    Compare the first versus second size column (the first one is the space taken on disk).
  • Copy a sparse file:
    cp foo bar
    Copy already detects and handles correctly sparse files.
  • Make a non-sparse file sparse (works only if it contains blocks filled with zeros):
    cp --sparse=always foo bar
  • Expand a sparse file to a non-sparse one:
    cp --sparse=never foo bar
  • Copy remotely a sparse file: scp does not support sparse files, it will expand them to non-sparse ones. Rsync does support them. Just use the -S or --sparse option. Example:
    rsync -vS foo root@someserver:/some/path/

A sparse file is a file which does not take more space on disk than needed. Such a file is usually used to store a partition image on disk, for instance with a virtualization solution like Xen.

It’s super easy, to know if a file is sparse or not. …

I had posted that some times ago on Twitter. There is a new version of the excellent GPGMail plug-in for Mail (OS X). Grab it, if you haven’t already.

GPGMail for OS X 10.6.2

Just put it inside ~/Library/Mail/Bundles and restart Mail. (More information on GPGMail’s web page.)

Edit: This is not an official version of GPGMail. There is still no official version of GPGMail compatible with Snow Leopard.

Check out my new mix 03.

  • Extrabright Mix 03: electro to house with a squeeze of detroit and a drop of chill-out. Among others Gui Borrato, SMD remixed by DJ Pierre, Jori Hulkkonen, Miss Kittin & The Hacker, Mosca, Josh Wink, Black Dog, Clark plus a bunch of other great stuffs.
    [audio:Extrabright_Mix_03.mp3]

Patrick Jayet

Polyglot (FR, DE, EN, ES), polyglot programmer (Java, Groovy, Ruby, Swift, Objective-C, Scala, Python, O’Caml) polyglot methodologist (Scrum, Kanban, Lean).

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store