Scala, Java, Unix, MacOS tutorials (page 388)

I'm always looking for ways to make my Java Swing applications on Mac OS X look more and more like native Mac applications, and when a co-worker mentioned the name Quaqua, I decided to take a look at that library/framework one more time. I had looked at it before, but this time, looking at it with a new mindset, I noticed it offers a JSheet implementation.

Summary: In this post I share a Unix/Linux shell script that can be used to rename multiple files (many files) with one shell script command.

Problem

You're on a macOS, Unix, or Linux system, and you'd like to be able to rename a large number of files at once. In particular, you'd like to be able to change the extensions of a large number of files, such as from *.JPG to *.jpg (changing the case of each file extension from upper case to lower case), or something similar.

In several previous tutorials (see my references below) about testing for operating systems within Ant build scripts, and then conditionally executing targets based on the results of those tests, I noted that Mac OS X operating systems respond to both Mac and Unix test conditions based on the Ant "os family" test. I mentioned that I thought this behavior was probably correct, because Mac OS X is built an a Unix base (BSD, to be specific).

Problem

You're creating an Ant build script, and you need to determine the operating system the script is running on, so you can make conditional decisions within the build script. You typically want/need to do this if you're going to run tasks/targets that are different for each operating system (Mac, Windows, Unix, etc.).

Background

I was writing with a former co-worker the other day about how to do some things that are specific to Mac OS X in his Java Swing applications (see How to make a Java/Swing application look like a native Mac OS X application), but also keep his Ant build script working on a Windows computer.

Drupal default settings, security, and spam: I've created several new websites with Drupal lately (One Man's Alaska, Tequila/Monk, and Legend of the Squirrel), and while I really like a lot of things about it, you also have to be careful with Drupal's default settings, in particular the default "social" settings, which lead to a

I had to laugh a little bit about "usability experts" the last time I visited with my sister and her daughters. As I was creating a movie and a website with my nine-year old niece using iMovie and iWeb, we very quickly ran into several problems, including:

iPhone songs FAQ: Can I set or change the rating of an iTunes song on my iPhone or iPod?

Wow, I'm such an iPod/iPhone/Itunes dummy, I didn't realize that I could change the rating of a song from my iPhone until I dug into it a little bit. Here's a quick look at how to change the iTunes song rating from your iPhone/iPod.

Setting/changing an iPhone/iPod song rating

You can set the iTunes song rating directly from your iPhone (or iPod) when the song is playing.

Problem: You want to create an iTunes playlist of all your favorite songs. You've rated all your songs using the Rating field in your main iTunes Library, but you don't know how to turn all these song ratings into a great playlist.

jEdit

jEdit is an open source Java-based text editor that has been around for years. On the positive side it's free, reasonably quick, and most importantly, it has a ton of third-party plugins. All those plugins are what keeps me coming back to look at jEdit from time to time.

Smultron

2009-01-06 UPDATE: Smultron is dead; long live Smultron. I just visited the Smultron website, and the author has decided to discontinue development of the project.

Other than the application icon they use, Smultron looks as Mac-like as any text editor I reviewed. While I'll be using Komodo for editing language files (CSS, HTML, others), I'm currently using Smultron as a plain text editor instead of TextMate, and so far, I like it.

This article is now part of my new eBook, which is only $2.99 on Amazon.com:

You want me to do what? A Survival Guide for New Consultants

I hope you enjoy my book, and more than that, I hope it helps you have a very profitable and rewarding career.

 

Drupal login FAQ: Help, I just changed my Drupal theme, and I can't log in to my Drupal website(!).

Solution

You can do some really amazing things with Drupal, with one amazing thing being the ability to log yourself out of the system, and make you think you have no way of logging yourself back in.

Cool ... for anyone interested in online book publishing, Drupal offers a "book" content type that does a lot of the "magic" of page linking for you, creating links like next, previous, and up. If you're collaborating on a book, it also offers access control and permission features, which is also very cool.

Problem: You want to build your Java project using Ant but you need to be able to skip certain files -- typically unit test files -- during the compilation or deployment processes.

Solution: You can skip files during the Ant compilation process by using the Ant exclude pattern. Here's an example that shows several exclude patterns in some XML code taken directly from an Ant build script:

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.

Problem: You have a file that should be a plain text file, but for some reason it has a bunch of non-printable binary characters (also known as garbage characters) in it, and you'd like a Ruby script that can create a clean version of the file.

Solution: I've demonstrated how to do this in another blog post by using the Unix tr command, but in case you'd like a Ruby script to clean up a file like this, I thought I'd write up a quick program and share it here.

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.

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

Solution

I just ran into this problem while working on a script to remove binary/garbage characters from a Unix text file. In short, all you have to do to convert a character in Ruby to its equivalent decimal ASCII code is use the ? operator in front of it, like this:

For a variety of reasons you can end up with text files on your Unix filesystem that have binary characters in them. In fact, I showed you how to do this to yourself in my blog post about the Unix script command. (There’s nothing wrong with this approach; it’s just a by-product of using the script command.)