A Scala substring example: I ran into a situation today where I wanted to get a string after the Nth occurrence of another string, in this case after the 6th occurrence of a “:” character. There are probably many ways to determine the Nth occurrence of a string in another string, but as a quick example, this is what I did.
First, I started with this string:
Summary: This blog post shows one way to drop/filter the first matching element from a Scala sequence (Seq, List, Vector, Array, etc.). I don’t claim that the algorithm is efficient, but it does work.
While creating some Scala test code earlier today I had an immutable list of toppings for a pizza, and I got into a situation where I wanted to remove the first instance of a topping.
Mac OS X images FAQ: Can you recommend a small Mac app that scales Mac images fast, and is preferably free?
I've been creating a lot of scaled images for my One Man's Alaska website lately, and since I always scale them to a width of 600 pixels I've been trying to find the fastest, easiest way to create these scaled images.
I have been using the Gimp to do this, but it's really a little cumbersome and overkill for this. Another app named EasyCrop is closer to what I want, but it has a number of drawbacks as well.
Mac "file copy" FAQ: How do I copy files on my Mac?
When people move from Windows to Mac OS X, a common question is "How do I copy files on my Mac?" I hope this short Mac file copying tutorial will help answer that question.
Lately I've been doing a lot of Java programming on Apple's Mac OS X platform, and my most recent effort has been to handle drag and drop events in my Java Swing application. Not satisfied to handle "simple" drag and drop events, I decided I wanted to take my application even farther, and let users drag files and images to my Java application icon in the Mac Dock.
A very important warning: When you drag your folder over to the PLACES section of the Finder, make sure your image looks like the image shown above, where the folder is clearly going to be placed between two existing folders. If you drag your folder over to the left side, and you're highlighting another folder in the PLACES section, you're going to end up moving your folder to that other folder. That's a great technique for moving your folder from one place to another, but it's not what I'm trying to describe here.
One of the cool things about the Mac Finder is that you can create shortcuts, or bookmarks, to folders that you visit frequently. This is cool, because instead of clicking around to get to your commonly used directories, you can get to them with just one mouse click. That's as fast I can think to make it.
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.
Java Swing drag and drop FAQ: How do I get Java/Swing image drag and drop working on Mac OS X?
I've been working on several new Swing applications for Mac OS X recently, and most of these applications include features like image processing, copy and paste clipboard interaction, and in today's example, dealing with drag and drop events on the Mac.