All posts tagged “Getting”

Getting Started With Gulp.js

guide to gulp.js

In this article we’ll look at the basics of using Gulp — from installation to basic syntax and a couple of examples. By the end of the article you should be able to find, install and use packages that others have created for Gulp to compile SASS, optimize images, create sprites, concatenate files, and more!

Installing Gulp

Don’t worry, installation is very easy. We’ll need to use the terminal in OSX and Linux, or the command prompt for Windows. I’ll be referring to it as Terminal from now on.

Open it up and type npm -v and press enter. If you see version number displayed you have Node installed already — this is a dependency for Gulp.

If you get a "command not found" (or a similar error), head on down to the Node.js downloads page and select the appropriate package for your system. Once installed, the npm command will be available in the terminal.

Installing Gulp is just as easy. Paste the following command into the terminal, that’s it:

npm install --global gulp

This will install the Gulp command which will be available globally on your system.

Adding Gulp To A Project

Gulp is now installed, but we’ll need to add it to each project we need it for, separately. Create an empty folder now and navigate to it in your terminal. While in the folder for the project, use the following command:

npm install --save-dev gulp

This should create a node_modules folder and an npm-debug.log file in your project folder. These are used by Gulp to do its thing to your project, you don’t need to think about them at this stage.

The reason we need to add Gulp to each specific project is that each project has different requirements. One may call for SASS, another for Less. One may use Coffeescript, the other may not, and so on.

The Gulpfile

The Gulpfile is where the magic happens, it’s where you define the automations you require and when you want them to happen. Let’s create an empty default task by creating a file named gulpfile.js and pasting the following code into it.

