Posts Tagged 'Developers'

August 8, 2012

No iFrames! Dynamically Resize Divs with jQuery.

It's no secret that iframes are one of the most hated methods of web page layouts in the web development world — they are horrible for SEO, user experience and (usually) design. I was recently charged with creating a page that needed functionality similar to what iframes would normally provide, and I thought I'd share the non-iframe way I went about completing that project.

Before I get into the nitty-gritty of the project, I should probably unpack a few of the reasons why iframes are shunned. When a search engine indexes a page with iframes, each iframe is accurately recorded as a separate page — iframes embed the content of one we page inside of another, so it makes sense. Because each of those "pages" is represented in a single layout, if a user wanted to bookmark your site, they'd probably have a frustrating experience when they try to return to your site, only to find that they are sent directly to the content in one of the frames instead of seeing the entire layout. Most often, I see when when someone has a navigation bar in one frame and the main content in the other ... The user will bookmark the content frame, and when they return to the site, they have no way to navigate the pages. So what's a developer to do?

The project I was tasked with required the ability to resize only certain sections of a page, while asynchronously shrinking another section so that the entire page would always stay the same size, with only the two sections inside changing size.

Let's look at an example with two divs, side by side on a web page:

iFrame Tutorial

One div will contain a navigation menu to jump to different pages of the website (#sidebar), and the second div will contain all the content for that page (#content). If some of the elements in #sidebar are too long to read with the default width of the div, we want to let the user freely resize the two divs without changing the width of the page.

Our task is straightforward: When #sidebar expands in width, also expand the navigation and shrink #content along with the main content inside #content. If #sidebar shrinks, the navigation, #content and main content would respond accordingly as well:

iFrame Tutorial

It's a relatively easy concept to do with iFrames ... But then you remember that iframes are no longer cool (yes, there was a time long ago when iframes were cool). I decided to turn to my favorite alternative — jQuery — and the fix was actually a lot easier than I expected, and it worked beautifully. Let's run through a step-by-step tutorial.

1. HTML

Lay out your two divs:

<div id="sidebar"> 
<div class="sidebar-menu">
<!-- all your sidebar/navigational items go here -->
</div>
</div>
<div id="content">
<!-- all your main content goes here -->
</div>

2. CSS

Style your divs:

#sidebar {
       width: 49%;
}
#content {
width: 49%;
        float: left;
}

3. jQuery

Now that we have our two divs side by side, let's apply some jQuery magic. To do that, Let's include our jQuery files in the <HEAD> of our document:

<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>

Now that we have the necessary scripts, we can write our function:

