Javascript News

Syndicate content
Pipes Output
Updated: 48 weeks 6 days ago

The Growing World of Mobile Electronic Health Records

Di, 2015-09-22 17:00

Continuing my series on Mobile Healthcare, which began with "How Mobile Technology Is Changing Healthcare", this article discusses the increased usage of mobile electronic health records (EHRs) by medical practitioners.

Continue reading %The Growing World of Mobile Electronic Health Records%

WebCamp Zagreb 2015 – a Conference You Must Not Miss

Di, 2015-09-22 15:00

What do the some most influential community members of the web development world, like Bob Ippolito, Jaime Levy, Premshree Pillai and Peter Chittum, have in common? They’re all coming to WebCamp Zagreb!

WebCamp is an annual conference for web developers, held in Zagreb on the first weekend of October. This year, it falls on October 3rd and 4th.

Continue reading %WebCamp Zagreb 2015 – a Conference You Must Not Miss%

JavaHub: The Center of Your JavaOne Conference

Mo, 2015-09-21 22:00

This year's JavaOne conference will be held between October 25 and 29. SitePoint is partnering with Oracle to share highlights from the conference.

Meet up at the Java Hub, where you’ll see the latest Java technology innovations. Located at the Exhibition Hall in the Grand Ballroom at the Hilton San Francisco Union Square, the Java Hub will showcase the MakerZone, the Oracle Technology Network Community Café, and Wolf Nkole Helzle’s myMatrix. Coming back this year will be JavaOne favorites, including NightHacking, Hackergarten, and 3D printing.

For a more interactive experience, we are introducing the Geek Bar. There you’ll be able to speak in depth with Java and cloud experts from Oracle on subjects that pique your interest. Check the monitor next to the Geek Bar or the JavaOne mobile app to see a listing of the experts, their areas of expertise, and their availability throughout the conference.

Plan to make the Java Hub the center of your JavaOne conference.

Hours of Operation

Monday, October 26 — 9:30 a.m.–5:30 p.m.
Tuesday, October 27 — 9:30 a.m.–5:30 p.m.
Wednesday, October 28 — 9:30 a.m.–4:30 p.m.

3D Modeling

Watch a 3D printer do its magic creating clones of Duke. Experience the entire process from the modeling interface to the “birth” of Duke. All of it happens with JavaFX 3D, Java Embedded, and 3D printing. 3D Modeling is brought to you by Oracle Technology Network.

Continue reading %JavaHub: The Center of Your JavaOne Conference%

Transpiling ES6 Modules to AMD & CommonJS Using Babel & Gulp

Mo, 2015-09-21 20:00

ECMAScript 6 (a.k.a ECMAScript 2015 or ES6), the specification for next version of JavaScript has been approved and browser vendors are hard at work implementing it Unlike the previous versions of ECMAScript, ES6 comes with a huge set of changes to the language to make it a good fit for the scale at which it is used today. Sitepoint has a number of articles covering these features.

Although browsers haven’t implemented all of the features yet, we can already take advantage of ES6 during development and convert it to a version that browser understands before shipping the application. Babel and Traceur are two of the leading transpilers used for this purpose. Microsoft’s typed superset of JavaScript, TypeScript can also be used as an ES6 transpiler.

I covered how ES6 can be used today to write Angular 1.x applications in one of my previous articles. In this article I used Traceur’s on-the-fly transpiler to run the application. Although it works, it is always better to transpile beforehand and reduce the amount of work to be done in the browser. In this article, we will see how the same sample application can be transpiled to ES5 and the modules into either CommonJS or, AMD using Babel to make it run on today’s browsers. Though the sample is based on Angular, the techniques of transpilation can be used with any valid ES6 code.

As ever, you can find the code to accompany this article on our GitHub repo.

The Importance of Modules

[author_more]

One of the key features in any language used to write large applications, is the ability to load different pieces of the application in the form of modules. Modules not only help us keep the code cleaner but they also play a role in reducing the usage of global scope. The contents of a module are not made available to any other module unless the other module explicitly loads it.

The importance of modules is not limited to applications. Even large JavaScript libraries can take advantage of the module system to export their objects as modules and the applications using the libraries import these modules as required. Angular 2 and Aurelia have started using this feature.

