Showing posts with label Ubuntu. Show all posts
Showing posts with label Ubuntu. Show all posts

Saturday, August 9, 2008

UUID

You can run command to generate a uuid randomly:

sudo uuidgen

you can also run a perl script to get a randomly generated uuid:

#!/usr/bin/perl
#UUID generator

$uuid = `uuidgen`;
chomp $uuid;
print $uuid;

If you want to get UUID customized according to your need::

You will need UUID.pm file to get the below code running and you can get that by this command

sudo cpan Data::UUID

Synopsis:
use Data::UUID;

$ug = new Data::UUID;
$uuid1 = $ug->create();
$uuid2 = $ug->create_from_name(, );

$res = $ug->compare($uuid1, $uuid2);

$str = $ug->to_string( $uuid );

This modules provides several methods to create a UUID:

# creates binary (16 byte long binary value) UUID.
$ug->create();
$ug->create_bin();

# creates binary (16-byte long binary value) UUID based on particular
# namespace and name string.
$ug->create_from_name(, );
$ug->create_from_name_bin(, );

# creates UUID string, using conventional UUID string format,
# such as: 4162F712-1DD2-11B2-B17E-C09EFE1DC403
$ug->create_str();
$ug->create_from_name_str(, );

# creates UUID string as a hex string,
# such as: 0x4162F7121DD211B2B17EC09EFE1DC403
$ug->create_hex();
$ug->create_from_name_hex(, );

# creates UUID string as a Base64-encoded string
$ug->create_b64();
$ug->create_from_name_b64(, );

Binary UUIDs can be converted to printable strings using following methods:

# convert to conventional string representation
$ug->to_string();

# convert to hex string
$ug->to_hexstring();

# convert to Base64-encoded string
$ug->to_b64string();

Conversly, string UUIDs can be converted back to binary form:

# recreate binary UUID from string
$ug->from_string();
$ug->from_hexstring();

# recreate binary UUID from Base64-encoded string
$ug->from_b64string();

Finally, two binary UUIDs can be compared using the following method:

# returns -1, 0 or 1 depending on whether uuid1 less
# than, equals to, or greater than uuid2

Examples:

use Data::UUID qw(:all);

# this creates a new UUID in string form, based on the standard namespace
# UUID NameSpace_URL and name "www.mycompany.com"

$ug = new Data::UUID;

print $ug->create_from_name_str(NameSpace_URL, "www.mycompany.com");





AddThis Feed Button

Tuesday, November 27, 2007

Highly superior gifts for the Linux geek

  1. Lockpick Tool Set - I’m not giving you any suggestions for how this might come in handy.
  2. Ubuntu with Support - If you’re a true believer, and money is no object, you not only can give a copy of Ubuntu to friends or family, but spring $250 for a year’s desktop support to completely win them over.
  3. Daisy MP3 Player Kit - It’s Cracked Open before we crack it open!
  4. Giant penguin - I think this is self-explanatory.
  5. Star Theater 2 - Creates a home planetarium on your walls and ceiling. BABE MAGNET.
  6. Storm Hawk - PDA-based real-time weather forecasting and monitoring system that delivers weather info for your surrounding (250 miles) area. Expensive, but very handy — it could even be a lifesaver — and super-geeky.
  7. The Design of Future Things - Donald A. Norman, a Computer Science prof at Northwestern University has written this new book about what’s wrong with the design of emerging products like “smart” cars.
  8. Basic Black Tee - It’s very slimming.
  9. Screaming Monkey Slingshot - I like the looks of this little guy. It makes annoying sounds and is capable of flinging random objects at The Man…or maybe just your coworkers.
  10. USB Mini Lava Lamp - It’s a lava lamp — and it plugs into your computer! Awesome.