Liquid Templating 'latest_articles' Collection with limit N

Posted by seon on Friday, July 11

Recently I modified my home template to render only the latest X articles.

I changed this:
1
{% include 'article' with articles %}
... into this:
1
2
{{ site | latest_articles: 5 | assign_to: 'recent_articles' }}
{% include 'article' with recent_articles %}

I am not really satisfied with this markup. Is there a more concise solution that does not involve local variable assignment?

Code Syntax Highlighting Sample 1 balloon

Posted by seon on Monday, September 03

A few code snippets using CodeRay filters for syntax highlighting.

lang=”ruby”
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

require 'coderay'
class CodeMacro < FilteredColumn::Macros::Base
  def self.filter(attributes, inner_text = '', text = '')
    lang = attributes.delete(:lang)
    attributes[:line_numbers] = :table unless attributes.has_key?(:line_numbers)
    attributes.each do |key, value|
      attributes[key] = value == 'nil' ? nil : value.to_sym rescue nil
    end

    begin
      CodeRay.scan(inner_text, lang.to_sym).html(attributes)
    rescue ArgumentError
      CodeRay.scan(inner_text, lang.to_sym).html(:line_numbers => :table)
    rescue
      unless lang.blank?
        RAILS_DEFAULT_LOGGER.warn "CodeRay Error: #{$!.message}"
        RAILS_DEFAULT_LOGGER.debug $!.backtrace.join("\n")
      end
      "<pre><code>#{inner_text}</code></pre>"
    end
  end
end
lang=”javascript”
1
2
3
4
5
6
7

fixIEOverlapping: function() {
  Position.clone(this.update, this.iefix, {setTop:(!this.update.style.height)});
  this.iefix.style.zIndex = 1;
  this.update.style.zIndex = 2;
  Element.show(this.iefix);
},

Airake Ruby Gem Released

Posted by seon on Saturday, September 01

My friend and coworker Gabe (of Slickr and Dclicio.us fame) has recently released a great ruby gem for generating rake tasks and templates for developing Adobe AIR apps. Check it out!

Airrake, Rake tasks and generators for Adobe AIR apps.