Monday, February 22, 2016

SVG 3D Tag Cloud jQuery Plugin

SVG 3D Tag Cloud is a lightweight jQuery plugin that creates a three dimensional tag cloud. Easy to use, no dependencies. No additionals plugins. Fully customizable.


by via jQuery-Plugins.net RSS Feed

Web Crawling with Node, PhantomJS and Horseman

It is quite common during the course of a project to find yourself needing to write custom scripts for performing a variety of actions. Such one-off scripts, which are typically executed via the command-line (CLI), can be used for virtually any type of task. Having written many such scripts over the years, I have grown to appreciate the value of taking a small amount of time upfront to put in place a custom CLI microframework to facilitate this process. Fortunately, Node.js and its extensive package ecosystem, npm, make it easy to do just that. Whether parsing a text file or running an ETL, having a convention in place makes it easy to add new functionality in an efficient and structured way.

[author_more]

While not necessarily associated with the command-line, web crawling is often employed in certain problem domains like automated functional testing and defacement detection. This tutorial demonstrates how to implement a lightweight CLI framework whose supported actions revolve around web crawling. Hopefully, this will get your creative juices flowing, whether your interest be specific to crawling or to the command-line. Technologies covered include Node.js, PhantomJS, and an assortment of npm packages related to both crawling and the CLI.

The source code for this tutorial can be found on GitHub. In order to run the examples, you will need to have both Node.js and PhantomJS installed. Instructions for downloading and installing them can be found here: Node.js, PhantomJS.

Setting up a Basic Command-Line Framework

At the heart of any CLI framework is the concept of converting a command, which typically includes one or more optional or required arguments, into a concrete action. Two npm packages that are quite helpful in this regard are commander and prompt.

Commander allows you to define which arguments are supported, while prompt allows you to (appropriately enough) prompt the user for input at runtime. The end result is a syntactically sweet interface for performing a variety of actions with dynamic behaviors based on some user-supplied data.

Say, for example, we want our command to look like this:

$ node run.js -x hello_world

Our entry point (run.js) defines the possible arguments like this:

program
  .version('1.0.0')
  .option('-x --action-to-perform [string]', 'The type of action to perform.')
  .option('-u --url [string]', 'Optional URL used by certain actions')
  .parse(process.argv);

and defines the various user input cases like this:

var performAction = require('./actions/' + program.actionToPerform)

switch (program.actionToPerform) {
  case 'hello_world':
    prompt.get([{

      // What the property name should be in the result object
      name: 'url',

      // The prompt message shown to the user
      description: 'Enter a URL',

      // Whether or not the user is required to enter a value
      required: true,

      // Validates the user input
      conform: function (value) {

        // In this case, the user must enter a valid URL
        return validUrl.isWebUri(value);
      }
    }], function (err, result) {

      // Perform some action following successful input
      performAction(phantomInstance, result.url);
    });
    break;
}

At this point, we've defined a basic path through which we can specify an action to perform, and have added a prompt to accept a URL. We just need to add a module to handle the logic that is specific to this action. We can do this by adding a file named hello_world.js to the actions directory:

'use strict';

/**
 * @param Horseman phantomInstance
 * @param string url
 */
module.exports = function (phantomInstance, url) {

  if (!url || typeof url !== 'string') {
    throw 'You must specify a url to ping';
  } else {
    console.log('Pinging url: ', url);
  }

  phantomInstance
    .open(url)
    .status()
    .then(function (statusCode) {
      if (Number(statusCode) >= 400) {
        throw 'Page failed with status: ' + statusCode;
      } else {
        console.log('Hello world. Status code returned: ', statusCode);
      }
    })
    .catch(function (err) {
      console.log('Error: ', err);
    })

    // Always close the Horseman instance
    // Otherwise you might end up with orphaned phantom processes
    .close();
};

As you can see, the module expects to be supplied with an instance of a PhantomJS object (phantomInstance) and a URL (url). We will get into the specifics of defining a PhantomJS instance momentarily, but for now it's enough to see that we've laid the groundwork for triggering a particular action. Now that we've put a convention in place, we can easily add new actions in a defined and sane manner.

Crawling with PhantomJS Using Horseman

Horseman is a Node.js package that provides a powerful interface for creating and interacting with PhantomJS processes. A comprehensive explanation of Horseman and its features would warrant its own article, but suffice to say that it allows you to easily simulate just about any behavior that a human user might exhibit in their browser. Horseman provides a wide range of configuration options, including things like automatically injecting jQuery and ignoring SSL certificate warnings. It also provides features for cookie handling and taking screenshots.

Each time we trigger an action through our CLI framework, our entry script (run.js) instantiates an instance of Horseman and passes it along to the specified action module. In pseudo-code it looks something like this:

var phantomInstance = new Horseman({
  phantomPath: '/usr/local/bin/phantomjs',
  loadImages: true,
  injectJquery: true,
  webSecurity: true,
  ignoreSSLErrors: true
});