If you’d like a quick primer on using modules in ES6, please read: Understanding ES6 Modules

About the Sample Application

The subject of our sample application is a virtual book shelf. It consists of the following pages:

  1. Home page: shows a list of active books that can be marked as read, or moved to the archive.
  2. Add book page: adds a new book to the shelf by accepting title of the book and name of author. It doesn’t allow a duplicate titles.
  3. Archive page: lists all archived books.

The application is built using AngularJS 1.3 and ES6. If you look at any of the files in the app folder, you will see the keywords export and import used to export objects from the current module and to import objects from other modules. Now, our job is to use Babel’s Gulp tasks to convert these modules to one of the existing module systems.

But I’m Not Using Angular. I Just Want to Convert ES6 Modules to CommonJS/AMD

No worries! We got you covered. With a minor amount of tweaking the recipes demonstrated below can be used in any project involving ES6 modules. Angular is quite unimportant here.

Converting to CommonJS

CommonJS is a module system defined by the CommonJS group. It is a synchronous module system, in which the modules are loaded using the require function and exported using the exports property of the module object. The module object is expected to be available in all modules by default.

Node.js uses this module system, so it defines the module object natively and makes it available to your application. As browsers don’t have this object defined, we need to use a utility called Browserify to fill the gap.

Before we start, we will also need to install a few npm packages. These will enable us to use babel and browserify in conjunction with Gulp to convert our ES6 modules to one of the common module formats and package the application as a single file for the browser to consume.

Continue reading %Transpiling ES6 Modules to AMD & CommonJS Using Babel & Gulp%

What Are WordPress Nonces?

Mo, 2015-09-21 19:00

Keeping your WordPress theme or plugin code secure is important to prevent possible attacks from malicious users.

We’ve previously covered how to sanitize, escape and validate form data in WordPress, as well as improving your WordPress theme quality with the VIP Scanner.

Today we’ll look at how nonces (number used once) can also help keep your WordPress themes and plugins secure.

What are WordPress Nonces?

WordPress nonces are defined as:

… a “number used once” to help protect URLs and forms from certain types of misuse, malicious or otherwise.
https://codex.wordpress.org/WordPress_Nonces

Whilst in WordPress a nonce isn’t technically a number (it’s a hash made up of letters and numbers), it does help prevent actions from being run by malicious users.

WordPress nonces work in two parts:

Continue reading %What Are WordPress Nonces?%

How to Build VR on the Web Today

Mo, 2015-09-21 18:00

Virtual reality is set to be worth up to $7 billion by 2020. The web is definitely not going to remain an exclusively 2D environment during this time. In fact, there are already a few simple ways to bring VR into the browser. It is also incredibly fun to work with!

[author_more]

To begin your development adventure into the Virtual Web, there are three potential ways to do this:

  • JavaScript, Three.js and Watching Device Orientation
  • JavaScript, Three.js and WebVR (My new preferred method!)
  • CSS and WebVR (still very early days)

I'll go over each one and show a short summary of how each works.

JavaScript, Three.js and Watching Device Orientation

One of the ways that most browser based virtual reality projects work at the moment is via the deviceorientation browser event. This tells the browser how the device is oriented and allows the browser to pick up if it has been rotated or tilted. This functionality within a VR perspective allows you to detect when someone looks around and adjust the camera to follow their gaze.

To achieve a wonderful 3D scene within the browser, we use three.js, a JavaScript framework that makes it easy to create 3D shapes and scenes. It takes most of the complexity out of putting together a 3D experience and allows you to focus on what you are trying to put together within your scene.

I've written two demos here at SitePoint that use the Device Orientation method:

If you are new to three.js and how to put together a scene, I'd recommend taking a look at the above two articles for a more in depth introduction into this method. I will cover key concepts here, however it'll be at a higher level.

