→ Random Highlighting

Sun Sep 25 2011

Look at the code! I wrote something that will randomly get a random Pygments CSS theme whenever you load this page. If you don’t like a theme, refresh the page and it will change. Here’s some code from rhuidean for you to look at, to play around with it.

client = IRC::Client.new do |c|
    c.server   = "irc.example.com"
    c.port     = 6667
    c.password = "optional_password"

    c.nickname = "rhuidean-bot"
    c.username = "rhuidean"
    c.realname = "built by the Jenn Aiel"

    # These provide basic logging. Debug shows all network traffic.
    # Logger can be set to false to turn off logging.
    # Log level is one of :fatal, :error, :warning, :info, :debug
    c.logger       = Logger.new($stdout)
    c.log_level    = :info
end

EDIT: Nevermind, that was a really bad idea for a few different reasons…

→ Style Change

Tue Sep 20 2011

Just noting that I changed the color of the titlebar from black to white. If you have any suggestions to make this site better, shoot them my way via twitter or IRC.

If you have any other suggestions, e.g. a better title or a better description, go ahead and send those my way too. This is really new. I probably have a lot to learn about CSS.

edit

  • added the hr’s at the bottom of the posts like on ozmm.org
  • changed font-height in the title from 50px to 80px, so that there’s no overlapping

→ This website

Mon Sep 19 2011

Oh hi, you seem to have found my site. I wrote it with nanoc after stealing ozmm’s CSS. I started working on it a few days ago, and here it is.

I plan on using it to post things from code snippets, entire projects that I’m working on, pictures, cool websites I find, cool ruby stuff I find, cool stuff, like nanoc, that I find… It could be anything. I’ve already added a few posts below (mainly because of when I was testing this) from my tumblr.

The code for this site is on github, and I’ll be pushing to github whenever I push to my site.

I didn’t use any fancy blogging helpers (i.e. Nanoc3::Helpers::Blogging), but instead I wrote my own helper methods:

# nanoc's Blogging helper is too complicated for me, we're going to
# use this instead.

require 'time'

def posts
  @items.select do |item|
    item.identifier.include? 'posts'
  end.sort_by do |item|
    Time.parse(item[:created_at].to_s)
  end.reverse
end

def format_time(str)
  Time.parse(str.to_s).strftime("%a %b %d %Y")
end

There’s also a code method so I can do something like this:

<% code :ruby do %%>
puts "when I grow up I want to be printed"
<% end %%>

and get this:

puts "when I grow up I want to be printed"

Cool, huh?

I might change the style at some point. But for right now, it’s a starting point, so I’m going to leave it.

→ autoreload.rb

Sun Sep 18 2011

Put this in any folder where you want files from there to be automatically reloaded, e.g. lib, then require this file.

require 'fssm' # gem install fssm

Thread.abort_on_exception = true

Thread.new do
  FSSM.monitor(Dir.getwd), '**/*') do
    update do |b, r|
      fn = File.join(b, r)
      load fn
      puts "reloaded #{fn}"
    end

    create do |b, r|
      fn = File.join(b, r)
      load fn
      puts "loaded new file #{fn}"
    end
  end
end

→ I'm not sure which I like better

Sun Sep 11 2011

I’m not sure which I like better…

really_long_method_name_is_almost_80_characters(
    parameter,
    11,
    :parameter
)

or…

really_long_method_name_is_almost_80_characters \
    parameter,
    11,
    :parameter

I think it’s the latter.