Archive for September 2010

## An interesting Artic: Unix's Revenge

The article is titled Unix’s Revenge and it was quite a good read.

Here is a quote:

Now we’ve entered a new decade of devices where Unix(-like) operating systems will, on a CPU basis, probably out-install Windows. Not only is iOS based on Unix, but Android and MeeGo and even Bada are based on Linux as are QNX and WebOS. Google, Apple, HP, RIM, Samsung and Nokia are all now betting heavily on Unix or Unix-like implementations. The success is so overwhelming that there are really only two hold-outs: Microsoft and the rapidly depreciating Symbian.

http://www.asymco.com/2010/09/29/unixs-revenge/

## A brief history of my computer life…

Hello. I came across this post on the FreeBSD forums:  How you did you come FreeBSD world?

I started to respond but I felt my response was too long to put in a forum comment, so I am sticking it here on my blog.

A brief history of my computer life

My family had an Adam computer that ran on tape drives when I was young, boy was that Buck Rogers game and that Pong game awesome back then.  I did my math homework in a primitive text editor when I was in 4th grade (1986), even though it was harder than doing it with a pencil. Then at some point we got a 286 running DOS, which migrated to LeMenu, then to windows 3.11.  I remember hacking around Windows 3.1.1 just learning how the system worked.  Once moment, I would be gaming, the next, just looking at why the game installed the way it did, how the system was laid out.  At some point my family got a 386.

I remember getting online for the first time in 1994 with 14.4 modem. I remember windows 95. King’s Quest (1-6) were my favorite games.  At school I had programming and graphics course, all on Apple of some sort.

In 1995, I had a semester at the University of Utah which included one programming class. All their systems were unix based and we emailed using pine.

I didn’t touch computers much from 1996-1998 because I served a mission for my church in the Dominican Republic.  When I got back, Windows 98 was out and I earned enough to buy a computer. Technically it was the first computer that was “mine” because all the ones I had used before had belonged to my family or my school. StarCraft replaced King’s Quest as my favorite game.

In 1999 I took some MCSE courses. Around the same time, Microsoft outsourced their tech support for Windows 2000 to a company called Convergys.  This was in Orem, Utah. There was a guy there talking up Red Hat who gave me a Red Hat 6 CD. I told him to install it an get on the internet in under an hour.  It installed fine. But we never got it on the internet.  Turns out he was a newbie.  I played with Red Hat 6 for a week and never got Red Hat online. I was a Windows 2000 support guy anyway, right…I did get my NT 4.0 MCSE.

Well, Nortel Networks outsourced their tech support to the same place, and I jumped over there.  I guy named Joe introduced me to FreeBSD 4.6.

At some point, I convinced my brother to drop windows servers and use FreeBSD for his servers at his ISP, Psionyx.net (now FusionNetworks.com).

I then started www.bsdcertification.com, however, I was new to the BSD world and not really well-known and some other well-known members started www.bsdcertification.org a few months later, completely unaware of the effort I had put in.  At first I was irked and felt like they stole my project but I eventually got over it and turned my website over to them and now I am probably going to proxy exams at the upcoming UTOSC.

I got a job at LANDesk in 2004.  While it has an Agent for Linux/Unix it is pretty  much a windows tool.  I have really kept up my Windows knowledge and though I haven’t updated my MSCE, I probably have enough knowledge and experience with windows to be considered an expert. A year ago I became a developer with LANDesk and we do most everything in C# (though I get to touch legacy C++ code), so needless to say I use Windows 7 at work. I have really nice dev box running Windows 7 that is a VMWare host, and they give me a laptop with Windows 7 on it too.

So I’ve never really left Windows in the desktop world completely. I have a FreeBSD desktop and a FreeBSD server.  Actually, my work gives me a license for VMWare so I have dozens of virtual machines that I continue to use and test all kinds of platforms on, with FreeBSD being my open source platform of choice.  Twice I have gotten a FreeBSD server into production at LANDesk, once as a internal knowledge base, once as an SVN server, neither lasted.  I did become the subject matter expect for the LANDesk Linux agent and the LANDesk Linux-based appliance called the Management Gateway.

