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

As I mentioned in my earlier Pentax K-x camera review, I'm very happy with the Pentax K-x camera I purchased a few weeks ago. Amazon had a big discount on the Pentax K-x at that time, and I found a bundle deal for just a little over $500.

Looking for a camera as a Christmas geek gift idea? If so, here's an updated version of my Pentax K-x camera review from earlier this summer. I've had my Pentax K-x camera for almost six months now, and I have to say, I remain very pleased with it. (I hope to pick up a nice camera lens or two over the holidays.)

Two weeks ago I bought a Pentax K-x camera from Amazon for just a little more than $500, and while I'm not a photography wizard by any stretch of the imagination, I do believe this is an excellent camera. Frankly, the worst thing I can say about it is that it's a little heavy, but even then, it's not any heavier than other cameras in its class.

This announcement is a little premature, but ... for at least ten years I've thought about creating a search engine to make it easier to find source code examples, and while Google and thousands of writers have pretty much eliminated the need for such a search engine, I decided to create one anyway. The approach I'm working on is to create a source code search engine that is driven by "tags", in much the same way that del.icio.us and other tag concepts work.

iPod and iPhone Skins FAQ: Can you recommand some good iPod and iPhone skins stores/websites?

Holiday iPhone and iPod gifts - Apple iPhone/iPod skins! Looking for great 2010 holiday gifts for under $20? Take a look at the great collection of iPod and iPhone skins from websites like DecalGirl, Skinit, and others. Their artwork is outstanding, and almost all of their prices are under $20, typically around $15.

Here's a quick look at some of the great artwork from these iPhone skins websites.

PHP STDERR FAQ - How do I write to STDERR in a PHP script, specifically a PHP command line script?

I've written a lot of my command line scripts in PHP lately, and I just ran across this problem in my own script, how to write to STDERR in PHP. Fortunately the solution is easy, just use the PHP fwrite function like this:

fwrite(STDERR, “hello, world\n”);

Or, in a more real-world example, here's how I'm writing MySQL error messages to STDERR in PHP:

The other important piece of news from the Apple OpenJDK announcement this morning is that the new Mac OS X "Lion" operating system will continue to support Java, and specifically the Apple Lion Java implementation will be provided by Apple. Here's a statement from the Apple press release:

Apple also confirmed that Java SE 6 will continue to be available from Apple for Mac OS X Snow Leopard and the upcoming release of Mac OS X Lion. Java SE 7 and future versions of Java for Mac OS X will be available from Oracle.

Apple and Oracle today announced the OpenJDK project for Mac OS X, ending weeks of speculation about the future of Java on the Mac OS X platform. In the joint announcement from Apple and Oracle, it was stated that "Apple will contribute most of the key components, tools and technology required for a Java SE 7 implementation on Mac OS X, including a 32-bit and 64-bit HotSpot-based Java virtual machine, class libraries, a networking stack and the foundation for a new graphical client."

PHP string FAQ: Can you share some source code for a PHP last character function (string function)?

Sure, I just developed a PHP last character function for an app I'm working on, and here's the source code for that function, aptly named last_char:

# a php last character function
function last_char($str)
{
  $len = strlen($str);
  return char_at($str, $len-1);
}

As you can tell from the code, it returns the last character from a PHP string.

PHP FAQ: Is there a PHP char_at or charAt function, like there is in other languages?

No, there isn't, but you can easily mimic a PHP charAt function like this:

$char = $my_string{4};

That's equivalent to having a charAt function like this:

$char = charAt($my_string, 4);

or this:

Smarty templates object array FAQ: How can I display an array of objects with Smarty templates?

I just wasted about thirty minutes trying to figure out how to display an array of objects with Smarty templates, so I thought I'd share the solution here. I'll include my PHP class, some of the PHP logic that builds the Smarty variables (my Smarty object array), and then a portion of the Smarty template that displays my PHP object array.

PHP function FAQ: Help, I'm getting a PHP cannot redeclare function error message, how do I fix it?

Assuming you don't really have two PHP functions defined with the same name, this "cannot redeclare" function error message is usually caused by using the require or include functions to include the same common file (and therefore its functions) more than once.

If you ever need the source code for a PHP "SELECT FROM foo WHERE id in (1,2,3)" example, I hope the following PHP function will be a decent example to work from. I turned a given list of database table id values into a CSV list, then use that string in a "SELECT FROM ... WHERE ... IN ... (list)" SQL query.

I'm not going to explain it today, but I will share the PHP source code for your reading enjoyment (and problem solving).

MySQL vacuum FAQ: How do I vacuum a MySQL database table, or an entire MySQL database?

This may be an unusual situation, but as I'm creating a new application that uses a MySQL database, I've found that I want a "MySQL vacuum" operation; I want to reset all my MySQL auto_increment counters back to 1 without having to completely drop and then re-create my MySQL database.

Specifically what I'm doing is this:

PHP array to CSV FAQ: How do your convert a PHP array to a CSV string?

Converting a PHP array to a PHP CSV string is so easy, it actually felt like I trick question when I just found the answer in the PHP docs.

In my case, I just had a PHP array named $tags, and I wanted to convert it to a PHP CSV string. To do this, all I had to do was use the PHP implode function, like this:

PHP FAQ: What is the PHP Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in error message, and how do I fix it?

I just ran into this this "mysql_fetch_array() expects parameter 1 to be resource, boolean given" error message, and learned that it's because there's something wrong with my SQL query.

Automated GUI testing tools FAQ: I've read that you've done a lot of work with automated GUI testing tools, can you share some "lessons learned" about your automated GUI testing tools experience?

I'll come back and update this article from time to time as I run into more "lessons learned", but after writing my last article (Seven benefits of automated GUI testing), I also wanted to share these ideas on "Automated GUI testing best practices."

With Apple's recent Mac Java deprecation announcement -- and their otherwise complete silence on the issue -- there is one other thing people can read in the tea leaves that I haven't seen mentioned anywhere else yet: Nobody is buying the Apple Xserve server device.

MacBook skins FAQ: What do you know about MacBook skins, and MacBook skin websites?

I've mentioned here before that I'm looking to buy another MacBook for the devdaily.com international world headquarters, and the process of learning that the base MacBook only comes in white led me to the discovery of all sorts of cool "MacBook skins" (aka, MacBook protective covers, or MacBook covers). Wow -- I knew there were very basic MacBook skins and shells, but I had no idea what a huge market this is.

Waiting iPad apps: If you run into a problem with "waiting" iPad apps during the iPad app installation or update process, my "waiting iPhone apps solutions" article should be helpful. Because all these Apple devices use the same iOS operating system, and because we've found four possible solutions to the "waiting iPhone/iPod apps" problem, these waiting app tips should work just as well for waiting iPad apps (also referred to as "stuck" iPad apps).

In my other life (living in Alaska), I'm wondering if 84% of Alaska write-in voters can spell "Murkowski" right? In my Alaska Murkowski write-in story, I calculate that with the current vote totals, Lisa Murkowski will need a little less than 84% of voters to spell her name correctly to avoid any sort of legal challenge by Joe Miller.