performAction(phantomInstance, ...);

Now when we run our command, the Horseman instance and input URL get passed to the hello_world module, causing PhantomJS to request the URL, capture its status code, and print the status to the console. We've just run our first bona fide crawl using Horseman. Giddyup!

Output of running hello_world command

Chaining Horseman Methods for Complex Interactions

So far we've looked at a very simple usage of Horseman, but the package can do much more when we chain its methods together to perform a sequence of actions in the browser. In order to demonstrate a few of these features, let's define an action that simulates a user navigating through GitHub to create a new repository.

Please note: This example is purely for demonstration purposes and should not be considered a viable method for creating Github repositories. It is merely an example of how one could use Horseman to interact with a web application. You should use the official Github API if you are interested in creating repositories in an automated fashion.

Let us suppose that the new crawl will be triggered like so:

$ node run.js -x create_repo

Continue reading %Web Crawling with Node, PhantomJS and Horseman%


by Andrew Forth via SitePoint

Web Design Weekly #223

Headlines

The future of loading CSS

Jake Archibald explains the major changes that are coming to Chrome in regards to the way normal stylesheets are loaded in a HTTP/2 world. (jakearchibald.com)

Designers shouldn’t code. They should study business (medium.com)

Daily Deals for Web Professionals

MightyDeals is a daily deal website that offers massive discounts for web and creative professionals. Generally, our customers can save from 50% to 90% off on fonts, ebooks, icons, templates and much more. (mightydeals.com)

Articles

Getting Ready For HTTP/2

Rachel Andrew looks at the basics of HTTP/2 and explains some of the key features of the new protocol. A good solid read. (smashingmagazine.com)

Estimating A Front End Web Dev Job

If estimating is not your strongest skill then hopefully this post by Hans Kristian gives you some solid advice so next time you nail it. (hanserino.github.io)

Stack Overflow: The Architecture – 2016 Edition

A super interesting look at the architecture behind one of the most visited sites by developers. (nickcraver.com)

We won the moral argument but did we lose the business case for UX?(andybudd.com)

Tools / Resources

Introducing Vector Networks

The talented team at Figma seem to be rethinking more than just the interface, which is extremely refreshing. In this post Evan Wallace sheds some light on how they are using Vector Networks within Figma. Fingers crossed this tool lives up to the hype. (medium.com)

Unpacking Webpack

Samantha Geitz does a great job explaining what Webpack is and how it differs from task runner like Gulp and Grunt. She also runs through a simple application to demonstrate how it works. (blog.tighten.co)

How to prepare and write a tech conference talk

If you are freaking out and have no idea where to start in preparing your talk this is a brilliant writeup by Lena Reinhard. (schoenaberselten.com)

Finessing `feColorMatrix`

An awesome article by Una Kravats that looks into the power of SVG’s feColorMatrix to create detailed filters A word of warning… there are a few 1’s and 0’s in this post. (alistapart.com)

Why npm Scripts?

Do you really need to add the complexity of a task runner to your project when you can just use npm scripts? Damon Bauer gives a great introduction into why you should consider them for your next project. (css-tricks.com)

Inspiration

The (not so) secret benefits of hiring an external design team (medium.com)

Design, Process and Collaboration at Stripe (medium.com)

Jobs

Web Engineer at IFTTT

You are comfortable at all points in the typical Rails stack, and “one step beyond” — you can identify and fix slow DB queries as comfortably as you can work with flexbox’d divs in CSS. You love shipping, but still take pride in the quality of your code. (ifttt.com)

UI Designer at AWeber

We’re hiring a User Interface Designer who is passionate about design, thinks about “users” as people and really cares about their experience. Come design interfaces and interactions that engage customers and lead them to success using our email marketing software. (aweber.com)

Have a web related job you need to fill?

Last but not least…

Issue and Pull Request templates now available on GitHub (github.com)

The post Web Design Weekly #223 appeared first on Web Design Weekly.


by Jake Bresnehan via Web Design Weekly

Getting Started with Augmented Reality and Meta

Meta have been in the news recently after a much anticipated TED talk last week showcasing their next augmented reality headset, the Meta 2. This was fantastic timing for my first article on developing for the Meta augmented reality headset in Unity! If you have one of the original Meta headsets and you've been putting off building AR apps — now is a good time to dust that headset off and do some development!

In this tutorial, we will look at creating an augmented reality butterfly experience. We will be starting from the basics and will finish with a simple butterfly we can grab and move around our scene.

What You'll Need

In order to follow along with this tutorial, you will need the following:

  • A Meta 1 Developer Kit - These are sold out, so if you aren't lucky enough to have one, you'll need to find a friend who owns one or wait for the Meta 2!
  • Unity 5.2.1 (32 bit) or Unity 5.2.2 (64 bit) - Meta support for Unity 4 is ending soon, so it is best to get up to Unity 5 by this point! I'd recommend downloading via Meta's links which we'll cover below.
  • Windows 8.1 or Windows 10 - Sadly Mac OSX isn't supported and Windows 7 support is being phased out.

