Wednesday, September 9, 2015

Promises in JavaScript Unit Tests: the Definitive Guide

Promises are becoming a common part of JavaScript code. The native Promise object is already supported by all the major browsers including Chrome, Firefox, and Safari.

Despite making asynchronous code simpler, dealing with promises in unit tests is a hassle. You need to wire your test’s assertions into the callbacks of the promise, which adds extra code into the test. In this way the test itself becomes a bit complicated and it’s harder to see what’s happening.

In this article, I'll show you how to fix this issue and discuss about useful patterns which are able to simplify common promise-scenarios in tests' stage.

I've created an example project that you can download from my website which shows the techniques introduced in this article.

Getting Started

For this project I'll use Mocha as the testing framework and the Chai library to provide the assertions. You'll understand why in a moment.

Continue reading %Promises in JavaScript Unit Tests: the Definitive Guide%


by Jani Hartikainen via SitePoint

This Week's HTML5 and Browser Technology News (Issue 205)


Read this e-mail on the Web
HTML 5 Weekly
Issue 205 — September 9, 2015
Ashley Nolan
Analysis of 1044 survey responses on CSS preprocessors, task runners, JS libraries, and more.


Mozilla Hacks
CSS scroll snapping (available in Firefox 39+, partial support in IE and Edge, and in Safari 9+) allows you to control where to stop on an overflowing element when it’s scrolled.


Mozilla Hacks
A look at CSS Grid Layout, a relatively new W3C specification with limited but growing support (a polyfill exists, however).


Mailgun  Sponsored
Easy SMTP integration and a simple, RESTful API abstracts away the messy details of sending transactional or bulk email. Scale quickly, whether you need to send 10 or 10 million emails. Start sending email now with Mailgun.

Mailgun

MikoĊ‚aj Stolarski & Tomasz Grajewski
Digging into the implementation of visual effects in Canvas-based HTML5 games.


Robin Rendle
The practice of guessing what users need so assets can be fetched ahead of time has been called ‘prebrowsing’ and it’s formed of several techniques which Robin summarizes here.


Chris Youderian
A look at creating SVG maps of any area of the world ready for Web use.


ShaderFrog
Create shaders with no code. Compose multiple shaders together.


WebGL Stats
More stats than you could possibly want about native WebGL support on devices hitting a variety of sites.


BlogGeek.me
Recent news is suggesting browser support for WebRTC without the need for plugins is coming soon.


Jobs

  • Apply to top SF & NYC startups in 60 secondsWant to spend less time job searching? Sign up to Underdog.io and startup founders & hiring managers will email you directly. You decide where to interview and where to work. Your information is kept private from current & past employers.  Underdog.io

In brief

Curated by Peter Cooper and published by Cooper Press.
Want to post a job? E-mail us or use our self-serve system.

Unsubscribe : Change email address : Read this issue on the Web

Published by Cooper Press Ltd. Office 30, Lincoln Way, Louth, LN11 0LS, UK


by via HTML5 Weekly

The Most Popular WordPress Landing Page Plugins

Landing pages are the bread and butter of any successful marketing campaign. They are choc full of customized content that speaks to your website visitors. This content speaks to your website visitors because it delivers the exact, specific information that your visitor was expecting. Landing pages are aligned with your marketing messages 110%, and always have one clear objective in mind: making your website visitors take a specific course of action.

When it comes to creating landing pages in WordPress, there is a multitude of plugin options available, all of which have their distinct advantages. In this article, we'll cover a selection of the most popular WordPress landing page plugins.

[author_more]

What is a Landing Page?

A landing page is a stand-alone web page that has been designed with a specific goal or objective in mind. This goal or objective is usually focused on user actions, on motivating your landing page visitors to take action, to do something, to convert. Often, this something might be to request a quote, or sign up to a mailing list, or provide contact details in exchange for a freebie (like an e-book or a white paper or a template of some description).

Landing pages are completely separate from your main website. And, in general, are completely without the main menu navigation that would otherwise tie the landing page to your website. The main reason for this lack of navigation is to give visitors less choice in terms of actions. With less options available, your landing page visitors are more likely to take the course of action that you want them to take, inching them closer and closer to your intended conversion.

Continue reading %The Most Popular WordPress Landing Page Plugins%


by Sally Wood via SitePoint

A Full Screen Bootstrap Carousel with Random Initial Image

A few months ago, I wrote an article that covered Bootstrap’s Affix and ScrollSpy components. This time though, I’ll be focused on a different Bootstrap component: I’ll go through the process of building two simple extensions for the the Bootstrap carousel.

First, I’ll create a full-screen slideshow and then I’ll show you how to randomize the first slide on page load.

But before digging into those extensions, let’s start by creating a carousel based on the default styles.

To create the carousel, we’ll take advantage of the basic code for the carousel component that Bootstrap provides:

[code language="html"]
<div id="mycarousel" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#mycarousel" data-slide-to="0" class="active"></li>
<li data-target="#mycarousel" data-slide-to="1"></li>
<li data-target="#mycarousel" data-slide-to="2"></li>
<li data-target="#mycarousel" data-slide-to="3"></li>
<li data-target="#mycarousel" data-slide-to="4"></li>
</ol>

<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="1.jpg" data-color="lightblue" alt="First Image">
<div class="carousel-caption">
<h3>First Image</h3>
</div>
</div>
<div class="item">
<img src="2.jpg" data-color="firebrick" alt="Second Image">
<div class="carousel-caption">
<h3>Second Image</h3>
</div>
</div>
<!-- more slides here -->
</div>

