SmartLogic Logo (443) 451-3001

The SmartLogic Blog

SmartLogic is a web and mobile product development studio based in Baltimore. Contact us for help building your product or visit our website to learn more about what we do.

Using Sanitize Email to Preview HTML Emails Locally

April 30th, 2009 by

John Trupiano has a great post to get you started with sanitize_email for Ruby on Rails.

I wanted to preview my HTML emails without having to fill up my online email inboxes with tons of email (and then I’d have to make filters too). I also didn’t want to manage actually sending real email. So, I set up my machine for local delivery. Read on for instructions.
Read the rest of this entry »

Slow Actions in Rails Projects

March 13th, 2009 by

MySQL’s slow query log is a very handy tool to detect which SQL queries are running slowly in a production app.

So what about rails applications? Often, test data only contains a small amount of data. Over time more users use the site and generate more data. A page that usually renders in 100ms could be taking 3-5 seconds, or more!

I present, SlowActions. The goal was to analyze a standard log file to detect actions that render slowly. It had to be easy to use and also not require modification of rails’ logging mechanism. Observe:

  $> slow-actions --actions development.log
             Cost    Average Max
  - UsersController : game_history (22 entries, 0% Error)
    Total:   11275.447 3642.437 12728.0
    Render:  7.20300 2.32700 17.2450
    DB:      10.5020 3.39200 10.0000

  - QuestionsController : refresh_index_table (89 entries, 0% Error)
    Total:   908.494 202.348 307.000
    Render:  0.00000 0.00000 0.00000
    DB:      32.5880 7.25800 10.0000

More info after the break ….
Read the rest of this entry »

EXT4 On Ubuntu 9.04

January 16th, 2009 by

Ext4 got some attention recently because it was able to boot ubuntu to the login screen in about 20 seconds. However, the current daily release doesn’t support installing with Ext4. Here are the instructions for installing Ext4 onto the Ubuntu 9.04 (Jaunty Jackalope) daily-live cd.
Read the rest of this entry »

Aptinstaller 0.3.2 Released

January 14th, 2009 by

Do you program ruby on rails? Do you use geminstaller? Do you run Ubuntu?

If you want to pull it all together, read on!

Read the rest of this entry »

Watch Multiple Logs in a Single Terminal

November 12th, 2008 by

Have you ever opened 4 terminal windows, SSHed each one into a server, and ran tail on all of them to watch 4 log files?

Have you ever had a terminal window open whose sole purpose was to run “tail my_log” over and over again to look at the output of a file?

It’s a pain, isn’t it?

Introducing “Watch Me” a simple ruby script that allows you to watch multiple log files simultaneously.

go from this:

Before Watch Me

Using multiple terminals to watch logs

to this:

Using WatchMe to watch logs

Using WatchMe to watch logs

Read the rest of this entry »

Fork Pools in Ruby on Rails

September 19th, 2008 by

If you need to process 1000 items independently, the simplest thing to do is to handle them one-by-one. But what if there is a large delay that is not caused by your application when you handle an item? What if you need to make a 100ms web request per item, only to do about 10ms of processing on that item? This would take 1000 x 110ms (100ms to wait, 10ms to process)!

So what do we do?

Read the rest of this entry »

Google AJAX Libraries on Rails

June 20th, 2008 by

If you’re reading this blog you’ve probably already heard about Google’s AJAX Library API on many other news sites like Slashdot.

I’m going to describe my simple process for setting up a RoR app to use Google to pull the APIs in a rails friendly way, throughout layouts, views, and helpers.

Read the rest of this entry »

Ruby on Rails Polymorphic Association Benchmarks

June 13th, 2008 by

Polymorphic relationships in Ruby on Rails are great. If you don’t know what they are, check them out here:

Understanding Polymorphic Associations

John and I were curious about the speed of these relations, since the linking between objects searches on both the ID of the foreign object, and a string which is the model name. So if you have two tables, ChildA and ChildB, your parent has a reference to child which is acutally the combination of child_id (the ID in the ChildA or ChildB table) and child_type (equal to “ChildA” or “ChildB”).

The old-school way of doing this involves creating a lookup table and using integer IDs for type, instead of strings. So you’d have another table mapping “ChildA” to “1″ and “ChildB” to “2″, then when you do your query, you are matching against the number “1″ and not the string “ChildA”.

The down side of doing it that way is that you don’t get to use Rails’ snazzy polymorphism, which makes life a lot easier. So we decided to run some tests to see how much faster it would be, and therefore, if it was worth it.

Read the rest of this entry »

Multithreading in Ruby on Rails

June 11th, 2008 by

Don’t you hate it when sites say “Please Wait” when you’d rather just come back later? I am always worried my browser will close and it won’t work. Or maybe I want to shut my computer down but I have to leave my task running. Read on!

Read the rest of this entry »

Using FFMPEG to Encode Video for iPod, iPhone Streaming, and Flash 9

May 21st, 2008 by

Read on to learn how to encode videos in to H264 for use by Flash 9, and also to stream to an iPhone in Safari, and be able to sync them onto an iPod.
Read the rest of this entry »

Nick was a developer at SmartLogic Solutions from 2008 to 2011. He primarily worked in Ruby on Rails but also enjoyed working with Linux on the desktop and server.