<script type="text/javascript">
  $(document).ready(function() {
    $( "#sidebar" ).resizable({      
    });
    $("#sidebar ").bind("resize", function (event, ui) {
            var setWidth = $("#sidebar").width();
            $('#content).width(1224-setWidth);
            $('.menu).width(setWidth-6);
        });
  });
</script>

I know that might seem like an intimidating amount of information, so let's break it down:

   $( "#sidebar" ).resizable({      
   });

This portion simply makes the div with the ID of "sidebar" resizable (which accomplishes 33% of what we want it to do).

   $("#sidebar ").bind("resize", function (event, ui) {

By using the .bind, we are able to trigger other events when #sidebar is called.

            var setWidth = $("#sidebar").width();
            $('#content).width(1224-setWidth);

This is where the magic happens. We're grabbing the current width of #sidebar and subtracting it from the width you want your site to be. This code is what keeps your page stays the same width with only the divs changing sizes.

            $('.menu).width(setWidth-6);

This part of the code that expands the contents in the navigation along with #sidebar.

You can see a working example of iframe-like functionality with jQuery here: http://jqueryui.com/demos/resizable/

The only part you won't find there is the trick to adjust a corresponding div's size to make it grow/shrink with the first ... I had a heck of a time searching that on the web, so hopefully this quick tutorial will help other developers who might be searching for this kind of functionality!

- Cassandra

July 11, 2012

Mandrill: Tech Partner Spotlight

This is a guest blog with Chad Morris from our partner Mandrill. Mandrill is an email delivery platform built on and managed by MailChimp. Created for developers to set up and manage with minimal coding effort, Mandrill offers advanced tracking, easy-to-understand reports and hundreds of template options. In this video interview, Chad goes into detail about the history of the company as well as the major differences between Mandrill and MailChimp. In the near future, you'll see a separate guest blog from the Mandrill team with best practices for managing your email systems.

This guest blog series highlights companies in SoftLayer's Technology Partners Marketplace.
These Partners have built their businesses on the SoftLayer Platform, and we're excited for them to tell their stories. New Partners will be added to the Marketplace each month, so stay tuned for many more come.
May 10, 2012

The SoftLayer API and its 'Star Wars' Sibling

When I present about the SoftLayer API at conferences and meetups, I often use an image that shows how many of the different services in the API are interrelated and connected. As I started building the visual piece of my presentation, I noticed a curious "coincidence" about the layout of the visualization:

SoftLayer API Visualization

What does that look like to you?

You might need to squint your eyes and tilt your head or "look beyond the image" like it's one of those "Magic Eye" pictures, but if you're a geek like me, you can't help but notice a striking resemblance to one of the most iconic images from Star Wars:

SoftLayer API == Death Star?

The SoftLayer API looks like the Death Star.

The similarity is undeniable ... The question is whether that resemblance is coincidental or whether it tells us we can extrapolate some kind of fuller meaning as in light of the visible similarities. I can hear KHazzy now ... "Phil, While that's worth a chuckle and all, there is no way you can actually draw a relevant parallel between the SoftLayer API and The Death Star." While Alderaan may be far too remote for an effective demonstration, this task is no match for the power of the Phil-side.

Challenge Accepted.

The Death Star: A large space station constructed by the Galactic Empire equipped with a super-laser capable of destroying an entire planet.

The SoftLayer API: A robust set of services and methods which provide programmatic access to all portions of the SoftLayer Platform capable of automating any task: administrative, configuration or otherwise.

Each is the incredible result of innovation and design. The construction of the Death Star and creation of the SoftLayer API took years of hard work and a significant investment. Both are massive in scale, and they're both effective and ruthless when completing their objectives.

The most important distinction: The Death Star was made to destroy while the SoftLayer API was made to create ... The Death Star was designed to subjugate a resistance force and destroy anything in the empire's way. The SoftLayer API was designed to help customers create a unified, automated way of managing infrastructure; though in the process, admittedly that "creation" often involves subjugating redundant, compulsory tasks.

The Death Star and the SoftLayer API can both seem pretty daunting. It can be hard to find exactly what you need to solve all of your problems ... Whether that be an exhaust port or your first API call. Fear not, for I will be with you during your journey, and unlike Obi-Wan Kenobi, I'm not your only hope. There is no need for rebel spies to acquire the schematics for the API ... We publish them openly at sldn.softlayer.com, and we encourage our customers to break the API down into the pieces of functionality they need.

-Phil (@SoftLayerDevs)

May 9, 2012

Nexmo: Tech Partner Spotlight

This guest blog comes to us from Nexmo, a featured member of the SoftLayer Technology Partners Marketplace. Nexmo is the wholesale messaging API that lets you send and receive high volumes of SMS at a global level. In this video we talk to Nexmo CEO Tony Jamous about the benefits of Nexmo, how it came to be and the problem it solves for you.

Cutting out the Middleman with Nexmo

These days, optimizing mobile messaging deliverability comes at a price. Businesses must connect to multiple carriers, operate heavy infrastructure, and build their own data analytics. On top of that, many third-party SMS solutions require contracts, price negotiations and significant up-front costs.

Nexmo was created to eliminate the need for a business to connect to carriers or complex third party protocols through simple, powerful RESTful and SMPP APIs. Our scalable infrastructure allows you to send and receive SMS in high volumes to over 5 billion users around the world. This is a market need that hasn't been addressed, and we approached it with a few ideas in mind. If you were going to replicate the functionality of Nexmo on your own, these are the key areas you'd have to look at:

Direct to Carrier Model

With every hop, the quality of a connection has the potential to degrade, and cost inflates. Adding intermediaries in the chain also impact the granularity of collected data, such as delivery reports and reasons of failure. By reducing the number of hops to the final subscriber you'll see:

  • An improved delivery ratio and lower latency
  • Enhanced security
  • Fewer single points of failure
  • Reduced cost, less fat in the chain

With a closer position to the final carrier, a business can access more "Telco" data like phone status, whether it is ported to another network, or if it's roaming abroad. With that information, you can also make better routing decisions and ultimately see higher delivery ratios.

Get Your own SMS-Enabled Phone Numbers

We've seen in the last two years the emergence of "Over the Top" (OTT) messaging apps such as Google Voice and TextPlus. Those apps provide a virtual phone number to each user, and Nexmo behaves similarly by enabling apps to behave like a "super virtual carrier" without the need for heavy Telco infrastructure. North America is the most mature market with OTT players generating significant SMS traffic, and now these models are going abroad. We pinpointed a unique need in the value chain:

  • Source virtual phone numbers from global carriers
  • Build the business models that protect carriers' interests without eliminating the opportunity for innovative apps
  • Provide the elastic and scalable cloud infrastructure for high volume two-way transactions

Nexmo approached those needs with APIs that enabled app developers to search for available phone numbers, provision new numbers and cancel numbers they weren't using any more. It doesn't take days or weeks to launch in a new market ... Apps can launch in a new market in a matter of hours with minimal upfront investment!

Improve and Track Deliverability

Enterprises and developers have shifted the focus in the buying process. They are looking for more transparency and accountability, so tracking and monitoring hundreds, thousands or even millions of messages can be of utmost importance.

For every SMS sent, the Nexmo API provides a detailed report of delivery. We push this data into the cloud in real time, displayed in two ratios:

  • The Success Ratio: The percentage of message received by the phone. This ratio measures how well traffic is performing.
  • The DLR Ratio: The percentage of messages with a delivery receipt. This ratio tracks infrastructure and route performance.

Follow the Life of a Message from the Cloud

Most B2C services and resellers that send millions of SMS for things like alerts, phone verifications and access codes can get swarmed when it comes to user support. We know that's an intimidating prospect for any business looking to add SMS functionality to their app or platform, so we let our customers follow the life of a message from the cloud and gather more information about it. Some of the information we've found most helpful to track:

  • How fast was the message was delivered?
  • Was the phone available for receiving SMS?
  • Did the user enter the correct phone number?

Keeping an eye on these basic kinds of stats reduces the pain of supporting a large user base and enables your support staff to answer questions quickly because they have a good foundation of information.

Receive Outstanding Support

Building a customer centric culture is a sustainable competitive advantage. It is even more meaningful in a commoditized, price-driven industry like wholesale telecom. If you're going to approach the world of SMS messaging and deliverability, the need for outstanding support is even more urgent because, given the nature of SMS messaging, results are expected immediately.

When we started Nexmo, we knew that, and I'm proud to report that we constantly score over 95% in customer satisfaction, and we've noticed a few tricks that have helped us maintain that level of support:

  • Hire the right people: Empathy and service mindset are more important than technical skills
  • Provide self-help tools and open knowledge bases: Customers appreciate finding solutions by themselves
  • Measure help-desk performance and constantly improve: KPI includes first meaningful reply time, resolution time and satisfaction ratio.

We hope these tips can help you build on your existing support or give you a jumping-off point if you're just getting started.

There is so much more I could tell you about our experience in building Nexmo into the platform it is today, but it's a lot easier for you to just see for yourself. If you're interested in learning more about Nexmo, visit http://nexmo.com, sign up, and be ready to go live with us in a matter of minutes ... And to make it even easier, you can use the free credits we provide to give the platform a test drive.

If you've been intimidated by the daunting task of knocking on the doors of telcos and carriers to get easy-to-use and easy-to-track SMS functionality in your app, Nexmo can save you a lot of headaches.

-Tony Jamous, Nexmo

This guest blog series highlights companies in SoftLayer's Technology Partners Marketplace.
These Partners have built their businesses on the SoftLayer Platform, and we're excited for them to tell their stories. New Partners will be added to the Marketplace each month, so stay tuned for many more come.
March 30, 2012

Very Casual Fridays

One of the best things about working at SoftLayer is that we get awesome freebies. In the last year, I have seen a servers given away to authors of the best SoftLayer-themed Haikus, employees have won Apple iPads, solid state drives, extra vacation days, Napa Valley wine tasting trips and finely aged booze in fundraisers for the American Heart Association. On any given day, you'll see people handing out swag, snacks, beverages and catered meals. SLayers can get tickets to Rangers and Cowboys games, we have some great Happy Hour events, and our company parties are legendary. I thought I'd seen it all, but I was given something I never would have expected:

Chris (co-worker): "They gave you a tank?"
Me: "It's not a tank, it's a 1/24th scale REMOTE CONTROLLED BATTLE TANK TYPE 90, and it fires real missiles! I also got a coffee mug with a submerged octopus inside"
Chris: "But why would they gave you a tank?"
Me: "..."

Chris's incredulous tone was not surprising. I'm fairly certain the answer to his last question was not supposed to be, "So I'd bring it into corporate headquarters the next day, break it out around 5:00pm, and explore the (quite impressive) range of the 6mm missiles and their (again, quite impressive) ability to welt my colleagues."

Fast forward a few days, and in the midst of a celebration for the SoftLayer Engineering Team's completion of a recent project roll-out, a 1/24th scale battle erupted. As 20-30 members of the development team looked on (alongside our CTO and a few vice presidents who supplied "refreshments"), a convoy of RC Helicopters and my tank are in an all-out war. The battle tank misfires into a swarm of developers who scatter in chaos, and Chris peers over my cube wall ... "I can't believe they gave you a tank."

In light of those "unanticipated team-building exercises," I decided to jot down a few optimistic suggestions for Lance and the management that came to mind for how we could continue building SoftLayer's culture. Being comfortable and having a fun work environment improves employee productivity and reinforces the investment SoftLayer is making in its people, so we should totally be able to justify these! Here are a few ideas that came to mind (that probably won't cause anyone to loose an eye):

  • Omelet Chef and Bacon Buffet

    It's not just an old wives tale; numerous sources say that breakfast is the most important meal of the day. What better breakfast than all-you-can-eat crisp bacon and a Denver omelet cooked to order by a professional wearing a toque blanche and masterfully flipping frying pans?

  • Bring your Dog to Work Day Mandatory Policy

    Running home at lunch and/or after work to let out "Diesel" or "Delilah" cuts into employee availability. What's more, dogs in the office raise employee morale, subsequently improving productivity.

  • 3 Bars Logo Bow Ties

    Classier swag ... for the discerning gentleman.

  • Air Hockey, Table Tennis and Foosball Tournaments

    We have a lot of nerds 'round here, and exercise intended to prevent carpal tunnel syndrome can easily look like playing Foosball in slow motion. I propose we re-purpose the SLacker conference room and retrofit it with an arcade in the interest of improving employee health.

  • More Cake

    Forget Wheaties. Cake for breakfast a few days a week would provide a suitable alternative to the aforementioned bacon + omelet combo, and it would help soak up the all the free Frappacinos we drink.

  • Preemptively Remove Brown M&M's from DAL05

    "Welcome to SoftLayer. You're here because you're a rock star." - Lance Crosby, Employee Handbook, Page 1.

    When Van Halen added a blurb about brown M&M's to their tour rider, it wasn't (entirely) to show how awesome they knew they were; it was to quickly ascertain if a venue had read through the contract details ... If there were brown M&M's in the bowl, who knew whether their equipment would have been treated the way it was explained in the contract. Selectively banning certain colors of M&M's would be a great way to show visiting customers and vendors the attention to detail that goes on behind the scenes.

  • SoftLayer-Branded Shirts that Read, "I am a battle tank shooting survivor."

    I'm going to need about three of these ... stat.

If you want to join our team, we're hiring a ton of people right now: SoftLayer Careers ... Given the fact that there are 18 open positions for new SLayers in Dallas, it might be good to stock up on a few extra "Survivor" shirts.

-Nalin

March 14, 2012

Game On: SoftLayer + Game Developers + GDC

Last week, I spent a few days at GDC in San Francisco, getting a glimpse into the latest games hitting the market. Game developers are a unique bunch, and that uniqueness goes beyond the unbelievable volume of NOS Energy Drinks they consume ... They like to test and push the IT envelope, making games more diverse, interactive and social.

The new crop of games showcased at GDC is more resource-intensive — it's almost like watching an IT arms race; they're upping the ante for all online gaming companies. The appetite from the public remains relentless, and the pay-off can be huge. Consider that gaming industry research firm DFC Intelligence predicts that worldwide market revenue generated solely from online games is set to reach $26.4 billion in 2015, more than double the $11.9 achieved in 2009.

That's where SoftLayer comes in. We understand the high stakes in the gaming world and have tailored our IaaS offerings for an optimal end-user experience that stretches from initial release to everyday play. Take a look at what game developer OMGPOP (a SoftLayer customer) achieved with Draw Something: Almost overnight it became the #1 application in Apple's App Store, tallying more than 26 million downloads in just a few weeks. To put the volume of gameplay into perspective, the game itself is generating more than 30 hours of drawings per second. That's what what we refer to as "Internet Scale." When YouTube hit one hour of video uploads per second, they came up with a pretty impressive presentation to talk about that scale ... and that's only one hour per second.

Draw Something

Gamers require a high-performance, always on, graphically attractive and quick-responding experience. If they don't get that experience, they move on to the next game that can give it to them. With our core strengths of automation and extensive network reach, game developers come to us to easily enable that experience, and in return, they get a platform where they can develop, test, deploy and yes, play their latest games. True "Internet Scale" with easy consumptive billing ... Get in and out quickly, and use only what you need.

Some of the most interesting and innovative use cases of how customers take advantage of our platform come from the gaming industry. Because we make it easy to rapidly provision resources (deploy dedicated servers in less than two hours and cloud servers in as few as five minutes) in an automated way (our API), many developers have started incorporating cloud-like functions into their games and applications that add dedicated resources to their infrastructure on-demand as you'd only expect to see in a virtual environment. Now that Flex Images are available, we're expecting to see a lot more of that.

As I was speaking with a few customers on the show floor, I was amazed to hear how passionate they were about what one called the "secret ingredient" at SoftLayer: Our network. He talked about his trials and tribulations in delivering global reach and performance before he transitioned his infrastructure to SoftLayer, and hearing what our high-bandwidth and low-latency architecture has meant for his games was an affirmation for all of the work we've put into creating (and continuing to build) the network.

The rapid pace of innovation and change that keeps the gaming industry going is almost electric ... When you walk into a room filled with game developers, their energy is contagious. We ended GDC with an opportunity to do just that. We were proud to sponsor a launch party for our friends at East Side Game Studios as the celebrated the release of two new games — Zombinis and Ruby Skies. Since their NomNom Combo puzzle game is one of the most addicting games on my iPhone, it was a no-brainer to hook up with them at GDC. If you want a peek into the party, check out our GDC photo album on Facebook.

Draw Something

To give you an idea of how much the gaming culture permeates the SoftLayer offices, I need only point out a graffiti mural on one of the walls in our HQ office in Dallas. Because we sometimes get nostalgic for the days of misspent youth in video arcades playing Pac Man, Donkey Kong and Super Mario, we incorporated those iconic games in a piece of artwork in our office:

Retro Gaming Mural

If you are an aspiring game developer, we'd like to hear from you and help enable the next Internet gaming sensation ... Having a good amount of experience with our existing customer base should assure you that we know what we're talking about. For now, though, it's my turn to go "Draw Something."

-@gkdog

December 21, 2011

Spot Influence: Tech Partner Spotlight

This is a guest blog from Spot Influence. Spot Influence provides businesses with detailed information on who's influential in the world of social media and what those influencers actually care about. This data, accessed via an API, enables companies to react faster with more information and, more importantly, to be proactive and execute a strategic social media plan.

Discover the People Who Drive Your Business

If you're involved in marketing, you understand the importance of monitoring your business's community online. You also probably know that engaging with the "Influencers" who speak to your intended audience can be critical to understanding their needs and spreading your brand's message. But existing tools are limited in their ability to find these individuals. They don't allow you to sift through the noise and discover the people who are already impacting your business online.

Spot Influence is a data service that provides granular, actionable information to businesses about their online audience and the people who are influencing them. With this data, business can discover the key influencers they need to be paying attention to and gain valuable insight regarding their existing customers: their online profiles, where they publish and engage with content, and what they care about.

Solving this problem at scale is incredibly challenging. We deal with vast amounts of unstructured data, processing tens of millions of URLs and creating terabytes of data every day. That's why we're excited to be a SoftLayer customer and a part of the Technology Partners Marketplace. SoftLayer enables us to cost-effectively scale our machines to meet customer needs.

If you're interested in learning more about Spot Influence, please check out the following links and sign up for the Beta on our website!

Website: http://spotinfluence.com/
Blog: http://blog.spotinfluence.com/
Twitter: @spotinfluence

-Dave Angulo and Rich Grote, Co-Founders, Spot Influence

This guest blog series highlights companies in SoftLayer's Technology Partners Marketplace.
These Partners have built their businesses on the SoftLayer Platform, and we're excited for them to tell their stories. New Partners will be added to the Marketplace each month, so stay tuned for many more come.
August 16, 2011

SLDN 2.0 - The Development Network Evolved

SoftLayer is in a constant state of change ... It's not that bad change we all fear; it's the type of change that allows you to stretch the boundaries of your normal experience and run like a penguin ... Because I got some strange looks when coworkers read "run like a penguin," I should explain that I recently visited Moody Gardens in Galveston and saw penguins get crazy excited when they were about to get fed, so that's the best visual I could come up with. Since I enjoy a challenge (and enjoy running around like a penguin), when I was asked to design the new version of SLDN, I was excited.

The goal was simple: Take our already amazing documentation software infrastructure and make it better. A large part of this was to collapse our multi-site approach down into a single unified user experience. Somewhere along the way, "When is the proposal going to be ready?" became "When is the site going to be ready?", at this point I realized that all of the hurdles I had been trampling over in my cerebral site building were now still there, standing, waiting for me on my second lap.

I recently had the honor to present our ideas, philosophy and share some insight into the technical details of the site at OSCON 2011, and KHazzy had the forethought to record it for all of you!

It's a difficult balance to provide details and not bore the audience with tech specs, so I tried to keep the presentation relatively light to encourage attendees (and now viewers) to ask questions about areas they want a little more information about. If you're looking at a similar project in the future, feel free to bounce ideas off me, and I'll steer you clear of a few land mines I happened upon.

-Phil

May 9, 2011

Will Write Poetry for Servers

Two weeks ago, I inadvertently opened the floodgates to a wave of creativity from the SoftLayer Development/Technology organization. Lance came by my office and dropped off a server he was given, and while I would have taken it home, souped it up and done something cool with it in previous years (or decades) in my life, I find myself in more of a "just buy an iMac" camp now.

Rather than endanger the safety of our employees by sending out a "First one to grab the server from my office gets to keep it" email, I sent out more of a challenge: "Write a haiku or limerick stating why you want the server. If I get more than one submission, I’ll pick the best poem. Oh ... And no Nantucket limericks."

I expected one or two entries to come in, but to my surprise, I was greeted with dozens almost immediately:

Windows NT crashed.
I am the Blue Screen of Death.
No one hears your screams.

There was a young man with a lance
Who had three kids to finance
Yes they look and they see
Asking for a PC
But their dad said no not a chance

Linux or Windows
Not up to how the wind blows
The penguin's a go

When you’re whipping your verse into shape
And are caught in a verse-challenged scrape,
The delete key is handy.
Assisted by brandy,
And last, but not least, try escape.

Given the overwhelming initial response, we sweetened the deal a little by adding a second server to the mix (from George). When it came time to judge and announce the winners, I had to do so with my own poem ... which killed me because I hadn't written a poem in years.

My inbox laden
Server Poets bring me pride
Rewards were doubled

There once was a SLayer named Bradley
Whose poem was flattering badly
He said 3BFL
We said ‘Oh, What the Hell’
And gave him a server quite gladly

Among numerous entries we found
That nerdy rhymes and rhymers abound
And so many came forth
Our hand was quite forced
So to the contest more servers were bound

Thus also a Slayer named Hemsell
Was chosen to leave with a morsel
Wash the zeros away
Rip and store CDs today
Make this sad server sing loud and fell

With generous swagger Karidis did add
A prize sure to make the cable co mad
For Scott Thompson’s poem
Was moving and solemn
An Apple TV should not make him sad

And finally the team of Hannon and Chong
Grammar and spelling and format all wrong
But their desire so true
And coding poetry new
Request will be supported so strong

Translation:

Server Winner: Bradley Johnson

One, two, three bar life
Free drink, free shirt, free server
Movie files need home

Server Winner: David Hemsell

CDs sit offline
Once proud server is no more
Fill barren zeros

Apple TV Winner: Scott Thompson

Your free server will
fail to bring much joy to me
I use Macintosh

Additional Computer-Related Award of Some Kind: Chong and Harold

import com.softlayer.server;
public class freeAssetReserver{
   int count = 0;
   String you = “hero”;
   function void vmBoxOursObserver();
}

Congratulations to Bradley and David for winning the servers and to Scott Thompson for walking away with the unadvertised Apple TV! When we were going through the submissions, we couldn't help but reward the submission from Chong and Harold - A coding limerick!

We'll post more of the submissions in the comments on this post, so be sure to scroll down and add your own!

-Duke

April 7, 2011

Thou Shalt Transcode

Deep in the depths of an ancient tomb of the great Abswalli, you and your team accidentally awaken the Terbshianaki ghost army. You’re disconnected from the supply caravan with the valuable resources that could not only sustain your journey but also save your team. As Zeliagh the Protesiann hunter fires his last arrow, you come to the sudden realization that continuing your quest is now hopeless. Alas, true terror was unknown before this moment as you come to the most surprising realization: The one thing you truly can't live without is your trusty server that converts one type of media into another.

Fear not great adventurer, for I, Phil of the SLAPI, have come, and I bear the gifts of empowerment, automation and integration. Freedom from the horror of your epiphany can be found in our complementary media transcoding service.
Before we can begin, some preparation is required. First, you must venture to our customer portal and create a transcoding user: Private Network->Transcoding. As you know from the use of your other SoftLayer spoils, you shan't be obligated to access this functionality from your web browser. You can summon the API wizardry bequeathed to you by coders of old in the the SLDN scroll: SoftLayer_Network_Media_Transcode_Account::createTranscodeAccount.*

*For the sake of this blog, we'll abbreviate "SoftLayer_Network_Media_Transcode_Account" as "SNMTA" from here forward ... Shortening it helps with blog formatting.

You must then construct an object to represent a SoftLayer Network Media Transcode Job, like our SoftLayer Network Media Transcode Job template object. This template object will be built with a number of properties. Your pursuit in relieving your aforementioned horror only necessitates the use of the required properties.

You will need to decide in which format the final treasure will take form. You may find this information with the SNMTA::getPresets method.

$client = SoftLayer_SoapClient::getClient('SoftLayer_Network_Media_Transcode_Account', $trandcodeAccountId, $apiUsername, $apiKey);
$transcodePresets = $client->getPresets();
print_r($transcodePresets);
Array
(
    [0] => stdClass Object
        (
            [GUID] => {9C3716B9-C931-4873-9FD1-03A17B0D3350}
            [category] => Application Specific
            [description] => MPEG2, Roku playback, 1920 x 1080, Interlaced, 29.97fps, 25Mbps, used with Component/VGA connection.
            [name] => MPEG2 - Roku - 1080i
        )
 
    [1] => stdClass Object
        (
            [GUID] => {03E81152-2A74-4FF3-BAD9-D1FF29973032}
            [category] => Application Specific
            [description] => MPEG2, Roku playback, 720 x 480, 29.97fps, 6.9Mbps, used with Component/S-Video connection.
            [name] => MPEG2 - Roku - 480i
        )
 
    [2] => stdClass Object
        (
            [GUID] => {75A264DB-7FBD-4976-A422-14FBB7950BD1}
            [category] => Application Specific
            [description] => MPEG2, Roku playback, 720 x 480, Progressive, 29.97fps, 6.9Mbps, used with Component/VGA connection.
            [name] => MPEG2 - Roku - 480p
        )
.....

The freedom to use this power (the more you know!) is yours, in this instance, I scrolled through let my intuition find the option which just felt right:

stdClass Object
(
            [GUID] => {21A33980-5D78-4010-B4EB-6EF15F5CD69F}
            [category] => Web\Flash
            [description] =>
            [name] => FLV 1296kbps 640x480 4x3 29.97fps
        )

To decipher this language we must know the following:

  1. The GUID is the unique identifier which we will use to reference our champion
  2. The category section is used to group like presets together, this will be useful for those who's journey leads down the path of GUI creation
  3. A description of the preset, if one is available, will be listed under description
  4. name is simply a human-readable name for our preset

You are nearly ready to restore your yearned for transcoding service as the ghostly horde presses the defensive perimeter. We have but one more task of preparation: We must provide the transcoding service a file! Using your Wand of File Transference +3, or your favorite FTP client, you enter the details for your transcode FTP account found on the Transcoding page of the IMS (or of course SNMTA::getFtpAttributes) and choose the "in" directory as the destination for your source file. Lacking no other option, you may call upon Sheshura, a fairy sprite, specializing in arcane documents for a source video file: Epic Battle

The battle rages around you, as the Wahwatarian mercenaries protect your flank. The clicking of your laptop keys twist and merge in the air around your ears only to transcend into a booming chorus of "The Flight of the Valkyries" as you near transcoding Utopia. You strike:

<?php
//  Create a transcoding client
$client = SoftLayer_SoapClient::getClient('SoftLayer_Network_Media_Transcode_Job', null, $apiUsername, $apiKey);
 
// Define our preset GUID and filename
$presetGUID = '{95861D24-9DF5-405E-A130-A40C6637332D}';
$inputFile = 'video.mov';
 
/*
 * The transcoding service will append the new file extension to the output file
 * so we strip the extension here.
 */
$outputFile = substr($inputFile, 0, strrpos($inputFile, '.'));
 
try {
    // Create a SoftLayer_Network_Media_Transcode_Job template object with the required properties
    $transcodeJob = new stdClass();
    $transcodeJob->transcodePresetGuid = $presetGUID;
    $transcodeJob->inputFile = "/in/$inputFile";
    $transcodeJob->outputFile = "/out/$outputFile";
 
    // Call createObject() with our template object as a parameter
    $result = $client->createObject($transcodeJob);
    // $result will contain a SoftLayer_Network_Media_Transcode_Job object
    print_r($result);
} catch ( Exception $e) {
    die( $e->getMessage());
}

If your will did not waver nor did your focus break in the face of ever-closing ghouls pounding your resolve, your treasure will be waiting. Brandish your Wand of File Transference +3, or utilize your favorite FTP client to retrieve your reward: "out/video.flv"

If the gods be with thee, your resulting file should look like this: Epic Battle (in .flv)

With your victory fresh upon the tablets of history, you can now encode to any of our supported formats. Try using the process above to convert the video to .mp4 format so your resulting file output is Epic Battle (in .mp4)!

-Phil

P.S. If you're going to take off your training wheels, the second example uses "[description] => MPEG4 file, 320x240, 15fps, 256kbps for download" for the bandwidth impaired.

Subscribe to developers