Archive for April, 2009

HELLO! HERE IS YOUR WEEK 4 HOMEWORK

Wednesday, April 29th, 2009

Your week four homework is two parts. The first part is making your week 3 homework use threads. Make the tasks in your week 3 homework run in parallel. Make sure to synchronize when appropriate.

The second part is writing an apache log processor. For this project you will:

  • Provide a commandline tool that safely modifies files
  • Change IP Address at the beginning of the line in an Apache logfile
  • Must be multithreaded
  • Must maintain log order
  • Cache name lookups across invocations
  • Age the cache items (expire lookups)
  • Commandline option to limit number of threads (you should determine a sensible default)
  • Look at “resolv” for DNS lookups
  • This homework can be completed using only tools from ruby’s standard library

The file format will look like this:

208.77.188.166 - - [29/Apr/2009:16:07:38 -0700] "GET / HTTP/1.1" 200 1342
75.119.201.189 - - [29/Apr/2009:16:07:44 -0700] "GET /favicon.ico HTTP/1.1" 200 1406
75.146.57.34 - - [29/Apr/2009:16:08:38 -0700] "GET / HTTP/1.1" 304 -
75.119.201.189 - - [29/Apr/2009:16:09:53 -0700] "GET / HTTP/1.1" 200 1340
208.77.188.166 - - [29/Apr/2009:16:11:51 -0700] "GET / HTTP/1.1" 304 -
75.146.57.34 - - [29/Apr/2009:16:12:00 -0700] "GET / HTTP/1.1" 304 -
75.119.201.189 - - [29/Apr/2009:16:13:15 -0700] "GET / HTTP/1.1" 304 -
208.77.188.166 - - [29/Apr/2009:16:13:15 -0700] "GET / HTTP/1.1" 304 -
75.119.201.189 - - [29/Apr/2009:16:13:17 -0700] "GET / HTTP/1.1" 304 -
75.146.57.34 - - [29/Apr/2009:16:13:50 -0700] "GET / HTTP/1.1" 200 1294
75.146.57.34 - - [29/Apr/2009:16:13:55 -0700] "GET /stylesheets/main.css?1240264242 HTTP/1.1" 200 2968
74.125.67.100 - - [29/Apr/2009:16:13:55 -0700] "GET /stylesheets/home.css?1240264242 HTTP/1.1" 200 7829

We want the file to end up looking like this:

example.com - - [29/Apr/2009:16:07:38 -0700] "GET / HTTP/1.1" 200 1342
example.com - - [29/Apr/2009:16:07:44 -0700] "GET /favicon.ico HTTP/1.1" 200 1406
example.com - - [29/Apr/2009:16:08:38 -0700] "GET / HTTP/1.1" 304 -
example.com - - [29/Apr/2009:16:09:53 -0700] "GET / HTTP/1.1" 200 1340
example.com - - [29/Apr/2009:16:11:51 -0700] "GET / HTTP/1.1" 304 -
example.com - - [29/Apr/2009:16:12:00 -0700] "GET / HTTP/1.1" 304 -
example.com - - [29/Apr/2009:16:13:15 -0700] "GET / HTTP/1.1" 304 -
example.com - - [29/Apr/2009:16:13:15 -0700] "GET / HTTP/1.1" 304 -
example.com - - [29/Apr/2009:16:13:17 -0700] "GET / HTTP/1.1" 304 -
example.com - - [29/Apr/2009:16:13:50 -0700] "GET / HTTP/1.1" 200 1294
example.com - - [29/Apr/2009:16:13:55 -0700] "GET /stylesheets/main.css?1240264242 HTTP/1.1" 200 2968
example.com - - [29/Apr/2009:16:13:55 -0700] "GET /stylesheets/home.css?1240264242 HTTP/1.1" 200 7829

These domain names aren’t correct, but your output format should be similar.

Here is an example session using the command line tool you will write for your homework:

$ apache_lookup my_logs.log

After execution you should be able to examine my_logs.log and see that the ip addresses have been replaced with domain names. You should also be able to do this:

$ apache_lookup -t 100 my_logs.log
The above execution should spawn 100 threads to process your logfile.

This homework MUST be test driven. We will dock points for non-test driven code. You MUST turn your homework in as a tar.gz or as a gem. Remember to email the mailing list, use IRC, start early, test all the time, and have fun!

Week 4 Slides

Wednesday, April 29th, 2009

Hello everyone, here are your week 4 slides.

YOUR WEEK 3 HOMEWORK!

Wednesday, April 22nd, 2009

This week, your homework will be to write a program similar to Rake. Your program must deal with tasks and dependencies.

Here are the Phase 1 requirements:

  • tasks - take a block and can execute it
    • run outputs task execution including nesting of dependencies
    • tasks are executed via tests/code. cmdline interface extra credit.
  • dependencies amongst tasks - deps must run first
    • dependencies are intellegently run, they won’t re-execute if met.
    • declaration order doesn’t matter - aka resolve dependencies late.
    • architect this so it can be made multithreaded later
  • This will be TDD from the ground up with good coverage.

Here is an example task recipe w/ the basic public API needed:

require 'worker_bee'

WorkerBee.recipe do work :sammich, :meat, :bread do puts "** sammich!" end

work :meat, :clean do puts "** meat" end

work :bread, :clean do puts "** bread" end

work :clean do puts "** cleaning!" end end

WorkerBee.run :sammich

Executing this should output:

running sammich
  running meat
    running clean
** cleaning!
** meat
  running bread
    not running clean - already met depnedency
** bread
** sammich!

When building your project use “sow”. Just execute:

$ sow WorkerBee

Fill out the project with tests, and make it go.

WEEK 3 SLIDES

Wednesday, April 22nd, 2009

HEY EVERYONE GUESS WHAT? HERE ARE YOUR WEEK 3 SLIDES, THAT’S WHAT!

HAPPY WEEK 3!

Your Week 2 Homework

Wednesday, April 15th, 2009

You know what to do. Make the tests pass: Here is your week 2 homework.

Quarter the 3rd, Week the 2nd

Wednesday, April 15th, 2009

Hello everyone, this week is the second week of the third quarter. Here are your week 2 slides.

UW Ruby, Quarter the 3rd

Wednesday, April 8th, 2009

Hello everyone! Welcome to the 3rd and final quarter. Here are your week 1 slides.

Also, here is your week 1 homework. Get all the tests to pass, and send it in to Ryan and Aaron.