size

How to show the largest files under a directory on Mac OS X (Unix)

Here’s an example that shows how to find the largest files under a directory on MacOS and Linux/Unix systems.

A du/sort command to show the largest files under a directory on Mac OS X

The Unix/Linux command that worked for me on my MacOS system is this:

$ du -a * | sort -r -n | head -10

du is the disk usage command, and the -a flag says, “Display an entry for each file in a file hierarchy.” Then I use the sort command to sort the du output numerically and in reverse. After that, head -10 shows only the first ten lines of output. In the Music folder on my Mac the command and output look like this:

How to create an Array whose size can change (ArrayBuffer)

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is one the shortest recipes in the book, Recipe 11.8, “How to Create an Array Whose Size Can Change (ArrayBuffer)”

Problem

You want to create an array whose size can change, i.e., a completely mutable array.

Solution

An Array is mutable in that its elements can change, but its size can’t change. To create a mutable, indexed sequence whose size can change, use the ArrayBuffer class.

Mac OS X mouse cursor/pointer size

I haven’t figured out the exact issue yet, but ever since I (a) switched to Mac OS X 10.9 and (b) added a second monitor to my old iMac, the mouse pointer/cursor seems to disappear from time to time. Actually, I can’t tell what it’s doing, so I move the mouse around frantically until it reappears.

To help resolve this problem, I just made my mouse cursor larger. You do this on your Mac by going to System Preferences, then Accessibility, then Display, and then adjust the “Cursor Size” slider until you get the mouse pointer size that you want. You can see in the image shown here that I’ve made mine a little larger than normal. (I was surprised that this is under “Display” and not under “Mouse”, but there it is.)

Play Framework forms: specifying @textarea rows and columns

To specify the rows and columns in a Play Framework 2.1.x form field, use a syntax like this:

@textarea(
    urlForm("notes"), 
    '_label -> "Notes",
    'placeholder -> "Any notes you want to add",
    'rows -> 5,
    'cols -> 60
)

The textarea documentation shows that you can also specify the textarea size like this:

Mutable Scala arrays (adding elements to arrays)

Just a quick note today that if you want to create a mutable Scala array -- particularly an array that can grow in size after you first declare it -- you need to use the Scala ArrayBuffer class instead of the Array class, which can't grow.

Here's a short example of how to instantiate an ArrayBuffer object, then add elements to the array: