Faker Gem - A Quick and Dirty Introduction


One of the first ruby gems I used was the Faker Gem, a nice little ruby gem that ...wait for it... Fakes Data!

Usage is simple; first grab the gem using your gem program:

$sudo gem install faker
 

Now you can use it in your favorite ruby program or script. For now let's fire up irb and see what we can fake. 

require 'rubygems'
require 'faker'
 
#Let's see if we can make a fake person...
person_name = Faker::Name.name
person_email = Faker::Internet.email
person_company = Faker::Company.name
person_company_slogan = Faker::Company.bs
person_phone = Faker::PhoneNumber.phone_number
person_address = Faker::Address.street_address
person_city = Faker::Address.city
person_state = Faker::Address.us_state
person_zip = Faker::Address.zip_code
 
 
# Wowee-wow-wow. Now let's print him off some business cards
puts "#{person_name}
#{person_company}
'#{person_company_slogan.capitalize}'
#{person_address}
#{person_city}, #{person_state} #{person_zip}
Call me at : #{person_phone}
Email me at: #{person_email}
It's a pleasure doing business."
 
# Awesome, now we can go into business and
# get back our money from that Nigerian prince fellow...


 

As you can see Faker is pretty easy to use; you can build some powerful test bases using it inside a loop:

require 'rubygems'
require 'faker'
require 'activerecord'
 
1000.times do
  # make a person
  # save person
end

 


For more information see the Faker Docs: http://faker.rubyforge.org/rdoc/

In my next post I will show you how you can use all this fake data you're generating to test anything you need data for.

--Alex

author: alexmoore | posted @ Monday, January 18, 2010 7:57 PM | Feedback (1)

CodeMash 2.0.1.0. Hey, it’s a beta finally!


So there is this meme going around about people posting their CodeMash schedules, so I thought I would be a sheep and do the same.

 

  Primary Secondary
Wednesday    
AM Practical B/TDD
(Phil Japikse)
 
PM Competency & Leadership in Software
(Mary Poppendieck)
 
     
Thursday    
9:45am – 10:45am What Makes Ruby Different?
(Joe O’Brien/ Mark Peabody/ Leon Gersing)
Agile Iteration 0
(Ken Sipe)
11:00am – 12:00pm Maintainable ASP.NET MVC
(Chris Patterson)
An Introduction to MongoDB
(Mike Droll)
1:45pm – 2:45pm    
3:35pm – 4:35pm Refactoring the Programmer
(Joe O’Brien)
Techniques for Programming Parallel Solutions
(Michael Slade)
4:50pm – 5:50pm Testing ASP.Net Applications using Ruby
(Ben Hall)
Engineering vs Design – How to work together
(Joe Nuxoll)
     
Friday    
9:30am – 10:30am Software Design and Testability
(Jeremy D. Miller)
Oh Crap! I forgot (or never learned) C!
(Chris Adamson)
10:45am – 11:45am Leadership 101
(Jim Holmes)
 
1:45pm – 2:45pm Credit Crunch Code: Payback Tech Debt
(Gary Short)
Patterns: Studying not Stealing
(Jon Stahl, Carol Smith)
3:35pm – 4:35pm SOLID Ruby
(Jim Weirich)
Clojure: Concurrent Functional Programming
(Howard M. Lewis Ship)

 

I figured I would leave one timeslot open in case one of my secondary choices decided to repeat their session, or I to take a nap on the lazy river after lunch.  Decisions, decisions…

 

‘Til next time.

author: alexmoore | posted @ Tuesday, January 12, 2010 12:11 AM | Feedback (0)

Not dead yet. Goals for Q1 2010.


Let’s face it, 2009 was a bitch. My 2009 was an exceptionally crazy bitch.  In short I was laid off, worked as an independent contractor for the fine folks of LeanDog, found a nice Consultant job at HMB, got married, went on a honeymoon, bought a house, paid out the ass to get out of my lease, and have been tackling a never ending honey-do list ever since. I wouldn’t trade it for a year of cozy boring life though :)

 

I cannot remember what my 2009 goals were, but I’m sure they were shot-to-hell. The only one I do remember was I was looking for a career adjustment as they call it, however that was provided for me at the end of February.  So here is to 2010, and my new goals.

 

Goals for Q1 2010

Pass my 70-562 Microsoft Exam

So I can be the expert at making the internets, and be marketable.

Lose 10 lbs

We all probably need to do this, now put down that cupcake.

Get into a hobby that doesn’t exist within the “nerd ghetto”

I’ve been looking into woodworking to build some furniture, etc. I need a hobby that isn’t surfing the internet looking at lolcats and the latest reddit jokes.  If I can build a bookshelf by the end of March I will consider this completed.
 

Wait - Q1, WTF?

I’m limiting my goals to those which I can do in 3 months. This should help me be more realistic and proactive with my goals.  If I make yearlong goals I will just put them off until review time or November, whichever comes first.

 

As you can see, I’m giving myself 3 moderate goals that can be qualified as completed or not. Hopefully by keeping it simple, life won’t get in the way of my goals like usual. I will keep all 2 of my dear readers updated with a “How’s it going” post about mid-February, and will post my results at the end as well.  Feel free to heckle me if I don’t succeed.

 

Till next time.

