Author Archives: Lessan Vaezi

Use “rails” instead of “rake” in Rails 5

A pain point for new Rails developers is learning which command goes after the “rails” keyword and which go after the “rake” keyword. In Rails 5, just use “rails”. The source of this issue in previous versions of Rails is the fact that some commands make sense to be rails commands, such as rails server, […]

Posted in Technology | Tagged , , | Leave a comment

Rails 5 adds method source

Here is an example of the Rails team making it easier for developers to access much needed tools: you can now inspect the source code for a method right from irb. Say you had the following source code: In irb you can do: This functionality is from a gem called method_source, which is one component […]

Posted in Technology | Tagged , | Leave a comment

Rails 5 adds ActiveRecord or

Here’s a long awaited feature that is added in Rails 5: ActiveRecord or. Previously you had to use ARel or resort to a SQL snippet: Now you can do: In other words: you first build a relation, then use the or method on it passing in as an argument another relation. These two relations must […]

Posted in Technology | Tagged , , | Leave a comment

Using wrap_parameters to allow a non-ActiveRecord parameter

Rails 4 introduced strong parameters: With strong parameters, Action Controller parameters are forbidden to be used in Active Model mass assignments until they have been whitelisted. This means that you’ll have to make a conscious decision about which attributes to allow for mass update. This is a better security practice to help prevent accidentally allowing […]

Posted in Technology | Leave a comment

Using a period in YAML tokens

While working on an internationalized Rails application, I came across a case where the names of countries were being translated through the YAML locale configuration files. While a valid short-term measure, I would prefer using a gem like Globalize and storing the translations in a Country model, for example. But in the meanwhile, I was […]

Posted in Technology | Leave a comment

How to clear the Clipboard when exiting Microsoft Word

This week a colleague approached me to consult about a problem he had encountered, where it was necessary to ensure that the Clipboard was empty when Microsoft Word exits. It was part of a legacy Word automation solution that he wasn’t in a position to change just yet, and it would crash if there was […]

Posted in Technology | Tagged , , , | 1 Response

Get email Headers from an Outlook MailItem

While working on a VSTO add-in for Microsoft Outlook, I came across the need to access the headers of an email, to parse out X-CustomProperty tags that were put in by an application that sent the emails. However, I couldn’t find a Headers property in the Outlook object model, so below is an attempt to […]

Posted in Technology | Tagged , , , , , , | 4 Responses

How to filter select list options

Here’s a jQuery extension method to filter the elements of a select list (option tags). It binds to a textbox, and as you type in the textbox the select list gets filtered to match what you are typing. Parameters: textbox This could be a jQuery selector, a jQuery object, or a DOM object. selectSingleMatch This […]

Posted in Technology | Tagged | 55 Responses

Using Open XML SDK to get Custom Properties from a Word document

I stumbled across a library that I didn’t realize was out there, for working with Microsoft Office documents. It only works with the newer Office 2007 and 2010 files (and 2003 with a compatibility pack), i.e. those using the Open XML standard. Download and install the Open XML SDK 2.0 for Microsoft Office: I […]

Posted in Technology | Tagged , , | Leave a comment

How to hide the dotted border outline on focused elements in HTML, using CSS

While working on a web application for data entry, I had to scour the net for a way to hide the dotted border that appears when an element is focused on a web page. Here are my findings. First, the obligatory disclaimer – I do understand that the dotted border is for accessibility purposes and […]

Posted in Technology | Tagged , , , | 4 Responses