Chicago Ruby Hack Night - Ruby One Liners
Details
Come on out and hack!
Let's get some practice with Ruby text processing by writing some one-line programs that can be run from the command line like this:
ruby -e "puts 'hi there'"
Inspired by the one-line scripts for awk (http://www.pement.org/awk/awk1line.txt), we'll write Ruby programs to do things like double-space a file or add line numbers to the file or center the text in each line of a file. The challenge is to write the shortest possible program that works for each of these tasks:
doublespace a file add line numbers to each input file add line numbers for all files together add line numbers only for nonblank lines count lines in file count words in file output total number of lines that contain 'abc' output a string of 43 X's insert a string of 3 X's after column 6 of each input line delete leading whitespace from beginning of each line delete trailing whitespace from end of each line add leading blanks to right-align all text in 80-column width add leading and trailing blanks to center each line in 80 columns reverse the text in each line concatenate every 5 lines of input, using , as separator print first 10 lines of file print last 10 lines of file print line 13 of file delete blank lines from file delete consecutive duplicate lines from file delete any duplicate lines from file Hint: Type ruby --help and look at the options -e, -p, and -n
All levels of Ruby expertise are welcome, including beginners. We'll pair up to do the Ruby coding.
Our host, Enova Financial, will provide food and drink.
See you there!
Be sure to check out the ChicagoRuby Job Board (http://jobs.chicagoruby.org/). ChicagoRuby attracts some of the sharpest minds in software development. If you are building a software team, this is the audience you want to reach. If you are looking to join a team, the ChicagoRuby Job Board features employers who take team building seriously. http://jobs.chicagoruby.org (http://jobs.chicagoruby.org/)