Downloading Unity and the Meta SDK

The safest way to get the right versions of both Unity and the Meta SDK is to head to the Meta Dev Center. From here, you can download the latest Meta SDK:

Downloading the latest Meta SDK

Once that has downloaded (or do this simultaneously if you've got much faster Internet than I do!), scroll down to download either the 64 bit or 32 bit Unity depending on your operating system:

Downloading either the 64 bit or 32 bit Unity

Once Unity has downloaded, run through the install process for both the Meta SDK and Unity. Both are pretty straightforward, so I won't waste time discussing them here! Once both have installed, open up Unity and we will get started!

Creating Our First Project

When we first open up Unity, the welcome screen has an option for starting a new project in the top right. Click "New" to start a new project:

Creating a new project by clicking New

Then, we name our project (you can call yours whatever you'd prefer, we've gone with "Pretty Butterfly") and choose where you'd like it saved on your computer. Make sure you have 3D chosen on the bottom left! When ready, click "Create Project":

Setting up our Unity project settings

Before doing anything else, it can be a good idea to have your initial scene named and saved. To do so, go to File > Save Scene as....

Saving our initial scene, File > Save Scene As

We add a new folder for our scenes within the project's "Assets" folder called "Scenes":

Creating a new folder for our scene

Then name our scene "ButterflyScene" — you can name yours whatever you'd like!

Naming our scene

Importing the Meta SDK

Now that we have a scene saved and ready, it is time to import in the Meta SDK we downloaded earlier. To do this, we click Assets > Import Package > Custom Package...:

Importing a custom package via Assets, Import package, Custom Package

Navigate through your filesystem to the Meta SDK. For me, this was in C:/Program Files (x86)/Meta/Meta SDK. In this folder, we choose the "Meta" Unity package:

Selecting the Meta unity package

After a bit of loading time, a window with all of the Meta SDK assets found will appear. Ensure everything is checked and click "Import":

Importing Meta package ensuring everything is checked

If Unity pops up saying "This project contains scripts and/or assemblies that use obsolete APIs", that's okay. Just click "I Made a Backup. Go Ahead!"

Yes, I made a backup

We should now see two new folders, "Meta" and "MetaPackage", within our project:

Meta assets now visible

Adding MetaWorld Into Our Project

Within our new assets, we have our "MetaWorld" Prefab that will give us all of the Meta camera and interaction functionality we need. If you are new to Unity — Prefabs are basically like template objects that can be reused in multiple projects and scenes to share functionality.

The easiest way to add this into our scene is to search within the "Project" window. Type in "MetaWorld" and it should filter our assets to show us what we want. Drag the "MetaWorld" prefab into your project hierarchy (where you've currently got a "Main Camera" and "Directional Light"):

Dragging in MetaWorld Prefab

The actual location of the "MetaWorld" prefab for those wondering is Meta/MetaCore/Resources/Prefabs/MetaWorld.prefab.

Continue reading %Getting Started with Augmented Reality and Meta%


by Patrick Catanzariti via SitePoint

How to Use Swift on Linux

Contributing to Open Source: Gatekeeper Case Study

GateKeeper is a pretty nifty user registration, authentication and authorization library which uses its own database to store and query the user records. This means that it’s completely decoupled from your main app (so you can, essentially, use Postgre or Mongo for your business logic while using a completely different engine like MySQL for basic user records) and easy to tweak and extend.

Open source logo

This post isn’t about Gatekeeper per-se, though - an example of its use will be covered in a later post. It’s about contributing to open source, and going about the right way to doing it.

This post isn’t about Gatekeeper per-se, though. It’s about contributing to open source, and going about the right way to doing it.

In this tutorial, we’ll extend GateKeeper with a count feature. Currently, in order to find out the total number of users in the database one would have to fetch them all, then count them - either that or write a query to do so manually. But it might be better if this were built into the adapter interface so that it’s not only a native feature, but also a requirement for future database engines to be added.

Step 1: Ask the Owner

The first step of contributing to open source is doing due diligence. This can be as simple as asking the repo owner about the status of this feature, in order to make sure it isn’t planned and is, in fact, desirable. An issue in the repo is often enough, as evident in this case.

Continue reading %Contributing to Open Source: Gatekeeper Case Study%


by Bruno Skvorc via SitePoint

Roy Quilor

Roy Quilor

Lovely clean long scrolling One Pager for UK-based product designer, Roy Quilor. Dig who he includes a bit of small detail on each product to give context to the designs you're viewing. Also nice touch including a video of his public talk - this would really help increase the personal branding and in turn create trust for future clients. Well done on locking down this .com too Roy!

by Rob Hope via One Page Love