Javascript News

Syndicate content
Pipes Output
Updated: 48 weeks 6 days ago

CEO Blog – On Creating Products…

So, 2015-06-28 23:15

I’ll start by saying this could be a single post or it might be a series, depends on my time, ability to devote attention to this and more importantly on how we’re going with our new product! So for a couple of months now we’ve been on a pretty awesome ride creating the first entirely […]

Continue reading %CEO Blog – On Creating Products…%

Video: An Introduction to Component State

Sa, 2015-06-27 15:30

Loading the player...

Today's a good day because I'm teaching you about component states in React. We'll look at how to keep state, change state and finally how to render state.

Continue reading %Video: An Introduction to Component State%

On Our Radar: How Smartphones Have Changed Us

Fr, 2015-06-26 18:09

Yo mama is so fat, the recursive function computing her mass causes a stack overflow. On Our Radar And so began our week, kickin’ it old school with some pretty strong opinions coming from mikey_w: anyone who embraces responsive web design is stupid. Ryan agrees that “anyone that thinks Design alone is all there is […]

Continue reading %On Our Radar: How Smartphones Have Changed Us%

Easy Custom Web Servers with Dart and Redstone

Fr, 2015-06-26 18:00

Using Node.js to create server-side scripts is all the rage right now, and with good reason. It’s fast, event-driven, and perhaps best of all for web developers, it’s powered by JavaScript. If your front end code is all JavaScript, the benefits of using the same language on the back end are clear. Node even has great server-side frameworks like Express that make creating custom Web servers fast and easy.

But is there a better way?

What Is Dart?

Dart is an open-source, scalable, object-oriented programming language, with robust libraries and runtimes, for building web, server, and mobile apps. It was originally developed by Lars Bak and Kasper Lund for Google, but has since become an ECMA standard.

You can get all of Node’s benefits plus a few more when you use Dart and the Redstone framework on the server side. As an added bonus, you leave behind JavaScript’s quirks. Like Node, the Dart virtual machine is event-driven, asynchronous, and allows you to build a client and server app in one language and share code between them. There isn’t space here to go over all of Dart’s advantages over JavaScript (another article, maybe), but if you’re interested in more details, follow some of the links below.

Advantages of Dart
  • Immutable objects and simpler semantics, allowing for better code optimization (more speed) in the virtual machine.
  • Optional types and support for finals and constants.
  • Support for optional positional or named function parameters with default values.
  • Lexical scope for variables, closures, and this.
  • No variable hoisting.
  • No type coercion in assignments or comparisons.
  • Futures (promises) and Streams.
  • No undefined; just null.
  • Only true is truthy.
  • Comprehensive standard libraries.
  • Syntactic sugar to reduce verbosity in class constructors.
  • Built-in support for code modules, with support for deferred loading.
  • Dart has its own advanced code profiler, Observatory.
  • Watch Moving from Node.js to Dart for a look at one developer’s experience.

That list just scratches the surface. Check out the online book Dart: Up and Running for a crash course in the language. If you know JavaScript, Java, PHP, ActionScript, C/C++, or another “curly brace” language, you’ll find Dart to be familiar, and you can be productive with Dart within an hour or so.

Get Dart

There are many editors that support Dart development, and the Dart team has announced that JetBrains WebStorm will be the preferred editor going forward, but to keep things simple (and free), we’ll be using the popular Sublime Text 3 with a Dart plugin for this tutorial. Even though it’s technically still in beta, it is the recommended version to use.

Download Software

You will need a few pieces of software to complete this tutorial.

Sublime Text 3

If you don’t already have Sublime Text 3, download and install the version appropriate for your operating system. The latest build as of this writing is 3083.

Dart SDK

Download the correct Dart SDK for your system. Note that for this tutorial, you will not need the editor (now deprecated) or Dartium (a special build of Chromium with an embedded Dart VM).

Unzip the Dart SDK and place the dart-sdk folder anywhere on your system. On Windows, I prefer C:/Program Files/dart/dart-sdk.

Configure Sublime Text 3

Run Sublime Text 3. You’ll need to configure the editor to support Dart.

Package Control

If you haven’t already installed Package Control, follow these instructions to install it now. Note that you will need to restart Sublime Text 3 once the installation is complete.

