Javascript News

Syndicate content
Pipes Output
Updated: 12 hours 5 min ago

Practical CoffeeScript: Making a Tic-Tac-Toe Game

Mo, 2015-08-03 20:00

CoffeeScript is a tiny little language that compiles to JavaScript. There is no interpretation at runtime since you write CoffeeScript, compile it to JavaScript and use the resulting JavaScript files for your app. You can use any JavaScript library (e.g. jQuery) from within CoffeeScript, just by using its features with the appropriate CoffeeScript syntax. CoffeeScript can be used both for writing JavaScript on the front-end and JavaScript on the back-end.

So Why CoffeeScript? Less Code

According to the Little Book on CoffeeScript, CoffeeScript’s syntax reduces the amount of characters you need to type to get your JS working by around 33% to 50%. I will be presenting a simple Tic-Tac-Toe game created using CoffeeScript (you probably already guessed this from the title) which in its raw CoffeeScript format contains 4963 characters, whereas the compiled JavaScript code contains 7669 characters. That is a difference of 2706 characters or 36%!

Faster Development Time

Because you write shorter, less error-prone (e.g. variables are auto-scoped, meaning you can’t accidentally overwrite globals by omitting var) you can finish your projects quicker. CoffeeScript’s terse syntax also makes for more readable code, and ultimately code which is easier to maintain.

Getting Started

In this article, we will be building a simple Tic-tac-toe game with CoffeeScript and jQuery. If you want to read up on the syntax before examining a practical case, I suggest my Accelerate Your JavaScript Development with CoffeeScript article here at SitePoint. This also details how to install CoffeeScript via npm (the Node Package manager).

As ever, all of the code from this tutorial is available on GitHub and a demo is available on CodePen or at the end of the tutorial.

The most common CoffeeScript commands you will be using are:

coffee -c fileName will compile the CoffeeScript file to a file with the same name but with a .js extension (CoffeeScript files typically have .coffee extension).

coffee -cw fileName will watch for changes in a file (whenever you save the file) and compile it.

coffee -cw folderName/ will watch for changes to all .coffee files in the folder and compile them in the same directory when there are any changes.

Finally, it is handy to compile CoffeeScript from a folder with .coffee files to a folder containing only .js files.

coffee -o js/ -cw /coffee will watch for changes in all .coffee files located in the coffee folder and place the output (JavaScript) in the js folder.

If you are not into terminals, you can use a tool with a GUI to handle your CoffeeScript files. For instance, you can try Prepros on a free unlimited trial (although you have to buy it if you like it). The image below shows some of the options it provides:

You can see that Prepros does all the work for you—it sets up watchers so your .coffee files will be compiled to JS, it allows you to use Uglify JS which will minify/compress your code, it can automatically mangle variables and it supports Iced CoffeeScript. Prepros can also be used for CSS preprocessors such as Less and Sass and template engines like Jade.

The Game

Let’s start with the markup:

[code language="html"]

Tic Tac Toe ...



[/code]

The game’s interface consists of the following:

  • A header which briefly describes the game
  • A div element with the id of board which is where the 3x3 squares will be located
  • A div element with a class of alerts which is where the game status will be shown
  • A div element with a class of notifications which will show who is playing X and O, along with the general player statistics.
  • A form which will be displayed only when the game loads and will prompt the players to enter their names.

In accordance with best practice, both jQuery and the script that makes our app tick are loaded before the closing body tag.

The Styling

Using CSS, we can make the nine squares involved appear in a 3x3 grid by floating each square and clearing every 4th one.

[code language="css"]
.square:nth-of-type(3n + 1) {
clear: both;
}
[/code]

We can also add a different color to the squares depending on whether they have the class x or o (which is added using JavaScript).

[code language="css"]
.square.x {
color: crimson;
}

.square.o {
color: #3997ff;
}
[/code]

CoffeeScript in Action

Fore reference, you can find the main CoffeeScript file here.

You can see our Tic-Tac-Toe app starts with $ ->, this is equivalent to the shorthand for jQuery’s function that executes code when the DOM is ready: $(function() { ... });.

CoffeeScript does not rely on semicolons and braces but on indentation. -> tells CoffeeScript that you are defining a function so you can start the body of the function on the next line and indent the body with two spaces.

Next, we create an object called Tic which itself contains an object called data. You can see that braces or commas are not obligatory when creating objects, as long as you indent the properties correctly.

[code language="js"]
$ ->
Tic =
data:
turns: 0
x: {}
o: {}
gameOver: false
[/code]

The turns property will hold the total number of turns taken in the game. We can check whether it holds an even or uneven number and in that way determine whether it is the turn of X or O.

The x and o properties are objects and will contain data relating to the number of X’s or O’s on the three axes that are important for the game: horizontal, vertical and diagonal. They will be updated on every move through the checkEnd method to represent the distribution of X and O on the board. The checkEnd method will then call checkWin to determine if there is a winner.

After that we have a method inside the Tic object that will get everything up and running:

[code language="js"]
initialize: ->
@data.gameOver = false
@.setPlayerNames()
@.retrieveStats()
@.assignRoles()
@.prepareBoard()
@.updateNotifications()
@.addListeners()
[/code]

