July 24

REDLISTS Launch!

I have been working on redlists for a couple of months with Ross. It is now officially ready for launch. Redlists is an application for handling mailing lists. We sought to make the best experience for both list managers and list subscribers. We hate getting unsolicited mail, so we have made it easy to join and easy to leave. You can subscribe or unsubscribe with one click; or, you can change your settings so that you can stop receiving emails, yet still remain connected by viewing all messages through the web interface.

Redlists is currently in open beta. If you want a better way to manage your mailing lists register on redlists.com. If you have any questions you can email me at matt at redlists.com.

09:27 AM | 0 Comments | Tags: ,
July 23

This is a video of a sample application I made using rbvimeo.

11:45 PM | 0 Comments | Tags: , ,

Break Strings into Separate Lines with Ruby

# I'm working on a site that has a fixed page height and should not scroll.  
# Because of this, the amount of text displayed on a page needs to not exceed  
# a maximum value.  I wrote the following function to break a string into  
# lines based on either line breaks, or the amount of characters that can fit 
# across the div.
# 
# Ruby 1.9 already has a function to break a string into lines;
# (http://www.ruby-doc.org/core/classes/String.html#M000775) 
# however, this does not include the option to break up a line based on 
# characters and I am still on Ruby 1.8.6.
 
def lines s, chars=0
  string = s
  line_array = Array.new
  while(string.size > 0)
    i = string.index("\n")
 
    # Takes the string up to either the first line break
    line = string.slice!(0..(i|> || string.size - 1)).chomp
 
    # Breaks the line up into separate lines based on the number of characters
    if line.size > chars && chars > 0
      while(line.size > chars)
        ending = chars - 1
        unless line[ending + 1, 1] == " "
          ending = line.size - 1 - line.reverse.index(" ", -ending)
        end
        line_array << line.slice!(0..ending).strip
      end
    end
 
    line_array << line.strip
  end
  return line_array
end
11:37 PM | 0 Comments | Tags:

Document Monitoring in Ruby

# This program watches a file for changes.  Whenever a change is made, it
# prints a message in the terminal.
 
require 'ftools'
 
log_file = "test.log"
last_change = File.mtime(log_file)
 
while(true)
  if File.readable?(log_file) && 
    (file_time = File.mtime(log_file)) > last_change
 
    last_change = file_time
    puts "Log has been updated"
  end
end
09:04 PM | 0 Comments | Tags: