This file contains 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
desc 'add a new blog summary entry' | |
task :add_to_blog do | |
# Load up all files and populate the @pages DB | |
Webby.load_files | |
# Find the page that has the table of interest | |
page = Webby::Resources.pages.find('Page Title') |
This file contains 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
# This is a useful little pattern for working with gems without | |
# explicitly requiring rubygems in your code. | |
# | |
# The approach taken is to require a library and catch any LoadError | |
# that might get thrown. In the rescue clause we require rubygems. | |
# | |
# The require method is nice in that it will return true if the code | |
# was loaded, and it returns false if the code was _already_ loaded. | |
# If the require of rubygems returns true, we will retry our original | |
# require. It will either succeed this time (since we now have rubygems |
This file contains 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
desc "Strip trailing whitespace from .rb .txt .rake and .yml files" | |
task :strip do | |
cmd = 'find . ' | |
cmd << %w[rb txt rake yml].map {|str| "-name '*.#{str}'"}.join(' -o ') | |
cmd << %q{ | xargs sed -i 's/\s\+$//g'} | |
sh cmd | |
end |
This file contains 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 'yaml' | |
module PortalLinks | |
def fetch_link_definitions() | |
YAML::load_file('lib/links.yaml') | |
end | |
end |
This file contains 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
# This function returns the name of the current git branch | |
function gitb { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/' | |
} | |
# This function updates the current branch with the latest changes from the | |
# origin repository. The master branch is checked out, a git pull is performed, | |
# the original branch is checked out again, and then the changes from master | |
# are rebased back into the branch. | |
# |
This file contains 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 Kernel | |
# Settiing this global variable to +false+ will disable rubygems from | |
# being loaded at all. | |
$use_rubygems = true | |
# call-seq: | |
# require!( string ) | |
# require!( string, gem_version ) |
This file contains 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 ReentrantMutex < Mutex | |
def initialize | |
super | |
@locker = nil | |
end | |
alias :original_synchronize :synchronize | |
def synchronize |
This file contains 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
# Convert a string to a numeric value | |
class String | |
# Convert the string into a numeric value. If the string does not | |
# represent a valid Integer or Float, then the string itself is returned. | |
# | |
# "10".numeric #=> 10 | |
# "1.0".numeric #=> 1.0 | |
# "foo".numeric #=> "foo" | |
# |
This file contains 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 'servolux' | |
require 'thread' | |
q = Queue.new | |
ary = [] | |
3.times do | |
piper = Servolux::Piper.new 'rw' |
This file contains 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
function! AckSnippets(search) | |
let ft = &ft | |
if ft == 'objc' || ft == 'cpp' || ft == 'cs' | |
ft = 'c' | |
elseif ft == 'xhtml' | |
ft = 'html' | |
endif | |
let dirs = join(split( | |
\ globpath(g:snippets_dir, ft)."\n". |