Monday, March 26, 2012

Creating a Comma Delimited String from an Array

Something I haven't done very often is work with delimiters. But now is a time where I do have to occasionally generate some sort of output from an array and return a comma delimited string from it.

Previously, I would loop through every element of the array, append the delimiter and a space for readability, then go back, and chop off the last two characters. I never did like this, and always thought there may be a better way.

String[] Color ={"Red", "Orange", "Yellow", "Green", "Indigo", "Blue", "Violet"};
StringBuilder loopedColor = new StringBuilder();
foreach (var theColor in Color)
loopedColor.Append(", ");

var returnedLoop = loopedColor.ToString().Substring(0, loopedColor.ToString().Length - 2);

Later I would find the function that takes care of it for me- String.Join();

String[] Color ={"Red", "Orange", "Yellow", "Green", "Indigo", "Blue", "Violet"};
var JoinedStatement = String.Join(", ", Color);

Cleaner, and I'm sure Microsoft has thought about it more than I have. Why re-invent the wheel?

Saturday, March 24, 2012

Using Gmail/Google Apps for your Email

One issue I've always had with hosting websites is the email. I've never liked having to deal with mail servers, configuration, spam blocking, and so on. Google has come out with Google Apps. Google Apps is a suite of web based office tools, offered to businesses for basic organization. Tools like email, spreadsheets, calendars, and so on are just a few of the main tools available.

I'm using this for my personal site, so as long as I stay within a few reasonable limits, I don't have to pay to use this service. I was excited to get this started, and here are the steps to set this up.

1. Go to the Google Apps Home Page. Click on Begin Free Trial.

2. Enter in your domain name in the first box. I assume you've gotten a domain from GoDaddy, or Dotster, or some other registrar.

3. Fill in the remaining information, accept the terms and service, and click the create my account button at the bottom.

4. You may get a message about you being logged into a different Google account, but you'll want to switch to the new account you just made for your domain. It will be considered the Administrator account for your mail.

5. I went with the Express setup, so click Express. Then click next. Click next.

6. Download the HTML Verification file, and post it into the root directory of your website. By putting it there, Google can confirm you own that domain. Go back to the Google wizard, and click Verify.

7. Click the radio button No, and then click next. Click Next. Click Next. You're going to want to use Google's servers for routing, and click next.

8. Find your domain host in the drop down list (I had to select other).

9. Add the MX records to your domain. If you don't know how to do this, contact your registrar for help. You can do some Googling too to find out how to do this. What this does is have all of your mail go to Google's servers.

10. Click next. Make sure yes is selected, and click next. This screen tells you if you did it correctly, but is kind of useless because it'll take your changes quite a while to propagate through the internet. Usually 24 hours is the rule. Click Next.

11. Unless you want Google Calendar right away, click Do this later.

12. Unless you want Google Docs right away, click Do this later.

That's it. There are a lot of tools that you aren't using, but my goal was to get you up and running with your email pointed to Gmail as fast as I could. Any time you want to go in and make changes, like adding users, or setting up other services across your entire domain, you can go to the login for Google Apps, and select Sign In at the top.