## Saturday, March 8, 2008

### How many positive integers less than 1,000, 000 have exactly one digit equal to 9 and have a sum of digits equal to 13?

Solution.

There are six choices for the position where 9 appears.

After that choice has been made, the problem reduces to figuring out how many ways are there to select a sequence of five positive integers summing to 4 (since 13 − 9=4).

This is the same as counting permutations of four stars and four bars; the first integer in the sequence corresponds to the number of stars before the first bar, the second to the number of stars between first and second bars, etc.

The total number of ways to permute four stars and four bars is Bin(8,4) . Therefore th number of positive integers less than 1, 000, 000 that have exactly one digit equal to 9 and the sum of digits equal to 13 is 6 Bin(8,4) .

### Insert form value to MySQL table using PHP

Computer Description: \$test
";
// Close the database connection
mysql_close();
?>

Reference: http://bbs.blueidea.com/thread-2835996-1-1.html

### Only read unique values out of MySQL table

select all the values out of a MySQL Database that are UNIQUE:
\$result = mysql_query("SELECT DISTINCT fieldNAME FROM tableName");

Reference: http://www.dreamincode.net/forums/showtopic6057.htm

## Sunday, March 2, 2008

### ISBN-13 to ISBN-10 Convertion

Recommended Conversion Tool: http://www.isbn.org/converterpub.asp

To convert an ISBN-13 to ISBN-10, you need not only to remove the first three characters. You also need to recompute the checksum.

Here is a piece of code that Febrice wrote:

public static String Isbn13to10(String isbn13)
{
if (String.IsNullOrEmpty(isbn13))
throw new ArgumentNullException("isbn13");
isbn13 = isbn13.Replace("-", "").Replace(" ", "");
if (isbn13.Length != 13)
throw new ArgumentException("The ISBN doesn't contain 13 characters.", "isbn13");

String isbn10 = isbn13.Substring(3, 9);
int checksum = 0;
int weight = 10;

foreach (Char c in isbn10)
{
checksum += (int)Char.GetNumericValue(c) * weight;
weight--;
}

checksum = 11-(checksum % 11);
if (checksum == 10)
isbn10 += "X";
else if (checksum == 11)
isbn10 += "0";
else
isbn10 += checksum;

return isbn10;
}

## Thursday, February 28, 2008

### Spott: Free Link Exchange

If you've ever wanted an easy way to promote your site for free, you'll love Spottt.

A free link exchange service from AdBrite, Spottt helps you drive more users to your site. It can work together with the AdBrite ad zones you're already using and any ad buys you're doing.

The concept is simple: by joining, members agree to display ads for other members. Spottt's fully automated, using a small snippet of HTML inserted into any web page, including blogs and MySpace profiles. The amount of free advertising members receive is directly proportional to the amount they give to others. Spottt ads are 125x125 pixels.

Click here to give Spottt a try, or read more at the brand-new Spottt blog.

## Sunday, January 27, 2008

### Screen Rotation Shortcut For Vista

Supported OS: Windows XP Tablet Edition

Supported Graphic Card: Intel Graphic Card

Note: "complementary with ..." means if the combination does not function, try the other combination after "with".

Ctrl-Alt-Up: -180 degress (complementary with Ctrl-Alt-Down)

Ctrl-Alt-Right: 90 degrees (complementary with Ctrl-Alt-Left)

Ctrl-Alt-Down: +180 degrees (complementary with Ctrl-Alt-Up)

Ctrl-Alt-Left: 270 degree (complementary with Ctrl-Alt-Right)

To disable it:

On XP: Start >> Control Panel >> Display >> Settings >> Advanced >> Intel Graphics >> Graphics Properties >> Hot Keys >> Disable the combination

On Vista : Start >> Control Panel >> Personalization >> Display Settings >> Advanced Settings >> Intel Graphics >> Graphics Properties >> Hot Keys >> Disable the combination

Reference: Link

### The Flaws Of Macbook Air

The main problems:

1. Exclusive Price?
You do not know how much you will pay for Apple's products after Macbook Air. The accessory purchases, software purchases, and iTunes rentals, and you have to buy all of them exclusively in Apple Store. Many of these flaws can only be fixed or alleviated with more investment of money and time.

2. Device or Computer?
Parts, Ram and Battery are not interchangeable. So this computer is more like a human artifact than a tool?

Battery
Not user Replaceable
129 for a battery replacement(installation included)

No Optical Drive
True wireless productivity? Or is it more like iTunes dependency? Why?

Remote Disc ---not yet an alternative
1. Can't install OS via Remote Disc.
2.Remote CD/DVD host may not always be available when needed. (You need to bring your remote disc software when you're on the road too)

Hard drive
Slow ---only 4,200rpm
2GB of RAM only
No option to upgrade

MacAir-only External Optical Drive
The \$99 external Superdrive is only exclusive for Macbook Air, not compatible with any other laptops.

### Convert Integer to Byte in Java

I have been working on the Huffman Encode/Decode and this has been the most annoying part of the Encoder piece of the program----Converting an integer into a 3-byte or 4-byte representation.

private static int[] generateByte(int integer, int byteLength) {
int[] byteStr = null;
if (byteLength==4){
byteStr=new int[4];
byteStr[0]=(byte)((integer & 0xff000000)>>>24);
byteStr[1]=(byte)((integer & 0x00ff0000)>>>16);
byteStr[2]=(byte)((integer & 0x0000ff00)>>>8);
byteStr[3]=(byte)((integer & 0x000000ff));
}

if (byteLength==3){
byteStr=new int[3];
byteStr[0]=(byte)((integer & 0x00ff0000)>>>16);
byteStr[1]=(byte)((integer & 0x0000ff00)>>>8);
byteStr[2]=(byte)((integer & 0x000000ff));
}
return byteStr;
}

Reference:
1. Java Forum Post: Convert integer to 4 byte[ ] array and back to integer value
2. Java Quick Reference: Operators and Assignments - Binary/Octal/Hex and Decimal Number Systems

## Saturday, January 26, 2008

### Y! Mash Invite Share

According to the Mash Blog:

Y!Mash is a new approach to your profile that brings your people together and keeps things interesting. Mash is invite-only right now, so ask a friend who’s in to get you in.

In Mash, you can:
- Find and connect with your old and new friends
- Comment and make conversation on the page
- Add page modules to style the your page up.
- And so much more yet to come

If anyone wants an invite, please leave your email in the comments. That's all.