Notice the use of @ which compiles to the JavaScript keyword this. As illustrated in the first property of initialize, you can skip the dot after the @ keyword when setting or calling a property or method.

By giving the methods sensible names, we have a fair idea of what they are doing:

  • setPlayerNames stores the values entered by users in the inputs into the data object.
  • retrieveStats retrieves the player’s statistics from localStorage and sets them up in the data object.
  • assignRoles determines who is playing X and who is playing O.
  • prepareBoard hides the form, removes any notifications, empties the board and fills it with nine empty squares.
  • updateNotifications updates the UI with information about who is playing X and who is playing O, as well as the player’s statistics.
  • addListeners attaches the event listeners, so that we can respond to players making a move.

Continue reading %Practical CoffeeScript: Making a Tic-Tac-Toe Game%

The Entrepreneur’s Guide to Quora

Mo, 2015-08-03 18:03

Got questions? Well, Quora has the answers. This Q&A site has 500,000-plus topics and millions of threads, and thanks to its highly engaged, knowledgeable user base, it’s garnered a reputation as a “knowledge market,” “an extended family, a virtual salon, a potential revolution in knowledge.” And it’s fantastic for entrepreneurs. As Wired reporter Gary Rivlin […]

Continue reading %The Entrepreneur’s Guide to Quora%

Running Windows 10 IoT Core on a Raspberry Pi

Mo, 2015-08-03 18:00

It has been the week that Windows 10 was officially released worldwide and there was one aspect of Windows 10 that I was especially intregued by - the world of the Internet of Things (IoT). Windows 10 has a slimmed down version called "Windows 10 IoT Core" focused on the IoT. It is not a full version of Windows 10 by any means, instead it is focused on powering embedded systems. I had a very strong urge to give this OS a test drive and see what it'd be like, so I got out my Raspberry Pi and installed it!

If you're a developer who wants to get involved with the IoT and you are used to the Microsoft development ecosystem (C++ or C#, Visual Studio, Win32 Console, Azure... etc), Windows 10 IoT Core is exactly what you're looking for. If you're a developer that is used to Unix based systems, JavaScript, Node and Arduino-style "Wiring" code like myself, it's going to be a bit of a learning curve.

Approaching this whole endeavour from a non-Microsoft focused development background made this a challenge but also quite an interesting experience. It was nice to try out an alternative method to developing for the IoT. Whilst going through the whole process, there was a lot of documentation on how to install Windows 10 on the Raspberry Pi and get started, but various links and errors led me astray at times. In short - it was messy and confusing for the new guy. Definitely took a lot longer than I'd expected it to. In the hope that my own struggles would not be in vain, I've documented below how I installed Windows 10 IoT Core on my Raspberry Pi and the various issues I faced. Maybe there'll be a developer just like me in the same boat who'll stumble upon this article and gain an hour or two that would otherwise have been spent in confusion!

At the end, we'll get our Raspberry Pi to dance exuberantly! Well... as exuberantly as two servos with pipe cleaners attached can dance.

What You'll Need