I am typing this on my work provided laptop that is running Windows 7.  I have a Remote Desktop session to a decently powerful computer that is also running Windows 7 and is a VMWare Workstation host (BSD is not supported as a VMWare host). As VMWare guests,  I have two FreeBSD VMs running currently and about a dozen freebsd VMs that I create for learning. Eventually, I delete them once I have learned what I created them to learn.

No I haven’t found a permanent FreeBSD project to call my home.  I keep dabbling here and there.  Mostly, I just document my learning, but eventually, I want to develop some BSD-related project.  It would also be awesome to have a job focused on FreeBSD.  However, I am way more than happy at LANDesk and I had an opportunity to leave for a Linux training company and I came close to doing so, but I just couldn’t leave a great company like LANDesk.  So the LANDesk and Windows world remains my work life, and FreeBSD remains one of my hobbies.

# MSVCR100.dll

This msvcr100.dll is the Microsoft Visual C++ Redistributable dll that is needed for projects built with Visual Studio 2010. The dll letters spell this out.

MS = Microsoft
V = Visual
C = C program language
R = Run-time
100 = Version

If you create a C++ project in Visual Studio 2010, this file is probably needed.

# MSVCP100.dll

This msvcp100.dll is the Microsoft Visual C++ Redistributable dll that is needed for projects built with Visual Studio 2010. The dll letters spell this out.

MS = Microsoft
V = Visual
CP = C++
100 = version

If you create a C++ project in Visual Studio 2010, this file is probably needed.

# MSVCR100D.dll

The MSVCR100D.dll is almost the exact same file only the D at the end stands for Debug. This file has debugging enabled and is not considered redistributable.

# Why the error?

Ok, so recently I switched to Visual Studio 2010.  I had a C++ application that worked perfectly in Visual Studio 2008.  Once I compiled it with Visual Studio 2010 and ran it on a clean 2008 server (fully patched but otherwise clean), it failed to run with the following error.

TestWin32.exe – System Error

The program can’t start because MSVCR100.dll is missing from your computer. Try reinstalling the program to fix this problem.

Here is the screen shot:

The same things happens with the debug version of the file, only it is a the debug version of the same DLL as noted by the fact that the DLL name ends with D.

Autorun – System Error

The program can’t start because MSVCR100.dll is missing from your computer. Try reinstalling the program to fix this problem.

The screen shot is identical except for the D in the dll name.

I create a new project in Visual Studio 2010 using the project type of C++ Win32 Project and without making a single change to the default project, I built the file and tested it on my clean machine and the same issue occurred.

So obviously that is not acceptable.  It seems like this should just not happen by default, but unfortunately it does.

# Solution

It was actually really easy to resolve for my one project.

Here is what I did.

You can solve this any of the following ways:

1. Statically link to the dll files so they are compiled into my executable instead of referenced as separate dll files.
2. Included the dll in the same directory as the exe (I actually didn’t try this but I assume it would work).
3. Forced everyone to install the VC++ Runtime Redistributable before running the app.

The first option seems the most stable and robust and easiest for a single executable. So that is the one I am going to use.

The second option doesn’t really make sense to me and I would probably never do it.  Maybe if I had dozens of executable files that all required the same DLL and I didn’t have an installer, and I wanted to conserve size, which probably wouldn’t happen for me since I am pretty good at creating a quick installer. Though you might be in this a situation.

The third option would make sense if I was planning on running my executable after an install.  During the install I could include the VC++ Runtime Redistributable and all would be fine.

Make sure you resolve it for both Release and Debug.  The steps are slightly different.

### Release

1. In Visual Studio, I went to the project Properties.
2. I changed my Configuration to Release.
3. I went under Configuration Properties | C/C++ | Code Generation
4. Look at the Runtime Library setting.  It is set to this: Multi-threaded DLL (/MD)
Change it to this: Multi-threaded (/MT)
5. Rebuild.

### Debug

Almost exactly the same as release.

1. In Visual Studio, I went to the project Properties.
2. I changed my Configuration to Debug.
3. I went under Configuration Properties | C/C++ | Code Generation
4. Look at the Runtime Library setting.  It is set to this: Multi-threaded Debug DLL (/MDd)
Change it to this: Multi-threaded Debug (/MTd)
5. Rebuild the debug

