<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-US">
  <id>tag:matharvard.ca,2009:/posts</id>
  <link type="text/html" href="http://matharvard.ca" rel="alternate" />
  
  <title>MatHarvard.ca: Posts</title>
  <updated>2009-05-25T20:28:59-07:00</updated>
  <link rel="self" href="http://feeds.feedburner.com/matharvard" type="application/atom+xml" /><entry>
    <id>tag:matharvard.ca,2009:Post/25</id>
    <published>2009-05-25T20:28:59-07:00</published>
    <updated>2009-05-29T22:52:06-07:00</updated>
    <link type="text/html" href="http://matharvard.ca/posts/25-hello-comments" rel="alternate" />
    <title>Hello Comments</title>
    <content>
      <summary type="html" />
      <body type="html">&lt;p&gt;Search, categories, and what else? Oh yeah, comments! You can now leave your opinion, negative or otherwise, on any of my posts (that aren't over a week old). So feel free to flame, though you might get banned, but hey! The only bit missing out of the comment system is a way to preview your comment, I'll probably tackle this with a bit of AJAX trickery sometime this week or next. The previous CMS I wrote has all the code for previewing comments; however, the code is a bit dirty, and I'd like to take the time to write a fresh version (and maybe a tutorial to go along with it).&lt;/p&gt;</body>
      <exteneded type="html" />
    </content>
    <author>
      <name>Mathew</name>
      <email>mat.harvard@gmail.com</email>
    </author>
  </entry>
  <entry>
    <id>tag:matharvard.ca,2009:Post/24</id>
    <published>2009-05-23T08:49:36-07:00</published>
    <updated>2009-05-29T22:52:06-07:00</updated>
    <link type="text/html" href="http://matharvard.ca/posts/24-search-is-back" rel="alternate" />
    <title>Search is Back</title>
    <content>
      <summary type="html" />
      <body type="html">&lt;p&gt;My Saturday morning work quota is complete, and so is the search feature! (What I won't mention is that I had already written the code last week and just never bothered committing it until now.) Anyway, have fun finding stuff!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; Post categories are now viewable; however, the &lt;code&gt;show&lt;/code&gt; pages need some prettying up. Also, just to tempt people, the comments count shows up under each post... you just can't write comments yet! (Bad joke, I know)&lt;/p&gt;</body>
      <exteneded type="html" />
    </content>
    <author>
      <name>Mathew</name>
      <email>mat.harvard@gmail.com</email>
    </author>
  </entry>
  <entry>
    <id>tag:matharvard.ca,2009:Post/23</id>
    <published>2009-05-12T22:46:20-07:00</published>
    <updated>2009-05-29T22:52:05-07:00</updated>
    <link type="text/html" href="http://matharvard.ca/posts/23-about-halfway-through-may" rel="alternate" />
    <title>About Halfway Through May</title>
    <content>
      <summary type="html" />
      <body type="html">&lt;p&gt;I'm not sure what really happened, but the last time I wrote here was back in February. Back then I just started work on a website for a local garden center, &lt;a href="http://scentsationalplants.ca/"&gt;Scent-Sational Plants&lt;/a&gt;, which has been launched, though it's not fully operational; archiving and photographing every single plant one owns takes some time, so that part of the site is inaccessible for now. The other project I had going at the time was a tumblelog. Everything worked fine, or would have with a little more time, but I just decided to put it on hold. One reason for doing so was the lack of a proper design, and also the pending release of &lt;a href="http://weblog.rubyonrails.org/2009/3/16/rails-2-3-templates-engines-rack-metal-much-more"&gt;Rails 2.3&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In the meantime I've kept my self... occupied. Everything seems to get more intense as the end of term nears, and being my graduation year makes it even more tiresome (but awesome!). It's only recently that I've found some time to play around in Rails again, and update my website at the same time. The new design is barely worth mentioning, even though it was the first piece I finished. The star of the show is the fresh application running everything. Doing a full re-write was never my original plan; however, it was well worth it. I went all out this time, that means a full admin panel complete with a custom design and lots of nifty widgets.&lt;/p&gt;

&lt;h3&gt;What's Missing&lt;/h3&gt;

&lt;p&gt;It may seem a little sparse right now, that's because some pieces haven't yet made it to the public side of the website. Those include categorized posts, multiple authors and a curious comment system. All of which are fully functional, and will slowly be added in due time. The only thing that makes the comments, "curious", is that it's now polymorphic. Which will allow me, one day, to extend it's scope into other parts of the site, say a photo gallery or back-end multi-author editing with criticism comments thing.&lt;/p&gt;

&lt;h3&gt;What's New&lt;/h3&gt;

&lt;p&gt;Here are a few screenshots of the admin panel. It's pretty modular, so the basic design from these pages carries into everything else.&lt;/p&gt;

&lt;h4&gt;The Dashboard&lt;/h4&gt;

&lt;p&gt;A list of recent activity around the site. It's just done by a global observer on all saves, updates and deletes.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.flickr.com/photos/matharvard/3527874072/" title="Dashboard Screen by Mat Harvard, on Flickr"&gt;&lt;img src="http://farm4.static.flickr.com/3650/3527874072_9f9ec3e01c_o.jpg" width="630" height="533" alt="Dashboard Screen" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;Post List&lt;/h4&gt;

&lt;p&gt;Lists all posts and basic information about them. The same design is used for categories and users, just different columns.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.flickr.com/photos/matharvard/3527874192/" title="Post List by Mat Harvard, on Flickr"&gt;&lt;img src="http://farm3.static.flickr.com/2019/3527874192_49a0838599_o.jpg" width="630" height="533" alt="Post List" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;Publish Page&lt;/h4&gt;

&lt;p&gt;A post has a summary, body and extended field, which make up the content of the post. I can select multiple categories, or set the publish date in the future, or even set a custom permalink (I've kept the &lt;code&gt;id-post-title&lt;/code&gt; format so as not to break too many links, &lt;strong&gt;Update:&lt;/strong&gt; Changed to just &lt;code&gt;permalink&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.flickr.com/photos/matharvard/3527062661/" title="New Post Screen by Mat Harvard, on Flickr"&gt;&lt;img src="http://farm3.static.flickr.com/2253/3527062661_7e7b1b4222_o.jpg" width="630" height="533" alt="New Post Screen" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's all there is to it for now. Eventually I'll add some more features, such as automatic comment expiration, or post drafts/revisions. For now, it does just what I need.&lt;/p&gt;</body>
      <exteneded type="html" />
    </content>
    <author>
      <name>Mathew</name>
      <email>mat.harvard@gmail.com</email>
    </author>
  </entry>
  <entry>
    <id>tag:matharvard.ca,2009:Post/22</id>
    <published>2009-05-11T23:16:31-07:00</published>
    <updated>2009-05-29T22:52:05-07:00</updated>
    <link type="text/html" href="http://matharvard.ca/posts/22-works-in-progress" rel="alternate" />
    <title>Works in Progress</title>
    <content>
      <summary type="html" />
      <body type="html">&lt;p&gt;It's definitely been a good last few weeks for me.  First signed on a project for a garden center, and made some good business connections (both local!), secondly I've almost completed my tumblelog application, which as of yet has no name.  The only features missing are a few post types, videos, audio and pictures to be precise.  Sure they may be the trickiest to implement, but I love challenges.  It should hopefully be done by the next &lt;a href="http://groups.google.com/group/vicruby"&gt;VicRuby&lt;/a&gt; meet-up (February 25th, 7:30 PM at the Fernwood Inn), so I can show it off.&lt;/p&gt;

&lt;p&gt;Here's a few snippets I've found useful as of late:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;#
# I use this to convert pixel font-sizes to ems.
#
def em(pixels)
  pixels.to_f / 16.0
end

#
# Gets those nested em line-heights/margins/font-sizes.
# If you know the documents base line-height then it's faster
# to just divide it by the parent's font-size manually.
#
def nested_em(child, parent)
  child.to_f / parent.to_f
end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This is my version of Apple's Time Machine, couple it with a cronjob and you're golden.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;#!/bin/bash

rsync -avl --delete --stats --progress "/Users/mat/Documents/Important Data" "/Volumes/External HD/Backups/"
rsync -avl --delete --stats --progress "/Users/mat/Documents/Legal" "/Volumes/External HD/Backups/"
rsync -avl --delete --stats --progress "/Users/mat/Documents/Portfolio" "/Volumes/External HD/Backups/"
rsync -avl --delete --stats --progress "/Users/mat/Documents/Programming" "/Volumes/External HD/Backups/"
rsync -avl --delete --stats --progress "/Users/mat/Documents/Projects" "/Volumes/External HD/Backups/"
rsync -avl --delete --stats --progress "/Users/mat/Documents/School" "/Volumes/External HD/Backups/"
rsync -avl --delete --stats --progress "/Users/mat/Documents/Server" "/Volumes/External HD/Backups/"
rsync -avl --delete --stats --progress "/Users/mat/Documents/Writings" "/Volumes/External HD/Backups/"
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;That's it for now.  There may be a new design in store for my website, but it won't happen till after the release of Rails 2.3.&lt;/p&gt;</body>
      <exteneded type="html" />
    </content>
    <author>
      <name>Mathew</name>
      <email>mat.harvard@gmail.com</email>
    </author>
  </entry>
  <entry>
    <id>tag:matharvard.ca,2009:Post/21</id>
    <published>2009-05-11T23:16:07-07:00</published>
    <updated>2009-05-29T22:52:05-07:00</updated>
    <link type="text/html" href="http://matharvard.ca/posts/21-alias_attribute" rel="alternate" />
    <title>alias_attribute</title>
    <content>
      <summary type="html" />
      <body type="html">&lt;p&gt;The jewel that is &lt;code&gt;alias_attribute&lt;/code&gt; "allows you to make aliases for attributes, which includes getter, setter, and query methods". Observe how these 18 lines of code becomes 3.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;def code
  content
end

def code=(code)
  self.content = code
end

def title
  header
end

def title=(title)
  self.header = title
end

def url
  cite
end

def url=(url)
  self.cite = url
end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This piece of code was taken from a tumblelog app I've been working on, it makes use of single-table-inheritance (STI) to store the posts. On different post types, for example code snippets, It would be nicer to be able to use &lt;code&gt;snippet.code&lt;/code&gt; instead of &lt;code&gt;snippet.content&lt;/code&gt;, or always having to remember what each attribute represents.&lt;/p&gt;

&lt;p&gt;Time for a magic trick.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;alias_attribute :code, :content
alias_attribute :title, :header
alias_attribute :url, :cite
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This code does the exact same as above (getters, setters and nice names). Just in 3 lines, instead of 18.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;alias_attribute(new_name, old_name)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;That's a wrap.  Thank you Paul Cortens for the kick in the right direction with &lt;code&gt;alias_method&lt;/code&gt;.&lt;/p&gt;</body>
      <exteneded type="html" />
    </content>
    <author>
      <name>Mathew</name>
      <email>mat.harvard@gmail.com</email>
    </author>
  </entry>
</feed>