To get the basic set up of Windows 10 IoT Core along with our dancing servo demo working, you'll need the following:

  • A Raspberry Pi - Mine in particular was a Raspberry Pi 2 Model B.
  • A 5V micro USB power supply - Most Raspberry Pi users should have one of these. Microsoft say it needs at least 1.0A current, or more than 2.0A if you're attaching a lot to it. I personally just used the one that came with my Pi and all was well.
  • An 8GB or greater micro SD card - This will hold the Windows 10 IoT Core OS and your files. In order to ensure the card is fast enough to run the OS, make sure you get one that is class 10 or better. Microsoft suggests the Samsung 32GB EVO or the SanDisk 16GB Ultra Micro SDHC (I had the second one, conveniently enough that's the one I was using on my Pi beforehand and it worked perfectly).
  • A Windows 10 PC - In order to do any of this development, you'll need Windows 10 on your computer. I was part of the Insider Preview program and thus already had a version I could use.
  • Microsoft Visual Studio Community Version 14.0.23107.0 D14Rel - I'll detail how to get this soon.
  • Windows IoT Core Project - I'll provide details on how to download these too.
  • Windows IoT Core ISO - It's a little over 500MB, so if you've got a slowish connection like me - you might want to get this downloading as soon as you can. Download the ISO for Windows IoT Core here.
  • Putty or another SSH client - Only if you want to SSH to the Pi. You could use PowerShell instead.
  • A HDMI cable and a monitor to connect it to - You'll need one to set up the install process and see your IoT app in action at the end.
  • A USB keyboard and USB mouse - These will be your controllers for the Raspberry Pi, when we're not SSHing into it.
  • An ethernet cable - Sadly, it looks like only the official Raspberry Pi Wi-Fi adapter has the potential to work with Windows 10 IoT Core so far (I can't guarantee that either as I don't have that one!), so in order to connect to your network you'll need to plug it in via the Ethernet port.
  • A micro SD card reader - You'll need to be able to read that micro SD card on your PC. I used a micro SD adapter to plug it into my PC.
  • Two servos - I used micro servos similar to these servos at SparkFun. Most servos will work here, the main difference will be how far they can rotate.
  • Six male to female jumper wires - These are what we'll need to connect the servos to the Raspberry Pi's GPIO port. If you aren't sure what these look like, here are some on the SparkFun site to reference.
  • Two pipe cleaners - These are optional, if you want to give the servos arms, add some pipe cleaners!
Installing Visual Studio

One thing that threw me whilst installing everything is that the version linked to in some of the Microsoft documentation isn't compatible with the Windows IoT Core Project Templates due to an updated Microsoft signature. The correct version you'll want to make sure you've installed is Microsoft Visual Studio Community Version 14.0.23107.0 D14Rel. Go to the Visual Studio website and download the "Community 2015" version. This should be the compatible version, rather than any linked to directly in documentation.

If you have installed Microsoft Visual Studio and you are receiving the error of "#SignatureDescription could not be created for the signature algorithm supplied", then you've got the incompatible version of Visual Studio like the one I'd initially downloaded. All I can say to you is... you're not alone! Grab a coffee and/or visit the outside world for a bit as this new Visual Studio does another run through of the installation process.

When you install it, choose "Custom" installation.

It will ask what features you would like to install. Make sure you've got Windows and Web Development > Universal Windows App Development Tools > Tools and Windows SDK 10.0.10240 checked like in the below screenshot:

Installing Windows IoT Core Project

You can find the Windows IoT Core Project files you'll need at the Windows IoT Core Project Templates MSDN page. Just click "Download" and you'll have them:

Enabling Developer Mode on Windows 10

If you try to do much in Visual Studio at the moment, you'll see this error message:

This is another area where I was caught off guard a bit. The initial documentation I tried led me into the "Update & Security" settings in Windows 10. However there is a bug in my version of Windows 10 where any time you click the "For developers" link to enable it, the Settings window crashes and closes. So this method wasn't the best option.

Instead, I had to do it via group policies:

  1. First, open up a command prompt window with administrator priveleges. To do so in Windows 10, I found it easiest to enter "Command Prompt" into the Cortana field in the taskbar, right click it and choose "Run as administrator":
  2. Type in Gpedit.msc
  3. Then, navigate to Local Computer Policy > Computer Configuration > Administrative Templates > Windows Components > App Package Deployment.
  4. Open up the policy for "Allow all trusted apps to install" and click the "Enabled" radio button:
  5. Do the same for the policy on "Allows development of Windows Store apps and installing them from an integrated development environment (IDE)"
  6. Restart your computer to enable these policies.

If you have difficulties with this method, check the Enable your device for development page in Microsoft's documentation for other potential ways to enable it.

Installing Windows IoT Core On Your Pi

The first thing you'll need to do is download the ISO for Windows IoT Core. If you started downloading it from earlier in the article, hopefully it's all finished downloading already and you're ready to go!

From there:

  1. Double click it to get Windows 10 to mount it as a virtual drive (this is a really nice feature of Windows 10)
  2. Go to the new drive that has popped up and install "Windows_10_IoT_Core_RPi2.msi".
  3. Once that is complete you can eject your virtual drive from the system.
  4. Next, we want to put Windows 10 IoT Core onto your Raspberry Pi's micro SD card. Place that into your SD card reader (or adapter of some kind if your PC doesn't have a reader for it).
  5. Type in "WindowsIoT" into the taskbar and choose "WindowsIoTImageHelper":
  6. It will bring up a lovely bright blue window which lets you select your SD card and an ffu file. The ffu file you want was extracted by the Windows_10_IoT_Core_RPi2.msi program. You can find the file you need at C:\Program Files (x86)\Microsoft IoT\FFU\RaspberryPi2\flash.ffu. Make sure there is NOTHING you need on this flash drive and then hit "Flash":
  7. When it's done, eject the drive nicely via the "Safely Remove Hardware" option in Windows and then safely remove it.
  8. Put it into your Raspberry Pi and connect up your HDMI monitor, USB keyboard and mouse.
  9. When you're preparing to turn on the Pi, make sure you don't have any other peripherals connected. My Pi wouldn't boot at first, it only booted once I removed my Raspberry Pi camera and USB Wi-Fi module.
  10. When you've got them all connected, connect up the power supply to your Raspberry Pi and it should begin to boot up.
Weird warping or stretching screen?

If you have issues where your screen's display looks weirdly warped and stretched, you'll need to make a slight adjustment to the settings for your Windows 10 IoT Core. For me, the display worked fine on one of my screens but then another went really warped and weird. To fix it:

  1. Take the power out from your Pi and plug your SD card back into your PC.
  2. In the SD card, there'll be a file called config.txt. Open that up.
  3. There is a line in this file that starts with hdmi_group =. If it says hdmi_group = 2, try switching it to hdmi_group = 1 and vise versa. One of those should work on your screen.
  4. Once you've changed the 1 to a 2 or the 2 to a 1, safely remove it from your PC and plug it back into your Pi. Connect the Pi to power and you should now be able to see the display in its full glory!

If that still doesn't work, this post on the Raspberry Pi forums might provide you with a bit more info.

Connecting To Your Raspberry Pi via SSH