author: alexmoore | posted @ Monday, January 11, 2010 11:34 PM | Feedback (0)

Using ActiveRecord with SQL Server 2000/2005/2008


On a recent project I needed to test my application with lots of data so I remembered my good friend the Faker Gem from the Ruby world. 
I didn’t know how to connect ActiveRecord to SQL Server, so I searched the webs and found this article by Ray Houston at Los Techies
Unfortunately since the article was 13 months old, the Ruby libraries have evolved to not work that way anymore :)  So after some head scratching I got it to work again.

How to connect ActiveRecord to SQL Server

  1. If you don’t have Ruby installed, grab the one-click installer from http://rubyforge.org/frs/?group_id=167&release_id=28426 and make sure you check the box to install rubygems.
  2. Open up your PowerShell or console, and run: 
    gem update ––system
    gem install activerecord activerecord-sqlserver-adapter
    *This should install all prerequisites gems as well.
  3. Grab my example from github:
    http://github.com/alexmoore/activerecord-with-sqlserver-example/tree/master
  4. Run the CreatePersonTable.sql script to add the example table to your database.
  5. Open Config.rb and put your database connection info in.
  6. Run: ruby PersonFactory.rb  and you should be golden!

In my next post I will show how to use the Faker gem and some statistics tricks to quickly mock up a plethora of test data.

-- Alex

author: alexmoore | posted @ Monday, August 17, 2009 12:11 AM | Feedback (1)

Good .Net Performance Talks


So I've been following PDC this week as much as possible, and came across this gem on Vance Morrison's Blog.

Slides for our All Day PDC 2008 talks on: Performance By Design

I recommend the Parallel Talk as it is more in depth than mine (they had more than 10 minutes for their presentation ). 

Two things to take away:
  1. You can run your Garbage Collector on a separate thread:
        EXE.Config <gcServer enabled="true" />
  2. Shared state is the enemy!

The ASP.Net slides are good too, and go into great length about caching and IISconfiguration.

-- Alex Moore

author: alexmoore | posted @ Thursday, October 30, 2008 1:48 PM | Feedback (0)

CONDG Lightning Talk Slides


Here are the slides for my “Shallow Dive: PFX” talk, as promised.

http://www.slideshare.net/alexmoore/shallow-dive-pfx-presentation-695596

For the demos, I used the LINQRayTracer and C# Raytracer examples that come with the June08 PFX CTP. 

If you have any questions about PFX or the slides, just email or twitter DM me.

 

Till next time,

Alex Moore

author: alexmoore | posted @ Sunday, October 26, 2008 10:55 PM | Feedback (0)

CONDG October Meeting Recap


So I gave my 10 minute “Shallow Dive: PFX” presentation at CONDG tonight, and it went really smoothly.  There were a lot of good presentations tonight, and it’s wonderful to see people in the development community giving back by doing these presentations, teaching, and inspiring people.  I will post my slide deck this weekend, after I add some notes so readers can follow along.

I would like to give props out to Steve Horn for his JQuery presentation, and to Greg Malcolm for his Mono presentation.  Great stuff!

I did stay up late last night and submitted a CodeMash perspective titled “Belly Flop: PFX”, hopefully it gets accepted.  I would love to extend on this presentation to show more of the architectural and design implications of Concurrent / Parallel Programming, and I think CodeMash would be the perfect venue for this.

More to come soon…

-- Alex

author: alexmoore | posted @ Friday, October 24, 2008 12:29 AM | Feedback (0)

Parallel Extensions Links


Here are some links to help you get started with the Microsoft Parallel Extensions to the .Net Framework (PFX).

 

 

Starting Out

PFX CTP – Here are the latest CTP bits from June 2008.  They come with a whole lot of good examples and good documentation to get you started.

MSDN Parallel Computing Dev Center – Plenty of white papers, videos, podcasts, and articles to get you started.

Channel 9 Back to Basics Series (RSS) – This series is just getting started but looks very promising as a resource for developers new to parallel and concurrent programming.  It plans to cover Race Conditions, Deadlocks, Task Granularity,  Load Balancing, and Data Locality. 

 

Blogs

Joe Duffy (RSS) – Joe is one of the lead developers for the Parallel Computing Platform, and also just got done writing “The” book for concurrent programming in Windows and .Net.  There is a lot of great information here.

Herb Sutter (RSS) – One of the great names in concurrent programming, a little more for the C++ crowd.

PFX Team Blog (RSS) – News and information straight from the horse’s mouth.

 

Books

Concurrent Programming on Windows, Joe Duffy – This is supposed to be “The” book about programming concurrently in Windows.  I have personally bought the “Rough Cut” from Safari and can safely recommend it to anybody trying to learn about concurrent and parallel programming.  It is divided into 4 section:  Concepts, Mechanisms, Algorithms, and Systems, so there is fun for the whole family.

 

Videos/Screencasts

Channel 9 Parallel Extensions (RSS) – Great collection for learning all about the Parallel Extensions in and out.

Channel 9 Parallel Computing (RSS) – Focuses more on the whole of the Parallel Computing Platform movement.

 

I hope these resources can get you started into the world of Parallel/Concurrent programming.

-- Alex

author: alexmoore | posted @ Wednesday, October 22, 2008 4:40 PM | Feedback (0)