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

Just a quick note here to share a Drupal get user id (uid) function. I've found that when I'm developing a Drupal module or Drupal application, I often need to access the user id, so I created this simple function and include it in a common utilities module:

# return the current drupal user id (uid)
function get_user_id() {
  global $user;
  return $user->uid;
}

As you can see, the code accesses the global Drupal user object ($user), then gets the uid from the user object.

Summary: A Drupal "theme table" example, where I show how to generate an HTML table from a Drupal module, using the Drupal theme function (and specifically not the theme_table function).

Drupal table view FAQ: How do I create a simple Drupal table view in Drupal module? I want to create a simple "list view", the sort of list view you might see in a simple CRUD application.

I just ran into this Drupal "table list" problem while creating a Drupal module, and after a lot of digging around, I found a formula that lets me display a Drupal table view like this:

Summary: This article shares a quote from Apple’s Tim Cook about products, quality, and revenue, and how it might help your business to think the same way.

I don’t remember exactly where I read the following quote from Tim Cook of Apple (it may have been at AppleInsider), but I made a note of it, and just ran across it again:

When you're working as a business analyst, the words you write are what you get paid for. Just like the author of a book, when you write software requirements, you shouldn't be loose with the words you write.

While working on a recent project, I started thinking about software requirements again, and was reminded how vague a requirement can be, even when you think it's well written. What made me think about this today was running across this performance requirement I found in an a requirements specification:

Java Swing FAQ: How can I tell if my Java/Swing code is running on the Event Dispatch Thread (EDT)?

As a business analyst, one of the things you have to do sometimes is organize your client's thinking. For instance, I've worked on several projects where clients didn't know anything about the Unified Modeling Language (UML), or thinking about projects in terms of Use Cases and Actors. As a result, they came up with some very elaborate diagrams in an attempt to explain their thinking.

Summary: This short article describes a way to know when a software requirements specification is complete by using Function Point Analysis techniques.

I've written dozens — maybe hundreds — of software requirement specifications over the years, and at one point in my career I learned an important little secret about knowing when the process of gathering requirements for a software requirements specification was really complete. Here's my secret.

MySQL/MariaDB FAQ: How do I show or list MySQL users, i.e., show the user accounts in a MySQL or MariaDB database?

Solution

To show the users in a MySQL or MariaDB database — i.e., the user accounts in the database — first log into your MySQL/MariaDB database as an administrative user using the mysql command line client (such as the root user), then run this MySQL query:

iMac dual monitor setup FAQ: Can I connect an external monitor to my iMac? (Or, how do I use the Apple Mini DisplayPort to connect a second monitor to my iMac or MacBook Pro?)

Yes, you can connect a second monitor (external monitor) to your iMac -- here's how.

iMac dual monitor - iMac Mini DisplayPort

To create a dual monitor iMac, first locate the "Mini DisplayPort" on the back of your iMac. You can see the iMac Mini DisplayPort in this photo:

Apple Mac Mini tv FAQ: How do I create a Mac Mini tv setup? (Also written as, How do I connect my Apple Mac Mini to my tv?)

As I wrote in an earlier article, I think a Mac Mini makes a better Apple TV than, well, the Apple TV. I was just talking with a friend about a Mac Mini TV setup, and here's what he did to connect his Mac Mini to TV.

A Mac screensaver desktop tip: Hey, it's almost Friday -- wanna have some fun? How about setting your Mac OS X screensaver as your desktop background? If you set your Mac screensaver to something interesting, this can make for a very cool, animated desktop background.

I was just reminded of this Mac screensaver desktop background trick when updating my website and I ran across it again. Here's how to do it:

1) Open a Mac OS X Terminal

MacBook battery calibration FAQ: My MacBook battery life seems reduced, is there something I can do to improve my MacBook battery life? (Also written as, "Can I calibrate my MacBook battery?", or, "How do I calibrate my MacBook battery for better battery life/performance?")

Unix/Linux shell script args FAQ: How do I access Unix or Linux shell script command line arguments?

You can process Unix shell script command line arguments in at least two ways:

  • With getopts, when you want to handle options like -n 10
  • By number, such as $1, $2, etc.

I show both of these solutions below.

[toc hidden:1]

Unix/Linux date FAQ: How do I create a formatted date in Linux? (Or, “How do I create a formatted date I can use in a Linux shell script?”)

I just ran into a case where I needed to create a formatted date in a Linux shell script, where the desired date format looks like this:

2010-07-11

To create this formatted date string, I use the Linux date command, adding the + symbol to specify that I want to use the date formatting option, like this:

MySQL database backup FAQ: Can you share a Linux shell script that I can use to make a MySQL backup (i.e., a shell script that wraps the mysqldump command)?

I currently have a collection of websites on several different servers (including GoDaddy and A2 Hosting web servers), so I was just spending some time trying to automate my MySQL database backups. To that end, I just created a MySQL shell script that I use on each Linux server to make my database backups, and I thought I'd share that script here.

Mac iPhone photos download FAQ: How do I download iPhone photos to my Mac? I assumed I could import them with iTunes, but I can't seem to do anything with them from iTunes.

Mac OS X disk space FAQ: Help, I'm running out of disk space on my Mac OS X system; can you recommend any Mac disk utilities to help me reclaim my lost Mac disk space?

Mac .DS_Store files FAQ: What are these .DS_Store files on my Mac, and how can I get rid of them?

Those crazy Mac .DS_Store files (also referred to as "dsstore" files) finally got to me, so I did some research on where they come from, and how to get rid of them (or more accurately, how you can't get rid of them).

Here's what I've learned about Mac OS X .DS_Store files.

Mac BMP image FAQ: How can I convert BMP image files to the JPEG format?

If you have just one BMP file you need to convert, or just a few, you can convert BMP images to JPEG using Preview. However, if you have a lot of BMP images, and want to convert them all to JPEG or PNG format, you'll probably want to look at a Mac command-line tool like ImageMagick. (Unfortunately my Mac batch image conversion tutorial using the Mac Automator doesn't work on BMP files.)