There are two ways you can connect to your Pi remotely from your PC via command line style input. Either via PowerShell or via SSH. Most articles cover PowerShell but I was more familiar with SSH and figured why not take the road less travelled? It also felt like the better long term option in order to keep the way I access all of my IoT devices and servers consistent as most of them work via SSH too.

If you would prefer to use PowerShell, see the Microsoft PowerShell documentation.

In order to SSH to the Pi, take a look at the screen running your Raspberry Pi and get the IP address of it. Then open up Putty and put in that IP address like so:

Make sure that SSH is selected and then click "Open". Click "Yes" to any security alerts that pop up about the server's host key.

If that works, you'll have a Terminal window ready and waiting for a username and password. Your Pi's username will be "Administrator" and the password will be "p@ssw0rd". If it works, you'll end up at C drive:

[bash]C:\>[/bash]

Update The Default Administrator Password

Clearly you don't want the Administrator password to stay as "p@ssw0rd" for security reasons. So once you've logged in, run the following command, substituting [superstrongpassword] with your own super strong password:

[bash]net user Administrator [superstrongpassword][/bash]

Rename Your Pi Device

The default name is a little boring. Feel free to rename the Pi to something more fun:

[bash]setcomputername [yourpreferreddevicename][/bash]

Restarting Your Device

That name won't be used until you restart your Pi. To do that via SSH, type in this command:

[bash]shutdown /r /t 0[/bash]

Connecting Our Servos To The Pi

I've connected my servos directly to my Pi for my quick demo using my male to female jumper wires like so:

