My Profile Photo

Personal Webpage of David Duggins


Well, I was born on a normal day in July, 1981 and have been creating chaos ever since. Born in North Carolina, but raised in the aftermath of the Soviet Union, Kazakhstan, I have been messing around with computers nearly my entire life. I wrote my first program in assembly when I was 11. In my early teens I ran a BBS connected to Fidonet and started building a website for my band. In 1999 I was introduced to Linux, and it was love at first compile. I started my career in IT in the early 2000's doing IT for a Car Dealership in Charlotte NC. I wrote my first major web app in Cold Fusion (an ecom app) at that time. In 2006 I left Charlotte and moved down to Columbia where starting working as a developer, freelancer and consultant. Currently I am working as a freelance developer and DevOps consultant!!


Everytime I look at ruby I just have to say "Wow"

\n So here is the background: At our last Mac User’s Group gathering, my good friend and Ruby on Rails Jedi, Jed Schneider in the process of his talk showed a pretty nifty little ruby script that created a single file that repeated the same line over and over again a set number of times. It was pretty sweet. Fast forward to almost a week later and I am having to create a massive amount of test data for some final testing. I need to create a grand total of 61 csv files, all with different names but that contain the same five email address (as well as some other information) So I decided to try and implement a solution in Ruby, drawing on the concepts of Jed’s script. Ianand I sat down for a spare second and knocked out a little script that does just that.

Surprisingly enough (or un-surprisingly enough if you are a ruby programmer) that’s all she wrote.

The line 1.upto(61) relies on the fact that in Ruby everything is an object. We want to output the numbers 1 through 61. We use i to catch the output into a variable i then use File.open to create a file called test1.csv through test61.csv. For each file we want to write some lines. Each line can be written with file.puts. Notice that we pass the name of our file to a variable called file with file just like we did for i above.

So after I created 61 csv files with different names but the same data, I decided to check and see if ruby could help me with any of the other test data generation. Of course it could!

The next little bit of code is really just based on the code above. Instead of writing the same line of data to 61 different files, I wanted to write 61 different email address to one file, using the same base.

Considering that this is pretty much the same as the previous script, only inside out, I’m sure you can figure it out without much effort.

This Ruby Wow Moment was brought to you by the Letter R and the Number Awesome

Questions? Comments? Any ruby Jedi’s out there that can see of a better way of doing this? I await your comments with much anticipation!

© 2024 David Duggins. All rights reserved.