Hi! Thanks for visiting my blog. If you've received any value from my content would you mind supporting my new startup by downloading our browser add-on? It's called PriceBlink and makes online shopping a breeze. You can watch it in action here and download it for Chrome, Firefox, IE, or Safari by going to PriceBlink.com. Thank you and I hope you enjoy!

Escaping Single Quotes with Ruby

Dec 31

I ran into a problem this evening when inserting data in MySQL. Some of the data had single quotes and I needed to escape them. One easy one to do this is using the following regular expression:

gsub(/[']/, ‘\\\\\”)
A simple example to run is:

puts “My name’s Dennis”.gsub(/[']/, ‘\\\\\”)

I know there are a couple of methods within the Ruby MySQL module, but I had problems and settled for the example listed above.

Read More

Installing the MySQL Module for Ruby on Linux

Dec 31

I was recently working on a project where I had the need to use pure Ruby (not Rails) to insert information into a MySQL database. My Ruby installation did not have the necessary MySQL module installed so I had to install it manually. With Linux I’m generally used to doing things the hard way, which normally consists of installing the development source, configuring, making, compiling, and installing. I went through all these steps such as the ones documented here as was to the point of giving up (after 2 hours). I had thoughts of Perl and PHP flashing in my mind as my frustration grew. As a final effort I reverted to good ole Yum, which I pretty much assumed would fail:

yum install ruby-mysql

and it worked! This taught me a valuable lesson in working with Linux. In the past I’ve been accustomed to taking the difficult approach, but times have changed and Linux is becoming much more user friendly. Maybe I should rephrase that and say more developer friendly since your average user probably won’t be installing a MySQL module for Ruby. After installing I was able to successfully run the following Ruby script:

begin
db = Mysql.real_connect(“localhost”, “root”, “root_pass”, “database_name”)
puts “Server version: ” + db.get_server_info
res = db.query(“select * from tablename”)
puts “#{res.num_rows} rows returned”
rescue Mysql::Error => e
puts “Error code: #{e.errno}”
puts “Error message: #{e.error}”
puts “Error SQLSTATE: #{e.sqlstate}” if e.respond_to?(“sqlstate”)
ensure
db.close if db
end

This simply connects to the desired database, queries a table, and then prints the number of row returned.

Read More

Introducing Ublip.com – Location matters

Nov 29

I’ve had this idea for over a year now about the ability to share important locations with friends and family. Call it a digital canvas on a map that allows you to pinpoint a location, tell a story, and share photos for all to see. This stems from my passion for location based services and seeing the potential of marrying an on-line social network with mobile devices. As the mobile device market is still very fragmented, and due to carrier restrictions devices with GPS capabilities are few and far between, it made sense to deliver this experience initially through a desktop browser. This little concept is called Ublip (www.ublip.com).

While having lunch with a good friend of mine, Nick Palmby, we discussed the idea and he encouraged me to bring this idea to life. Ideas are plentiful for me, yet sometimes it takes the motivation of friends and families to push the concept over the edge. In most cases, the next step is validating whether the idea will sink or swim. In this case feedback from the user community has been very positive, and to be honest, it’s hard to keep up with the demand. We’re not attempting to be the next MySpace or Facebook as there are plenty of social copycats. I believe there’s something more to social networking that ties into location and having the ability to share common interests geographically. I’m by no means declaring ownership of this space. If you look around you’ll see many ventures aimed at the same market: Flagr, Platial, Plazes, and Wayfaring to name a few. Yet this doesn’t deter me from investing time and energy into Ublip. There’s unlimited potential with what can be done with a service like this. Realistically, it comes down to finding that niche and pushing forward with it. The niche IS NOT sharing locations on map as I mentioned earlier that’s being done in many different manners. It extends beyond that and I’ll follow up with a few posts discussing what I’ve learned over the past couple of months.

Nick has been responsible for being the “voice of the community” and done a tremendous job at that. Many friends have consistently provided feedback and helped understand what our users are asking for (a special thanks to Marwan, Tony, Matt, Curtis, Mike, Bill, Adam and many more). I’ve been trying to stay involved at some level, but have spent lots of late nights building Ublip using Ruby on Rails. It’s been a tremendous learning experience and we’re continuously brainstorming ways to differentiate ourselves and build something that sets us apart from the rest.

I get a lot of emails asking “what’s next for Ublip?” and “where do we go from here?”. All I can say is that we’ve BARELY scratched the surface and as I mentioned earlier the mobile device integration is an essential piece to this puzzle. There is a mobile application under develpment, but once again there are so many delivery platforms (WAP, J2ME, Symbian, Brew, Windows Mobile, etc) that it tends to get a bit overwhelming. We’re starting with J2ME since most of our users have Java enabled devices. Yet, once again, GPS is limited so the process of adding a “blip” will be somewhat manual initially. There are many talented engineers trying to solve the problem of pinpointing a device’s location so we’re constantly trying to keep informed of what’s happening in the LBS space.

I’ve mentioned the term “blip” and I’d like to take a minute to clarify that. Merriam-Webster defines a blip as “a spot on a radar screen“. It seemed fitting to me to add “blips” on a map and since users are doing it the term Ublip resonated. I can’t even begin to describe the lengthy and painful process of determining a name for this venture. My thoughts are find something you love and stick with it. We could have easily settled on “geotaggedmaps” or “locationbasedmaps”, but those are hard to use in an active context: “you should blip that restaurant because it had great salsa”. I think Google can take credit for becoming a verb used in everyday conversations.

It’s incredible to see what users are posting and how Ublip is becoming a part of their daily lives. Ublip is still a work in progress and through this process we’re learning more about users want on how to create an appealing service that keeps them coming back. There’s been quite a buzz in the community about Ublip and the fact that it’s just Google Maps with some user-generated content overlayed. Agreed, but there’s much more to it than that. Or I should say there’s much more planned for future releases. Many investment dollars are being spent on trying to find where this space is headed and we’re doing the same….through sweat equity and lots of late nights. I’m positive we’ll figure out our niche and in the meantime we’ll pull our hair out and enjoy every minute of it.

If you’re reading this post I encourage you to sign up for a free account and give it a test drive. All you’re investing is a little time and a few keystrokes. At the very least you can share your favorite Christmas light display with the community! If you have any suggestions or comments you can share below or contact me directly: dennis at ublip dot com. Enjoy and thanks for reading!

Read More

Dynamic Select Lists in Rails

Nov 14

I’ve come to find out that Rails has pretty good support for dynamic select lists.  This is achieved through different form helpers, one of which is called collection_select.  You can read more about collection_select here.  The usage is simple and the best part of this is that you get pre-select functionality for free.  To clarify, let’s say you’re adding a product to your web store and associating it with a category called “books”.  The next time you go to edit the product the “books” category will be pre-selected in the drop down menu.  This can be achieved through the following code:

collection_select(:product, :category_id, @categories, :id, :name) 

Instead of duplicating content I will let you read more about the parameters by going here. Once again Rails, thank you for making my life simpler and letting me focus on solving more important problems.

Read More

Rails File Upload and Content Types

Oct 07

You’re most likely going to deal with file uploads within your Rails application.  If you haven’t yet, it’s coming and hopefully this will save you some time.  I spent about an hour today racking my brain as to why I couldn’t validate different image types: image/jpeg, image/gif, and image/png.  I was doing a simple string check that looked like this:

def check_format
content_type = params[:photo].content_type
if content_type != “image/pjpeg” && content_type != “image/jpeg” && content_type != “image/gif” && content_type != “image/png”
“Error: You’ve specified the wrong file type”
end
end

This was failing repeatedly and even printing the content_type variable would yield image/jpeg.  It seemed that everything should work perfectly.  The only thing I could fathom is that there may be some extraneous garbage at the end of the string.  After doing a nice ruby chomp this solved the problem:

content_type = params[:photo].content_type.chomp

I hope this saves you some frustration in the future.

Read More

The Killer Rails Experience

Sep 26

I’ve been MIA for a while caught up in a project, but wanted to do a brief post.  If you’re considering developing and deploying a Rails app in the near future then you need to consider using Rails Playground for your hosting.  These guys have given me the best experience I’ve ever encountered when dealing with a web hosting company.  Even better, they completely understand Rails inside and out.  There have been several occasions where I’ve had a configuration issue and they’ve fixed it within minutes.  You’ll most likely have the pleasure of working with Joe Clarke, their tech support extraordinaire.  If you listen to my advice only once then go with Rails Playground.  This is THE hosting company for Rails developers.

Read More