It might be a good idea for me to figure out how to change the project so when I create a new project of this type, those settings are the default.

# OSQL basic commands

## Logging into a database with osql

Example1: Specifying the user and letting the command line prompt for a password.

c:\> osql -S Core\ldmsdata -U sa

Example2: Specifying the user and the password.

 c:\> osql -S ld87\ldmsdata -U sa -P pw

Example3: Using a trusted connection

 c:\> osql -E

## Show databases

 1> 2> select * from sysdatabases go

Note: Or to see only the database Name row do the following:

 1> 2> select Name from sysdatabases go

## Creating a database

 1> 2> create database DatabaseName go

## Selecting a database

 1> 2> USE master go

## Drop a database

 1> 2> drop database DatabaseName go

## Show tables

 1> 2> 1> 2> USE DatabaseName go select * from INFORMATION_SCHEMA.TABLES go

Note: Or to see only the Table_Name row do the following:

 1> 2> 1> 2> USE DatabaseName go select TABLE_NAME from INFORMATION_SCHEMA.TABLES go

## Drop a table

 1> 2> 1> 2> USE DatabaseName go drop table TableName go

## Insert a row into a table

 1> 2> 1> 2> USE DatabaseName go INSERT INTO TableName Values(“Column1value”,”Column2value”,”Column3value”) go

Note: Or to insert by only providing values for a few columns and letting the other columns take the default values. This is useful when the first column is set to AUTO_INCREMENT.

 1> 2> 1> 2> USE DatabaseName go INSERT INTO TableName (Col2, Col3) Values(“Column2value”,”Column3value”) go

## Update a value in row of a table

 1> 2> 1> 2> USE DatabaseName go UPDATE TableName set ColumnName=’NewValue’ where SomeColumn=’whereValue’ go

## Drop a view

 1> 2> 1> 2> USE DatabaseName go drop view ViewName go

## Backup a database

 1> 2> BACKUP DATABASE ulddb TO DISK=’c:\path\to\dbbackup.bak’ WITH FORMAT go

You can do this at the command prompt with one single command:

 c:\> osql -S ld87\ldmsdata -U sa -P pw -Q “BACKUP DATABASE ulddb TO DISK=’c:\path\to\dbbackup.bak’ WITH FORMAT”

## Change the SA password with one line in a command prompt

 c:> osql -E -S localhost\ldmsdata -d ULDDB -Q “sp_password NULL,’P@ssword’,'sa’”

I hope this helps you.

# Enabling SQL Statement Logging in Postgresql

It is often nice to see what SQL statements an application will run.  Maybe there is a gui app to add a user and you want to script adding one thousand users and you want to make sure you know how users are add.

So in Microsoft SQL Server there is a SQL Profiler tool that will show you all the SQL statements.  However, when using Postgresql on FreeBSD, there is often nothing but the command line.

You can easily have all SQL statements logged to a file in Postgresql on FreeBSD.

Note: I already have a post on Installing and Using Postgresql on FreeBSD.

# Logging all SQL statements

Here is how to do it:

## Step 1 – Configure the postgresql.conf

1. Open the postgresql.conf file.
ee /usr/local/pgsql/data/postgresql.conf

2. Find the log_statement value in the log. Uncomment it and set it to all.
log_statement = 'all'                   # none, ddl, mod, all

3. Close and save the postgresql.conf file.

## Step 2 – Configure the syslog.conf

1. Open the syslog.conf file.
ee /etc/syslog.conf

2. Add the following line to the end of the log.
local0.*                                        /var/log/pgsql.log

3. Close and save the syslog.conf file.

## Step 3 – Create the log file

1. Create the log file.
touch /var/log/pgsql.log

2. Make the file a little more secure.
chmod 600 /var/log/pgsql.log


## Step 4 – Restart Posgresql and Syslog services

1. Restart the postgresql service.
/usr/local/etc/rc.d/postgresql restart

2. Or in FreeBSD 8.1 and later, you can use this syntax.

service postgresql restart

3. Restart the syslogd service.
/etc/rc.d/syslogd restart


