Liquid Galaxy installation at Westfield State University
This past week End Point installed its newest Liquid Galaxy installation at Westfield State University. The unveiling on April 23rd featured a talk from local glass artist Josh Simpson (whom I have long admired) and a video conference with his wife Cady Coleman, a NASA astronaut. I volunteered to head up the installation effort for two reasons really: First, I was excited to have another Liquid Galaxy in an academic setting, and second, I am originally from western Massachusetts and I couldn’t resist the prospect of some home cooked meals courtesy of my mother.
I arrived at Westfield State to a small army of people who helped me with every aspect of the installation from creative electrical wiring to campus security kindly giving my car a jump. The team at Westfield made this installation a breeze and all the smiling faces made it easy to put in the extra effort to finish in time for the opening. As always I got great remote support from my End Point colleagues during the installation process.
Once the Liquid Galaxy started to take shape the excitement of the students who happened to be passing by was certainly a motivating factor, but the greatest perk was getting to show my …
gis visionport education
Custom plans prepared statements in PostgreSQL 9.2
Someone was having an issue on the #postgresql channel with a query running very fast in psql, but very slow when using DBD::Pg. The reason for this, of course, is that DBD::Pg (and most other clients) uses prepared statements in the background. Because Postgres cannot know in advance what parameters a statement will be called with, it needs to devise the most generic plan possible that will be usable with all potential parameters. This is the primary reason DBD::Pg has the variable pg_server_prepare. By setting that to 0, you can tell DBD::Pg to avoid using prepared statements and thus not incur the “generic plan” penalty. However, that trick will not be needed much longer for most people: version 9.2 of Postgres added a great feature. From the release notes:
Allow the planner to generate custom plans for specific parameter values even when using prepared statements.
Because the original IRC question involved a LIKE clause, let’s use one in our example as well. The system table pg_class makes a nice sample table: it’s available everywhere, and it has a text field that has a basic B-tree index. Before we jump into the prepared statements, let’s …
database dbdpg postgres
RailsConf 2014: My Sketchnote Summary