The key components of each of these involve the following JavaScript files (you can get these files from the example demos above and also will find them in the three.js examples download):

  • three.min.js - Our three.js framework
  • DeviceOrientationControls.js - This is the three.js plugin that provides the Device Orientation we discussed above. It moves our camera to meet the movements of our device.
  • OrbitControls.js - This is a backup controller that lets the user move the camera using the mouse instead if we don't have a device that has access to the Device Orientation event.
  • StereoEffect.js - A three.js effect that splits the screen into a stereoscopic image angled slightly differently for each eye just like in VR. This creates the actual VR split screen without us needing to do anything complicated.
Device Orientation

The code to enable Device Orientation controls looks like so:

[code language="js"]
function setOrientationControls(e) {
if (!e.alpha) {
return;
}

controls = new THREE.DeviceOrientationControls(camera, true);
controls.connect();
controls.update();

element.addEventListener('click', fullscreen, false);

window.removeEventListener('deviceorientation', setOrientationControls, true);
}
window.addEventListener('deviceorientation', setOrientationControls, true);

function fullscreen() {
if (container.requestFullscreen) {
container.requestFullscreen();
} else if (container.msRequestFullscreen) {
container.msRequestFullscreen();
} else if (container.mozRequestFullScreen) {
container.mozRequestFullScreen();
} else if (container.webkitRequestFullscreen) {
container.webkitRequestFullscreen();
}
}
[/code]

The DeviceOrientation event listener provides an alpha, beta and gamma value when it has a compatible device. If we don't have any alpha value, it doesn't change our controls to use Device Orientation so that we can use Orbit Controls instead.

If it does have this alpha value, then we create a Device Orientation control and provide it our camera variable to control. We also set it to set our scene to fullscreen if the user taps the screen (we don't want to be staring at the browser's address bar when in VR).

Orbit Controls

If that alpha value isn't present and we don't have access the device's Device Orientation event, this technique instead provides a control to move the camera via dragging it around with the mouse. This looks like so:

[code language="js"]
controls = new THREE.OrbitControls(camera, element);
controls.target.set(
camera.position.x,
camera.position.y,
camera.position.z
);
controls.noPan = true;
controls.noZoom = true;
[/code]

The main things that might be confusing from the code above is the noPan and noZoom. Basically, we don't want to move physically around the scene via the mouse and we don't want to be able to zoom in or out - we only want to look around.

Stereo Effect

In order to use the stereo effect, we define it like so:

[code language="js"]
effect = new THREE.StereoEffect(renderer);
[/code]

Then on resize of the window, we update its size:

[code language="js"]
effect.setSize(width, height);
[/code]

Within each requestAnimationFrame we set the scene to render through our effect:

[code language="js"]
effect.render(scene, camera);
[/code]

Continue reading %How to Build VR on the Web Today%

Watch: Create Elegant and Responsive Bootstrap Buttons

Mo, 2015-09-21 17:30

In this screencast, I will show you how to create elegant responsive Bootstrap buttons including overcoming white-space issues and hiding content at various screen sizes.

You can find code samples for this screencast on GitHub. This is the first video in the Quick Real World Bootstrap Tricks series.

Loading the player...

Continue reading %Watch: Create Elegant and Responsive Bootstrap Buttons%

Build an Ecommerce Business: Tips From an Ecommerce Founder

Mo, 2015-09-21 17:03

Many entrepreneurs mistake the “e” in “ecommerce” for “easy,” and frankly, it’s hard to blame them. The rise of platforms like Shopify and Volusion have made setting up an online shop a breeze, and with drop shipping services like Scalable Press and Doba, you never even have to be in the same room as the […]

Continue reading %Build an Ecommerce Business: Tips From an Ecommerce Founder%

Removing the Pain of User Authorization with Sentinel

Mo, 2015-09-21 16:00

Most non-basic multi-user applications need some roles and permission levels. If you ever used Wordpress, you must have noticed that they have a super admin, admin, editor, author, etc. Simplifying the development and integration of a permission system is what Cartalyst’s Sentinel package is trying to accomplish. The package provides an API for dealing with users, groups, permissions, etc. In this article, we’ll use it to create a small demo app.

Environment Setup

For our sample application in this tutorial, we will be using the Slim micro-framework and Vagrant. You can check out the final demo on Github to see the result. Let’s start by first requiring the necessary packages:

composer require slim/slim:~2.0 composer require twig/twig:~1.* composer require cartalyst/sentinel:2.0.*

