Subscribe to the MPC blog rss feed feed-icon-14x14
 

Letting Google Know About The Site

Posted on 04:56PM on 08/10/2008
Tags: google

I just went through most of the tools in Google's webmaster tools. Interesting stuff. I created at robots.txt file and placed it in the root of the site. I also created a sitemap.xml file and placed it in the site's root. According to Google, these are two of the most important pieces to have in place if you want your site indexed. Interesting stuff up there for webmasters - lots of analytical tools. Check it out.

0 Comments (Show) (Comments are closed for this post)

Google Analytics

Posted on 05:12PM on 08/09/2008
Tags: google, analytics

Originally on this site, I had implemented a kind of crappy hit tracking mechanism. Today after thinking about it, I thought - why am I bothering to code this when I can get a much better service from Google and for free as well. Check out Google Analytics if you haven't.

0 Comments (Show) (Comments are closed for this post)

Google Syntax Highlighter - Nice!

Posted on 02:19AM on 08/08/2008
Tags: syntax, highlighting, google

I was looking for a way to highlight code in this blog. There appear to be a few ways to go about it. What I like most so far is Google's SyntaxHighlighter. Using nothing but CSS and Javascript, I can make code snippets look good.

For example

C#:

public class SomeClass : SomeBaseClass
{
     public string FirstName {get; set;}
     public string LastName {get; set;}

     public SomeClass(string firstname, string lastname)
     {
         this.FirstName = firstname;
         this.LastName = lastname;
     }

     public string GetFullName()
     {
         return String.Format("{0} {1}", this.FirstName, this.LastName);
     }
}

Python:

class Spam:
    def __init__(self):
        self._state = []

    def eggs(self, arg):
        self._state += arg
end

Ruby:

class SomeRandomClass

  def initialize(hash={})
    #do some initialization with the hash
  end

end

I think that this is pretty slick.

The other cool thing is that I can conditionally control when to include the css and js files. Say I have a collection of posts to display on this page. If none of the posts contains code, why include the additional files?

  #The /posts action
  get '/posts' do
   @posts = Post.all
   #not_empty? is a method I've added to Array/Hash
   @requires_highlighting = @posts.select {|p| p.contains_code?}.not_empty?
   erb :posts
  end

An then in the layout.erb file, I just check for the presence of the @requires_highlighting variable. Simple, but effective

  <% if @requires_highlighting %>
    <%= render_syntax %>
  <% end %>

0 Comments (Show) (Comments are closed for this post)

Please note that I am currently unavailable for any large, long term work.