Permalink
Browse files

remove files ready for new ones

  • Loading branch information...
1 parent ecb92c5 commit 7b2162bfb6553fe9fb62b193b094961b9d7050b3 Chris Brown committed Jun 8, 2010
View
@@ -1,25 +0,0 @@
-# cascader #
-
-*cascader* helps you get help
-
-
-*cascader* helps you help
-
-## Usage ##
-
- $ cascader
- Searching for cascaders...
-
- There is 1 cascader in this lab:
- Chris Brown raycroft (Level 5 - West) Git, Python, Django, 1st Year, 2nd Year
-
- There is 1 other cascader on this floor:
- Joe Bloggs jak (Level 5 - North) Maths, Graphics, 1st Year, Ruby
-
-
- $ cascader cascade "Chris Brown" git python django 1 2
- You are now cascading:
- Chris Brown raycroft (Level 5 - West) Git, Python, Django, 1st Year, 2nd Year
-
- Other cascaders on this floor:
- Joe Bloggs jak (Level 5 - North) Maths, Graphics, 1st Year, Ruby
View
@@ -1,24 +0,0 @@
-#!/usr/bin/env ruby
-
-require 'socket'
-require 'pathname'
-
-APP_ROOT = File.join(File.dirname(Pathname.new(__FILE__).realpath),'/..')
-LIB_ROOT = APP_ROOT + '/lib'
-require LIB_ROOT + '/cascader'
-
-user = User.new
-
-if ARGV.first.eql? "--help" or ARGV.first.eql? '-h'
- puts 'Find a cascader:'
- puts ' cascader'.blue
- puts
- puts 'Do some cascading:'
- puts ' cascader cascade "Your Name" [topics which you cascade]'.blue
-elsif ARGV.first.eql? "cascade"
- cascade, name, *topics = ARGV
- server = Server.new(name, user.hostname, topics)
-else
- client = Client.new(user)
- client.search
-end
@@ -1,14 +0,0 @@
-tay
-tarsan
-strathberg
-lessard
-treig
-getunde
-villeneuve
-fangio
-alonso
-surtees
-fittipaldi
-ascari
-lauda
-prost
@@ -1,38 +0,0 @@
-beriot
-nokelainen
-lovecchio
-kesler
-kobasew
-drury
-karsums
-teal
-edler
-marchand
-krajicek
-auer
-marquardt
-demitra
-cowan
-goodwin
-drake
-chara
-dancla
-baumgartner
-allard
-bieska
-stradebroke
-canungra
-daxter
-jak
-hordichuk
-bouillon
-ference
-salo
-rollo
-luongo
-iggy
-egener
-bazzini
-stobbart
-burrows
-wideman
@@ -1,24 +0,0 @@
-dunsborough
-yallingup
-rockingham
-nannup
-yelle
-savard
-harvey
-sturm
-busselton
-schaefer
-sobotka
-bodnarchuk
-thom
-leeuwin
-mandurah
-subiaco
-bunbury
-augusta
-vasse
-albany
-wallcliffe
-ghauts
-pemberton
-esperance
@@ -1,59 +0,0 @@
-wallander
-cottontail
-lemming
-bobcat
-moose
-raccoon
-mankell
-coyote
-ohlund
-samuelsson
-oduya
-plekanec
-djurgardens
-scaven
-sloy
-alsh
-woodend
-modupe
-bradford
-kostitsyn
-koivu
-chipchura
-brittle
-wharral
-boisdale
-bracadale
-willsie
-raycroft
-guite
-clark
-monotreme
-buie
-duich
-creran
-carron
-davidson
-coulthard
-hill
-brabham
-mansell
-ledin
-svatos
-kovalev
-wolski
-prospal
-hamilton
-eishort
-hunt
-assynt
-holmstrom
-senna
-samsonov
-lidstorm
-modin
-cumiskey
-stastny
-salei
-budaj
-liles
@@ -1,7 +0,0 @@
-CAS_ROOT = File.join(File.dirname(Pathname.new(__FILE__).realpath), '/cascader')
-
-require CAS_ROOT + '/colour'
-require CAS_ROOT + '/user'
-require CAS_ROOT + '/hosts'
-require CAS_ROOT + '/client'
-require CAS_ROOT + '/server'
@@ -1,94 +0,0 @@
-require 'thread'
-
-class Client
- def initialize(user)
- @user = user
- @cascaders = []
- @mutex = Mutex.new
- end
-
- def format_cascader(cascader)
- cascader_re = /^\[([^\]]*)\]\[([^\]]*)\]\[([^\]]*)\]$/
- name = cascader_re.match(cascader)[1]
- host = cascader_re.match(cascader)[2]
- topics = cascader_re.match(cascader)[3].split(':').map { |topic| topic.capitalize }
-
- lab = HostManager.name_lab(HostManager.lookup_lab(host))
- padding = " " * (35 - (host.length + lab.length))
-
- topics.map! do |topic|
- puts topic
- puts (/^\d$/ =~ topic).nil?
- unless (/^\d$/ =~ topic).nil?
- pretty_years(topic.to_i).yellow
- else
- topic.yellow
- end
- end
-
- return "\t#{name.red}#{" " * (40 - name.length) }#{host.green} -- #{lab.blue}#{padding}#{topics.join '/'.white}"
- end
-
- def pretty_years(year)
- years = { 1 => "First Year",
- 2 => "Second Year",
- 3 => "Third Year",
- 4 => "Fourth Year" }
-
- return years[year]
- end
-
-
- def search
- puts 'Searching for cascaders...'
-
- lab_hosts = HostManager.get_hosts_lab(@user.floor, @user.lab)
- floor_hosts = HostManager.get_hosts_floor(@user.floor)
- lab_cascaders = []
- floor_cascaders = []
-
- lab_hosts.each do |hostname|
- Thread.start do
- begin
- session = TCPSocket.new(hostname, 54415)
- rescue
- next
- end
-
- server_message = session.gets
- lab_cascaders << server_message
-
- if server_message.include?("End Transmission")
- clientSession.close
- end
- end
- end
-
- floor_hosts.each do |hostname|
- Thread.start do
- begin
- session = TCPSocket.new(hostname, 54415)
- rescue
- next
- end
-
- server_message = session.gets
- floor_cascaders << server_message
-
- if server_message.include?("End Transmission")
- clientSession.close
- end
- end
- end
-
- (floor_cascaders & lab_cascaders).each { |dup| floor_cascaders.delete(dup) }
-
- lab_cascaders.map! { |cascader| format_cascader(cascader) }
- puts "There are #{lab_cascaders.length} cascaders in this lab:"
- lab_cascaders.each { |cascader| puts cascader }
-
- floor_cascaders.map! { |cascader| format_cascader(cascader) }
- puts "There are #{floor_cascaders.length} other cascaders on this floor:"
- floor_cascaders.each { |cascader| puts cascader }
- end
-end
@@ -1,7 +0,0 @@
-# This wonderful code taken from http://github.com/michaeldv/awesome_print.
-class String
- [:gray, :red, :green, :yellow, :blue, :purple, :cyan, :white].each_with_index do |color, i|
- define_method color do "\033[1;#{30+i}m#{self}\033[0m" end
- define_method :"#{color}ish" do "\033[0;#{30+i}m#{self}\033[0m" end
- end
-end
@@ -1,51 +0,0 @@
-class HostManager
- level5_n = IO.readlines(File.dirname(__FILE__) + '/../../hosts/level5-n.txt').map {|host| host.chomp}
- level5_s = IO.readlines(File.dirname(__FILE__) + '/../../hosts/level5-s.txt').map {|host| host.chomp}
- level5_e = IO.readlines(File.dirname(__FILE__) + '/../../hosts/level5-e.txt').map {|host| host.chomp}
- level5_w = IO.readlines(File.dirname(__FILE__) + '/../../hosts/level5-w.txt').map {|host| host.chomp}
-
-
- @@hosts = { '5' => { 'at5n' => level5_n,
- 'at5s' => level5_s,
- 'at5e' => level5_e,
- 'at5w' => level5_w } }
-
- @@lab_names = { 'at5n' => 'Level 5 (North Lab)',
- 'at5s' => 'Level 5 (South Lab)',
- 'at5e' => 'Level 5 (East Labs)',
- 'at5w' => 'Level 5 (West Lab)' }
-
- def self.name_lab(lab)
- return @@lab_names[lab]
- end
-
- def self.lookup_lab(hostname)
- @@hosts.each_key do |floor|
- @@hosts[floor].each_pair do |lab, computers|
- return lab if computers.include? hostname
- end
- end
- puts "The computer you are using doesn't exist. Seek help."
- exit
- end
-
- def self.lookup_floor(hostname)
- @@hosts.each_key do |floor|
- @@hosts[floor].each_pair do |lab, computers|
- return floor if computers.include? hostname
- end
- end
- puts "The computer you are using doesn't exist. Seek help."
- exit
- end
-
- def self.get_hosts_floor(floor)
- hosts = []
- @@hosts[floor].each_value { |host| hosts << host}
- return hosts.flatten
- end
-
- def self.get_hosts_lab(floor, lab)
- return @@hosts[floor][lab]
- end
-end
@@ -1,29 +0,0 @@
-require 'thread'
-
-class Server
- def initialize(name, host, topics)
- @server = TCPServer.new(54415)
- @host = host
- @name = name
- @topics = topics.map { |topic| topic.gsub('[', '').gsub(']', '') }
-
- start
- end
-
- def start
- puts "Cascading...".blue
- response = "[#{@name}][#{@host}][#{@topics.join ':'}]"
-
- while (session = @server.accept)
- Thread.start(response) do |response|
- puts "Log: Cascader search from #{session.peeraddr[2].green} at #{session.peeraddr[3].green}"
-
- puts "Log: Sending Response"
- session.write "#{response}\n"
-
- puts "Log: Closing Connection"
- session.write "End Transmission\n"
- end
- end
- end
-end
Oops, something went wrong.

0 comments on commit 7b2162b

Please sign in to comment.