Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Andrew Pennebaker http://mcandre.devjavu.com/wiki

« Newer Snippets
Older Snippets »
Showing 1-3 of 3 total  RSS 

Runt.rb

// A tiny Ruby web server.

#!/usr/bin/env ruby

require "webrick"

s=WEBrick::HTTPServer.new(
        :BindAddress => "localhost",
        :Port => 8080,
        :DocumentRoot => File.dirname($0)+"/"+"www/"
)

trap("INT") { s.shutdown }

s.start

itcrowdquote.rb

// Prints a quote from Channel 4's "The IT Crowd"

#!/usr/bin/env ruby

require "rubygems"
require "open-uri"
require "hpricot"
require "htmlentities"

coder=HTMLEntities.new()

doc=open("http://www.channel4.com/entertainment/tv/microsites/I/itcrowd/quote_generator/") { |f| Hpricot(f) }

section=doc/"blockquote"/"p"
(section/"cite").remove()
quote=section.inner_html

# remove leading whitespace
quote=quote.gsub(/^\s+/, "")

# remove trailing whitespace
quote=quote.gsub(/\s+$/, $/)

# remove dash
quote=quote.gsub(/\s\-\s+$/, $/).chomp

# decode HTML entities
quote=coder.decode(quote)

puts quote

yn.rb

// Ruby Yubnub launcher

#!/usr/bin/env ruby

# Andrew Pennebaker (andrew.pennebaker@gmail.com)
# 7 Aug 2007
# Copyright 2007 Andrew Pennebaker
# License: GPL
# URL: http://snippets.dzone.com/posts/show/4400

parser="http://yubnub.org/parser/parse?command="

command=ARGV.join("+")

system "open "+parser+command
« Newer Snippets
Older Snippets »
Showing 1-3 of 3 total  RSS