Javascript News

Syndicate content
Pipes Output
Updated: 48 weeks 6 days ago

Appserver – a Production-ready PHP-based Server

Mi, 2015-08-05 16:00

It has been just over a year and a half since the team at TechDivisionGmbH were interviewed here on Sitepoint about their paradigm changing PHP application server system called appserver.io. At the time of the interview, appserver was just breaking out as an alpha. Since then, a lot has happened and appserver is now GA as a production system, currently in version 1.0.5, with version 1.1.0 on the horizon.

You’re probably asking, “Why is appserver paradigm changing?”

The answer is, because it tackles the last frontier of PHP application development: high performance for large applications from a server resource optimization and collaboration perspective. This is the realm of PHP development which a good number of professional PHP developers have been calling for, like Manuel Lemos in his “PHP7 Features and Release Date” blog (see the section about a “Standalone Multi-threading Web Server”) and Fabien Potencier, father of Symfony, in his presentation “My Take on PHP”, where he notes he is also working on such an application server solution himself. Well, look no longer Fabien, we already have a really good solution with appsever.io.

Appserver Community Edition is licensed under the Open Source License 3.0. The TechDivsion team also offer a Professional Edition and an Enterprise Edition too.

Continue reading %Appserver – a Production-ready PHP-based Server%

Live Q&A with Guilherme Müller on HTML

Mi, 2015-08-05 07:45

Join us for a Chat with an Expert!

Guilherme Müller, the creator of three of our most popular HTML courses on SitePoint Premium, is joining us for an exclusive Q&A session on the SitePoint Forums on Wednesday, 5th August at 4pm (EST).

This is the perfect opportunity to hear from an HTML expert! Join us on Wednesday to chat with Guilherme live in the forums, or submit any burning questions early on the Forums or via Twitter.

Want to know more? Here's a Q&A about the Q&A:

Q. How do I chat with Guilherme?
A. To participate in the chat, or to submit a question early on the Forum, you'll need to log in to the SitePoint Forums (or create an account if you don't have one yet).

Q. I'd rather not create an account for the Forums. Is there another way to participate?
A. No worries! You can view the conversation on the Forum without logging in, and tweet us any questions you'd like Guilherme to answer.

Q. My time zone isn't EST - when is the forum happening in my time zone?
A. You can use this handy checker to find out what time the Q&A will be taking place in your area. If you'll be sleeping during the session, don't forget that you can submit a question in advance.

Q. I've got some friends who would be keen on this - can they participate?
A. Absolutely! Forward them this email or spread the news on Twitter. We'd love to have as many people as possible involved.

Continue reading %Live Q&A with Guilherme Müller on HTML%

Asm.js and WebGL for Unity and Unreal Engine

Mi, 2015-08-05 00:20

This article is part of a web dev series from Microsoft. Thank you for supporting the partners who make SitePoint possible. Unity and Epic’s Unreal Engine, the popular middleware tools frequently used by game developers, are not limited to creating compiled applications that run as an executable. Unity previously had a web player, which was […]

Continue reading %Asm.js and WebGL for Unity and Unreal Engine%

10 Essential Atom Add-ons

Di, 2015-08-04 22:00

GitHub's Atom is rapidly maturing into one of the best code editors available. While it lost to Sublime Text in last year's SitePoint Smackdown, many issues no longer exist:

  • version 1.0 has been released
  • it's easy to install on Windows, Mac and Linux
  • speed has significantly improved, and
  • it's still free but betters many commercial offerings.

The number of add-ons has increased exponentially with more than 750 themes and 2,400 packages at the time of writing. The reason: Atom can be extended using web technologies. If you're working on Node.js or front-end projects, Atom is a great choice.

Package installation is simple. You can either:

  1. open the + Install panel in the Settings tab then search for a package by name, or
  2. install from the command line using apm install <package-name>.

Here are ten essential add-ons, plus a few bonus ones to make Atom even better …

Continue reading %10 Essential Atom Add-ons%

Cutting the Mustard with CSS Media Queries

Di, 2015-08-04 18:00

Cutting the Mustard is a term coined by Tom Maslen at the BBC. The method uses JavaScript that checks for browser capabilities before loading further CSS and JavaScript to give the user an ‘enhanced’ experience, otherwise the browser will only load the files necessary for a ‘core’ experience.

There has been a flurry of interest in cutting the mustard of late, for example Migrating to Flexbox by Cutting the Mustard and Server Side Mustard Cut, and in Progressive Enhancement in general.

Doing Better

In my experience, however, even a very basic ‘core’ experience can cause problems on some very old browsers, so I wanted to build on this idea and see if it was possible to deny really old browsers any CSS at all, leaving them with only the HTML.

Of course, the obvious solution is to use JavaScript to conditionally load all the CSS if the browser cuts the mustard, but this felt too heavy-handed for my liking; modern, capable browsers that didn’t load the JavaScript would be penalised by having no styles at all. So I looked for a CSS-only approach to the problem and I found an old post by Craig Buckler. After a fair bit of experimentation and adaptation, I came up with this:

[code language="html"]

media="only screen and (min-resolution: 0.1dpcm)"/> media="only screen and (-webkit-min-device-pixel-ratio:0)
and (min-color-index:0)"/>
[/code]

Let’s examine what’s happening here.

How it Works

The first <link> element’s media query allows the stylesheet to load only in the following browsers:

  • IE 9+
  • FF 8+
  • Opera 12
  • Chrome 29+
  • Android 4.4+

The second <link> element’s media query allows the stylesheet to load only in:

  • Chrome 29+
  • Opera 16+
  • Safari 6.1+
  • iOS 7+
  • Android 4.4+