Sentinel suggests installing Illuminate Eloquent, Illuminate Events, Symfony Http Foundation and ircmaxell password-compat so let’s add those to the project.

composer require illuminate/database illuminate/events symfony/http-foundation ircmaxell/password-compat

Because working with users, groups and permissions requires some database interaction, we need to create our database with the necessary tables. If you are using Laravel you can install the database using the migrate command.

Continue reading %Removing the Pain of User Authorization with Sentinel%

7 MORE Photoshop Master Tips to Speed up Your Workflow

Mo, 2015-09-21 15:00

Speed and quality.

That's what everyone is looking for when they use Photoshop. That's why knowing how to fully automate and optimize your working process is so important.

In the previous article, we explored some of the best tips which can help you to boost your workflow. Now, we're going to examine seven more tips, focused on streamlining the way your work with Photoshop.

Again, for the sake of brevity, we'll talk mostly what needs to be done, rather than the nitty-gritty detail. For fine-grained instructions, dig into the Photoshop's documentation or you can search the Web for practical solutions and tutorials.

1. Learn and Practice Keyboard Shortcuts

[caption id="attachment_115284" align="alignright" width="240"] WPM by Jason Devaun[/caption]

When beginners start using Photoshop, they usually learn to perform a particular task by following a logical set of steps. During their movement from point A to point B, they are like a tourist train that needs to stop at every way station along the route.

This is not wrong – we all started in that way – but at some point you have to step up your game. Once we know how to perform a particular task, we need to catch that express train that skips the way stations. That express train is the keyboard shortcut!

Here is a Photoshop's default keyboard shortcuts list. If you prefer other shortcuts, you can edit the existing ones or even create your own for the tasks which don't have a shortcut assigned. Just go to Edit > Keyboard Shortcuts and make the needed changes.

2. Swap Your Computer Mouse with Graphic Tablet

Let's face it: Using a mouse for drawing and painting is not natural. There's a reason that pens aren't shaped like potatoes.

Using a tablet for the first time may feel a little strange, but once you get used to working with it, you'll wonder how you coped without it.

With one hand on your keyboard (remember those keyboard shortcuts) and the other on the pen, your speed will really spike for tasks like masking, retouching, and vector linework.

The key factors to consider when buying a drawing tablet are:

  • size
  • pressure sensitivity
  • tilt sensitivity
  • price

You don't need to spend a great deal but if you use Photoshop for painting you might find a tablet with tilt sensitivity useful.

There are also some other handy features, like touch support and shortcut keys, which can add an extra layer of speediness and comfort to your workflow, but are dependent on your budget.

Rather than going into fine detail on tablets here, I'd recommend you check out Parka Blogs excellent 2015 tablet buyers guide for a great summary of what you'll need in a tablet.

Personally, I use an old Bamboo Pen with no tilt sensitivity, no touch support, and no express keys, as I don't generally use Photoshop for painting or drawing. The tablet works perfectly for making selections, using tools such as Dodge and Burn, etc. – all the features I need for my current Photoshop work.

3. Automate Your Workflow with Photoshop's Actions, Droplets, and Scripts

Photoshop's actions can be one of the most powerful weapons in your automation arsenal. A task made up of multiple steps can be performed automatically with one single click. It takes time to record an action the first time, but time is saved every time that action is repeated in future.

Let's say that you have a dozen images which you want to convert to a specific size and resolution. Instead of repeating the conversion for each one of the images, you can perform the task once, and save it as an action.

[author_more]
7 Photoshop Master Tips to Boost Your Productivity
What is Adobe Extract - And Why Should You Care?
Generating Responsive Image Assets with Photoshop CC 2014
[/author_more]

Applying actions in Photoshop requires you to:

+open the Actions panel +find the desired action +click the Play button

Wouldn't it be great, if we could perform this operation in a faster and easier way? Well... there is such a way, and it's called droplet.

Droplets

{IMG}

A droplet is a special file – which you create and save on your hard drive – containing a specific action defined by you. To apply that action, you only need to drag an image over the droplet and.. well.. drop it. Et voila.

The cool part is you don't even have to open Photoshop!

