• Home

  • Custom Ecommerce
  • Application Development
  • Database Consulting
  • Cloud Hosting
  • Systems Integration
  • Legacy Business Systems
  • Security & Compliance
  • GIS

  • Expertise

  • About Us
  • Our Team
  • Clients
  • Blog
  • Careers

  • VisionPort

  • Contact
  • Importing Comments into Disqus using Rails

    Brian Buchalter

    By Brian Buchalter
    December 27, 2011

    It seems everything is going to the cloud, even comment systems for blogs. Disqus is a platform for offloading the ever growing feature set users expect from commenting systems. Their website boasts over a million sites using their platform and offers a robust feature set and good performance. But before you can drink the Kool-Aid, you’ve got to get your data into their system.

    If you’re using one of the common blog platforms such as WordPress or Blogger, there are fairly direct routes Disqus makes available for automatically importing your existing comment content. For those with an unsupported platform or a hand-rolled blog, you are left with exporting your comments into XML using WordPress’s WXR standard.

    Disqus leaves a lot up to the exporter, providing only one page in there knowledge base for using what they describe as a Custom XML Import Format. In my experience the import error messages were cryptic and my email support request is still unanswered 5 days later. (Ok, so it was Christmas weekend!)

    So let’s get into the nitty gritty details. First, the sample code provided in this article is based on Rails 3.0.x, but should work with Rails 3.1.x as well. Rails 2.x …


    ruby rails

    Labeling input boxes including passwords

    Ron Phipps

    By Ron Phipps
    December 23, 2011

    I’m currently working on a new site and one of the design aspects of the site is many of the form fields do not have labels near the input boxes, they utilize labels that are inside the input box and fade away when text is entered. The label is also supposed to reappear if the box is cleared out. Originally I thought this was a pretty easy problem and wrote out some jQuery to do this quickly. The path I went down first was to set the textbox to the value we wanted displayed and then clear it on focus. This worked fine, however I reached a stumbling block when it came to password input boxes. My solution did not work properly because text in a password box is hidden and the label would be hidden as well. Most people would probably understand what went in each box, but I didn’t want to risk confusing anyone, so I needed to find a better solution

    I did some searching for jQuery and labels for password inputs and turned up several solutions. The first one actually put another text box on top of the password input, but that seemed prone to issue. The solution I decided to ultimately use is called In-Fields Labels, a jQuery plugin by Doug Neiner. In this solution Doug has floating labels …


    javascript jquery tips tools

    Converting CentOS 6 to RHEL 6

    Jon Jensen

    By Jon Jensen
    December 22, 2011

    A few years ago I needed to convert a Red Hat Enterprise Linux (RHEL) 5 development system to CentOS 5, as our customer did not actively use the system any more and no longer wanted to renew the Red Hat Network entitlement for it. Making the conversion was surprisingly straightforward.

    This week I needed to make a conversion in the opposite direction: from CentOS 6 to RHEL 6. I didn’t find any instructions on doing so, but found a RHEL 6 to CentOS 6 conversion guide with roughly these steps:

    yum clean all
    mkdir centos
    cd centos
    wget http://mirror.centos.org/centos/6.0/os/x86_64/RPM-GPG-KEY-CentOS-6
    wget http://mirror.centos.org/centos/6.0/os/x86_64/Packages/centos-release-6-0.el6.centos.5.x86_64.rpm
    wget http://mirror.centos.org/centos/6.0/os/x86_64/Packages/yum-3.2.27-14.el6.centos.noarch.rpm
    wget http://mirror.centos.org/centos/6.0/os/x86_64/Packages/yum-utils-1.1.26-11.el6.noarch.rpm
    wget http://mirror.centos.org/centos/6.0/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.26-11.el6.noarch.rpm
    rpm --import RPM-GPG-KEY-CentOS-6
    rpm -e --nodeps redhat-release-server
    rpm -e yum-rhn-plugin rhn-check rhnsd rhn-setup rhn-setup-gnome
    rpm -Uhv --force *.rpm
    yum upgrade

    I then put …


    hosting open-source redhat sysadmin tips

    Rails Request-Based Routing Constraints in Spree

    Brian Gadoury

    By Brian Gadoury
    December 21, 2011

    I recently adopted an unreleased ecommerce project running Spree 0.60.0 on Rails 3.0.9. The site used a Rails routing constraint and wildcard DNS to dynamically route subdomains to the “dispatch” action of the organizations_controller. If a request’s subdomain component matched that regular expression, it was routed to the dispatch method. Here’s the original route:

    match '/' => 'organizations#dispatch', :constraints => { :subdomain => /.+/ }

    The business requirement driving this feature was that a User could register an Organization by submitting a form on the site. Once that Organization was marked “approved” by an admin, that Organization would become accessible at their own subdomain—​no server configuration required.

    For marketing reasons, we decided to switch from subdomains to top-level subdirectories. This meant RESTful routes (e.g. domain.com/organizations/143) wouldn’t cut it. In order to handle this, I created a routing constraint class called OrgConstraint. This routing constraint class works in tandem with a tweaked version of that original route.

    match '*org_url' => 'organizations#show', :constraints => OrgConstraint.new …

    ecommerce open-source ruby rails spree

    Modifying Models in Rails Migrations

    Sonny Cook

    By Sonny Cook
    December 20, 2011

    As migrations have piled up in projects that I work on, one problem seems to come up fairly consistently. New changes to models can break migrations.

    This can happen a number of different ways. One way is to break old migrations. Another is for the changes to be made to the file before the migration is run (timing issues with version control).

    While these can be (and usually are) considered coordination rather than technical issues, sometimes you just need to handle them and move on.

    One case I’d like to cover here is removing or changing associations. At the time the migration is expected to run, the file for the model class will have been updated already, so it is hard use that in the migration itself, even though it would be useful.

    In this case I found myself with an even slightly trickier example. I have a model that contains some address info. Part of that is an association to an external table that lists the states. So part of the class definition was like so:

    Class Contact 
     belongs_to :state
     ...
    end

    What I needed to do in the migration was to remove the association and introduce another field called “state” which would just be a varchar field representing the state part …


    ruby rails

    Nifty In-Button Confirmation

    Evan Tann

    By Evan Tann
    December 19, 2011

    I’ve been working on a personal email client after work, called Warm Sunrise, that forces myself to keep a manageable inbox. One of the goals of the project was to get to a zero-inbox everyday, so I needed a ‘Delete All’ button that was easy-to-use without running the risk of accidentally deleting emails. I took a look at JavaScript’s confirm, which is jarring, and jQuery’s dblClick, which doesn’t provide any feedback to the user after the first click, leaving the user to wonder why their emails weren’t deleted.

    Given these options, I built my own button using Rails 3.1, jQuery, and CoffeeScript, that better fit the goals I set out with. It requires a double click, but gives the user a confirmation in the button itself, without any sort of timeout.

    Starting with app/views/letters/index.html.erb, I generated the buttons using Rails helpers and Twitter’s Bootstrap classes:

    <%= link_to 'Write letter', new_letter_path, :class => "btn primary pull-right far-right" %>
    <%= link_to 'Delete all', '#', :class => "btn pull-right no_danger", :id => "delete_all" %>
    <%= link_to 'Are you sure?', …

    javascript jquery rails

    Sanitizing supposed UTF-8 data

    Jon Jensen

    By Jon Jensen
    December 17, 2011

    As time passes, it’s clear that Unicode has won the character set encoding wars, and UTF-8 is by far the most popular encoding, and the expected default. In a few more years we’ll probably find discussion of different character set encodings to be arcane, relegated to “data historians” and people working with legacy systems.

    But we’re not there yet! There’s still lots of migration to do before we can forget about everything that’s not UTF-8.

    Last week I again found myself converting data. This time I was taking data from a PostgreSQL database with no specified encoding (so-called “SQL_ASCII”, really just raw bytes), and sending it via JSON to a remote web service. JSON uses UTF-8 by default, and that’s what I needed here. Most of the source data was in either UTF-8, ISO Latin-1, or Windows-1252, but some was in non-Unicode Chinese or Japanese encodings, and some was just plain mangled.

    At this point I need to remind you about one of the most unusual aspects of UTF-8: It has limited valid forms. Legacy encodings typically used all or most of the 255 code points in their 8-byte space (leaving point 0 for traditional ASCII NUL). While UTF-8 is compatible with 7-bit ASCII, it does not …


    perl postgres tips tools unicode

    Hurray for tracking configuration files in source control

    Josh Williams

    By Josh Williams
    December 15, 2011

    In a number of places we’ve started tracking configuration files locally in Git. It’s great for Postgres configs, Apache or nginx, DNS zone files, Nagios, all kinds of things. A few clients have private offsite repos we push to, like at GitHub, but for the most part they’re independent repos. It’s still great for keeping track of what was changed when, and by whom.

    In one case we have a centralized Nagios instance that does little more than receive passive checks from a number of remote systems. I’d set the checks on the remote systems but not loaded that configuration in yet. However while getting the central system set up, muscle memory kicked in and I suddenly had a half-red console as it’s loading in stale data.

    We don’t need a flood of false alerts over email, but I don’t want to completely revert the config and lose all those services…

    [root nagios]# git stash; service nagios restart; git stash apply
    Saved working directory and index state WIP on master: 0e9113b Made up commit for blog
    HEAD is now at 0e9113b Made up commit for blog
    Running configuration check...done.
    Stopping nagios: .done.
    Starting nagios: done.
    # On branch master
    # (etc)

    Green! A small victory, for …


    git monitoring
    Previous page • Page 159 of 225 • Next page