This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'growl' | |
module Jekyll | |
class GrowlHook < Hook | |
safe false | |
sequence :pre, :post | |
def run(site, sequence) | |
case sequence | |
when :pre |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Not sure if we should throw an exception or not. | |
def self.sequences(*sequences) | |
if sequences.any? && (sequences - SEQUENCES.keys).empty? | |
@sequences = sequences | |
else | |
raise ArgumentError, "Invalid sequence" | |
end | |
@sequences || [:in] | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Revision 3: | |
# | |
# Just define the method, don't declare which sequences | |
# this hook will be executed in. | |
# | |
# More meaningful sequence names, following rails naming conventions | |
# for familiarty. | |
# | |
# pre -> before_process | |
# in -> before_render |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'fileutils' | |
module Jekyll | |
class CleanHook < Hook | |
sequences :pre | |
def pre(site) | |
FileUtils.rm_r(site.dest, :force => true) if File.directory?(site.dest) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Jekyll | |
# Specify a post's time in the YAML front matter. An in-hook | |
# guarantees we'll have all the post data before rendering the payload. | |
class TimeHook < Hook | |
safe true | |
sequences :in | |
def in(site) | |
site.posts.each do |post| | |
if post.data.has_key?('time') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class String | |
# Converts degrees, minutes and seconds to decimal degrees | |
# | |
# "52°12′17.0″N".to_degrees # => 52.2047222222222 | |
# "27 28 05S".to_degrees # => -27.4680555555556 | |
# "Invalid".to_degrees # => 0.0 | |
# | |
# Returns Float | |
def to_degrees | |
self =~ /^(\d+)[^\d]+(\d+)[^\d]+([\d\.]+)[^NESW]*([NESW])/i |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Import terrestrial transmitter data into an SQLite database for use in | |
# Antenna Mate (http://antennamate.com). | |
# | |
# Supported Regions: | |
# Australia - http://www.acma.gov.au/scripts/nc.dll?WEB/STANDARD/1001/pc=PC_9150 | |
# United States - http://www.fcc.gov/mb/video/tvq.html | |
# | |
# Usage: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rake' | |
require 'erb' | |
UNLINKABLES = %w[Rakefile] | |
desc "install the dot files into user's home directory" | |
task :install do | |
replace_all = false | |
Dir['*'].each do |file| | |
next if UNLINKABLES.include? file |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Layout.new.tap do |layout| | |
layout.body <<-HTML | |
<!DOCTYPE html> | |
<html> | |
<head> | |
</head> | |
<body> | |
{{ content }} | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Citizen < ActiveRecord::Base | |
contextual :everyone do | |
validates_presence_of :last_name | |
validates_format_of :email, :with => /\w+/ | |
end | |
contextual :admin do | |
validates_presence :first_name | |
end | |
end |