Liquid Galaxy in GSoC 2012!

Once again The Liquid Galaxy Project has been accepted for the Google Summer of Code! Google Summer of Code is a tremendous program that provides an excellent opportunity for talented undergraduate and graduate students to work developing Open Source software guided by a mentor. Students receive $5000 stipends for successfully completing their summer projects. Last year The Liquid Galaxy Project had three GSoC slots for students. This year we are hoping for at least this number of slots again. I know it is not the point, but did I mention that participation in the program is a very nice credit for students to have on their resumes? ;-)
Right now we are in the “would-be student participants discuss application ideas with mentoring organizations” phase of the program. Interested students should contact the project’s mentors and admins by emailing lg-gsoc@endpoint.com or by jumping into the #liquid-galaxy Freenode IRC channel. Applicants are well advised to take advantage of the opportunity to consult with project mentors in developing their applications. Student applications are being accepted until April 6 and should be emailed to lg-gsoc@endpoint.com.
The Liquid Galaxy GSoC 2012 …
visionport open-source
Firebug in Action: CSS Changes
When I work with clients, I encourage them to use tools to improve efficiency for web development. Sometimes my clients want styling (CSS) adjustments like font-size, padding, or orientation changes, but they aren’t sure what they want before they’ve seen it applied to real content. I recommend embracing a tool such as Firebug for examining temporary on-page CSS edits. Here’s a quick video that demonstrates Firebug in action as I try out a few adjustments to End Point’s home page.
Some of the changes I test out in the video include:
- Font-color changes
- Deleting DOM elements
- Padding, margin adjustments
- Background color changes
Firebug offers a lot more functionality but the video covers interactive CSS changes only. Read more about Firebug’s features here. Chrome has similar functionality with the Developer Tools included in the core software. There are similar tools in the other browsers, but I develop in Chrome or Firefox and I’m not familiar with them.
css tips tools
Check JSON responses with Nagios
As the developer’s love affair with JSON continues to grow, the need to monitor successful JSON output does as well. I wanted a Nagios plugin which would do a few things:
- Confirm the content-type of the response header was “application/json”
- Decode the response to verify it is parsable JSON
- Optionally, verify the JSON response against a data file
Verify content of JSON response
For the most part, Perl’s LWP::UserAgent class makes short work of the first requirement. Using $response->header(“content-type”) the plugin is able to check the content-type easily. Next up, we use the JSON module’s decode function to see if we can successfully decode $response->content.
Optionally, we can give the plugin an absolute path to a file which contains a Perl hash which can be iterated through in attempt to find corresponding key/value pairs in the decoded JSON response. For each key/value in the hash it doesn’t find in the JSON response, it will append the expected and actual results to the output string, exiting with a critical status. Currently there’s no way to check a key/value does not appear in the response, but feel free to make a pull request on check_json on my …
hosting monitoring
A Cache Expiration Strategy in RailsAdmin
I’ve been blogging about RailsAdmin a lot lately. You might think that I think it’s the best thing since sliced bread. It’s a great configurable administrative interface compatible with Ruby on Rails 3. It provides a configurable architecture for CRUD (create, update, delete, view) management of resources with many additional user-friendly features like search, pagination, and a flexible navigation. It integrates nicely with CanCan, an authorization library. RailsAdmin also allows you to introduce custom actions such as import, and approving items.
Whenever you are working with a gem that introduces admin functionality (RailsAdmin, ActiveAdmin, etc.), the controllers that provide resource management do not live in your code base. In Rails, typically you will see cache expirations in the controller that provides the CRUD functionality. For example, in the code below, a PagesController will specify caching and sweeping of the page which expires when a page is updated or destroyed:
class PagesController < AdminController
caches_action :index, :show
cache_sweeper :page_sweeper, :only => [ :update, :destroy ]
...
end
While working with RailsAdmin, I’ve come up with a …
rails
Check HTTP redirects with Nagios
Often times there are critical page redirects on a site that may want to be monitored. Often times, it can be as simple as making sure your checkout page is redirecting from HTTP to HTTPS. Or perhaps you have valuable old URLs which Google has been indexing and you want to make sure these redirects remain in place for your PageRank. Whatever your reason for checking HTTP redirects with Nagios, you’ll find there are a few scripts available, but none (that I found) which are able to follow more than one redirect. For example, let’s suppose we have a redirect chain that looks like this:
http://myshop.com/cart >> http://www.myshop.com/cart >> https://www.mycart.com/cart
Following multiple redirects
In my travels, I found check_http_redirect on Nagios Exchange. It was a well designed plugin, written by Eugene Kovalenja in 2009 and licensed under GPLv2. After experimenting with the plugin, I found it was unable to traverse multiple redirects. Fortunately, Perl’s LWP::UserAgent class provides a nifty little option called max_redirect. By revising Eugene’s work, I’ve exposed additional command arguments that help control how many redirects to follow. Here’s a summary of usage: …
hosting monitoring
RailsAdmin: A Custom Action Case Study
RailsAdmin is an awesome tool that can be efficiently used right out of box. It provides a handy admin interface, automatically scanning through all the models in the project and enhancing them with List, Create, Edit and Delete actions. However, sometimes we need to create a custom action for a more specific feature.
Creating The Custom Action
Here we will create an “Approve Review” action, that the admin will use to moderate user reviews. First, we need to create an action class rails_admin_approve_review.rb in Rails::Config::Actions namespace and place it in the “#{Rails.root}/lib” folder. Here is the template for it:
require 'rails_admin/config/actions'
require 'rails_admin/config/actions/base'
module RailsAdminApproveReview
end
module RailsAdmin
module Config
module Actions
class ApproveReview < RailsAdmin::Config::Actions::Base
end
end
end
end
By default, all actions are present for all models. We will only show the “Approve” action for the models that actually support it and are yet unapproved. It means that they have approved attribute defined and set to false:
register_instance_option :visible? do
authorized? && …
rails
A Little Less of the Middle
I’ve been meaning to exercise a bit more. You know, just to keep the mid section nice and trim. But getting into that habit doesn’t seem to be so easy. Trimming middleware from an app, that’s something that can catch my attention.
Something that caught my eye recently is a couple recent commits to Postgres 9.2 that adds a JSON data type. Or more specifically, the second commit that adds a couple handy output functions: array_to_json() and row_to_json(). If you want to try it out on 9.1, those have been made available as a backported extension.
Lately I’ve been doing a bit of work with jQuery, using it for AJAX-y stuff but passing JSON around instead. (AJAJ?) And traditionally that involves something in between the database and the client rewriting rows from one format to another. Not that it’s all that difficult; for example, in Python it’s a simple module call:
jsonresult = json.dumps(cursor.fetchall())
… assuming I don’t have any columns needing processing: TypeError: datetime.datetime(2012, 3, 09, 18, 34, 20, 730250, tzinfo=psycopg2.tz.FixedOffsetTimezone(offset=0, name=None)) is not JSON serializable Similarly in PHP I can stitch together a …
jquery json postgres
The Mystery of The Zombie Postgres Row
Being a PostgreSQL DBA is always full of new challenges and mysteries. Tracking them down is one of the best parts of the job. Presented below is an error message we received one day via tail_n_mail from one of our client’s production servers. See if you can figure out what was going on as I walk through it. This is from a “read only” database that acts as a Bucardo target (aka slave), and as such, the only write activity should be from Bucardo.
05:46:11 [85]: ERROR: duplicate key value violates unique constraint "foobar_id"
05:46:11 [85]: CONTEXT: COPY foobar, line 1: "12345#011...
Okay, so there was a unique violation during a COPY. Seems harmless enough. However, this should never happen, as Bucardo always deletes the rows it is about to add in with the COPY command. Sure enough, going to the logs showed the delete right above it:
05:45:51 [85]: LOG: statement: DELETE FROM public.foobar WHERE id IN (12345)
05:46:11 [85]: ERROR: duplicate key value violates unique constraint "foobar_id"
05:46:11 [85]: CONTEXT: COPY foobar, line 1: "12345#011...
How weird. Although we killed the row, it seems to have resurrected, and shambled like a zombie into our …
bucardo database postgres