Atlantic Business Technologies, Inc.

Category: Managed Services

  • AtlanticBT is hosting/speaking at ‘Refresh’ event Thursday night!

    This month’s Refresh event is on Sept. 22: “Growth Patterns: Building a foundation for expansion — Driving, or being driven, to grow in order to meet demand”

     We’ll meet  from 6:30-8:00pm and then head to a nearby bar for more conversation.

    Attending?

    Atlantic BT’s new space is across from Crabtree Valley Mall
    4509 Creedmoor Road, 3rd Floor
    Raleigh NC 27612

  • Create your own Javascript Library

    Create your own javascript library in these fun, easy steps!

    Background

    We all know about the performance benefits of putting all of our javascript/jQuery calls into .js files, so that browsers will cache the whole chunk on the client-side.

    It’s even more tempting to put all of our complicated jQuery calls into a single file, thus further enhancing performance by reducing HTTP requests (i.e. the browser doesn’t have to download so many files).

    However, have you ever taken a look at a site using the jQuery Cycle plugin on the homepage? If you open up the debugging console (firebug), go to a page without the slideshow, and I bet you’ll see a little message in the console like:

    [cycle] terminating; too few slides: 0

    This is because the cycle init code, while correctly put inside the DOM-ready function, is still being called on every page, regardless of whether it has a slideshow or not.

    Most of the time you won’t even notice the extra overhead because jQuery fails gracefully, but it’s still traversing the DOM, looking for elements that aren’t there.

    Solution

    The solution is to encapsulate your code in a segmented library, and only call necessary aspects within the actual page. This has the benefits of:

    • separation – keeps functionality organized as atomic units, so there’s no conflict between similar functions
    • readability – when properly documented and structured, it should be easier to find your way around a library than code just stuck in a page.
    • usability – make your functions as complex as you want, but use them in multiple places with a single call. Added bonus: some IDEs like Eclipse can provide autocomplete and some documentation for the library class, making it easier to call what you’re looking for.
    • performance – since you’re only calling the functions you need when you need them, there’s no overhead from wasted DOM manipulation.

    Library Shell

    The following section provides a summarized example with most of the principles involved. It will:

    1. Declare the library “namespace” (see red section)
      • this is the external variable you’ll use to actually call your library publicly — you can change this name to avoid conflicts, or customize for each site.
      • wrap your library in a scope “wrapper” — this is to protect your methods, etc from external conflicts, and optionally to protect your usage of jQuery within the library.
    2. Declare the private “namespace” (see green section)
      • you’ll use this to refer to your library internally — basically just a shorthand reference
      • sets up the library as a javascript Object (JSON)
    3. Declare page directives or sublibraries (see blue section)
      • group functions or data into sublibraries, or organize along pages — here, we have a section for common tools, and a section for the search pages
      • use javadoc-style commenting to explain each sublibrary – some IDEs may pick this up
      • mark-off the closing { of sublibraries and methods with ///—- and the name of the library, to aid in navigation and organization
        • use 2 slashes with 3 dashes for methods
        • 3 slashes with 4 dashes for sublibraries
        • 4 and 4 for the library itself
        • this is really just so that monospaced fonts line them up; (my IDE also colors // vs //// differently)
      • you can also place the commas on separate lines as well, just so they don’t interfere with comments, and provide extra visual padding
    4. Declare actual function calls
      • within each function, you can bind to the jQuery document-ready function (see purple section); this is just to make it easier to use them with just 1 line outside the library.
      • you can use other methods and sublibraries within function calls (see yellow text); refer to the library with LIB.section.method, while you may also be able to use the shorthand this to call the current sublibrary (depending on whether you’re inside another anonymous function scope).
    5. Close all sublibraries and methods
    6. Return internal reference (see green text at bottom) – exposes the library object to public view.
    7. Close library scope wrapper (see red text at bottom)

    Then, in your actual page, reference your library with the public namespace variable (see yellow text at bottom).

    The Code

    var Mylib = (function($) { //reference “namespace”, scope wrapper, encapsulates jQuery

    var LIB = { //internal name of library
    /**
    * Testing function – indicates if our library is present
    */

    ”’test”’ : function(){ $(‘body’).prepend(‘SPECIAL library loaded’); } //page directives or sublibraries
    ,
    /**
    * General tools
    */

    ”’tools”’ : {
    /**
    * Console-log wrapper
    */
    ”’log”’ : function() { if( window.console && window.console.log ){
    window.console.log( Array.prototype.slice.call(arguments) ); }
    }//— lib.tools.log

    }///—- lib.tools
    ,
    /**
    * Search namespace – related to search box or pages
    */

    ”’search”’ : {
    /**
    * Helper function
    * @param msg a message for the alert
    */

    ”’notify”’ : function(msg){
    alert(‘Doin’ the search:’ + msg);
    }//— lib.search.notify
    ,
    /**
    * Enable advanced search box
    */

    ”’toggleAdvancedSearch”’ : function(){
    this.notify( ‘self-reference the sublibrary OUTSIDE’ ); //call the sublibrary outside anon-func

    $(function(){ //waits for document-ready
    var $advancedSearch = $(‘#site-search-advanced’)
    $searchResults = $(‘#search-results’)
    ;
    LIB.tools.log( ‘here’s an example of self-referencing’ ); //call the library internally
    LIB.search.notify( ‘self-reference the sublibrary INSIDE’ ); //call the sublibrary inside anon-func scope

    //hide by default
    $advancedSearch.slideUp(‘3000’);

    $searchResults.delegate(‘#refine-search’, ‘click’, function(){
    $advancedSearch.slideToggle();
    return false;
    });
    });
    }//— lib.search.toggleAdvancedSearch
    }///—- lib.search
    };////—- lib
    return LIB; // send the internal name back out
    })(jQuery); //scope wrapper, encapsulates jQuery

    Mylib.tools.log( ‘actually using the library’ ); //call the library externally

    Extensions

    Multiple Internal Libraries

    You could conceivably include more than one internal library (LIB, LIB2, etc) within your library scope. This is more for the following – #DOM wrapper like jQuery

    DOM wrapper like jQuery

    You can also include DOM-manipulation within your library. In the “shipping estimator” example, the library has an internal myDOM object that takes an HTML #id tag and creates a new instance of itself, which has several attached methods. This is similar to how jQuery works.

    You’ll notice that at the end of the scope wrapper, instead of returning the LIB internal namespace, it’s merging the properties of that library back on to the myDOM object with:

    //attach sublibraries to manipulation object (to avoid writing an .extend method?)
    for(func in LIB){
    	myDOM[func] = LIB[func];
    }
    return myDOM;

    Again, this is similar to how jQuery extends itself (also see the “Build Your Own Library” reference).

    Examples

    See attached files – I apologize that these are mostly out-of-context, and probably have too much extra junk to be very simple to follow, but should give you an idea of what you can do with a library.

    • Shipping Estimator – Example (zip) — instance of DOM-manipulation wrapper
    • javalib-test.html — super simple implementation of example shell
    • ggroup.js — has some pagination and ajax helpers, also very flexible form validation

    References

  • Start Up a Business Website over a Weekend

    Start up a business over a weekend.  That was the premise behind this weekend long event that was hosted in Durham, North Carolina.

    Nancy Jin, a co-worker of mine, and I attended the Start Up Weekend.  Over the weekend, participants met the challenge created by the Start Up Weekend committee and outputted prototype Facebook applications, Mobile applications and websites that encapsulated an idea that was created and pitched by a participant.

    Here is a quick summarization of Nancy Jin’s experience at Start Up Weekend:

    Friday night, out of over 100 participants (evangelists and hackers – basically marketing specialists and developers), 54 people each had 60 seconds to pitch an idea. We then voted and picked which ones we wanted to work on. I landed a team of 2 other designers, two ruby developers, and three marketing specialists, with an idea of urban farming. We were then up till midnight figuring out what our plan was the next day.

    8:30am – 12pm Saturday was spent surveying real people, defining problems, coming up with a solution and a base model for the business. Wireframing started at 2:00pm. By 4:00pm we had a logo and by 6:00pm we had a homepage. By 8:00pm we had a working site where people could log in and sign up, and by 11:00pm the rest of the pages were designed, functioning, and the homepage sliced out. Then I went and got some sleep.

    The website was completed at 1:00pm the next day, and we had 5 minutes to pitch the idea against 17 other teams in front of everyone including a panel of judges.

    We won.

    Here’s the site: yardsprout.heroku.com

    We addressed that local food is important for economic, environmental, and health reasons. Urban farming is important because we are utilizing fertile spaces that are otherwisewasted. People can grow their own gardens but for most people the toughest part is getting started. We wanted to first establish a business model where novices can seek master farmers to help them plant something,  to eventually have the company provide people with gardening kits, which is where yardsprout could team up with brands like Lowes and Home Depot.

    Some other cool stuff I got to do was working with github, some ruby on rails (it was like what? I think where I’m sticking my HTML makes sense), and a lot of SASS (my first time).

    Here is a quick summarization of my experience at Start Up Weekend:

    Friday – I did not plan on making a pitch but one of the hosts came by everyone’s tables and urged us to make a pitch, so I motivated myself to bounce ideas off of random people around me.  I decided to pow wow with two random students from NCSU about business concepts.  First one that we came up with was struck down by our very own Nancy Jin who saved me the embarassment of pitching a product that pretty much existed in the wild.

    I considered the 5-10 minute pow wow over a great idea and being shown the thriving product by my coworker next to me my first “failure” of the night.

     
    Then, I started thinking about Atlantic BT and how businesses hear about us.  That’s when I brought up another concept which was Business-2-Business Reviews.com.  A site where a business owner or business decision maker can read reviews (should be testimonials).  Needless to say, I had 15 minutes to come up with something to say in a crowd of 100 people for 60 seconds.  I took the plunge and *cues drumroll* did not get voted as a top 10 concept.

    I considered the pitch my second “failure” of the night.

     
    I ended up being asked to join one of the winning teams, namely “Carpoolicious”!  The idea was created by Sam Gong who is currently studying for his PhD in Theoretical Physics at Duke University.  Our plan was to use a complex algorithm to determine best travel patterns and travel partners during your commute.
    I was not swayed by the fact that Sam had came up with this concept during his drive to the event.  In fact, I felt it really interesting to break down a concept, analyze potential failure points, doing the research and pivoting the product to something we both believed in.
    “Pivoting” is when you change a fundamental part of the business model. It can be as simple as recognizing that your product was priced incorrectly. It can be more complex if you find the your target customer or users need to change or the feature set is wrong or you need to “repackage” a monolithic product into a family of products or you chose the wrong sales channel or your customer acquisition programs were ineffective.
    Unfortunately, we did not win the final pitch.
    Although it was not my original concept, I felt that the resulting concept was very much something I was a part of.

    Therefore, I considered not winning my third “failure” of the night.

     
    But, with all those fails – I learned a lot.
     

    What I learned and did over the weekend:

     
    • Learned how difficult it was to tell a team member they were holding back discussions and need to re-evaluate what they aimed to get out of the weekend.
    • Learned that your product needs a solid customer acquisition strategy & financial forecast model.
    • Came up with the following short-term customer acquisition strategies adopted by the Carpool team
    • Deals along the way (think Groupon deals for long point to point trips)
    • Concert and Sporting Events (which led to more focused growth strategies by my teammates)
    • Other ideas by my teammates.
    • Work with TicketMaster, StubHub & Political Campaign managers to push individuals to Carpool to events.
    • A spinoff website called “Designated Driver Roulette”… basically utilizing the carpooling engine to determine who gets the job of DD when going out with a group of friends in a car.  Unfortunately, that got nixed.. but it would’ve been fun.
    • Loved the idea pitched by the Mentor for our concept which was
      • Creating a white label Carpool tool for corporations to reduce carbon emissions by their employees for gov’t tax breaks and clean tech PR.
    • Learned how to create a Features/Benefits vs. Ease of Use graph from our teammate who used to work for Accenture for 12 years.  This was a great way of showing competitor analysis in one graph.
    • Created a survey to figure out customer validation.  I found out at 8:00 am on Sunday that it is important to have some sort of customer validation.  A bit late for me to generate survey results.  But, I managed to finagle ~100 responses via the following methods:
      • Facebook Survey
      • Tweeted SurveyMonkey link to individuals at the event
    • Visited United Kingdom chat rooms to post the SurveyMonkey link.  It was approximately 2:00 pm in the UK when these individuals saw my link.  United Kingdom was a good target market for us because of their interest in cleantech.
    This most recent study comes on the back of an earlier survey E&Y carried out between between August and October 2010 found that 76 per cent of UK businesses questioned believe urgent and decisive action is needed or the UK will fall behind other countries that are prioritising cleantech as a sector of national strategic importance.

    The survey I created was this:

    1. Do you carpool to work? (97% responded no)
    2. Would you carpool to work with a coworker? (85.2% responded yes)
    3. Do you know about company incentives for carpooling?  (77.8% responded no)
    From the above results, we determined a potential market size.  If given more time, we would have added more questions that focused on customer validation.

    It was definitely a memorable weekend and I plan on attending this event again next year.

  • Creating Custom Gateway in WordPress Plugin Cart66

    Ah payment gateways.  The, uh, gateway…to making payments. Yeah.

    Previously called PHPurchase, Cart66 (and its free sibling Cart66 Lite) are full-featured e-commerce plugins for selling products via WordPress. Cart66 comes out-of-the-box with several integrated gateways:  Authorize.net, PayPalPro, and PayPal Express. It also has a handy feature where you can add an Authorize.net-compatible gateway right in the payment options menu.

    But, what if you need a customized payment gateway? Like, say TransFirst TransLink?

    After purchasing/downloading Cart66 (I’m using the paid version 1.0.7), follow these “easy” steps —

    1. Add additional option for your payment gateway to the option list in contentpluginscart66adminsettings.php
    2. Make a copy of an existing gateway file (such as contentpluginscart66progatewaysCart66AuthorizeNet.php)
    3. Update the properties of the gateway class to handle the payment in an appropriate manner specific to that gateway — remap fields, change the remote-request format, etc (see the following table)
    4. Add shortcodes for the checkout form of your new gateway:
      • to the shortcode init function initShortcodes() in contentpluginscart66modelsCart66.php, register the checkout shortcode itself like checkout_xxxgatewayxxx
      • to the shortcode manager class contentpluginscart66modelsCart66ShortcodeManager.php, add the shortcode callback xxxgatewayxxxCheckout()
      • to the actual checkout page (via the WP dashboard) on your checkout page, add/replace the default gateway checkout shortcode with your new shortcode checkout_xxxgatewayxxx
      • also allow the new gateway type by adding your gateway class name to the $supportedGateways array in contentpluginscart66viewscheckout.php

    Please note that in step 1, I chose to simply add the gateway to the Authorize.net section of the Cart66 options, instead of creating a whole new section (like PayPal vs. Auth.net), as the parameters ended up being very similar. This means you only need to add the gateway URL (http://epaysecure1.transfirst.com/elink/authpd.asp) to the select-list (in /content/plugins/cart66/admin/settings.php), and processing is handled by Cart66.

    The meat of the change, obviously, comes in your custom gateway class. Download the sourcecode for the custom class (attached).

    I’ve added some additional methods not present in the original gateway abstract to help with processing and validation:

    Method/Property Inherited From Abstract? Description

    $field_string, $fields, $response, etc
    Yes, unchanged internal storage for gateway parameters

    $_amountFieldKey, $_possibleFields, $_requiredFields, etc
    No helper lists of potential fields – for validation, and in the case of TransFirst to keep track of everything

    gatewayResponseDescription
    No Translates the gateway response code value (for TransFirst)

    __construct
    Yes + Modified constructor – add default fields and initialize the _possibleFields, etc.

    getCreditCardTypes
    Yes, unchanged just lists the available card types

    addField
    Yes helper method to add fields to internal storage

    Added validation to check if key is in _possibleFields


    initCheckout
    Yes + Gets the payment and billing details, then sets up the checkout properties.
    Added $mapFields loop to set up variables

    parseResponse
    No Process the string response into meaningful sections, and return transaction success or failure (with reason)

    doSale
    Yes Handles the curl (remote-request) to the actual payment gateway after building the post-string from the user submission.

    Minor changes here – mostly remapping the different fields


    getResponseReasonText, getTransactionId, etc
    Yes, unchanged helper methods for retrieving stuff

    Update: I’ve since found out about the built-in WordPress remote-request function wp_remote_post. I haven’t updated the source file, but any use of curl should be replaced with this function.

    Update 2: Added the gateway URL per commenter request.

  • “Wait for it…” — Loading Content Progressively

    Progressive Loading is a technique whereby you automatically load content in a webpage after set intervals or triggers, such as when the user scrolls in the vertical direction.  With the advent of easier AJAX, and probably helped by some popular examples, progressive loading is gaining traction as another shiny bauble in the modern web development toolkit.

    But why is it useful?  For a more definitive answer, I plan to nag my UX teammates to follow up with their perspective, but I can still tell you a couple things:

    • + It keeps users on the same page, and so browsing may be perceived as “easier.”  It literally requires less effort from the viewer, as you just scroll instead of hunting for and clicking a “next page” link, or bypasses the unsightly flash of reloading of the entire page.
      ex) Google’s recent changes to their image search (props to James Costello for pointing out how awesome it feels)
    • + less server intensive — while this may be a non-issue with our super deluxe hardware, you’re still only serving up “essential” content in the initial visit.  This can help reduce overall page load time, since you’re not trying to download and render a million images/comments/posts at the bottom of an article.  This is especially important for bandwidth-limited mobile browsing.
      ex) The Disqus commenting system, as used on the jQuery API documentation watch for the spinner at the bottom of the page as it loads comments when you scroll there really quickly

    However, there are two potentially important caveats to consider:

    • ‑ Progressively loaded content may not be indexed by crawlers and search engines.  Since it only appears after user interaction with the webpage, it probably won’t happen with the robots.  Although, this may depend on implementation — if you programmatically trigger the regular-old “next” or “more” link that’s been included for graceful degradation, a spider might also be able to follow that link to index the rest of the content.
    • ‑ Similarly, progressively loaded content isn’t available to in-page searches (i.e. CTRL+F “Find Text”).  So, depending on the implementation (like a really long article with comments) there’d be no way for a reader to jump to content of interest without scanning the whole page first.

    So where’s the beef?  Stay tuned for a quick intro on a really slick implementation of progressive loading using jQuery Waypoints (credit for the find goes to fellow dogbone castaway Chad Quigley).

  • WordPress – Password Protected Templates

    Need a simple solution for a “members only” WordPress page?  “But password-protecting a single page is part of WP core!” you say — and you’re right, except if you want to display additional content not part of the protected post.  Read on for how to customize a post template to protect category loops and other page elements.

    When creating content, you can hide it behind a simple password on the right sidebar under “Visibility” — choose “Password protected”, and enter your password. As long as you don’t need the precision, this avoids the complication of multiple user accounts and role/permission integration.

    However, if you are using a custom template on a “category” page (i.e. you have an additional query loop for other content) like, say, a products page for a store, or member database then you’ll need to wrap the additional content in a password check.

    Fortunately, Codex to the rescue — all you need is the simple function call post_password_required().  Wrap an if-else clause around the additional queries, and you’re done!

    Example:

    <?php get_header(); ?> <div> <div id=”content” role=”main”> <?php //initial loop for calling page if ( have_posts() ) while ( have_posts() ) : the_post(); … stuff … ?> <div id=”post-<?php the_ID(); ?>” <?php post_class(); ?>> <div> … </div><!– .entry-content –> </div><!– #post-## –> <?php endwhile;//—-    end post loop //only do the following if the calling page is allowed if(!post_password_required()): ?> <div> <?php query_posts( ‘post_type=abt_member’); // calls in all posts of the custom type ?> <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?> <div <?php post_class(); ?>> … stuff … </div><!– #products –> <?php endwhile; ?> </div> <?php endif;    //—-    !post_password_required() ?> </div><!– #content –> <?php get_sidebar( ‘store’ ); ?> </div><!– #container –> <?php get_footer(); ?>

    Strangely, WordPress doesn’t allow you to “log out” of password-protected pages, and it doesn’t seem like deleting cookies makes a difference. Of course, someone made a plugin that’ll take care of that — install the plugin, then add the following to your template:

    do_action(‘posts_logout_link’, ‘TEXT ON THE LOGOUT LINK’);

    Further reading – Digging into WordPress – password protect more than the content.