Or in FreeBSD 8.1 and later, you can use this syntax.

service syslogd restart


Ok, now you should be able to capture the sql statements.  Here is a log entry from my /var/log/pgsql.log.

Sep  9 22:10:26 FBSD81 postgres[18507]: [5-1] LOG:  statement: select * from "Member";


# Logging the time it takes to execute the SQL statement

Ok, this assumes you have already done the steps above.

## Step 1 – Configure the postgresql.conf

1. Open the postgresql.conf file.
ee /usr/local/pgsql/data/postgresql.conf

2. Find the log_min_duration_statement value in the log. Uncomment this line and set it to zero.
log_min_duration_statement = 0          # -1 is disabled, 0 logs all statements
# and their durations, > 0 logs only
# statements running at least this number
# of milliseconds


NOTE: It is interesting to note that you can have the log_statement value on or off.  So technically, enabling the log_min_duration_statement will also log all SQL statements if it is set to 0.

3. Close and save the postgresql.conf file.

## Step 2 – Restart Posgresql

1. Restart the postgresql service.
/usr/local/etc/rc.d/postgresql restart

2. Or in FreeBSD 8.1 and later, you can use this syntax.

service postgresql restart


Ok, now you should be able to capture the sql statements.  Here is a log entry from my /var/log/pgsql.log.

Sep  9 22:26:06 FBSD81 postgres[18759]: [4-1] LOG:  statement: select * from "Member";
Sep  9 22:26:06 FBSD81 postgres[18759]: [5-1] LOG:  duration: 0.957 ms


# Logging SQL queries that take too long to execute

If the log_statement value is on.  All SQL

## Step 1 – Configure the postgresql.conf

1. Open the postgresql.conf file.
ee /usr/local/pgsql/data/postgresql.conf

2. Find the log_min_duration_statement value in the log. Uncomment this line and set it to a value in milisecond.  For example, to log any statement that takes longer than 3 seconds, use 3000.
log_min_duration_statement = 3000     # -1 is disabled, 0 logs all statements
# and their durations, > 0 logs only
# statements running at least this number
# of milliseconds

3. Find the log_statement value in the log. Comment out the line or set the value to none (or both).
#log_statement = 'none'                   # none, ddl, mod, all

4. Close and save the postgresql.conf file.

## Step 2 – Restart Posgresql

1. Restart the postgresql service.
/usr/local/etc/rc.d/postgresql restart

2. Or in FreeBSD 8.1 and later, you can use this syntax.

service postgresql restart


Ok, I don’t really have a SQL statement that will take 3 seconds, so I configured it for 10 milliseconds and I could see that statements that took less than 10 milliseconds were not logged while those that took more were logged.

# IMPORTANT! Turn logging off when you are done

Don’t forget to turn this logging off when you are finished as this is a huge performance hit.  Leaving this on is not efficient and can result in slowness.

## How to document a function so Visual Studio's Intellisense displays it?

So, when I code, I am usually in Visual Studio and I am used to writing documentation above my functions as follows:

        /*
* The is SomeFunction that does some action.
*/
private void SomeFunction(int inSomeValue)
{
// write code here
}


However, it annoys me that this information doesn’t show up in Visual Studio’s Intellisense. So I took time to look up the proper way to make function documentation show up in Intellisense.

It turns out that you can type /// above a function and Visual Studio will automagically populate the markup needed to have your comments show up in intellisense.

        /// <summary>
///  The is SomeFunction that does some action.
/// </summary>
/// <param name="inSomeValue">Enter an integer as some value here.</param>
private void SomeFunction(int inSomeValue)
{
// write code here
}


So it seems if you use this syntax, the function documentation will now show up in Visual Studio’s Intellisense.

# Choosing a Content Management System

Ok, so as today, August 26, 2010, my blog is hosted by WordPress.com.  It will be this way for some time.

However, I am probably going to eventually have my own server hosted somewhere. Probably with my brother’s company, Fusion Networks.

So I will probable build a FreeBSD server that will host my site.  At this point, I think I will stop using WordPress and use a different Content Management System.

## Content Management Systems Lists

