Ruby command line arguments

Ruby FAQ: How do I read command line arguments in a Ruby script (Ruby command line args)?

To read command line args in a Ruby script, use the special Ruby array ARGV to get the information you need. Here are a few examples.

1) Getting the number of command line args

To get the number of command line arguments passed in to your Ruby script, check ARGV.length, like this:

Changing iPhone ring length alvin March 20, 2011 - 5:44pm

iPhone ring length FAQ: Can I change the iPhone ring length, or number of rings? My iPhone doesn't ring long enough, and often goes to voicemail before I can get to it.

After digging into this, yes, it looks like you can change your iPhone ring length, and there are at least two ways to do this.

Changing iPhone ring length - Option 1 (The safe way)

First, the safest option is to call AT&T customer service, or visit an AT&T store, and they can do it for you.

Perl string length FAQ

Perl string length FAQ: How do I get the length of a Perl string?

To get the length of a string in Perl, use the Perl length function, like this:

# perl string length example
$size = length $last_name;

The variable $size will now contain the string length, i.e., the number of characters in the variable named $last_name.

Another Perl string length example

I just thought to write this article out here when I ran across the following Perl string length code:

Perl hash size - How to get the size of a hash in Perl

Perl hash size FAQ: How do I get the size of a hash in Perl?

Short answer: To get the size of a Perl hash (the Perl hash size), use the Perl "keys" function, and assign it to a scalar value, like this:

A Java array length example

Java array FAQ: How do I determine the Java array length, i.e., the length of a Java array?

Answer: While you might logically expect there to be a length method on a Java array, there is actually a public length attribute on an array (instead of a length method). Therefore, to get the Java array length, you just have to access this array length attribute.

Here's a source code example that demonstrates how to determine the Java array length for an array named toppings:

Java String length (String size)

Question: How do I determine the Java String length, i.e., the length of a String in Java?

Answer: Just use the length method of the Java String class.

Here's the source code for a short but complete example that demonstrates how to determine the Java String length for a String appropriately named string:

Perl array length (size)

Perl array length FAQ: "How can I determine the length of a Perl array?"

Answer: There are several different ways to determine the Perl array length.

Perl array length - Version 1

The first way to determine the Perl array length is by simple assigning a scalar variable to the array, like this:

Ruby - Variable length argument lists with Ruby

Ruby FAQ: How do I create a variable length argument list in a Ruby method?

One thing I really dig about Ruby is that I can create methods and functions that support variable-length argument lists. It's not something you need all the time, but it sure is nice to have it when you need it.

Here's how you create and then call a Ruby function/method that can take a variable number of arguments:

Perl array size/length - How to determine the size of a Perl array

A frequently asked question Perl question is "How do I determine the size/length of a Perl array?", or the equivalent "How do I determine how many elements are in a Perl array?"

There are at least three different ways to do determine the Perl array size/length. Here's some Perl source code that shows these three Perl array size approaches:

LaTeX PDF document size/length example

In the example below I'm showing how you can change a bunch of LaTeX document length parameters. The values don't really make any sense -- I've just thrown some numbers in there. I just want to remember how to do this for the next time I need to create a LaTeX PDF document.

(For what I'm trying to achieve today my goal was to get rid of all the margins on the left side of the page. Then I decided to throw in a few other values.)

I found some of these LaTeX examples on pp. 84-89 of The LaTeX Companion.