<!-- Controls -->
<a class="left carousel-control" href="#mycarousel" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#mycarousel" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
[/code]

Notice that each of our images contains the custom data-color attribute. Later we’ll use its value as a fallback in case the corresponding image fails to load.

The next step is to initialize the carousel via JavaScript and modify the predefined values of the interval and pause configuration properties. Take note that we choose to set the value of the pause property to false because we always want the cycling to be active:

[code language="javascript"]
$('.carousel').carousel({
interval: 6000,
pause: "false"
});
[/code]

Having followed those simple steps (and of course imported the required files), we should now be able to build the first version of the carousel. Here’s how it looks so far:

See the Pen A Basic Bootstrap Carousel by SitePoint (@SitePoint) on CodePen.

Creating Full-screen Slides

At this point we’ll go one step further, converting the existing carousel into a full-screen slideshow. To implement this updated version we have to add some custom jQuery:

Continue reading %A Full Screen Bootstrap Carousel with Random Initial Image%


by George Martsoukos via SitePoint

Google Play Services: Using the Nearby Connections API

Watch: Singleton Methods in Ruby

Did you know that in Ruby you can define personal method for objects? That is, a method that only one object will respond to. Such methods are called singleton methods and it is worth knowing how to work with them. In this video we are going to discuss callbacks to observe method changes as well as differences between removing and undefining methods. The next mystery of Ruby is going to be revealed!

This is the third video of the Ruby Metaprogramming Revealed series. Learn more about Ruby metaprogramming by viewing the rest.

Loading the player...

Continue reading %Watch: Singleton Methods in Ruby%


by Ilya Bodrov-Krukowski via SitePoint

This Week in Mobile Web Development (#73)

Read this on the Web

Mobile Web Weekly September 9, 2015   #73
Brian Rinaldi recommends
7 Steps to Building a Hybrid Apple Watch App — Rob Lauer walks through the steps to build a hybrid Apple Watch app using web technologies with the Telerik Platform.
Telerik Developer Network
Holly Schinsky recommends
Is the web platform getting too big? — More thoughts on some recent posts that the web platform is being pushed too hard to emulate native and the web vs native debate in general.
Nicholas C Zakas
Holly Schinsky recommends
WebRTC Plugin Free World is Almost Here: Apple and Microsoft joining the crowd — Recent news is suggesting browser support for WebRTC without the need for plugins is coming soon.
BlogGeek.me
This issue is sponsored by PubNub
Mobile Push Notifications with iOS, Android and PhoneGap — Learn best practices for setting up GCM and APNs environments and sending mobile push notifications using PubNub's Mobile Push Gateway with Android, iOS and PhoneGap. Register for webinar
PubNub

Brian Rinaldi recommends
The Anatomy of Responsive Images — A good quick reference with examples for responsive images.
Jake Archibald
Holly Schinsky recommends
How A Hack Day Project Made Mobile Pages 6x Faster
Schibsted Tech Polska
Holly Schinsky recommends
PhoneGap Day US 2016 - Save the Date — PhoneGap Day US dates have been set and will be held in a new location. Be sure to mark your calendars and submit an entry to the call for speakers if you’re interested in speaking.
PhoneGap Blog
Brian Rinaldi recommends
Google’s ad penalties are more significant than Apple’s ad blocker — Nathaniel Mott says that, because of the ubiquity of Google search, it’s decision to penalize sites around app install interstitials, could have a much more far reaching impact than Apple’s decision to allow ad blockers.
Gigaom
Holly Schinsky recommends
Designing Web Code in a Native App — Why you should consider using web technologies for building hosted apps across platforms and devices using ManifoldJS.
SitePoint
Peter Cooper recommends
How to Test React Native Apps on a Real iPhone
Chirag Shah
Peter Cooper recommends
Mobile Pages That Are 1s Faster Experience Up to 27% Increase in Conversion Rate — A case study.
SOASTA
Brian Rinaldi recommends
The Problems with Feature Detection — The issue with feature detection is that it assumes, if a feature exists, this means that its entire API does too.
Niels Leenheer
Holly Schinsky recommends
Apache Cordova iOS 4.0.0 and WKWebView support — Find out the latest updates on the upcoming release of cordova-ios 4.0.0 and support for WKWebView.
Shazron's Blog
Job listing
Want to work on new projects? Make more money? Try a new stack? Relocate? — On Hired, we'll bring the options to you. With over 2,000 pre-screened tech companies in 10 cities in the US & UK, you'll be sure to find what you're looking for. Join Hired today.
Hired.com

Brian Rinaldi recommends
Mobile Apps Have a Short Half Life; Use Falls Sharply After First Six Months — Mobile apps achieve half their lifetime usage in the first six months.
Re/code
Brian Rinaldi recommends
Creating a Mobile App with WP-API and React Native — How to use the WP REST API plugin with WordPress as a datasource for a simple React Native mobile app.
Jeff Gould
Peter Cooper recommends
Office UI Fabric: The Front-End Framework for Building Experiences for Office and Office 365 — A responsive, mobile-first, front-end framework, for creating web experiences using the Office Design Language.
Microsoft
Holly Schinsky recommends
Amazon Mobile Ad Network Plug-in Now Available for PhoneGap — Check out the new PhoneGap plugin available for using Amazon’s mobile ad network in your hybrid apps.
PhoneGap Blog
Curated by Brian Rinaldi and Holly Schinsky for Cooper Press.
Cooper Press is located at Office 30, Fairfield Enterprise Centre, Louth, LN11 0LS, UK
Update your email address
or stop receiving MWW here


by via Mobile Web Weekly