When combined, this technique will not load the stylesheet unless the browser is:

  • IE 9+
  • FF 8+
  • Opera 12, 16+
  • Chrome 29+
  • Safari 6.1+
  • iOS 7+
  • Android 4.4+

Note: the stylesheet is only loaded once no matter how many <link> elements there are.

It’s possible to combine the media queries into one link element by separating the declarations with a comma, like so:

[code language="html"]

media="only screen and (min-resolution: 0.1dpcm),
only screen and (-webkit-min-device-pixel-ratio:0)
and (min-color-index:0)"/>
[/code]

However, I personally like to keep them separate as I find it easier to see what’s going on.

So if you structure your markup in a semantic and accessible way, older browsers should still be able to see your un-styled content in plain HTML.

This is of course very opinionated, but it’s my view that anyone using these browsers still deserves to be able to get to what they need. It’s quite likely that by giving these browsers CSS intended for newer browsers, some things will just break, and that could mean a totally unusable page. Using this method they at least get a clean slate. More importantly, you’ll never need to test in those browsers again. You’re done with them! At least, that’s the theory.

Of course, your support needs are likely to vary, but the great thing about this technique is that you can build on it. For example, if you need to add support for IE8, you can use a conditional comment to load the same stylesheet only for that browser:

[code language="html"]

[/code]

Or, if you need to support older WebKit devices with a pixel ratio of greater than 1, you could add another <link> element with a targeted media query, like this:

[code language="html"]

media="only screen and (-webkit-min-device-pixel-ratio:1.1)"/>
[/code]

By itself, this will load the stylesheet only for Android 2.2+ (I wasn’t able to test earlier versions), but since it’s included in addition to the other <link> elements, it’s effectively just adding support for this other group of browsers.

It’s also possible that you can alter the main <link> element’s media queries from how I’ve presented them here to get the custom support you need. However, it took quite a lot of testing to get this right, so be warned!

“But, they’re hacks!”

Yes, I suppose they are, though that depends on your definition. Media Queries are designed to test the capabilities of the browser before applying the CSS, and that’s exactly what we want to do in this case, albeit indirectly.

Still, hack or not, I’m pleased with this technique and it’s been working well for me in all the testing I’ve done so far, and I plan to use it on a production site soon.

Where it Doesn’t Work

In all my testing to date, I’ve found only one case where things don’t work as expected. On Android 4.4 the UC Browser doesn’t respond to the media query. From what I can tell, the UC Browser uses an older version of WebKit, which would explain things.

Continue reading %Cutting the Mustard with CSS Media Queries%

Video: Finding Performance Bottlenecks with Chrome Audits

Di, 2015-08-04 17:30

In this short video I go over a feature in chrome developer tools that's rarely used, but can deliver great insight when doing a performance audit.

Loading the player...

Continue reading %Video: Finding Performance Bottlenecks with Chrome Audits%

How to Run Node.js with Express on Mobile Devices

Di, 2015-08-04 17:00

We released a JXcore plugin for Apache Cordova recently and in this article I will show how to run a Node express application with Cordova.

At the time of writing the jxcore-cordova project on github has two samples prepared for running the express module.

Continue reading %How to Run Node.js with Express on Mobile Devices%

4 Simple Ways To Create A Better Work Environment

Di, 2015-08-04 16:00

The modern workplace is experiencing a renaissance. Following the lead of big tech companies like Google and Facebook, more and more businesses are turning their offices into mini-cruise ships, complete with on-site daycares, nap-pods, game rooms and spa days. But while we'd all like to take a water slide to our desk and zipline to […]

Continue reading %4 Simple Ways To Create A Better Work Environment%

Taking the Guesswork out of Typography on the Web

Di, 2015-08-04 15:09

Too many designers guess their way through typography.

Books and articles from all over are guilty of presenting typography in an overly arty “you have to just know” style.

In actual fact there is a lot of logic behind typography. There are many guidelines that, if followed, will make your typography infinitely better—even if you’re not a designer.

In this article we’re going to go through some practical tips that you can use to take the guesswork out of typography.

Choosing & Pairing Fonts

The sheer amount of typefaces to choose from is overwhelming to say the least.

Take the classic Garamond: A search on MyFonts brings up just under 60 different variations of this one font family alone! 


Sifting through all these typefaces is a laborious task for the non type enthusiast but crucial to the success of your typographic endeavours.

How To Find Your Perfect Typeface

The trick is to find a few typefaces you like and stick with them. If you pick families with a wide range of styles (Light, Regular, Bold, Italics etc.) you will find you can use them over and over again. You'll get a feel for how they work best.

I almost never use font foundry websites to choose my fonts. They're just too overwhelming.

The best way to find some great fonts for your projects is to take from what already exists around you.

The easiest way I've found to do this is right in your browser with a Chrome extension called WhatFont. Simply highlight and click on any live text and it will show you the name, size, line-height and color.

Of course the browser isn’t the only way you can identify fonts you like. If you have a static image (even phone pics) you can upload it to What The Font which will analyse it for you or you can use Identifont which will ask you simple questions based on the characters you have in front of you.

What Makes a Good Font Choice?

When choosing a font it’s best to start with your body text. This will be used the most throughout your website and is the most crucial to get right.

There are 3 main points that you should bear in mind when choosing a body text font:

1. Check the contrast


In the left image you can see there is a lot of variation between the widths of the letter. When this runs over a large amount of text it can be difficult to read.



In the same token, a font with no variation at all (the right image) can be just as bad because it gets harder to differentiate one letter from the rest.



For longer stretches of text it is best to choose a typeface with medium to low contrast because it won’t interrupt the flow of reading.



Leave the extremes for your titles.


Continue reading %Taking the Guesswork out of Typography on the Web%

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%