Besides actions, there is one more similar method to automate your workflow. Photoshop allows you to use built-in or user-created scripts. A script is more flexible and powerful than a standard action because it can change its behavior according to certain conditions – but you will need at least a decent working knowledge of JavaScript to write it.

This is not a big problem. There are plenty of scripts built by other people which you can download and use. One the other hand, if you know JavaScript, you can surely take the advantage of writing your own custom scripts.

Continue reading %7 MORE Photoshop Master Tips to Speed up Your Workflow%

How to Save Multiple Checkbox Values to a Database in Rails

Mo, 2015-09-21 14:00

Imagine you have a form in your Rails app which is backed by an ActiveRecord model. In this form there are a bunch of checkboxes, the values of which you want to persist to your database. How do you go about handling this scenario?

As ever, the code for this article can be found on our GitHub repo.

The Anti-Pattern

Well, an initial reaction might be to create a string column in the database to hold all of the checkbox data. You could then use a before_save hook in the model to build the string and use check_box_tag helpers in the view to display the check boxes.

Let’s have a quick look at what this might look like. To do so, we’ll create a demo app into which you can enter the name of a professor and select their various areas of expertise.

rails new cb-demo && cd cb-demo rails g scaffold professor name:string expertise:string rake db:migrate

After that open up /app/views/professors/_form.html.erb and replace:

<%= f.label :expertise %><br> <%= f.text_field :expertise %>

with:

<%= label_tag 'expertise_physics', 'Physics' %> <%= check_box_tag 'professor[expertise][]', 'Physics', checked('Physics'), id: 'expertise_physics' %> <%= label_tag 'expertise_maths', 'Maths' %> <%= check_box_tag 'professor[expertise][]', 'Maths', checked('Maths'), id: 'expertise_maths' %>

In /app/controllers/professors_controller.rb alter:

params.require(:professor).permit(:name, :expertise)

to:

params.require(:professor).permit(:name, expertise:[])

Then in /app/models/professor.rb add:

