Friday, June 9, 2017

PracticalVR experience

Discover PracticalVR's website to enjoy and learn more about tomorrow's mixed reality tools
by via Awwwards - Sites of the day

Thursday, June 8, 2017

Search Smarter: 30+ Google Search Tricks You Might Not Already Know (infographic)

“Google seems to have the answers to everything. Want the weather forecast? Ask Google. Need directions to a restaurant? Search Google. Have a weird rash or wonder why dogs eat grass? Yup, Google it. In a fraction of a second, Google gives you links to hundreds of millions of webpages. But if...

[ This is a content summary only. Visit our website http://ift.tt/1b4YgHQ for full links, other content, and more! ]

by Irfan Ahmad via Digital Information World

A Guide to Proper Error Handling in JavaScript

Ah, the perils of error handling in JavaScript. If you believe Murphy’s law, anything that can go wrong, will go wrong. In this article, I would like to explore error handling in JavaScript. I will cover pitfalls, good practices, and finish with asynchronous code and Ajax.

This popular article was updated on 08.06.2017 to address reader feedback. Specifically, file names were added to snippets, unit tests were cleaned up, wrapper pattern was added to uglyHandler, sections on CORS and 3rd party error handlers were added.

I feel JavaScript’s event-driven paradigm adds richness to the language. I like to imagine the browser as this event-driven machine, and errors are no different. When an error occurs, an event gets thrown at some point. In theory, one could argue errors are simple events in JavaScript.

If this sounds foreign to you, buckle up as you are in for quite a ride. For this article, I will focus only on client-side JavaScript.

This topic builds on concepts explained in Exceptional Exception Handling in JavaScript. I recommend reading up on the basics if you are not familiar. This article also assumes an intermediate level of JavaScript knowledge. If you're looking to level up, why not sign up for SitePoint Premium and watch our course JavaScript: Next Steps. The first lesson is free.

In either case, my goal is to explore beyond the bare necessities for handling exceptions. Reading this article will make you think twice the next time you see a nice try...catch block.

The Demo

The demo we’ll be using for this article is available on GitHub, and presents a page like this:

Error Handling in JavaScript Demo

All buttons detonate a “bomb” when clicked. This bomb simulates an exception that gets thrown as a TypeError. Below is the definition of such a module:

// scripts/error.js

function error() {
  var foo = {};
  return foo.bar();
}

To begin, this function declares an empty object named foo. Note that bar() does not get a definition anywhere. Let’s verify that this will detonate a bomb with a good unit test:

// tests/scripts/errorTest.js

it('throws a TypeError', function () {
  should.throws(error, TypeError);
});

This unit test is in Mocha with test assertions in Should.js. Mocha is a test runner while Should.js is the assertion library. Feel free to explore the testing APIs if you are not already familiar. A test begins with it('description') and ends with a pass / fail in should. The unit tests run on Node and do not need a browser. I recommend paying attention to the tests as they prove out key concepts in plain JavaScript.

Once you have cloned the repo and installed the dependencies, you can run the tests using npm t. Alternatively, you can run this individual test like so: ./node_modules/mocha/bin/mocha tests/scripts/errorTest.js.

As shown, error() defines an empty object then it tries to access a method. Because bar() does not exist within the object, it throws an exception. Believe me, with a dynamic language like JavaScript this happens to everyone!

The Bad

On to some bad error handling. I have abstracted the handler on the button from the implementation. Here is what the handler looks like:

// scripts/badHandler.js

function badHandler(fn) {
  try {
    return fn();
  } catch (e) { }
  return null;
}

This handler receives a fn callback as a parameter. This callback then gets called inside the handler function. The unit tests show how it is useful:

// tests/scripts/badHandlerTest.js

it('returns a value without errors', function() {
  var fn = function() {
    return 1;
  };

  var result = badHandler(fn);

  result.should.equal(1);
});

it('returns a null with errors', function() {
  var fn = function() {
    throw new Error('random error');
  };

  var result = badHandler(fn);

  should(result).equal(null);
});

As you can see, this bad error handler returns null if something goes wrong. The callback fn() can point to a legit method or a bomb.

The click event handler below tells the rest of the story:

// scripts/badHandlerDom.js

(function (handler, bomb) {
  var badButton = document.getElementById('bad');

  if (badButton) {
    badButton.addEventListener('click', function () {
      handler(bomb);
      console.log('Imagine, getting promoted for hiding mistakes');
    });
  }
}(badHandler, error));

Continue reading %A Guide to Proper Error Handling in JavaScript%


by Camilo Reyes via SitePoint

How to Take Incremental Backups in WordPress

Keeping a regular backup for your website will help you to restore lost data if something goes wrong. Incremental backups take it a step farther, backing up only the changes since the last backup, the perfect mix of safety and efficiency.

You must have heard people narrating their data loss horror stories, in which they were unable to recover their data because they were not keeping backups. Backups are no less than website insurance. It is like you have placed copies of your data in some safe locker, and in a case of emergency, you retrieve it and use it to rebuild your site. WordPress plugins have been very helpful in this respect, and you find many good choices to opt from to create backups easily. When a backup is created, you will want it to contain everything from the website at that very moment (files, database, etc).

Backups Secure a WordPress Website

WordPress security has been a discussion for quite a long time, and you find ample content regarding it. Backups are a permanent solution which should be in your arsenal of tools used to secure a site. However, WordPress backups can consist of different types, such as:

  • Manual: Here all your web files (like plugins, themes, uploads directory) and database are downloaded manually via PhpMyAdmin, the terminal, FTP, etc. Manual backups are not so handy if you are making regular changing on your WP site. They require more time and more work. If you're determined to perform manual backups, though, you can learn more about it on SitePoint Premium
  • Automatic: You'll use a WordPress plugin or some service to automatically take a backup. Plugins can be configured for the time interval (i.e. daily, weekly, monthly, hourly) at which the backup is to be made.
  • Real-Time: These backups are synchronized live as you make any changes in your site content.
  • Full-Site Backups: Here, the backups are taken for the entire site and not just the database or an XML export of the content.
  • Incremental Backups: It is a type of backup that only copies files and data that have changed since the previous backup.

Incremental Backups

The primary purpose of this post is not, however, to highlight the importance of backups. I'm sure most of you are already aware that you need backups. Instead, I'm going to specifically discuss incremental backups, which not only offer site security, but also save web resources. But I get into further details let's take a look at the few of the basics about incremental backups.

For example, consider that a full-site backup was made on Day 1. An incremental backup taken later will save all of the files which have been changed since Day 1's backup. However, the next incremental backup will only backup files that have changed since the most recent incremental backup, and so on. The process is repeated until another full-site backup is performed.

The main advantage of incremental backups is that fewer files are backed up daily, allowing for shorter backup windows (backing up full sites can sometimes cause performance issues and require longer backup windows). In this way, you can preserve web resources like server memory and storage space usage.

Hopefully, by now, you recognize the usefulness of taking incremental backups for your websites. There are a couple of go-to backup plugins for it, but the WP Time Capsule plugin replaces the need for nearly all backup solutions out there.

Continue reading %How to Take Incremental Backups in WordPress%


by Maedah Batool via SitePoint

Podcast: Behind the Facebook Logo – A $100 Million Story

Choe at Facebook

Imagine for a moment that we are back in the early 2000’s – 2005 to be specific. You are in San Francisco and own fledgling design agency. You saw first hand the highs achieved by those at the crest of the dotcom bubble and what happened to them once it burst.

The design agency you started only a few years early has begun to attract some amazing clients. Celebrities, technology companies like Google and industry giants like NASA. So, what would you say if a new, unproven start-up came to you and offered equity in return for designing their brand and logo?

This is the question posed to the Cuban Council when Mark Zuckerberg and Sean Parker met with them in 2005.

False Positives

Although Facebook had a promising start and seasoned entrepreneur in former Napster founder, Sean Parker, there was nothing to say the positive signs were to be trusted. There have been plenty of examples where quality entrepreneurs started new services that looked promising but ultimately failed and netted investors zero or negative return.

An example of this was the Kevin Rose founded Oink. Rose had founded the enormously successful website Digg and went on to a litany of high profile wins. With this background, Oink saw it’s app usage sore to over 150,000 users.

Despite this rapid rise, it still ended up shutting its doors less than 6 months after it’s launch.

Hindsight is 20/20 but at the time it was not even remotely clear that what they were being offered would turn out to be worth roughly $100 million dollars… to design a logo.

This is not hyperbole.

At the very same time as the Cuban Council were pondering this offer David Choe, a San Franciscan artist, had taken equity to create a now famous mural at the Facebook offices. His equity, post IPO, was valued at approximately $200 million dollars.

We’d all like to think that we are savvy enough to take the equity, do the work and laugh all the way to the bank. I mean it’s just a logo. How much work could it be? You’d have it done in no time. Right?

Maybe.

Taking equity in place of money is a pretty good way to ensure your business doesn’t last very long. When do you stop working for equity? It certainly doesn’t pay the bills or your employees. If we follow the success of even the best venture capitalists you’re looking at a very low success rates. So unless you are very lucky you might have to make equity deals with dozens of companies before one returns any value.

In this episode of True North we tell the story of the Cuban Council and the decision they faced when offered equity to design the Facebook logo.

Continue reading %Podcast: Behind the Facebook Logo – A $100 Million Story%


by Alex Walker via SitePoint

Legs of Steel

Award winning outdoor films. Legs of Steel emerged from 15 years as professional athletes, and 6 years of producing award winning outdoor film content and feature length movies.
by via Awwwards - Sites of the day

Google I/O 2017 Aftermath: What's New in Android Studio 3?