Monday, August 3, 2015

Practical CoffeeScript: Making a Tic-Tac-Toe Game

Ascend

Ascend

'Ascend' is a free One Page HTML template based on Bootstrap framework. The responsive template is suited for any type of portfolio and provides modals for more information on projects. Cheers TemplateGarden for this freebie!

by Rob Hope via One Page Love

Creating Your First CocoaPod

The Entrepreneur’s Guide to Quora

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%


by Aja Frost via SitePoint

Running Windows 10 IoT Core on a Raspberry Pi

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.

Installing Visual Studio with Custom Settings

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:

Choosing the right settings for Visual Studio and the IoT

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:

Downloading Visual Studio IoT Templates

Enabling Developer Mode on Windows 10

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

Developer Mode Required

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":
    Running Command Prompt as Administrator
  2. Type in Gpedit.msc
  3. Then, navigate to Local Computer Policy > Computer Configuration > Administrative Templates > Windows Components > App Package Deployment.
    Finding Group Policy Settings
  4. Open up the policy for "Allow all trusted apps to install" and click the "Enabled" radio button:
    Enabling group policies
  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":
    Opening IoTImageHelper
  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":
    Putting IoT Core on SD Card
  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:

Connecting via Putty

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:

Raspberry Pi Sketch with Servos

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.

Opening IoTCoreWatcher

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

TARDIS found in IoT Core Watcher

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%


by Patrick Catanzariti via SitePoint

Video: Shorthand if-else Conditionals with PHP

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%


by Lami Adabonyan via SitePoint

6 Free Online Tools to Make Your Life Easier

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 […]

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


by Simone Sala via SitePoint