sample

A collection of 100+ Scala String examples

This page contains a collection of over 100 Scala String examples, including strings functions, format specifiers, and more. I don’t provide too many details about how things work in these examples; this is mostly just a collection of examples that can be used as a reference page or cheat sheet. (I do show the output of most examples.)

First, here are some basic uses of the Scala String class to help get us warmed up:

A job interview question about three people at a bus stop alvin July 7, 2009 - 5:57pm

The content of this post was sent to me in an email from a friend, where he mentioned it as a job interview question. As I just learned, this question was (also) posed in the movie 16 Blocks, featuring Bruce Willis and Mos Def. Regardless of its origin, it presents a fun problem (though I personally wouldn’t ask it during a job interview).

Java: How to handle drop events to your Mac OS X Dock icon (Part 2)

In Part 1 of this tutorial I shared the Java source code you need to handle drag and drop events on Mac OS X. But as I mentioned in that tutorial, the recipe to handle files that are dropped onto your Dock application icon requires a little more work, in particular an Ant build process that uses the JarBundler task. So here in Part 2 of this tutorial, I'm sharing my Ant build script that completes this recipe.

Ruby - How to convert ASCII decimal (byte) values to characters

Problem: You have a byte value, or a string of byte values, and you want to use a Ruby script to convert each byte to its equivalent ASCII character.

Solution

I just ran into this problem while working on a script to remove binary/garbage characters from a Unix text file. In short, the file had a bunch of binary "garbage" characters in it, and I wanted a clean version of the file that contained only printable ASCII characters in it.