Printing Address Labels from MS Outlook

Today I had to find a way to print address labels (the ones that a sticked on to the mail envelopes) from MS Outlook contacts. After looking around for a while I found a way to do it through MS Word and I think that this is too complicated, but no other ways were found, so here is how I had to do such a simple (from the first glance) thing:

1. Go to MS Outlook and find all contacts for which I needed to create labels

2. Copy all those contacts found in step 1 to some temporary contact folder

3. Open MS Word

4. Go to Tools -> Letters and Mailings -> Mail Merge from the top menu

5. In the right panel (Mail Merge) select Label as a document type and press Next: Starting document at the bottom of the pane

6. Press Label Options… link in the right pane and select a format of the labels I want in the popped up dialog.

7. Press OK to close the dialog and Next: Select recipients link in the right pane

8. Choose Select from Outlook contacts option in the right pane

9. Press Choose Contacts Folder link (still in the right pane)

10. Select a temporary contact folder created in step 2 from the list in the popped up dialog and press OK to close the dialog

11. Review the list of contacts fetched by MS Word from the selected folder and press OK to confirm (in the new popped up dialog)

12. Press Next: Arrange your labels link at the bottom of the right pane

13. Select Address block… option link in the right pane

14. Customize the contact fields to be included in the popped up dialog and press OK

15. Press Update all labels button in the right pane to update all cells in the document template

16. Press Next: Preview your labels link in the right pane

17. Press Next: Complete the merge link in the right pane

18. Press Print… link in the right pane

19. Press OK in the popped up dialog leaving All option selected

And only after all the steps above I had labels printed.

I think this is way too long and complicated. If anybody knows the better way – please let me know.

MySQL Backup Script

JRB Technology blog offers a script on how to backup a MySQL database. The described solution uses perl to call three commands:

@b1 = `mysqldump -h localhost -u mysql_username –password=mysql_password mysql_database > /path/to/put/mysql_database.sql`;@z1 = `zip -r -9 ~/path/to/mysql_database.zip ~/path/to/mysql_database.sql`;@d = `rm -f ~/path/to/mysql_database.sql`;

I have posted a comment directly to the origin blog with some (as I see it) improvements, but unfortunately the comment was deleted, so I will reproduce it here.

First of all I think that there is no need to create a temporarily SQL file with dump from the database and then zipping it. The zip command supports getting data from STDIN, so this way, instead of running 3 commands, only one is needed:

mysqldump -h hostname -u username –password=somepassword databasename | zip -9 mysql_database.zip

Then I offered to hide a password, since otherwise it is possible to see it by running the ps command under any user during script execution, and password will be seen in the arguments list. To hide a password, we can create a text file which is accessible only to us (chmod 600) and store a password string there, then modify the backup command accordingly:

mysqldump -h hostname -u username –password=`cat /path/to/securefile.txt` databasename | zip -9 mysql_database.zip

This way, even if someone will see that the password for accessing database is in the specified text file, it will be harder to get it, since file is readable only by owner user.

Finally, I would like comment a bit on Perl script itself, which author of the original script provides: first of all, I don\’t see any point of using Perl here, since nothing, except for calling standard commands is done during execution. A plain bash script would do a job fine. Anyway, even if you prefer using Perl, I would strongly recommend using -w switch and use strict; statement (even in such simple script, it is just good to use this every time)

Got myself a photo camera

I have finally got myself a photo camera. I was planning to buy one for a long time and I did it. While selecting a type of camera , I had a number of criterias:- The camera should use Memory Stick Duo as a storage since I also have the same in my phone

– The camera should be 5+ megapixels (I don\’t think that whatever is above matters a lot for non-professional photographer)

– The camera should operate on AA size batteries since they are easy to find anywhere.

– The camera should use standart USB cable for connecting to PC, since it is easy to replace in case of failures

– The camera should be able to take videos in MPEG format and 640×480 size
I got myself a Sony Cybershot 600s and I like it a lot. In addition I have purchased a number of accessories like carrying case, battery charger and 1GB memory card.

Here is how it looks like:

\"Sony

Java Stuff

I think I have already mentioned before that due to the Object Oriented Programming college class I have to play around Java now. I was assigned to do a project in Java and I decided to check what I can do there. Being more a perl guy, I have a faced a numerous problems with Java which I try to overcome in all possible ways. Here is what problems I have:

1. Static method declaration in abstract class. This really drives me crazy :(. I have a case where I really need to have static methods in abstract class (with implementation code inside) and I can not do it which causes me a lot of headache.

2. I am really missing an analog of perl keyword __PACKAGE__ in Java. This, sometimes also have to do with the first issue. For example I want to create an abstract class which defines the structure of a database table model, and this class should have static methods such as retrieveAll or search to return an array of objects of this class. Lets assume that I am allowed to have static methods in abstract classes and that I have a __PACKAGE__ option, then I would write something like this:

abstract public class DBModel extends DB {

abstract static private String dbTableName;

static public __PACKAGE__ retrieveAll () {

DB myDB = new DB();
myDB.query(\"SELECT id FROM \" + dbTableName + \"\");

if (myDB.getResultCount() > 0) {
int i = 0;

__PACKAGE__ itemList[];
while (myDB.getResultSet().next()) {

itemList[i++] = __PACKAGE__ new( myDB.getResultSet().getInt(\"id\") );
}
return itemList;

}

return null;
}
}

public class MCategories extends DBModel {

static private String dbTableName = \"customers\";
}

Like this, all classes which extend DBModel would have a static method retrieveAll() which would retrieve a list of all items from the DB.

3. Declaration and assignment to a variable inside of if/while/whatever. Sometimes I just need to do something like this (using the above example):

if ((Object[] objectsList= MCategories.retrieveAll()) != null) {

// do something with objectsList[].
}

If you know some workarounds, please let me know.

Sun JDK on Fedora Core 6

I am not a Java fan and I do prefer doing all my stuff in Perl (due to the perl being more flexible and comfortable to code in [my personal view] and probably due to the nature of the tasks I have), but due to the college class Object Oriented Programming which is totally taught in Java, I have to install Sun JDK on my laptop for some time.

It turned out that the task is not that easy (actually easy, but tricky), but I found a nice article which describes all steps needed to get Sun JDK configured on the system – works for me