So I went into this having done reasearch before, so I knew what I was getting into.  There are plenty of different Content Management Systems and unfortunately there is no way I could find time to test them all.

Wikipedia had a great list of Content Management Systems.
http://en.wikipedia.org/wiki/List_of_content_management_systems

Ok, now that  you have seen the very large list of Content Management Systems, you realize that I have to narrow my list down without really testing them all.

## Narrowing down the list

First, let me document what I would like and see if which fit into the list.  These are not in order of priority, and some are important and some are not.

I want it to

1. use PHP
2. have a large community
4. use Postgresql (as it is BSD licensed and MySQL is not)
5. import my existing WordPress blog
6. have great feature sets
7. have common plugins
8. support multiple Blogs with one install
9. manages website as well as blog
10. manages multiple sites
11. have a descent editor
12. be well documenated

### PHP-Based

They have their lists separated  into tables by programming language.  The PHP table has the most options and since I for sure want to use PHP, it is the only table I will focus on.  These tables even lists the license.

However, I did look at the other tables, just in case one was mostly PHP-based but didn’t show up in the PHP list.  For the full PHP list, go here:

http://en.wikipedia.org/wiki/List_of_content_management_systems#PHP_2

### Large community

So the big three Content Management Systems seems to be these.  I don’t have any data to back this up.  I think this is just because these three seem to be more mentioned when doing Google searches.

• Drupal
• Joomla
• WordPress

However, none of those are BSD Licensed, which I prefer. I am not opposed to GPL or LGPL, but I feel more comfortable with BSD licenses software.

The Content Management Systems that are PHP-based and use the BSD License are these:

Had one of the Big 3 been BSD licensed, my decision would have probably been easy.  However, obviously I am going to have to test some of the three BSD licensed Content Management Systems.

### Supports Postgresql

Of the six Content Management Systems listed above, the following support Postgresql.

• Drupal
• Serendipity
• SilverStripe

### Can import my WordPress blog

It appears that they all can do this.

I am worried about links, however.  My blog entries often link to each other.  I question whether they do it perfectly.  For example, a link to one of my WordPress blogs might be this:

http://rhyous.com/2010/08/25/freebsd-now-has-the-service-command/

So the link has this format:

http://homepage/YYYY/MM/DD/name-of-blog-entry/

So if I go with something other than WordPress, then after importing my blogs, are all the links going to be broken?

# Making the Decision

So here is the rating, after a very small overview of the different CMS web sites, and before verifying their marketing claims.

I am giving 0 to 3 points for each feature. (This is subject to change over time, should I want to come back after the decision and report on something).

 Features Worpress Drupal Joomla Serendipity SilverStripe Pimcore 1. PHP-Based 3 3 3 3 3 3 2. Large community 3 3 3 1 1 1 3.BSD License 0 0 0 3 3 3 4. Postgresql Support 0 3 0 3 3 0 5. Imports WordPress 3 1 ? 1 1 ? 6. Great Feature set 3 3 3 1 3 ? 7. Has common plugins 3 3 3 3 2 ? 8. Multiple Blogs 3 3 3 3 2 ? 9. Manages Website as well as blog 3 3 3 0 3 ? 10. Multiple Sites 2 3 ? 0 3 ? 11. Editor 3 3 ? 2 3 ? 12. Documenation 3 3 ? 1 3 ? Score: 29 31 ? 21 30 ?

Here is what I am going to do:

I am going to build a BSD, Apache, PHP, Postgresl virtual machine and test Drupal and Serendipity to see how the import goes.

Perhaps I will have a follow-up some time because:

1. I have to test these different CMSes
2. I am sure there are a dozen other items that should be scored 1-3 that I haven’t thought of.

## Serendipity

I started out looking at Serendipity first.

### Positives

There was a FreeBSD port.

The install was painless.

### Negatives

Their web site didn’t seem very good, which is a big turn off for a company that is a CMS.

The links to their Forum on their web site and other pages were broken.  I did find that the forum does exist, so the links are just broken.

I tried to sign up for the Forum to report the broken links.  I registered, but was supposed to be sent a confirmation email, which I never received, even after re-requesting it, so I have never reported the broken links.  They are still broken a day later. Also, there appear to only be a handful of people on their forums at any given time. Both suggest they have a small community.