My RailsConf Sketchnote Summary
In the heat of the moment, it’s hard for me to do anything other than regurgitate RailsConf talks into blog articles (case in point: my review of Leah Silber’s talk on building an open source focused company, and my summary of the machine learning workshop at RailsConf). But after a bit of processing and brain-churning, I’ve pieced together the common themes that resonated for me throughout RailsConf, in Sketchnote form!
There was of course a bit of bantering regarding code as “writing” versus code as “engineering” and the arguments supporting both ends of the spectrum. As my fifth RailsConf, I did walk away with some Rails topical knowledge, but the overwhelming theme of many talks I attended was the human element behind coding. People as a part of building communities, sharing commonalities, building relationships and mentorships, being influenced by their own biases and perceptions. Many of my memorable talks of the conference for me had great stories, great humor, and both.
Here’s a list of memorable talks referenced in my sketchnote above if you are interested in checking them out. Not all of the slides have been posted, so I’ll revisit and …
conference ruby rails
Building an Open Source Software-Centric Company at RailsConf 2014
It’s RailsConf 2014 in Chicago and Day 4 (the last day)! Today I attended many good talks. One of them was Building an OSS-Centric Company (and Why You Want To) by Leah Silber. Leah is super passionate and knowledgeable and has good perspective from being involved in many successful open source software companies and projects through the years, including her current work at Tilde on Skylight and Ember.js.
Why Open Source?
First, Leah covered the justification for building a company with a focus on open source (ie how to convince the people that pay you to focus on open source). Here are the bullet points for why open source?:
- Expertise: When you have a company with a focus on open source, you are building the expertise on your own open source tools and you have the available resources as opposed to outsourcing to other companies for expertise. Of course, in my mind, this shouldn’t be a justification for creating an unneeded open source tool, but it’s more of a long-term benefit after your open source projects gain traction.
- Influence and Access: Building a OSS-centric company allows you to sit at the table as stakeholders when it comes to making big decisions about focus, …
conference open-source ruby rails
ActsAsTaggable acts quirky
I’ve been recently working on a project with the extensive use of ActsAsTaggable gem (version 2.4.1). I would like to share a couple of things that were not immediately evident and caused some confusion.
Issue #1
You should be consistent with how you assign tags. ActsAsTaggable is very versatile as it provides such features as tagging contexts and tagging ownership. Contexts allow to create named subsets of tags for the item. Ownerships allow for the item to have different tags for different owners. It is very easy to assign tag in the default “tags” context and later be wondering why the tag is not showing up in the custom context, or vice versa. The following method always assigns the tag within the “tags” context:
@photo.tag_list = "New York, USA"
So if you update the tag list in the custom context later:
@photo.set_tag_list_on("album_3", "New York, USA")
you will basically be creating the second tagging for the “New York” tag with the “album_3” context.
The third tagging is generated if the same photo is tagged by the “owner” @user.
@user.tag(@photo, :with => "New York", :on => "album_3")
Issue #2
Tag count methods include the …
rails
RailsConf 2014 on Machine Learning
This year at RailsConf 2014, there are workshop tracks which are focused sessions double or triple the length of the normal talk. Today I attended Machine Learning for Fun and Profit by John Paul Ashenfelter. Some analytics tools are good at providing averages on data (e.g. Google Analytics), but averages don’t tell you a specific story or context of your users, which can be valuable and actionable. In his story-telling approach, John covered several stories for generating data via machine learning techniques in Ruby.
Make a Plan
First, one must formulate a plan or a goal for which to collect actionable data. More likely than not, the goal is to make money, and the hope is that machine learning can help you find actionable data to make more money! John walked through several use cases and examples code with machine learning and I’ll add a bit of ecommerce context to each story below.
Act 1: Describe your Users
First, John talked about a few tools used for describing your users. In the context of his story, he wanted to figure out what gender ratio of shirts to order for the company. He used the sexmachine gem, which is based on census data, to predict the sex of a person based on a …
conference rails machine-learning
Dictionary Comprehensions in Python
Python has many features which usually stay unknown to many programmers.
List Comprehensions
List comprehensions are much simpler way of creating lists. This is one feature which is rather widely used and I saw this in many examples and source of many libraries.
Imagine you have a function which returns a list of data. A good example of this is xrange(start, end) function which returns all numbers within the range [start, end), so it excludes the end. This is a generator, so it doesn’t return all numbers at once, but you need to call this function many times, and each time it returns the next number.
Getting all numbers from range [1, 10] using this function can be done like this:
numbers = []
for i in xrange(1, 10):
numbers.append(i)
If you want to get only the even numbers, then you can write:
numbers = []
for i in xrange(1, 11):
if i % 2 == 0:
numbers.append(i)
List comprehensions can make the code much simpler.
The whole expression evalutes to a list, and the main syntax is:
[ expression for item in list if conditional ]
The first example can be then written as:
numbers = [i for i in xrange(1, 11)]
and the second:
numbers = [i for i in xrange(1, 11) if i % 2 == 0] …
python
Rails Tips & Tricks at RailsConf 2014

Rails: They start so young!
One of the talks I attended on Day two of RailsConf 2014 was Tricks that Rails didn’t tell you about by Carlos Antonio. As the title suggests, Carlos covered a number of Rails items that are either not widely used or not well documented. I’ve taken the lazy approach and listed out all the topics he covered, but provided documentation or relevent links to all of the tricks in case you’d like to learn more.
Migrations
- Use change_column_null to change a column null, which is reversible in a migration.
- Use change_column_default to change a column default, but this doesn’t work with change (isn’t reversible).
ActiveRecord
- Relation.merge, e.g.
Product.joins(:reviews).merge(Review.approved)
, allows you to utilize scope from another model rather than passing in exact SQL conditional, i.e. limiting knowledge of Review to Product. - Utilize group counting to group results by a column and get the count. This also accepts multiple fields to group.
- relation.first! and relation.last! are similar to first & last but raise exception RecordNotFound if there are no records.
- where.not is a cool finder trick, e.g.
scope :some_scope
, ->{ where.not status: 'draft' } …
conference rails