Dart Plugin
  1. From Sublime’s menu, select Tools->Command Palette… and type in install.
  2. Select Package Control: Install Package from the dropdown.
  3. Type dart and select the Dart package. Note that you may need to restart Sublime before all of the plugin’s features will be available.
  4. From Sublime’s menu, select Preferences->Package Settings->Dart->Settings - User. This will open a settings file for the Dart plugin.
  5. Enter the following code into the settings file and save it, where /path/to/dart-sdk is the path to the dart-sdk folder on your system.

[code language="js"]
{
"dart_sdk_path": "/path/to/dart-sdk"
}
[/code]

Create a Dart Project
  1. From Sublime’s menu, select Tools->Command Palette… and type in Dart:.
  2. Select Dart: Stagehand and then console-full to create a command-line application.
  3. At the bottom of the Sublime window, enter the path where you would like Dart’s Stagehand tool to create your new Dart project. Note that the target directory must be either new or empty. I recommend naming it something like redstone_intro.

Note: if during the above process, you see an error that Stagehand is not enabled, you need to do the following from a terminal:

[code language="bash"]
cd /path/to/dart-sdk/bin
pub global activate stagehand
[/code]

Acquire Dependencies

With your new project created, open up the file pubspec.yaml. Dart uses your pubspec file to manage your project’s dependencies. Replace the pre-generated dependencies section in pubspec.yaml with one that looks like this (remove any # characters, which indicate a comment):

[code language="js"]
dependencies:
redstone: '>=0.5.21 <0.6.0'
[/code]

Save the file. Sublime will automatically instruct Dart’s package manager, called Pub, to acquire all necessary dependencies, including the Redstone framework. Pub will only get Redstone versions in the specified range. You can also cause Sublime to get your dependencies with the hotkey F7 while you’re editing pubspec.yaml.

For more information and examples for Redstone, see the project’s Github wiki.

Create a Web Server

Setting up a simple server with Redstone is easy. Open the main.dart file and remove all of the pre-generated code. Insert the following code in its place.

[code language="js"]
import 'package:redstone/server.dart' as Server;

void main() {
Server.setupConsoleLog();
Server.start();
}
[/code]

Since this may be your first Dart program, let’s analyze this code line by line. Developers familiar with Java, JavaScript, C#, or similar languages will find most of these concepts instantly familiar.

[code language="js"]
import 'package:redstone/server.dart' as Server;
[/code]

First, you tell the Dart analyzer that you will be using code from Redstone’s server.dart. The special package: prefix indicates that this code is an external dependency acquired by Pub. (If you like, you can examine this and all other downloaded packages by exploring the contents of the packages folder in your project.) This imports Redstone’s classes and top-level functions into your Dart program’s namespace. Since it includes functions with common names like start(), you contain the imported code within a custom namespace called Server with the syntax as Server.

[code language="js"]
void main()
[/code]

All Dart programs start execution with the top-level main() function. Dart allows you to optionally specify types for variables and function return values, and void indicates that main() will return nothing.

[code language="js"]
Server.setupConsoleLog();
[/code]

You imported the Redstone package under the alias Server, so you must use that reference when calling its functions. This call isn’t strictly necessary, but it’s helpful during development. It sets up console logging for the Redstone framework, so informative messages will appear in the console as Redstone’s code executes.

[code language="js"]
Server.start();
[/code]

This line calls Redstone’s start() function, which starts up the web server. By default, it listens for requests on 0.0.0.0:8080 (current IP on port 8080), though this is configurable.

That’s it! Your server doesn’t yet respond in any meaningful way to requests, but it is listening. Run the code in main.dart with the hotkey Shift+F7. Console output will appear in Sublime’s output panel, which displays by default in the lower portion of the Sublime interface.

[code language="js"]
INFO: : Running on 0.0.0.0:8080
[/code]

You can stop the running application using the hotkey Ctrl+Keypad0 (that’s Ctrl and the zero key on your keypad).

Note: You can also start/stop the server via the terminal:

[code language="bash"]
cd /path/to/dart-sdk/bin
./dart /path/to/redstone_intro/bin/main.dart
[/code]

To access all of the Dart file commands through Sublime’s command palette (necessary if you don’t have a keypad), select Tools->Command Palette… from the menu and type Dart:, then select the command you need. The keyboard shortcut for that is Ctrl+., Ctrl+. (hold down Ctrl and tap the period twice).

For more handy keyboard shortcuts, refer to the Dart plugin’s Shortcuts page.

Continue reading %Easy Custom Web Servers with Dart and Redstone%

Mobile App Development with Zend Studio

Fr, 2015-06-26 16:00

The world has turned mobile. This is not new, and it should therefore be no surprise to anyone that the results of the 2015 DevPulse survey by Zend show that a vast majority of PHP developers are working on, or intend to work on, mobile apps.

Mobile app development poses many challenges for developers, one of which is tying in the front end of the mobile application with the back-end web service APIs.

This tutorial describes how to simultaneously create, test and modify both the front and back end of a modern mobile app using Zend Studio’s mobile development features.

The steps described in this article were performed using Zend Studio 12.5 and a Zend Server 8 AWS instance. You can, of course, use any PHP server of your choice, local or remote, to host the API project.

Step 1: Creating a Cloud Connected Mobile Project

Your first step is to create a new Cloud Connected Mobile (CCM) project in your Zend Studio workspace.
A CCM project contains both a hybrid mobile project defining the front-end of your mobile app and a project containing all the back-end APIs.

Continue reading %Mobile App Development with Zend Studio%

Video: Understanding React Events

Fr, 2015-06-26 15:30

Loading the player...

Understand how to create events through React. In this video I demonstrate the differences in events through React vs JavaScript.

Continue reading %Video: Understanding React Events%

Mastering Visual Hierarchy for Menu Design

Fr, 2015-06-26 15:07

When we hear the phrase 'menu design', most of us think of user interfaces, but there are many wonderful lessons in design and information architecture that we can learn from the long and competitive history of restaurant menu design. Let's have a looks at a few of my favorite examples.

Eleven Madison Park in New York City is a world-class restaurant in every sense of the term. They have clocked in as one of the top five in the world, in fact, and a meal here will set you back a couple hundred bucks—without wine.

But let’s say you saved your pennies and managed to land a reservation. The menu you received would have looked like this:


Eleven Madison Park by Juliette Cezzar (via Art of the Menu)

Amazing. Designed by Juliette Cezzar, it is absolutely free of clutter, containing literally just the essential information—the main component of every dish, arranged in a 4 x 4 grid. As such, it demonstrates one of the key principles of visual hierarchy: put extra space around the important things, so they are easier to see.

Unfortunately, as a practical model for menu design, it is pretty much useless. Eleven Madison Park’s situation is extremely particular. Here, the restaurant’s reputation is so awesome, customers can order on faith, without even seeing descriptions of the dishes.

By contrast, most menus are required to provide a lot more information, including categories (starter, main course, dessert), descriptions, and prices, at the very least.

Here’s how a typically loaded menu might look:


Crespella by Tag Collective (via Art of the Menu)

We would say that this design, by Tag Collective, is perfectly solid, but less than inspiring. It is orderly and effort was clearly made to add variety and charm. But there is also a lot of information here, and the visual hierarchy is too weak. The result is that at first glance, the menu looks dense and overwhelming. It is missing the ingredient in which Eleven Madison Park’s menu luxuriates: space.

The point of this contrast is to demonstrate the key importance of visual hierarchies in menu design, where designers often must cram quite a lot of information into not so big a space. If you’re not familiar with the concept of visual hierarchy, this post will take you through the basics.

The basic idea is that there are several principles for making certain graphic information more visible—higher in the hierarchy—than other information. Bigger rather than smaller, above rather than below, to the left rather than to the right (assuming a culture that reads left-to-right), color rather than grayscale, bold rather than slim: these are all ways of assigning visual primacy.

In this post we will revisit visual hierarchy, specifically with menu design in mind. We’ve broken it down into five categories:

  1. Spacing
  2. Alignment
  3. Borders
  4. Font
  5. Color

We think the menu designs included below are exemplary of these principles, finding good middle grounds between the two approaches shown above.

Spacing

The Eleven Madison Park design and the Crespella design are both examples of the importance of good spacing: the former has plenty, the latter has somewhat too little.

We think the design below strikes a good balance, allowing important text to breathe so it is easily legible and stands out as important.


Russ & Daughters by Kelli Anderson

Alignment

Alignment is a simple hierarchy principle: if text is in a line, it probably belongs together as a group. You can use this instead of, or more likely in addition to, other grouping cues like uniform typeface, size and boldness.

Note that slight disalignment can also achieve a useful effect. This is clear in the second example below, for Ellie’s table, where staggering the menu items gives the information more life and personality.


Varvary by Shierly DC (via Behance)


Ellie’s Table by Brian Rau (via dribbble)

Continue reading %Mastering Visual Hierarchy for Menu Design%

How to Develop a Music Streaming Android App

Fr, 2015-06-26 15:00

The Android multimedia framework provides extensive support for playing a variety of common media types, allowing you to integrate audio, video and images into applications. You can play audio or video from media files stored in an application’s resources (raw resources), from standalone files in the filesystem, or from a data stream arriving over a network connection. In this article, we’ll look at how to use the media framework to play streamed audio. We’ll look at two major classes in the media framework - MediaPlayer (The primary API for playing sound and video) and AudioManager (Manages audio sources and audio output on a device) and use them in creating a simple audio player which allows the user to browse and play content from SoundCloud.

Continue reading %How to Develop a Music Streaming Android App%

Video: Sass Colour Palettes

Fr, 2015-06-26 14:30

Loading the player...

There are 12 points of colours in a colour wheel that have allowed designers to come up with perfect colour themes. In this video I will show you how to develop a complimentary colour palette using Sass and where it does all the thinking.

Continue reading %Video: Sass Colour Palettes%

ECMAScript 2015: Generators and Iterators

Do, 2015-06-25 20:00

A few days ago ECMAScript 2015, also known as ECMAScript 6 or ES6, has been finalized. Even if this event happened very recently, there are already a number of features supported in the latest versions of Chrome, Firefox, Safari, and Opera. If you're really itching for the ES6 goodness, you can even use a number of well-supported transpilers right now.

Two of the new features, generators and iterators, are set to change some of the ways we write specific functions when it comes to some more complex front-end code. While they do play nicely with one another, what they actually do can be a little confusing to some, so let's check them out.

Iterators

Iteration is a common practice in programming and is usually used to loop over a set of values, either transforming each value, or using or saving it in some way for later.

In JavaScript we've always had for loops that look like this:

Continue reading %ECMAScript 2015: Generators and Iterators%

Customizing Bootstrap Icons using Gulp

Do, 2015-06-25 19:30

If you are developing a web project using Bootstrap, you may have the need to add a set of custom icons in the place of the default Glyphicons that come with the framework.

I’ve already covered the topic of building an icon using Illustrator and Icomoon, but what is the better way to integrate icons in a Bootstrap project?

Icomoon CSS vs Glyphicons CSS

When we download a set of icons from Icomoon (for this demo I’ve created a project called my-icons), we get the font files, some demo files (that provide a useful reference to our glyphs), and a style.css file. This one contains all the CSS rules you need to use the font in your project.

Lets take a look at the CSS file. It contains a @font-face declaration, a rule to catch all icon classes (based on the first part of their names) and a list of all icon classes:

[code language="css"]
@font-face {
font-family: 'my-icons';
src:url('fonts/my-icons.eot?-dp1fqh');
/* other properties */
}

[class^="myicon-"], [class*=" myicon-"] {
/* some properties */
}

.myicon-alert:before {
content: "\e600";
}

.myicon-arrow-down:before {
content: "\61";
}

/* ... more icons */
[/code]

Now, let’s see the glyphicons.less file from Bootstrap:

[code language="css"]
// Import the fonts
@font-face {
font-family: 'Glyphicons Halflings';
src: url('@{icon-font-path}@{icon-font-name}.eot');
/* other properties */
}

// Catchall baseclass
.glyphicon {
/* some properties */
}

// Individual icons
.glyphicon-asterisk {
&:before {
content: "\2a";
}
}

.glyphicon-plus {
&:before {
content: "\2b";
}
}

/* ... more icons */
[/code]

They are very similar, but with some fundamental differences:

  • First, Glyphicons is a Less file (there is a Sass file too) and the icon font path and name are assigned to two variables (@{icon-font-path} and @{icon-font-name}).
  • Glyphicons uses a class as a “catchall” selector (.glyphicon), while Icomoon uses an attribute selector.
  • Glyphicons uses the parent selector (&) for individual classes.

The last point can be really useful in some situations, because it can simplify the way you build your CSS files.

The ampersand refers to the parent of each rule, and when glyphicons.less is compiled, it produces exactly the same result as the Icomoon CSS:

[code language="css"]
.glyphicon-asterisk:before {
content: "\2a";
}
[/code]

So, what’s the difference?

Simply put, you can use each icon class as a mixin, therefore you can embed them in other rules without worrying about any changes to the original class.

Lets see a sample.

Using font mixins

In the screenshot below, you can see an alert block that uses an icon from the my-icons font created with Icomoon.

The icon is applied using a span element; this is the “classic” way to use an icon font, and it is the same way suggested for Bootstrap Glyphicons.

Therefore, to build our example we need to add a span.myicon-alert element inside a container (in this case a div):

[code language="html"]


.alert

[/code]

You can’t apply the myicon-alert directly to the div, because it would inherit the icon font. This is the reason we need the additional span element. But using mixins there’s another way to solve our problem.

First, let’s rearrange our icon font in the same way as Glyphicons and build the alert rules using mixins:

[code language="css"]
/* this replaces the [class^="myicon-"], [class*=" myicon-"] selectors */
.myicon {
/* catchall properties */
}

.myicon-alert {
&:before {
content: "\e600";
}
}

.alert {
/* some properties */
.myicon-alert();
&:before {
.myicon();
}
}
[/code]

.myicon-alert and .myicon (parentheses can be omitted) refer to the respective classes, and import all their properties inside the .alert rule.

This is the generated CSS:

[code language="css"]
.myicon {
/* catchall properties */
}

.myicon-alert:before {
content: "\e600";
}

.alert {
/* some properties */
}

.alert:before {
content: "\e600";
}

.alert:before {
/* myicon catchall properties */
}
[/code]

Now we can minimize the markup and obtain the same result as the previous sample without a span element:

[code language="html"]

.alert

[/code]

But the generated CSS is redundant: the catchall properties are repeated twice, there are two .alert:before rules, and so on.

We can do it more efficiently using the :extend pseudo-class:

Continue reading %Customizing Bootstrap Icons using Gulp%

How to Create a Vorlon.js Plugin

Do, 2015-06-25 18:05

This article is part of a web dev series from Microsoft. Thank you for supporting the partners who make SitePoint possible. During the keynote at the recent //BUILD 2015 conference, our team at Microsoft released Vorlon.js, a tool to debug your website. Vorlon.js is mainly composed of a dashboard which displays data coming from your […]

Continue reading %How to Create a Vorlon.js Plugin%

Videos: Making Sass Variables Work for You

Do, 2015-06-25 17:30

Loading the player...

Variables allow you to use data over and over again throughout your CSS files. In this video I'll teach you about how to use variables in your projects.

Continue reading %Videos: Making Sass Variables Work for You%

Horizontal Scaling with CloudBees Jenkins Operation Center

Do, 2015-06-25 16:30

This article was sponsored by CloudBees. Thank you for supporting the sponsors who make SitePoint possible!

Picture this: You start using Jenkins, probably with one machine. As both the number of projects and the size of the projects themselves start to grow, you start to add slaves. Slowly, your cluster of Jenkins servers grows, and you slowly start to lose your grip. What if your Jenkins master crashes? If you recognize this feeling or you want to avoid this, you definitely should read on.

In this article we’ll take a small peak at CloudBees Jenkins Operation Center (CJOC). CJOC, created by CloudBees, offers you a lot of additional functionality to take your Jenkins cluster to the next level. The key features for CJOC are:

  • Consolidated navigation experience across all the client masters.
  • Shared build slave resources that can be used by any client masters.
  • Control of authentication and authorization schemes used by client masters. This enables features such as: single sign-on and consolidated permission schemes.
  • Management of update centers used by client masters.
  • Consolidated management of Jenkins Enterprise licenses.
  • Management and enforcement of certain key security settings on client masters.

Within this article we’ll just use a small amount of the available features. We’ll be creating a client master and a shared slave. For this we will be using three separate servers. The first one will run CJOC, the second one will run Jenkins Enterprise and the third will be used as a shared slave. We will be explaining everything in the next couple of chapters.

Preparation

I’ll be using three virtual machines on my local computer. If you want to follow along, you might want to make sure your own computer is powerful enough. If you happen to have three spare servers somewhere, you can also try it directly on those servers.

The three servers will be managed through Vagrant. I created a multi-machine Vagrant file which will boot all three servers. If you’re not familiar with Vagrant yet, you might want to read this article.

Let’s start off with our Vagrant file. You can find the content here

Note: All three boxes are running CentOS 7. You can easily replace them with Ubuntu boxes if you prefer, but do note that all commands below are meant for CentOS.

The three servers which will be created when you run vagrant up. They all got a different IP:

  • 192.168.56.105: CloudBees Jenkins Operation Center (CJOC)
  • 192.168.56.106: Jenkins Enterprise - Client Master (master)
  • 192.168.56.107: Shared Slave (slave)
Installing CloudBees Jenkins Operation Center

We start by installing CJOC on our first server. CJOC is our main control hub to manage all Jenkins instances. We’ll be using it to create our client master and shared slave. After logging in to the first Vagrant machine by running vagrant ssh CJOC in your terminal, you can perform the following commands to install CJOC.

[code language="php"]
sudo rpm --import http://nectar-downloads.cloudbees.com/jenkins-operations-center/latest/rpm/jenkins-ci.org.key
sudo wget -O /etc/yum.repos.d/jenkins-oc.repo http://nectar-downloads.cloudbees.com/jenkins-operations-center/latest/rpm/jenkins-oc.repo
sudo yum update
sudo yum install java jenkins-oc
sudo chkconfig jenkins-oc on
sudo service jenkins-oc start
[/code]

You will receive an ok message to indicate CJOC has been successfully installed and started.

Before we can actually start using CJOC, we’ll have to open the web service port to allow access as well as allow our other servers to access this server. We can do this by changing the firewall by running the following commands.

[code language="php"]
sudo firewall-cmd --zone=public --permanent --add-port=8888/tcp --permanent
sudo firewall-cmd --zone=public --permanent --add-rich-rule='rule family="ipv4" source address="192.168.56.105/32" accept'
sudo firewall-cmd --zone=public --permanent --add-rich-rule='rule family="ipv4" source address="192.168.56.106/31" accept'
sudo firewall-cmd --reload
[/code]

By now, you should be able to reach CJOC with the following URL: http://192.168.56.105:8888/. After entering the above URL, a registration form will show up. You can register for an evaluation license if you haven’t bought the product yet from CloudBees. Just fill in your details and press Next.

When you’ve registered yourself, I recommend you update all the plugins. CJOC requires some specific versions of plugins so we want to make sure we have these. Generally, it’s not recommended to update plugins when it’s not needed, as indicated in this article, 7 ways to improve Jenkins.

Note: Problems installing CJOC, or using a different server setup? Have a look at the official manual_ for troubleshooting._

Continue reading %Horizontal Scaling with CloudBees Jenkins Operation Center%

Video: Loops in Swift

Do, 2015-06-25 16:30

Loading the player...

In this video I've demonstrated how to Work with while and for loops with Swift.

Continue reading %Video: Loops in Swift%

Video: Using Props to Pass Data in React

Do, 2015-06-25 15:30

Loading the player...

In this video I'm going to show you how to send data into components using React. This will get you working your way towards more dynamic data with props.

Continue reading %Video: Using Props to Pass Data in React%

Fully Functional Jekyll Blog

Do, 2015-06-25 15:00

[caption id="attachment_108470" align="aligncenter" width="2388"] Blog (блог). Красное слово на белом фоне[/caption]

There's comes a time when tutorials on getting started aren't enough. This is not one of those tutorials. After this article, you will have the ability to make a fully functional Jekyll blog, complete with pagination and search capabilities. Get ready to see just how awesome Jekyll can be.

Audience

This is for:

  • People who have basic knowledge of Jekyll (Note: If you don't read the docs. It's easy to get to basic.)
  • Know how to use a text editor
  • Can do gem install
  • Are very good at HTML and JavaScript
  • Understand Liquid templating (Again...see the docs if not)

Continue reading %Fully Functional Jekyll Blog%

Getting Started With SCSS-Lint

Do, 2015-06-25 14:00

As surprising as it might sound, writing working code is actually the easy part when developing a website, application or any piece of software. Making the whole thing scalable, tested, properly documented and easy to contribute to is the hard part.

One part is having a code base which is both clean and consistent. Clean, because maintaining ugly 'weird' code is definitely not a pleasure and consistent because it makes maintaining the code base easier and faster. If code looks the same everywhere in the software, then it should be quite fast to get used to the way it's written.

When it comes to Sass, there are a couple of things you can do to make your code clean and consistent. The first one would be to respect some coding guidelines, such as CSS Guidelines and Sass Guidelines. The other thing is to lint your codebase.

If you are not familiar with the word lint, here is what Wikipedia says:

Continue reading %Getting Started With SCSS-Lint%

Video: Borders on Bootstrap Columns

Do, 2015-06-25 06:00

Loading the player...

In this video I'll show you how to add an equal height border to columns using Bootstrap.

Continue reading %Video: Borders on Bootstrap Columns%

Understanding the Pebble Watch Timeline

Mo, 2015-06-22 20:00

Earlier this year, Pebble announced the Pebble Time, their third generation smartwatch, funded via their hugely successful Kickstarter campaign. The Pebble Time ships with a new feature called Timeline for displaying information to the user (such as notifications, news, reminders and events) in chronological order on a timeline. Previously, Pebble required developers to write native apps for displaying information on the Pebble. Now, developers can push information onto the timeline directly using JSON from their own private server, via a public REST API.

If you’re unfamiliar with the Pebble Time, I encourage you to check out this article by Patrick Catanzariti by way of a refresher.

What Is the Timeline?

Smartphone notifications are instant and represent a transaction that occurs at that very moment in time. By definition they can’t arrive earlier or later.

The Pebble Time ships with a new OS feature called timeline. Timeline brings another dimension to your notifications; the dimension of time. The timeline shouldn’t be confused with a notification history. Timeline allows third parties to send past notifications and future notifications to you; notifications that you don’t need to know immediately, but may want to look up some time later. For example, you may want to look up what time you left your house in the morning, or what time sunrise was, or what percentage points the stock market opened at earlier, or when the next train out of Kennedy Town is.

Credit: pebble

The beauty of the timeline is that you can dump virtually any information into it, no matter how insignificant, because the information doesn’t interrupt the user. For example, an egg timer app which buzzes the user when the timer goes off can also push the event onto the timeline. You can never tell when a user is going to ask him or herself, “when did I set that timer for that cake I baked this morning?”.

Of course, the timeline can also hold important timely information, such as a train schedule or movie times at your local cinema. Rather than being notified five minutes in advance of when a train departs, users can look ahead on their watch for the next train and the train after that. All this information is pushed silently to your watch and condensed into a single scrollable interface.

Other than being an outlet for random bits of information relevant to your life, Pebble automatically fills your timeline with past and future events from your smartphone’s calendar, so that you get a holistic view of your day.

Credit: pebble

How Does It Work?

Pebble calls timeline notifications “pins”. Pins are universally managed on Pebble’s server and Pebble devices are set to periodically connect and download a fresh list of pins to display on the timeline. Pebble’s server ensures that users are not spammed with too many pins and allow developers to push pins to multiple users with one command.

All pins must go through Pebble’s server. Even local apps which want to display a pin on the local device must first push the pin to the server and allow the device to receive it in its regular update schedule (15 minutes).

The issuer of the pin can update and delete the pin and Pebble’s server will push the changes to the Pebble device.

Anatomy of a Pin

All pins are written in JSON format and are pushed to Pebble’s server over HTTPS.

An example of a minimal pin looks like this:

[code language="js"]
{
"id": "xxxxxxxxx",
"time": "2015-05-25T08:42:00Z",
"layout": {
"type": "genericPin",
"title": "You left your house",
"tinyIcon": "system://images/NOTIFICATION_FLAG"
}
}
[/code]

  1. The id is a random unique string for each event and allows the issuer to update and delete the pin.
  2. The time determines where in the timeline it should appear.
  3. The layout contains the information that will be shown on the screen.
  4. The type defines whether the pin should be formatted as a generic, calendar, sports, weather, etc. event.
  5. The title is the text shown on the screen.
  6. The tinyIcon is from a list of permitted icons.

Continue reading %Understanding the Pebble Watch Timeline%