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

Apple made some new iMac announcements today, and the most interesting one for me is their new "Magic Mouse".

I've written here before that Apple has driven me crazy with some of their mouse designs. In fact, I currently use a Dell USB mouse instead of my wireless Mighty Mouse (yes, a cabled mouse instead of a wireless mouse), because I can't get the little track ball on the Mighty Mouse clean enough to scroll consistently.

But getting rid of the trackball altogether and replacing it with their multitouch technology? That might be a really clever idea.

I just read this announcement on the Apple Java Mailing List about a new library/tool named GCDExecutorService.

As the announcement states, this is "an implementation of a Java ExecutorService that completes tasks (Runnables and Callables) by passing them to Grand Central Dispatch to be run." On his web page the author later writes, "GCDExecutorService is a Java ExecutorService (Executor) that runs tasks by passing them to Cocoa's NSOperationQueue."

One of my favorite things about Unix, Linux, and Mac OS X systems is that you can create your own commands by merging other commands. There isn't any formal name for these command combinations, other than to say that you're "piping" commands together, so I recently started referring to these as "command mashups".

Here's a simple pipeline command I use all the time, creating a long list of files and piping the output into the Linux more command:

I’ve written, edited, and re-organized a lot of vi/vim tutorials over the last few days, and to make it a little easier to find them all, I thought I’d link to them all from this “vi/vim tutorial collection” post.

To that end, here is a list of the vi and vim tutorials on my website, organized by category.

vim FAQ: Can you recommend a good vim tutorial?

Need help learning how to use the vi or vim editor? How about an interactive vim tutorial? Wouldn't that be great?

Many people don't know it, but if you have the vim editor installed on your Unix or Linux system, you probably have a built in vim tutorial right there at the command line.

vim editor syntax faq: How do I turn on (enable) or turn off (disable) vim syntax highlighting?

Short answer

Turning on syntax highlighting in your vim editor is usually fairly simple; you just need to issue a syntax on command, either in your current editor session, or in your vimrc configuration file. Here are a couple of quick examples.

Java clipboard FAQ: How do I get an image off the clipboard using Java?

I guess timing is everything ... I just received this Java clipboard question as I am working on a Java Swing application that does a lot of graphics and image work, so I have a little source code here I can share.

Java FileFilter FAQ: How do I implement a file filter in Java so I can limit the possible files that are shown to a user in a "select file" dialog, or limit the list of files that I see when listing the files in a directory?

Perl array foreach FAQ: How do I loop over every element in a Perl array with a for loop (or foreach loop)?

A friend recently asked how to create a simple array of numbers with Perl, and also how to iterate over that list of numbers in a Perl foreach loop. In this article I'll share with you the code I shared with him.

Here's my latest Log4J properties file example (log4j.properties), which includes some support for Spring and JSF debug output:

Today I was configuring a MySQL JNDI connection pool on a Glassfish server, when my brain went completely blank, and I couldn't remember what port MySQL listens on by default.

After a few moments of research, including looking at some output from netstat, I found the answer ... the MySQL default port is 3306.

3306

 

Using JavaServer Faces (JSF), if you can't see the error message (FacesError) you're creating in your controller/handler when you forward to a new JSP (JavaServer Page), the problem may be that you have a "redirect" tag in your faces-config.xml file.

For example, the following JSF faces-config.xml example shows the problem, where I do have a redirect tag when I bounce control back to the login.jsp page:

JSF HttpSession FAQ - How do I access the traditional HttpSession from my JSF code?

I've been working with JavaServer Faces (JSF) a lot lately, and one thing I was curious about was how I can get back to the old-fashioned Java session (HttpSession) if and when I need to, while also wondering what was in the session.

The vi editor can be a little difficult to learn, so I've been writing some vi tutorials here recently. One of the first things to know about vi is that it typically functions in three different modes:

  1. Command mode
  2. Insert mode
  3. Last line mode

Here's a quick description of each vi mode.

[toc hidden:1]

vim quit/save/exit FAQ: How do I quit/exit vim?

Answer: This depends by what you mean by the word exit. Here's a short list of the different ways I normally quit or exit a vi/vim editor session.

vi exit - no changes made to your file (vim quit command)

If you haven't made any changes to your file you can just quit your vi (or vim) editing session like this:

[toc hidden:1]

Here's the source code for a Perl CGI password field example. The Perl code below shows how you can display an HTML form with a password field, using the Perl CGI.pm module. The first time this script is called it displays a password field in a form. After you submit the form, this script displays the text that you entered in the password field.

Here's the source code for this Perl CGI.pm password field example script:

Here's the source code for a Perl CGI popup menu example. (It's called a "popup menu" in the CGI.pm module, but it renders an HTML SELECT/OPTION form in a browser.)

The Perl code below shows how you can display an HTML form with a popup menu, using the Perl CGI.pm module. The first time this script is called it displays the popup menu (combo box) in a form. After you submit the form, this script displays the item you selected from the combo box.

Here's the source code for this Perl CGI.pm combo box example script:

Perl CGI redirect FAQ: Can you share some Perl CGI redirect example code?

Here's the source code for a simple Perl CGI redirect example. An HTML redirect is pretty easy to program manually, but the Perl CGI.pm module makes it even easier to redirect a user from one page to another.

Perl redirect CGI script example

Here's the source code for this Perl CGI redirect example script:

Here's the source code for a Perl CGI scrolling list example. The CGI.pm module calls this a scrolling list, but it renders an HTML SELECT/OPTION form field with the "multiple" attribute.

The Perl code below shows how you can display an HTML form with a scrolling list field, using the Perl CGI.pm module. The first time this script is called it displays a scrolling list field in a form. After you submit the form, this script displays the item you selected in the scrolling list.

Here's the source code for this Perl CGI.pm scrolling list example script:

Here's the source code for a Perl CGI textarea example (a Perl form example). The Perl code below shows how you can display an HTML form with a textarea field, using the Perl CGI.pm module. The first time this script is called it displays a textarea field in a form. After you submit the form, this script displays the text that you entered in the textarea field.

Here's the source code for this Perl CGI.pm script, which generates a textarea in an HTML form: