• 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
  • Testing Anti-Patterns

    Mike Farmer

    By Mike Farmer
    April 4, 2013

    Testing is always a popular subject at MountainWest RubyConf. Now that many developers are embracing test driven development, there is a big need for guidence. Aja Hammerly is talking about testing anti-patterns. Tests should be trustworthy. You should be able to depend on them. If they fail, your system is broken. If they pass your system works. Tests should be simple. Simple to read, simple to write, simple to run.

    Here are some anti-patterns that Aja addressed:

    Pointless Tests

    • No tests! Solution: Write tests.
    • Not Running Tests. Solution: Use Continuous Integration so you have to run your tests.
    • Listen to your failing tests. Fix team culture that ignores a red CI.
    • That test that fails sometimes. Fix it!

    Wasted Time / Effort

    • Testing Other Peoples Code (OPC). Solution: Test only what you provide and use third-party code that has good coverage.
    • assert_nothing_raised or in other words, don’t assert that a block runs without an exception only. If an error is raised, it will just raise an exception, which is a failure.

    False Positives and Negatives

    • Time sensitive tests. For example, using Time.now. Solution: stub Time.now().
    • Hard-coded dates in tests. Use relative dates instead. …

    conference ruby

    Deploying password files with Chef

    Matt Vollrath

    By Matt Vollrath
    April 3, 2013

    Today I worked on a Chef recipe that needed to deploy an rsync password file from an encrypted data bag. Obtaining the password from the data bag in the recipe is well documented, but I knew that great care should be taken when writing the file. There are a plethora of ways to write strings to files in Chef, but many have potential vulnerabilities when dealing with secrets. Caveats:

    • The details of execute resources may be gleaned from globally-visible areas of proc.
    • The contents of a template may be echoed to the chef client.log or stored in cache, stacktrace or backup areas.
    • Some chef resources which write to files can be made to dump the diff or contents to stdout when run with verbosity.

    With tremendous help from Jay Feldblum in freenode#chef, we came up with a safe, optimized solution to deploy the password from a series of ruby blocks:

    pw_path = Pathname("/path/to/pwd/file")
    pw_path_uid = 0
    pw_path_gid = 0
    pw = Chef::EncryptedDataBagItem.load("bag", "item")['password']
    
    ruby_block "#{pw_path}-touch" do
      block   { FileUtils.touch pw_path } # so that we can chown & chmod it before writing the pw to it
      not_if  { pw_path.file? } …

    automation chef devops hosting

    Debugging Localization in Rails

    Mike Farmer

    By Mike Farmer
    April 1, 2013

    Rails offers a very extensive library for handling localization using the rails-i18n gem. If you’ve done any localization using Rails, you know that it can be difficult to keep track of every string on your web application that needs translation. During a recent project, I was looking for an easy way to visually see translation issues while browsing through the UI in our application.

    Missing Translations

    I’ve known for some time that when I was missing a translation for a given text that it would appear in the HTML with a special <span> tag with the class translation_missing. So in my global CSS I added the following:

    .translation_missing { background-color: red; color: white !important; }

    Now when I viewed any page where I had forgotten to add a translation to my en.yml file I could see the text marked in bright red. This served as a great reminder that I needed to add the translation.

    I’m an avid watcher of my rails log while I develop. I almost always have a terminal window right next to my browser that is tailing out the log so I can catch any weirdnesses that may crop up. One thing that I thought would be nice is if the log showed any translation issues on the page it …


    rails localization

    Custom helper subs in Dancer templates

    Jon Jensen

    By Jon Jensen
    March 30, 2013

    I recently was writing some code using the Dancer Perl web framework, and had a set of HTML links in the template:

    <a href="/">Home</a> |
    <a href="/contact">Contact</a> |
    [etc.]

    Since it’s possible this app could be relocated to a different path, say, /something/deeper instead of merely /, I wanted to use Dancer’s handy uri_for() routine to get the full URL, which would include any path relocation. (This concept will be familiar to Interchange 5 users from its [area] and [page] tags.)

    The uri_for function isn’t available in templates. The easiest way to cope would be to just use it in my route sub where it works fine, and store the results in the template tokens as strings. But then for any new URL needed I would have to update the route sub and the template, and this feels like a quintessential template concern.

    I found this blog post explaining how to add custom functions to be used in templates, and it worked great. Now my template can look like this:

    <a href="<% uri_for('/') %>">Home</a> |
    <a href="<% uri_for('contact') %>">Contact</a> |
    [etc.]

    And the URLs are output …


    dancer perl

    Paper Source Case Study with Google Maps API

    Steph Skardal

    By Steph Skardal
    March 29, 2013

    Basic Google map with location markers

    Recently, I’ve been working with the Google Maps API for Paper Source, one of our large Interchange clients with over 40 physical stores throughout the US.

    On their website, they had previously been managing static HTML pages for these 40 physical stores to share store information, location, and hours. They wanted to move in the direction of something more dynamic with interactive maps. After doing a bit of research on search options out there, I decided to go with the Google Maps API. This article discusses basic implementation of map rendering, search functionality, as well as interesting edge case behavior.

    Basic Map Implementation

    In its most simple form, the markup required for adding a basic map with markers is the shown below. Read more at Google Maps Documentation.

    HTML
    <div id="map"></div>
    CSS
    #map {
      height: 500px;
      width: 500px;
    }
    JavaScript
    //mapOptions defined here
    var mapOptions = {
      center: new google.maps.LatLng(40, -98),
      zoom: 3,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    
    //map is the HTML DOM element ID where it will be rendered
    var map = new google.maps.Map(document.getElementById("map"), mapOptions);
    
    //all locations is a …

    interchange javascript jquery maps case-study clients

    Google Sitemap rapid deployment

    Jeff Boes

    By Jeff Boes
    March 21, 2013

    I was going to call this “Quick and Dirty Sitemaps”, but “Rapid Deployment” sounds more buzz-word-worthy. This is how to get a Google sitemap up and running quickly, using the Google sitemap generator and the Web Developer Firefox plug-in.

    I had occasion to set up a sitemap using the Google sitemap generator for a site recently. Here’s what I did:

    Download the generator using the excellent documentation found at the previous link. Unpack it into a convenient location and copy the example_config.xml file to something else, e.g., www.mysite.com_config.xml. Edit the new configuration file and:

    1. Modify the “base_url” setting to your site;
    2. Change the “store_into” setting to a file in your site’s document root;
    3. Add a pointer to a file that will contain your list-of-links, e.g.,
    <urllist path="site_urls.txt">
    </urllist>

    I would locate this in the same path as your new configuration file.

    Now, if you don’t already have Web Developer, give yourself a demerit and go install it.

    Okay, you’ll thank me for that. Now pick a few pages from your site: good choices, depending on your site’s design, are the home page, the sitemap (if you have …


    seo

    Generating PDF documents in the browser

    Kamil Ciemniewski

    By Kamil Ciemniewski
    March 15, 2013

    What you will learn

    • How to generate PDF documents in the browser with JavaScript
    • How to generate them out of normal HTML
    • How to open those PDFs in new windows
    • How to render them inline inside the DOM

    Introduction

    Every once in a while as web developers we face the challenge of providing PDF documents for the data we have persisted in the database.

    The usual approach is to:

    • generate the document with a library / DSL in the language of the backend
    • or—​generate normal html view and use a utility like wkhtmltopdf

    That works nice, but what if you’re developing an SPA app which only consumes JSON data from its backend? Imagine a scenario when the backend isn’t capable of producing responses other than JSON data. What could you do there?

    The solution

    Thanks to some very bright folks behind the jsPDF library we have both above mentioned options right inside the browser.

    I strongly encourage you to visit their website. There is a nice live coding editor set up which reflects in real time the PDF your code is producing.

    Using the DSL

    The whole process looks like this:

    # 1. create jsPDF object:
    doc = new jsPDF()
    
    # 2. put something interesting in there:
    doc.setFontSize(22)
    doc.text(20, 20 …

    javascript pdf

    NoSQL benchmark of Cassandra, HBase, MongoDB

    Jon Jensen

    By Jon Jensen
    March 12, 2013

    Benchmarking Top NoSQL DatabasesBenchmark White Paper

    We’re excited to have recently worked on an interesting benchmarking project for DataStax, the key company supporting the Cassandra “NoSQL” database for large horizontally-scalable data stores. This was done over the course of about 2 months.

    This benchmark compares the performance of MongoDB, HBase, and Cassandra on the widely-used Amazon Web Services (AWS) EC2 cloud instances with local storage in RAID, in configurations ranging from 1-32 database nodes. The software stack included 64-bit Ubuntu 12.04 LTS AMIs, Oracle Java 1.6, and YCSB (Yahoo! Cloud Serving Benchmark) for its lowest-common-denominator NoSQL database performance testing features. Seven different test workloads were used to get a good mix of read, write, modify, and combined scenarios.

    Because cloud computing resources are subject to “noisy neighbor” situations of degraded CPU or I/O performance, the tests were run 3 times each on 3 different days, with different EC2 instances to minimize any AWS-related variance.

    The project involved some interesting automation challenges for repeatedly spinning up the correct numbers and types of nodes, configuring the node software, running tests, and …


    database mongodb nosql performance cassandra
    Previous page • Page 125 of 222 • Next page