I couldn’t figure out how to design my home page. It seemed the blog was my home page.  I couldn’t figure out how to move my blog entries to a different page.

### Result

If you want one blog and nothing else, this would work for you.

I need more. I stopped trying and have dropped Serendipity from the list.

## SilverStripe

I looked at SilverStripe second and I way more pleased with its feature set.

### Positives

Though I had some install problems, I found solutions on their forums.

• Home

They had both Site Management and Blog management.

There are many extensions: modules, themes, widgets.

Modules include a Blog Modules and Sub-site module, so I could manage multiple sites and multiple blogs.

The user interface is simple and easy to use.

The documentation is sufficient.

### Negatives

I had install/setup problems (that were resolved) by the Forum.  Supposedly they only occur with Postgresql.

Not a lot is included in the default install.

The community is smaller than I would like.

The documentation is only sufficient.

### Conclusion

I really like the SilverStripe interface.

It had almost everything I am looking for.  It is BSD Licensed.  It supports Postgresql.

It is a Content Management System first, and has modules to add to it.  There a blog module, a multi-site module, which really interested me.

However, while it has a module to import a WordPress xml, I have yet to get it to work.  That is something I can live with, but I would prefer it to work.

## Drupal

### Positives

It has many features, and any feature it lacks is pretty much filled by an add-on or widget.

The documentations seems thorough.

The community looks to be large.

### Negatives

I had to install a different version of wordpress to support multiple blogs.

The admin site seemed rather overwhelming. There were almost too many options.

Conclusion

If this were BSD licensed, it would be my pick.  It seems great.

## WordPress

### Positives

It is popular and familiar.  The most common platform of the blogging world.

It has many features, and any feature it lacks is pretty much filled by an add-on or widget.

Migrating from my existing WordPress blog is flawless.

The community is huge.

The documentation is a plenty.

### Negatives

It doesn’t support Postgresql.

## Joomla

I almost feel like apologizing to Joomla.  I had two BSD servers, one with FreeBSD, Apache, PHP, MySQL where I installed WordPress a year ago for testing.  I have another brand new server with FreeBSD, Apache, PHP, and Postgresql where I tested all the postgresql capable CRMs.  However, I installed Joomla to the wordpress server and it just didn’t work.  The page was blank.  I actually think there was a php error, not a Joomla error.

Unfortunately, Joomla doesn’t support postgresql, it isn’t BSD licensed.  I did research and it appears like it would score high with WordPress, Drupal, and Silverstripe, but I can’t really see how it would be any better than Drupal, or Silverstripe so I really had to cut it loose.  Lets be honest.  As a BSD users, it was beaten out by Drupal and Silverstripe for the same reason I am looking to replace WordPress.  It doesn’t support Postgresql.

## Others

There are two other Content Management Systems that I feel are worth mentioning.

Django is also a CMS that is BSD licensed and supports Postgresql. However, it runs on Python, a language which I have occasionally touched but never really developed in.  If you know Python, this might be the choice for you.

Bricolage is also a CMS that is BSD licensed and supports Postgresql. However, it runs on Perl, which I have written a few things with, but not as much as PHP.  If you know Python, this might be the choice for you.

# My Decision

I know, you all want to know which I chose to use.

I have chosen…

But don’t expect my blog to move to Silverstripe tomorrow.  It move slowly with things like this.  It could take months or get delayed for a year.

Anyone who might choose a CMS differently would be completely happy with any of the others they evaluate and feel meets their needs.  I am not saying I chose the best.  I am saying I chose the best for my needs.  Hopefully, you know your needs and this will help you choose the best Content Management System for your needs.

## The Utah Open Source Conference – October 7th, 8th, and 9th

Hey all,

I am going to be attending the Utah Open Source Conference and manning the BSD table for maybe part of or the majority of the time.

Here are some details:

There will probably be some BSD swag if you attend, courtesy of iXsystems and PC-BSD.

You can schedule a BSD Certification exam if you desire.

Hope all you computer geeks in Utah can attend.

If you aren’t into Open Source, then then this conference is especially for you. If you don’t know much about Open Source, then you are missing out.