Ruby Snippets

Cafe Server

Cafe Server opens ports in a firewall for a coffeeshop or other pay or limited time internet access environments. It was written in collaboration with Ryan Verner on irc.freenode.net/#ruby-lang.

The client was written in VB and installed on windows boxes, but the protocol should be readily apparent from the server code.

Client

Client is a generic read/write TCP socket. You could probably use it for telnet.

Clip

Clip can read or write to the Windows Clipboard. It doesn't support fetching the fancy formats like HTML or RTF though.

Database

Database is a Singleton wrapper for a database handle. It uses the Ruby DBI.

GetIP

GetIP fetches the machine's IP adresses from ifconfig on FreeBSD.

Hash Configuration

Hash Configuration parses a simple Hash-like syntax for use as a configuration file.

HTTP Digest Authentication

HTTP Digest Authentication generates a response header for use with HTTP servers that use HTTP digest authentication (RFC 2617). It may be buggy.

Set the third argument to true if authenticating against an IIS server, since Microsoft implements RFC 2617 differently from everybody else. You can typically determine if a server needs the hack from the Server header.

httpdump

httpdump is a WEBrick servlet that lets you see what's going on on your network. It uses ruby-pcap and a WEBrick servlet to serve up the most recent thousand requests on an interface.

Server

Server is a simple TCP server that listens for connections, then echos them to the console.

CGI::Session

Session is a demo of how to use Ruby's CGI::Session.

Stub

Stub writes out stubs for missing methods. It can be very helpful when developing new code.