Others have connected servos to a Raspberry Pi via a GPIO pin connector onto a breadboard (see Adafruit's example) and some connect it up to a breadboard first. Choose your own personal preference. It will work either way as long as the pins correspond correctly to the app's definitions of them.

If you'd like to check which pins correspond to which output, Microsoft have a lovely page which defines the Raspberry Pi 2 Pin Mappings. The numbers you'll refer to in your code on that page are the ones like "GPIO 27".

Our Demo Code

Our IoT Demo Code is available on GitHub. Download that if you're already familiar with the process and just want to see it running.

Getting Our Dancing Demo On Our Pi

Our Raspberry Pi by this point is ready to go. If you type in "Windows IoT" into the Cortana taskbar search box again, you'll see one of the options other than the WindowsIoTImageHelper one is WindowsIoTCoreWatcher.

If you open that up, you'll be able to see whether your Pi is able to be found by your PC:

After all the previous steps, your Pi should appear. If it wasn't here, you wouldn't be able to SSH into it. I point out this screen only because it can be useful if your Pi times out or loses network connectivity for some reason whilst your developing. It's a good tool to know about!

Continue reading %Running Windows 10 IoT Core on a Raspberry Pi%

Video: Shorthand if-else Conditionals with PHP

Mo, 2015-08-03 17:30

In this screencast I'll show you how to make your code more succinct by using the ternary operator to write shorthand if-else conditional statements in PHP.

Loading the player...

Continue reading %Video: Shorthand if-else Conditionals with PHP%

6 Free Online Tools to Make Your Life Easier

Mo, 2015-08-03 17:00

We're all on the lookout for ways to do things better. In this article, I'm going to take you through a roundup of some of the less well known tools that almost any web designer can benefit from. Each one can solve common design challenges while also increasing your productivity.

Let’s start!

Typegenius

I’m sure all designers at some point in time, have had difficulty in choosing which fonts work best together. That’s why I want to start with MunoCreative's Typegenius to the list.

Typegenius is an online tool which helps designers “find the perfect font combo in just few clicks. You only need to enter the name of the typeface you are using and then click on “view matches” to discover a selection of font combinations which work well in concert. Notably, the output you receive is a simple example text document which uses your font selections for the headings and body copy, giving you a good sense of the final result.

What I like most about this tool is the showcase of website designs which are already using the suggested combination with nice results.

I think to get the most out of Typegenius you should use its suggestions as a starting point for further research of typefaces to create a unique combination. For example, you can plug one of the suggested fonts back into the tool to discover other pairings.

I believe Typegenius - which is, of course, completely free - certainly warrants your attention.

Typeform

Typeform is an online app which helps you create beautiful forms for your website. Developing surveys, registration forms or questionnaires is no more a nightmare nor a time consuming process. With Typeform you can build almost everything just by dragging and dropping some ready-made elements in the editor.

The best part of Typeform is it encourages you to build user friendly, conversational and (dare I say it?) fun web forms. Questions are delivered one at a time and users can enter their own answer or choose from a set of multiple choice answers. What's more, these multiple choice answers can include icons, images or even GIF, and you can even set keyboard shortcuts so that the user can answer without even touching the mouse.

In particular, with Typeform you can create all the following structures:

  • Contact Forms
  • Surveys
  • Contests
  • Landing pages
  • Examination and Tests

Typeform is free for the basic account, but you can upgrade to a Pro account for $20/month. The Pro version adds some features to the form such as the upload of files or the creation of a custom thank you page.

In conclusion, if you want to create great forms, give Typeform a go.

Pixate

Pixate is an online tool designed to reduce the gap between designers and developers who work together on a same application project. Pixate gives you the ability to create complex UI animations and interactions for iOS and Android without writing a line of code.

To make an element interactive, you only need to choose the gesture you prefer from a panel and drop this on the element. Pixate provides seven default interactions/gesture: drag, tap, double tap, long press, rotate, pinch and scroll. You can then bind an animation to each interaction.  

Another important feature of Pixate is the familiar use of layers which are extremely useful in managing different shapes and elements.

For me, what distinguishes Pixate from other similar tools is the simplicity of use: every aspect of the app can be quickly understood even by a non-experienced designer. Moreover, on the official site, you can find several video tutorials, some demos and a useful user guide which explains all the functions of the app.

Another reason to use Pixate?

It is completely free.

Continue reading %6 Free Online Tools to Make Your Life Easier%

Introduction to Elasticsearch in PHP

Mo, 2015-08-03 16:00

In this tutorial, we’re going to take a look at Elasticsearch and how we can use it in PHP. Elasticsearch is an open-source search server based on Apache Lucene. We can use it to perform super fast full-text and other complex searches. It also includes a REST API which allows us to easily issue requests for creating, deleting, updating and retrieving of data.

Installing Elasticsearch

To install Elasticsearch we first need to install Java. By default, it is not available in the repositories that Ubuntu uses so we need to add one.

sudo add-apt-repository ppa:webupd8team/java

Next, we execute the following to update the sources.

sudo apt-get update

Once that’s done, we can install Java.

sudo apt-get install oracle-java8-installer

Next, let’s download Elasticsearch using wget.

wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.5.2.tar.gz

Currently, the most recent stable version is 1.5.2 so that is what we used above. If you want to make sure you get the most recent version, take a look at the Elasticsearch downloads page.

Then, we extract and install.

mkdir es tar -xf elasticsearch-1.5.2.tar.gz -C es cd es ./bin/elasticsearch

When we access http://localhost:9200 in the browser, we get something similar to the following:

{ "status" : 200, "name" : "Rumiko Fujikawa", "cluster_name" : "elasticsearch", "version" : { "number" : "1.5.2", "build_hash" : "62ff9868b4c8a0c45860bebb259e21980778ab1c", "build_timestamp" : "2015-04-27T09:21:06Z", "build_snapshot" : false, "lucene_version" : "4.10.4" }, "tagline" : "You Know, for Search" }

Continue reading %Introduction to Elasticsearch in PHP%

Introducing Theme Juice for Local WordPress Development

Mo, 2015-08-03 15:00

Like most WordPress developers, I used MAMP for local development environments. MAMP works well for some people, but it doesn’t really allow you to create reproducible development environments. Your environment is really at the will of both MAMP itself (i.e. your settings), as well as which operating system you’re developing on; and that’s really not a good thing.

After awhile, the MAMP workflow isn’t all that it’s cracked up to be, especially once you begin needing to share environments between team members. Suffice it to say, we left the MAMP workflow behind once we were introduced to the ubiquitous Vagrant. I won’t get into the details of that affair, because there’s already a great article written on that happening to somebody else. But how do you ease yourself into Vagrant, when you’re so used to your beloved MAMP workflow?

Enter, Theme Juice (or tj), a command line utility for modern WordPress development. It takes the pain out of local development by taking advantage of Vagrant and an Apache fork of VVV called VVV-Apache as the virtual machine. It allows you to generate an unlimited number of local development projects, manage their dependencies, and even handles deploying them, all from the command line.

Requirements

This project requires Vagrant and VirtualBox to be able to create virtual machines for local development. Please download and install both of these before following along with this article.

Continue reading %Introducing Theme Juice for Local WordPress Development%

Why You Should Use Neo4j in Your Next Ruby App

Mo, 2015-08-03 14:00

I have needed to store a lot of data in my time and I've used a lot of the big contenders: PostgreSQL, MySQL, SQLite, Redis, and MongoDB. While I've built up extensive experience with these tools, I wouldn't say that any of them have ever made the task fun. I fell in love with Ruby because it was fun and because it let me do more powerful things by not getting in my way. While I didn't realize it, the usual suspects of data persistence were getting in my way. But I've found a new love: let me tell you about Neo4j.

What is Neo4j?

Neo4j is a graph database! That means that it is optimized for managing and querying connections (relationships) between entities (nodes) as opposed to something like a relational database which uses tables.

Why is this great? Imagine a world with no foreign keys. Each entity in your database can have many relationships referring directly to other entities. If you want to explore the relationships there are no table or index scans, just a few connections to follow. This matches up well with the typical object model. It is more powerful, though, because Neo4j, while providing a lot of the database functionality that we expect, gives us tools to query for complex patterns in our data.

Continue reading %Why You Should Use Neo4j in Your Next Ruby App%

Video: Your First Backbone.js Model

Fr, 2015-07-31 20:00

In this video I'll be discussing Backbone.js models, a vital component to work with data; define validation rules and default values. Think of models as of blueprints of your data.

I will show you how to create your first model by employing extending mechanism. That basically means copying properties from one object to another and further redefining them. Once you have that under wraps, I will demonstrate other various methods to work with models: getters and setters, binding events and more. After watching this video you will have a basic understanding of models and also see Backbone.js in action.

If you like this video then you may like my new course Getting Started with Backbone.js, available on SitePoint's Premium. This is a sample lesson from the course.

Happy learning!

Loading the player...

Continue reading %Video: Your First Backbone.js Model%

Hack Your Productivity With These 9 Gmail Tips

Fr, 2015-07-31 17:52

Watching my business grow is an amazing feeling. Dealing with the administrative headaches that come along with it SUCKS. Pitching new clients, managing existing ones, maintaining staff, keeping an eye on the books and holy shit – the emails! I mean, really, people are out of control with emails, aren’t they? A friend of mine […]

Continue reading %Hack Your Productivity With These 9 Gmail Tips%

10 Time-saving Tips for Pythonists

Fr, 2015-07-31 17:00

Python is a beautiful language, able to inspire love in its users. So if you're looking to get into programming, or if you're a bit tired of C++, Perl, Java and the rest, I recommend you give Python a try.

Python has many features that make it attractive to programmers. It's easy to learn, object oriented, byte-compiled, free and open-source. It also has run-time type checking, full and fast support, and extensive libraries for performing various tasks.

Efficiency with Python

In this article, I want to highlight some of the ways you can save time in Python and thus maximize productivity.

In preparation, I quizzed several Pythonists on their best time-saving tips. Here are the results …

1. Don’t Use Semicolons

Since using semicolons is considered optional in Python—as opposed to other object-oriented programming languages—you don’t need to end each statement of your code with a semicolon.

This may seem simple and not really time wasting; but once your code stretches into thousands of lines, all these semicolons can get a bit distracting, and it's a lot of unnecessary typing.

2. Get a Good Code Editor

Choosing the right Python editor can be a huge time saver. Many new Python programmers are confused over which code editor to pick—especially with so many available.

It's very disruptive to get used to one editor and then have to change to another, so it's best to start with a good one. Make sure whichever you choose does flake8 and PEP8 in real time.

For guidance on which editor to choose, see my previous article on Which Code Editors Do Pythonists Use?

3. Follow the Python Code Style

Following the Python code style can enhance the readability of the code, and thus saves time while walking through your code. (The design philosophy of Python emphasizes the issue of code readability.)

Continue reading %10 Time-saving Tips for Pythonists%

The State of Accessibility in PHP Tools

Fr, 2015-07-31 16:00

Usually when I tell people that I’m blind, many people ask me how I can use the computer. “Is someone reading you my messages?” I remember someone asking. Many people imagine that I have this super-nifty speech recognition software that I can just talk to, and it would do anything, even write code. Imagine dictating code to a speech recognition system!

I gave an answer on Quora, to someone who had asked How does a visually impaired computer programmer do programming? I recommend you go through that answer to have a better context on what I’ll be talking about in this post. As is my habit, though, I’ll still point out the important bits here, so if you don’t feel like clicking on that link, don’t worry!

Before I get to the comparison, allow me to give you a few facts so that we are all on the same page. Feel free to skip forward if you already know these points, but I’ve found that a lot of people don’t, and I’m going to start with those.

How do the blind use computers?

They use screen readers. As the name implies, these applications read the screen through synthesized speech, and they also have an optional Braille output through a Braille display. Both of these options (speech and Braille) have to go through the screen reader, though, so if the screen reader can’t see the content, it can’t display it through either of these outputs.

How do you type? How do you use the mouse?

The answer to both these questions is, “through the keyboard”. Our screen readers have very specialized keystrokes that allow us to move the mouse, click, hover on an item, and jump around in web documents (by links, h1-6 headings, lists and list items, form fields and many more).

Continue reading %The State of Accessibility in PHP Tools%

3 Options for Creating Mobile Apps Without Coding

Fr, 2015-07-31 15:00

There was a time when mobile application development was only for the elite programmer (i.e. people who knew the native platform language). With the dawn of hybrid mobile application technology, it was possible to create mobile applications using HTML, CSS and JavaScript. Hybrid application development made it possible for non-mobile developers to get their hands dirty with mobile app development.

But what about those people who don't have any prior programming knowledge? Can they make a mobile applications on their own?

They certainly can.

Continue reading %3 Options for Creating Mobile Apps Without Coding%

Design Secret #4: Taking Advantage of Behance Mobile Apps

Fr, 2015-07-31 14:00

We all love Dribbble, but lots of designers overlook the power of the Behance Network. Daniel looks at some of the neat tricks this quiet achiever can deliver.

Continue reading %Design Secret #4: Taking Advantage of Behance Mobile Apps%

Video: Populating a Table with Data

Do, 2015-07-30 20:00

In this video I'll show you how to populate a table with data.

Loading the player...

Continue reading %Video: Populating a Table with Data%

Getting started with Ember and Ember CLI

Do, 2015-07-30 20:00

Ember has gone through a lot of changes over the years. One of the biggest ones has been the introduction of the Ember CLI, a command line utility built for Ember. It combines several features including generators, minifiers, CSS preprocessor compilers, autoreload, and ES6 module loaders. This command line tool will help you reduce the time spent on setting up some of your tools such as Grunt and Gulp. We can say that it could be a good alternative to these tools for any of your brand new Ember projects.

In this article, you’ll learn how to build a simple contacts manager application using Ember CLI. This tutorial will be a bit different from the other articles about Ember I’ve published on SitePoint since they did not ship with Ember CLI. However, most of those concepts still apply, so I suggest you to take a look at them and follow on.

The complete code for this article is available on GitHub.

Continue reading %Getting started with Ember and Ember CLI%

Foundation Board Update – Renewed Focus on Key Priorities

Do, 2015-07-30 18:57

In June, the jQuery Foundation Board of Directors held an in-person meeting, hosted by Famous in their San Francisco offices. During the meeting, the Board agreed to the following priorities to fulfill the Foundation’s Mission of improving the open web, making it accessible for everyone, through the development and support of open source software, and collaboration with the development community.

Our priorities are:
  1. Diversity: Open source depends on contributions. An organization’s vitality can be destroyed by having a closed group that excludes or even actively antagonizes newcomers. There is incredible value in having a diverse set of contributors with different cultures, backgrounds, perspectives, and skill sets. The jQuery Foundation is committed to improving diversity at all levels, from the development community in general to the projects we host and all the way to our own board, which we acknowledge isn’t very diverse today.
  2. Accessibility: As with diversity, this goal is again in the spirit of inclusiveness. Web technology has many features to make it friendly to users with sight, motor, or cognitive issues. Many web developers don’t know about them, or defeat them without realizing the implications. We want to change that. Last month’s jQuery SF conference had several excellent speakers who showed what the web can be like for some users: https://www.youtube.com/watch?v=HWzEF1P-bvI#t=7h34m30s
  3. Education: This goal crosses all of our priorities and encompasses many different subjects. By educating developers, both on the world of open source and also on the issues of diversity and accessibility, we can make the web an inclusive place.
We will achieve these goals by focusing our efforts on three key areas:
  1. Actively Recruiting New Projects: As you can tell, the jQuery Foundation’s mission goes far beyond the original jQuery projects. We are looking to host projects that we can help. The Foundation offers projects greater visibility, a voice in the standards process, help in managing their community, infrastructure such as a CDN, and other benefits. Projects remain autonomous, the Foundation doesn’t dictate the project’s goals or roadmap. We can, however, offer financial support for meeting mutually agreed upon project goals.
  2. Defining and Delivering Essential (basic through advanced) Web Developer Education: We want to help developers learn how to contribute to open source projects, how to run open source projects, and how to build web sites or applications that apply best practices and beyond that, we want to educate developers on the importance and implementation of diversity and accessibility in their projects. Finally, we want to get the word out about how the jQuery Foundation can help developers do their jobs better.
  3. Growing Our Impact through Outreach: The jQuery Foundation can only accomplish its goals with the support of companies and individuals who believe in the mission. If you or your company is interested in joining us to improve the web development community, please get in touch info@jquery.org. Like the open source projects we host, the jQuery Foundation itself is powered by memberships, volunteers and donations! Those of you who have already contributed, we thank you for supporting the mission.

jQuery Foundation Project Updates

Do, 2015-07-30 18:57

In order to make it easier for jQuery Foundation Members and Web developers to quickly stay abreast of all our projects, we will periodically publish consolidated project updates here.

jQuery Core

Powering 2/3 of sites, jQuery is a fast, small, and feature-rich JavaScript library

Since last December’s release, the team has been hard at work on a major 3.0 release. This release – the alpha of which came out on July 8 – comes with many updates (including Promises/A+ compliant Deferreds) and bug fixes, and it finally removes some previously deprecated and underused features.

Links: download, meeting notes, full list of 3.0 changes

A big thank you to the core team and everyone who contributed – and will contribute – to the upcoming release.
Questions?  Contact Timmy Willison

Globalize

JavaScript library for internationalization and localization that leverages the official Unicode CLDR JSON data.

Globalize version 1.0 was released in April and provides developers with localized number formatting and parsing, date and time formatting and parsing, relative time formatting, currency formatting, and message formatting (with pluralization and gender support) that runs in browsers and Node.js, consistently across all of them.

One exciting thing the community is focused on is the ability to compile Globalize for production. This will enable applications to generate custom runtime code that is extremely small and fast.

Links: git, mailing list,
Questions?  Contact Rafael Xavier de Souza

jQuery Mobile

Unified, HTML5-based user interface system for all popular mobile device platforms, built on the jQuery and jQuery UI foundation

The team has been heads down on version 1.5.0, which will bring numerous improvements including:

  • A new standalone enhancer module for customizable, fast declarative initialization of any javascript including jQuery widgets and plugins.
  • Improved and re-written shared with jQuery UI including button, checkboxradio, and controlgroup and the accordion widget which will replace the current collapsible and collapsible set widgets.
  • All of jQuery Mobile’s widget will now also feature the classes option for improved customizability and theming.
  • Re-written table and navbar widgets
  • Greatly improved modularity

Check out full release plans here

Links: download, meeting notes

Questions?  Contact Alexander Schmitz

Esprima

High performance, standard-compliant ECMAScript parser written in JavaScript

In March, we released Esprima 2.1.0, introducing support for several new pieces of ES6 syntax. In the mean time, a lot of work has been done to complete its ES6 support (check the roadmap). We’ve also improved the testing infrastructure and workflow to make the codebase more contributor-friendly.

Links: git, mailing list

A big thank you to all those who contributed patches to this release: Ariya Hidayat, Bei Zhang, Brandon Mills, Mike Rennie, Mike Sherov.

Questions?  Contact Ariya Hidayat

jQuery UI

Curated set of UI interactions, effects, widgets, and themes built on top of the jQuery Library.

The team released jQuery UI 1.11.4 in March, bringing bug fixes for Draggable, Resizable, Sortable, Accordion, Dialog, Slider, and Tooltip.

We are focused now on support for Pointer Events, and splitting up UI Core and old jQuery support to enable smaller builds

Links: git, meeting notes
Questions? Contact Scott González

Chassis

Creating open standards for CSS libraries, JavaScript UI libraries, and web developers in general.

The team is working on its Phase One release which will involve an initial CSS Framework – this is planned for later this summer.

Work is also underway for a themeroller.

Links: git, meeting notes

Thanks to Micheal Arestad, Alexander Schmitz and Rohit Mulange

Questions?  Contact Sarah Frisk

QUnit

Powerful, easy-to-use JavaScript unit testing framework

The latest release, 1.18.0, made a lot of improvements to the HTML reporter, making it more efficient to debug failures. For example, a new diff algorithm makes it easier to spot the difference in failed expected/actual assertions.

We’re currently working on the js-reporters project, which QUnit will implement, along with hopefully many other JavaScript testing frameworks and tools. The goal is to standardize an API with events and event data for test runners. A tool like Karma could then adopt a single interface instead of having to support each testing tool individually.

If you want to help moving QUnit along, check out these issues.

Links: git, meeting notes

Questions?  Contact Jörn Zaefferer

PEP

PointerEvents Polyfill: a unified event system for the web platform

PEP’s First release (0.3.0) came out in April and the the project is presently working to automate and improve the W3C test suite.

Links: git, meeting notes,

Questions?  Contact Scott González

Get Some Credit!

Do, 2015-07-30 17:57
Submit Your Project for the jQuery Foundation Web Excellence Program

How awesome is your project/site/integration/app? Probably really awesome, otherwise, you wouldn’t be doing it, right?!?

The jQuery Foundation wants to tell the world about all the incredible things developers are doing with jQuery Foundation projects. That’s why we are launching the jQuery Foundation Web Excellence program.

Here’s how it works:
  1. You pick the category or categories you in which want to submit (See category descriptions below)
  2. Tell us about you, your company/project, and how jQuery Foundation projects help you make it happen
  3. We’ll highlight projects on the jQuery Blog and promote it on social media

What are you waiting for? Get the the visibility you and your project deserve!  Go to the Web Excellence Submission Form and submit your project Today!

Category Descriptions
  • All Around Rock Star: This category highlights the sites/apps that leverage any jQuery Foundation project to produce a stellar digital experience. Please highlight your approach to leveraging jQuery Foundation tools, libraries and resources stand-alone or in combination with other Open Web components and frameworks to solve real problems and delight users.
  • Mobile Masterpiece: This category highlights the sites/apps that use any jQuery Foundation project to engage consistently with users across all devices, including mobile.
  • Enterprise: Highlights the organizations leveraging any jQuery Foundation project to help their enterprise organization (5,000 and up employees) achieve strategic IT and/or business objectives (e.g.  system integration, uptime, compatibility/accessibility, revenue, cost reduction).
  • Top Speed: Highlights the organizations that use any jQuery Foundation project as part of a rapid project/product launch and/or to achieve fast site/app performance.  Do your users have a need for speed that jQuery Foundation projects help you deliver? Tell us about it!
  • Globetrotter: Showcases the sites, apps, systems or projects that best demonstrate the power of Globalize when implemented stand-alone or in combination with other jQuery Foundation projects.
  • Powered by jQuery: Showcases the SDKs and other toolsets that leverage any jQuery Foundation project as a dependency.
Rules & Terms:
  • There is no fee to enter
  • Only English language submissions will be accepted
  • Your entry must be submitted using the Submission Form
  • Please provide box/drive links to all graphics/visuals in your text answers, so the desired placement is clear
  • You may submit for multiple categories, but please make individual submissions for each desired category
  • jQuery Foundation reserves the right to change or cancel a category at any time
  • A selection of submitted entries will be publicly displayed on the jQuery Foundation web site and promoted via our social media channels
  • Submitting an entry gives the jQuery Foundation the permission and approval to leverage submitted content for Marketing and Public Relations purposes

Social Media Management App Showdown: Buffer vs Hootsuite

Do, 2015-07-30 11:06

Building a disruptive product leaves little time for anything else. Life suddenly becomes a repetitive routine of tests, fixes and upgrades. Above all, you are focused on providing an amazing experience for users. What many startup founders forget is that unless you share that story, consistently and in front of a relevant audience, all the […]

Continue reading %Social Media Management App Showdown: Buffer vs Hootsuite%