before_save do self.expertise.gsub!(/[\[\]\"]/, "") if attribute_present?("expertise") end

And in /app/helpers/professors_helper.rb add:

def checked(area) @professor.expertise.nil? ? false : @professor.expertise.match(area) end

Finally, run rails s and navigate to http://localhost:3000/professors

And as you can see, it works. But unfortunately, that’s about all it does. Saving checkbox data to the database this way will just cause problems further down the road. For example as the number of professors and the number of areas of expertise grow, queries to find out which profs are assosciated with which areas will become a horrific mess.

Also what happens if you want to delete or rename an area of expertise? In this case you’d have to manipulate the database directly, which is almost never a good thing (not to mention time consuming and error-prone).

The Right Way

Luckily, there is a much better way to accomplish this — namely by moving Expertise into its own model and declaring a has_and_belongs_to_many association between Expertise and Professor. This will create a direct many-to-many connection between the models (by means of a join table — a database table that maps two or more tables together by referencing the primary keys of each data table).

As the Rails guide states:

A has_and_belongs_to_many association creates a direct many-to-many connection with another model, with no intervening model. For example, if your application includes assemblies and parts, with each assembly having many parts and each part appearing in many assemblies, you could declare the models this way:

You can visualize it like so (where expertises_professors is the join table):

Continue reading %How to Save Multiple Checkbox Values to a Database in Rails%

Build a Face Detection App Using Node.js and OpenCV

Fr, 2015-09-18 18:00

Human beings have an innate ability to detect, process and recognize faces — we’re born with it. Computers can do it, too — it just takes some clever algorithms, reams of code and some training of the algorithms.

Face detection is the process of identifying faces in digital images. It shouldn’t be confused with facial recognition — i.e., trying to work out who someone is from a photograph — but it’s the first part of the process. Facial recognition is a huge topic for another time, but face detection is the subject of this article.

To illustrate the process, here’s an example image:

…and here’s what the face detection does:

(Original image from Wikipedia)

Applications of Face Detection

There are numerous applications of face detection. Some modern biometrics systems detect faces and then use facial recognition to compare those faces to images in their databases, in order to try and identify someone without having to resort to good old-fashioned passwords. Some cameras use face detection for auto focussing. And like so many things, it also has applications in marketing.

For the purposes of this tutorial, we’ll replicate a feature that you may well have used yourself if you’re a Facebook user. When you upload a photo of your friends, Facebook often shows it back to you with any faces highlighted, in order to prompt you to “tag” people in it. We’re going to build something similar.

A Little Background

Before we dig into the code, let’s look at some of the tools and concepts we’re going to be using.

OpenCV and the Viola-Jones Object Detection Algorithm

OpenCV (Open Source Computer Vision) is an open-source library of hundreds of computer vision algorithms. Although OpenCV is written in C++, we can use it in Node.js applications thanks to the opencv package.

Amongst the algorithms implemented in OpenCV is the Viola-Jones object detection framework, which is used to detect features in images.

Face detection is simply a sub-set of feature (object) detection, but the algorithm is geared towards the challenges involved in detecting faces specifically.

Of course when we talk about feature detection in this context, it’s nothing to do with the sort of feature detection provided by libraries such as Modernizr and yepnope!

First presented in a 2004 article by Paul Viola and Michael J. Jones, this approach has become the de facto standard for face detection.

You’ll find some additional resources on the framework listed under Further Reading later on in this tutorial.

Cascades and Classifiers

[author_more]

An important aspect of the Viola-Jones algorithm is a cascade of classifiers, which is described as “a cascade of boosted classifiers working with haar-like features”. In practical terms, what this means is that it’s a set of visual features that OpenCV has been “trained” to look for in an image, in order to identify a particular type of object — in our case, faces. You’ll find more information about cascades and classifiers in the documentation. A cascade designed specifically for identifying faces is provided for us, as we’ll see when we look at the implementation.

Installation

Before we can start playing with face detection, we need to install a few pre-requisites.

The easiest (and recommended) way to get up-and-running is to use Vagrant. You’ll find the necessary configuration and provisioning script in the repository which accompanies this article. If you use this approach, there’s no need to go through these installation steps.

Installing OpenCV Linux (Debian-based systems)

OpenCV has a number of pre-requisites itself, which we can install using apt-get:

sudo apt-get install build-essential sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev

There are also some optional dependencies:

sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev

The easiest way to install OpenCV itself it is to use apt-get:

sudo apt-get install libopencv-dev

At time of writing, this installs version 2.4.8, although the latest 2.x version is 2.4.11 and there is currently a version 3.0.0. However, there are currently issues with the Node.js wrapper on version 3.0.0., so this version is just fine.

Building from Source

If you want to build from source, start by installing the dependencies listed above, then download and extract the files from the downloads page.

As noted above, there are currently issues with the 3.0.0. in conjunction with the Node.js module, so it’s best to download version 2.4.11.

Now we need to build it:

cd ~/opencv-2.4.11 mkdir release cd release cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local .. make sudo make install

Be warned, that last step might take a while!

Windows

If you’re using Windows, installation is as simple as downloading and running an executable file from the website. You’ll find a direct link to the latest version (at time of writing) right here.

Mac OSX

The easiest way to install on OSX is to use Homebrew:

brew tap homebrew/science brew install opencv

You’ll find further instructions here.

Imagemagick

You’ll also need Imagemagick, which is a dependency of the image-processing library we’re going to be using.

Debian-based Systems apt-get install imagemagick Mac OSX brew install imagemagick Windows

Download and run the appropriate Windows Binary Release — which is an executable file — from this page.

Building Our Application

A reminder that all the source code for this tutorial is available on Github.

Let’s start by defining a a few dependencies:

So without further ado, here’s our package.json:

{ "name": "sitepoint/face-detection", "version": "1.0.0", "description": "A simple application which demonstrates face detection in Node.js", "main": "index.js", "author": "Lukas White", "license": "MIT", "dependencies": { "async": "^1.4.2", "busboy": "^0.2.9", "connect-busboy": "0.0.2", "easyimage": "^2.0.3", "express": "^4.13.3", "express-handlebars": "^2.0.1", "lodash": "^3.10.1", "multer": "^1.0.3", "opencv": "^3.0.0" } }

Install the dependencies with npm install.

Next, create a few directories:

mkdir public mkdir public/css mkdir public/images mkdir views mkdir views/layouts mkdir uploads

Now create a basic layout for our application (views/layouts/default.hbs):

<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Face Detection Example</title> <link rel="stylesheet" href="/css/bootstrap.min.css"> <link rel="stylesheet" href="/css/bootstrap-theme.min.css"> <link rel="stylesheet" href="/css/styles.css"> </head> <body> <nav class="navbar navbar-inverse navbar-fixed-top"> <div class="container"> <div class="navbar-header"> <a class="navbar-brand" href="/">Face Detection Example</a> </div> </div> </nav> <div id="main" class="container"> {{{body}}} </div> </body> </html>

I’m referencing the Bootstrap framework to prettify the application slightly, but this is optional. Either download the files yourself, or you’ll find them in the repository which accompanies this article.

Add some basic styles (public/css/styles.css):

#main { margin-top: 50px; } .frame { position: relative; } .frame a { display: block; position: absolute; border: solid 2px #fff; border-radius: 50%; } .frame a:hover { background: rgba(0,0,0,0.5); }

Continue reading %Build a Face Detection App Using Node.js and OpenCV%

SQL vs NoSQL: The Differences

Fr, 2015-09-18 17:00

SQL (Structured Query Language) databases have been a primary data storage mechanism for more than four decades. Usage exploded in the late 1990s with the rise of web applications and open source options such as MySQL, PostgreSQL and SQLite.

NoSQL databases have existed since the 1960s but have been recently gaining traction with popular options such as MongoDB, CouchDB, Redis and Apache Cassandra.

You'll find many tutorials explaining how to use a particular flavor of SQL or NoSQL but few discuss why you should choose one in preference to the other. I hope to fill that gap. In this article we'll cover the fundamental differences. In a later follow-up article we'll look at typical scenarios and determine the optimal choice.

Most examples apply to the popular MySQL SQL and MongoDB NoSQL database systems. Other SQL/NoSQL databases are similar but there will be minor differences in features and syntax.

The SQL vs NoSQL Holy War

Before we go further, let's dispel a number of myths…

MYTH: NoSQL supersedes SQL
That would be like saying boats were superseded by cars because they're a newer technology. SQL and NoSQL do the same thing: store data. They take different approaches which may help or hinder your project. Despite feeling newer and grabbing recent headlines, NoSQL is not a replacement for SQL -- it's an alternative.

Continue reading %SQL vs NoSQL: The Differences%

Conquering Instagram with PHP and the Instagram API

Fr, 2015-09-18 16:00

Instagram’s API allows us to interact with data such as user info, media (photos and videos), likes, comments, and tags. For example, you can search for media around a specific location and filter the results by time. The API also allows us to post comments or like specific media. For now, only uploading media isn’t supported. You can always look at the API endpoints documentation if you want to know about the full functionality.

Types of API Calls

There are 2 types of API calls you can perform with the Instagram API: Unauthenticated and Authenticated. Unauthenticated API calls only need the client ID, and authenticated API calls use OAuth, specifically OAuth 2.0. If you don’t know what OAuth is, check out this Introduction to OAuth 2 article on DigitalOcean.

Limits

Before we move on, it’s important to understand that there are limits to this API. At the moment of writing of this article, you can only perform 5000 authenticated calls per token and 5000 unauthenticated calls to the API. This is regardless of the endpoint that you use, though there are specific endpoints each of which has its own limits. You can check out the endpoint-specific rate limits section in the limits page if you want to learn more.

Continue reading %Conquering Instagram with PHP and the Instagram API%

Offline Support in Firebase, a Truly Mobile Datastore?

Fr, 2015-09-18 15:00

Since being acquired by Google, Firebase has continued to develop into a powerful platform for building both web and mobile applications.

The company’s recent announcements from the Firebase team dealt with their pricing structure, which was changed dramatically. In the past some may have found Firebase too expensive, it is now significantly cheaper. As a result of this decrease in cost, there are sure to be a bunch of cool projects that utilize Firebase’s real time capabilities. More interesting to developers, Firebase’s development team announced full offline support for the platform at the annual Google I/O Conference in May. In this tutorial I intend to find out just how useful and usable the new features are.

Continue reading %Offline Support in Firebase, a Truly Mobile Datastore?%

JavaOne4Kids: Robots, Minecraft, and Coding

Do, 2015-09-17 22:00

This year's JavaOne conference will be held between October 25 and 29. SitePoint is partnering with Oracle to share highlights from the conference.

Much like with language, kids have the ability to absorb and understand the basics of technology amazingly at an early age. Building the next generation of developers, engineers, and tech lovers,JavaOne4Kids is an entire day’s worth of sessions hosted on Saturday October 24th right before JavaOne begins (schedule available here). In order to ensure that the kids have the best time possible and want to come back for more, we try to offer lessons that spark their interest and creativity. These sessions are aimed at children 10-18 years old. There are 21 total sessions being offered over 3 time slots. Technologies covered include: Greenfoot, LEGO Mindstorms, Scratch, Leap Motion, Arduino, Python, NAO Robot, HTML5, JavaScript, Polymer, Raspberry Pi, Scala, Forge 1.8, Tynker, and, of course, Java.

Each session is designed to reach out to a different age group or interest. For example, the young artists can draw their favorite animals with JavaScript; the gamers can mod Minecraft with Forge 1.8 or build their own game with Java or Scratch and Leap Motion, and robot enthusiasts can play with a NAO Robot. Registration for this event opens in September, but in order to make sure it’s the best that it can possibly be, we are now looking for volunteers to help with the workshops. Sign up to volunteer here. Your time will help inspire the next generation of Java Developers – a great way to give back to and help grow the Java Community.

SitePoint is partnering with Oracle to give away FORTY free tickets to the JavaOne conference. To win a ticket to the conference (October 25th-29th, 2015), leave a comment below telling us how you’ll convince your boss to give you the week off for the conference. The best answers win!

Continue reading %JavaOne4Kids: Robots, Minecraft, and Coding%

Controlling a Motorbot Using Arduino and Node.js

Do, 2015-09-17 20:00

Recently GitHub published a blog post which showed how the different languages have been evolving during the time. The rank represents the languages used in GitHub's public and private repositories, excluding forks, as detected by a library called Linguist. As evident from it, JavaScript is definitely winning the race, in a wide variety of fields. The programming language is becoming a very popular choice for game programming, robotics, and IoT devices, despite of the very strong competition coming from C, C++, and Java. When JavaScript started powering robots, NodeBots were born.

NodeBots are robots that are controlled by Node.js. If you are interested in knowing a little bit more about them, I suggest you to read the article titled An introduction to NodeBots by Patrick Catanzariti .

In this tutorial, we'll make a simple NodeBot which can be controlled from the browser. The source code of the whole project is available on GitHub.

Continue reading %Controlling a Motorbot Using Arduino and Node.js%

Watch: Responsive Images with Picturefill.js

Do, 2015-09-17 17:30

Working with images in responsive web design is one of the biggest challenges front-end developers currently have when building websites. In this screencast I will show you how to use the new picture tag and srcset attribute, together with the Picturefill.js polyfill, to achieve better flexibility, lessen the page size, and serve just the right image for that resolution and device.

View the code for this screencast on GitHub.

Loading the player...

Continue reading %Watch: Responsive Images with Picturefill.js%

4 Examples of Popups That Are Bringing Sexy Back

Do, 2015-09-17 16:00

Popup windows have a reputation for being evil. As an Internet browser, you’ve probably closed your fair share of boxes without even pausing—so as a designer or entrepreneur, it’s understandable to resist putting them on your own site. However, you might want to rethink that. Popups—when done well—benefit not only you, but your site visitors […]

Continue reading %4 Examples of Popups That Are Bringing Sexy Back%

Experiment with ECMAScript 6 on Babylon.js with TypeScript 1.5

Do, 2015-09-17 15:30

This article is part of a web development series from Microsoft. Thank you for supporting the partners who make SitePoint possible. Since releasing babylon.js, the WebGL open-source gaming framework, a couple of years ago, we (with help from the community) are constantly exploring ways to make it even better. I’m definitely more than happy that […]

Continue reading %Experiment with ECMAScript 6 on Babylon.js with TypeScript 1.5%