var gulp = require('gulp'); gulp.task('default', function() { // This does nothing for now, we'll add functionality soon });

Once this file is saved you can go back to your terminal and run the gulp command on its own. Gulp detects which project it is in and runs the default task — the one we just created. You should see something like this:

Nothing really happens here, since the task is empty, but it is working fine. Now, let’s get going with some proper examples!

Copying A File

This is a boring one, I’ll admit as much, but it will help you understand what’s going on easily.

In your project folder create a file named to_copy.txt , and a folder named dev. Let’s go into our Gulpfile and create a new task named copy.

gulp.task('copy', function() { return gulp.src('to_copy.txt') .pipe(gulp.dest('dev')); });

The first line defines a task that is named copy. Within this we use gulp.src to specify which files we are targeting with this task — in this case it is a single file named to_copy.txt.

We then pipe these files to the gulp.dest function which specifies where we want to put these files — I’ve used the dev directory.

Go back to your terminal and type gulp copy to run this task, it should copy the specified file to the specified directory, something like this:

The pipe command is at the heart of Gulp. It is an efficient way to move data between commands. The src command specifies the files which are piped to the dest command. In more complex scenarios we would pipe our files to other commands before specifying a destination.

You should also be aware that the source can be given as a single file, or multiple files. If we have a folder named production and we want to move all files from our development folder into it, we could use the following command:

gulp.task('copy', function() { return gulp.src('development/*') .pipe(gulp.dest('production')); });

The star character will match anything within the directory. You could also match all files within all subdirectories, and do all sorts of other fancy matching. Take a look at the node-glob documentation for more info.

Compiling SASS

Compiling a stylesheet out of SASS files is a common task for developers. It can be done with Gulp pretty easily, we’ll need to do some preparation though. Apart from basic commands such as src, dest and a number of others, all functionality is added via third party addons. Here’s how I go about using them.

I type SASS Gulp into Google, the first result is usually what I need, you should find the page for the SASS package. It shows you how to install it (npm install gulp-sass). Chances are you’ll need to use sudo to install it as an administrator, so it will probably be (sudo npm install gulp-sass) .

Once done, you can use the syntax the package dictates to compile your code. To do this, create a file named styles.scss with the following content:

$  primary: #ff9900; body { background: $  primary; }

Now create the following Gulp task in the Gulpfile.

gulp.task('sass', function () { gulp.src('*.scss') .pipe(sass()) .pipe(gulp.dest('./css')); });

Before running the command, don’t forget to ‘require’ the package at the top of the Gulpfile like this:

var sass = require('gulp-sass');

When you run grunt sass, all files with the scss extension will be piped to the sass function, which will convert them to css. These are then piped to the destination function which places them in the css folder.

Watching Files And Folders

So far this is all handy, but we still need to type a command each time we want to run a task, which isn’t very efficient, especially when it comes to stylesheet changes. Gulp allows you to watch files for changes and run commands automatically.

In the Gulpfile, create a command named automate which will use the watch command to watch a set of files for changes, and run a specific command when a file changes.

gulp.task(‘automate', function() { gulp.watch('*.scss', ['sass']); });

If you type gulp automate into the terminal, it will start and finish the task, but it won’t return to the prompt because it is monitoring for changes. We’ve specified that we want to watch all scss files in the root directory and if they change, we want to run the sass command that we’ve set up previously.

If you now change your style.scss file it should be compiled to the css file within the css directory automatically.

Running Multiple Tasks

There are many situations where you might want to run multiple tasks. When watching your javascript folder you may want to compile concatenate two files and then proceed to minify them. There are two ways you can get this done.

If tasks are related, I like to chain them. A good example would be the concatenation and minification of javascript files. We first pipe our files to the concat action, then pipe them to gulp-uglify, then use the destination function to output them.

If tasks are unrelated you could call multiple tasks. An example would be a task where we want to concatenate and minify our scripts and also compile our SASS. Here’s he full Gulpfile of how that would look.

var gulp = require('gulp'); var uglify = require('gulp-uglify'); var concat = require('gulp-concat'); var sass = require('gulp-sass'); gulp.task('scripts', function() { gulp.src('js/**/*.js') .pipe(concat('scripts.js')) .pipe(gulp.dest('.')) .pipe(uglify()) .pipe(gulp.dest('.')) }); gulp.task('styles', function() { gulp.src('/*.scss') .pipe(sass()) .pipe(gulp.dest('./css')); }); gulp.task('automate', function() { gulp.watch(['*.scss', 'js/**/*.js'], ['scripts', 'styles']); }); gulp.task('default', ['scripts', 'styles']);

If you type gulp scripts into the terminal, all javascript files within the js directory will be concatenated, output to the main directory, then uglified and saved to the main directory.

If you type gulp sass, all your scss files will be compiled and saved to the css directory.

If you type gulp (the default task), your scripts task will be run, followed by your styles task.

The gulp automate task watches multiple folders for changes in our scss and js files and will perform both tasks we’ve defined, if a change is detected.

Overview

Using Gulp is not difficult, in fact, many people prefer it over Grunt because of its simpler syntax. Remember the steps to take when creating a new automation:

  • Search for plugin
  • Install plugin
  • Require plugin in your Gulpfile
  • Use the syntax in the documentation

The five commands available in Gulp (task, run, watch, src, dest) are the only ones you need to know, all third party addons have great documentation. Here’s a list of some things I use which you could get started with right now:





hongkiat.com

Classic horror movie The Blob is getting remade with a lot of CGI

Campy horror classic The Blob is getting a remake, Deadline reports. The movie, about a small town terrorized by a hungry, vicious villain from another planet, is known for its shoddy graphics, strange premise, and the launch of Steve McQueen’s acting career.

Simon West, (Con-Air, The Expendables 2) will direct the movie for Goldcrest Films; Richard Saperstein and Brian Witten (Silent Night) will produce. In what may be a boon to fans of the original, Jack Harris, the 96-year-old producer of the 1958 movie, is credited as an executive producer.

Continue reading…

The Verge – All Posts

Tesla’s Roadster is getting an upgrade to nearly double its range

Tesla CEO Elon Musk has confirmed that the company’s Roadster model is getting a battery upgrade to extend its range from 244 miles to almost 400 miles. It’s a significant boost, and one that means the Roadster will be able to outdo even the company’s flagship Model S, which has a range of 265 miles.

Introduced in 2008, the Roadster was Tesla’s first production vehicle and though it has been overshadowed somewhat by the newer Model S, the company has been teasing a major upgrade for it since June this year. Musk and company are now rewarding the roughly 2,500 early adopters who bought into Tesla’s vision of the electric car years before it became so widely accepted. The upgrade is expected to come in the form of a full battery…

Continue reading…

The Verge – All Posts

Volvo’s Vision 2020: The Road to Safety: In five years, the Swedish automaker aims to have no deaths in its new cars: here’s how they’re getting there

Volvo's Vision 2020: The Road to Safety

Automakers face countless challenges when setting the goals they want their cars to achieve. Balancing interests between emissions, power, luxury, style and safety all weigh heavy in the minds of decision-makers. While some brands have a reputation……

Continue Reading…


Cool Hunting

7 tips for getting into the game art industry

Read more about 7 tips for getting into the game art industry at CreativeBloq.com


Rick worked on Massively Multiplayer Online game Everquest during his time at Sony.




Creative Bloq

Tips for getting a job at a top studio

Read more about Tips for getting a job at a top studio at CreativeBloq.com


Matt Pyke is a UK-based media artist and designer working between the Peak District and London. Formerly a senior designer at The Designers Republic, he founded multidisciplinary design studio Universal Everything in 2004. The studio has an impressive portfolio of progressive projects that harness new technologies and have attracted numerous global brands and bands, including Radiohead, Chanel,Intel, Nike, Audi, London 2013 Olympics and more.




Creative Bloq

Elon Musk may be getting into the satellite business

Elon Musk, the chief executive of automotive company Tesla — which reported a $ 75 million loss earlier this week and delayed, again, its Model X SUV — is considering global internet satellites as his next venture, The Wall Street Journal reported.

Musk is exploring a partnership with Greg Wyler, founder of WorldVu Satellites Ltd, to launch about 700 satellites, The Wall Street Journal says. The satellites would weigh less than 250 pounds, which is about half the size of the smallest current satellites used commercially for communication. The current largest fleet is about 10 times smaller. The effort may cost $ 1 billion or more, and the project “is in a formative stage, and it isn’t certain Mr. Musk will participate.” Musk’s SpaceX…

Continue reading…

The Verge – All Posts

Getting Started With AngularJS

Every once in a while a new tool arises and just as it suddenly appeared, it seeps down into oblivion. Not AngularJS though. While it’s been around since 2009 since its creation by Misko Hevery, AngularJS has been gaining a lot of attention in the past couple of months.

People are talking about it, developers have been integrating it in their works, and authors have been writing books about it and earning loads of cash. So, what is AngularJS and why should you hop on it? Is it life-changing? It sure is! Let me tell you why.

Note: I highly recommend that you get comfortable with JavaScript first before delving deeper into AngularJS. If you aren’t familiar with MVC and DOM, I suggest reading more about them before proceeding further, otherwise you might get confused with most of the terminologies used in this article.

What is AngularJS?

AngularJS is not just another JavaScript framework. Sure, we have Backbone, Ember, and the hottest jQuery, but AngularJS is different in many ways.

Data-Binding and Built for Single-Page Applications (SPA)

Firstly, AngularJS is a data-binding framework that is specifically built for SPAs. Meaning, you can easily build an application without using any other libraries since it already has everything you will ever need. It also maintains synchronization for the model and view.

The beauty of building a SPA is that it imitates a desktop experience in which the page remains the same all throughout, with only the views being changed along with the URL – AngularJS handles routing as well as views. It’s faster and smoother this wa. It’s as if you’ve just opened a desktop application and having everything you need already there.

Another thing is that unlike other SPAs, the browser history is actually kept. For example, if you want to click on the back button to get back to the previous view, AngularJS will actually take you back to the previous view. Most SPAs don’t work this way.

Model-View-Controller Implementation Done Right

AngularJS implements MVC in a beautiful way. Most frameworks that use MVC requires you to separate your application into modules and then write code that will connect them together. While the reasoning behind this is to make the code work more flexible and reusable, this leads to many coding horrors, especially for lazy (or sleepy) developers. AngularJS handles this beautifully by simply requiring you to just split your application into different modules. It then handles the rest.

Animation

Of course a single-page application can’t look good without the appropriate animations. As mentioned earlier, AngularJS is a feature-rich framework that has all of the things you’ll need in building generic applications. As such, it provides an easy way to introduce animation in every view the same way as jQuery does.

Here’s a good example of how AngularJS handles animations.

But that is just the surface of AngularJS. Here is more of what it can do:

  • Data validation
  • Dependency injection
  • Handle custom logic
  • Multi-element directives
  • Share data between controllers
  • Enhance HTML
  • DOM manipulation with the help of jQlite (built-in)
  • AJAX
  • Routing
  • Testing
  • and many more

A Comparison

Now, let’s take a peek on how AngularJS works by comparing it to the regular JavaScript and jQuery.

Vanilla JavaScript

Without using any JavaScript library, this is how it looks when you display the data you input in real-time.

 <html> <head> <title>Vanilla JavaScript</title> </head> <body> Name: <input id="textInput" type="text" /> <br/> Your name is <span id="name"></span> <script> var textInputElement = document.getElementById('textInput'), nameElement = document.getElementById('name'); textInputElement.addEventListener('keyup',function(){ var text = textInputElement.value; nameElement.innerHTML = text; }); </script> </body> </html> 

JQuery

With jQuery, displaying the data you input becomes much simpler since most of the back and forth is handled by jQuery. Thus, enabling you to write less code.

 <html> <head> <title>jQuery</title> <script src="http://code.jquery.com/jquery-2.1.1.min.js"></script> </head> <body> Name: <input id="textInput" type="text"/> <br/> Your name is <span id="name"></span> <script> $  ('#textInput').on('keyup',function(){ $  ('#name').html($  ('#textInput').val()); }); </script> </body> </html> 

AngularJS

AngularJS takes everything up a notch. Not only is the framework lightweight, the way you write your HTML becomes easier too.

 <!DOCTYPE html> <html ng-app> <head> <script src="angular.min.js"></script> <title>AngularJS</title> </head> <body> Name: <input type="text" ng-model="name" /> <br /> Your name is {{ name }} </body> </html> 

As demonstrated above, the beauty of AngularJS lies in making you write less code while maintaining integrity for your application. There is little back and forth across the code, since most of the stringing up of modules is done by AngularJS. Another noteworthy thing is that you don’t have to manipulate the controllers in order to make changes on the view.

Limitations of AngularJS

AngularJS is not all sunshine and rainbows. If you are aiming to create an application that does simple calculations – a calculator, a puzzle game, animations, dynamic forms and the like – then AngularJS is the framework you are looking for.

However, if you are building a big and intensive application like a management tool, you might want to veer off from AngularJS since it’s not developed for that, or at least use other frameworks in conjunction.

AngularJS is built for rapid prototyping, specifically for generic applications, but there are instances when you can use it to build applications of larger scales, but that is yet to gain popularity.

AngularJS Resources

Learn the fundamentals of AngularJS at CodeSchool. It’s a free course that is sponsored by Google. It teaches one how AngularJS can be used from many different angles. Don’t forget to check out AngularJS’ YouTube channel where the developers themselves publish tutorials and news updates.

But if you are more of a documentation sort of developer, you might want to check out the AngularJS API documentation. For people who are proficient in JavaScript, this documentation should be easy enough to breeze through.

You don’t need to reinvent the wheel either as there are a lot of modules that you can use and improve at ngmodules.org’s repository.

If you have the funds and are serious about learning AngularJS, I highly recommend checking AngularCourse.com with its 7 hour HD video course that will help you build a real-life product.

Are you a redditor? If you are, you can check out /r/angularjs for community discussion and support.

AngularJS In Action

ngSweetAlert

It’s a very sweet replacement for JavaScript’s monotonous “Alert”.

Angular-nvD3 Charts

As previously mentioned, you can use AngularJS for simple to intermediate calculations. Using Angular-nvD3, you can customize your charts according to your needs.

Shaking Login Form

You can even spice up your forms while having validation. Don’t forget to check out the tutorial!

AngularJS Sliding and Word Search Puzzle

This simple puzzle shows how flexible and simple AngularJS is. Don’t forget to fork it on Github as well.

2048 Game

Remember this game? It’s 2048 and the number is nowhere to be seen because I don’t want to get addicted again. The game has been remade using AngularJS. How cool is that? Check out the tutorial and learn for yourself!

Conclusion

AngularJS is a powerful framework that can help developers expedite development of web applications. The use of AngularJS is becoming more and more popular as the days go by, and I highly recommend hopping on the trend as there is a dynamic and helpful community out there waiting for you to join!





hongkiat.com

Android’s pursuit of ‘more everything’ is getting out of hand

The stage was set for a glorious battle of the 6es this fall as Apple’s iPhone 6 was preparing to take on Google’s Nexus 6 to determine the fate of the mobile world. But Google dodged the direct confrontation by making its new premier Android device an enormous 6-inch slate that barely qualifies as a phone. There’s nothing wrong with big phones, but there’s something fundamentally broken about the single-minded pursuit of larger sizes that has characterized Android history so far.

Consider the three best Android phones of 2013: the 4.7-inch Moto X, the 5.2-inch LG G2, and the 5-inch Nexus 5. Each one of them has added at least a third of an inch to its screen size in its 2014 iteration and in the process lost something valuable. The old…

Continue reading…

The Verge – All Posts

America’s biggest police departments are getting spy gear through private charities

Many Americans have recently expressed concerns with the increasing use of military gear by police departments in this country, especially in the wake of the police response to protests in Ferguson, Missouri (protests that were themselves sparked by a lethal police shooting). While it is very easy to focus on militarization after seeing jarring pictures of police pointing automatic rifles at demonstrators, a separate but no less questionable practice has been quietly taking root at some of America’s biggest police departments in the past decade. As ProPublica reports, the police departments of New York City, Los Angeles, Atlanta, and Oakland have all turned to private police foundations in recent years to acquire new crime fighting and…

Continue reading…

The Verge – All Posts