Generating an SSH Key and Using it on Azure

SSH KEYS allow us to connect to VMs without using passwords but by passing a private key that can be managed by you or your organization.

For more about SSH

There are three parts to this tutorial:
A. Generate an SSH Key
B. Create a VM in Azure that uses the public key
C. Connect to VM using SSH keys

Prerequisites:
Bash
ssh-keygen ($ info ssh-keygen to learn more)
An Azure Subscription

A. Generate an SSH Key

Open bash and enter:
$ ssh-keygen -t rsa -b 2048 -C "Ubuntu@azure-server"
Keyname: server-key
Passphrase: somethingMemorable

Copy the contents of server-key.pub
$ cat server-key.pub

Should look like this:
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDMlUr7PCEdBmCVZHG5RqI8i7GgYAzd2G/FZ987XXa63vnqxZmZogVmmXrTnBHeM6oDv7v7g495CiiiINhJbGR4o7t4agiHOM43egDv7BbiViTlfVr3y5AxLUvRwHnC3egl8ABVX1anfXXR73x7IS3YRNWkh6gXtlhImw8UKG04UoZEmWB9BLt53lk/9c3Hxz22YZarzImrpQYy1XEUZ096B9mK/Fe+/McH78ZHUpXEgOZBIDP5KdqPk5XKznpwUDJ4/SPXPEWWCCjQ8gOoTFcFMaiMnXp5o5Udsi/DFO1TS/t8BeCRymkr5tdPvzexjkjkjkjkjkjkjkjkjkjkjkjt Ubuntu@azure-server

Here’s what it looks like for me:
keygenandcat

Cool and you’ll also notice that there’s another file in that same directory – server-key
$ ls | grep server
Here’s what that looks like for me:
lskeys

Now that we have our public and private keys let’s get our VM setup.

B. Create a VM in Azure that uses the public key

1. Go to the Azure Portal

2. Select New -> Search: Ubuntu Server
(I’m using 14.04 this time)
selectubuntu1404

3. Make sure you’ve selected Resource Manger and click Create:
resourcemanagecreate

4. Now configure the basics per our ssh-keygen parameters
Name: azure-server
VM Disk Type: Up To You
User name: Ubuntu
Authentication type: SSH public key
SSH public key: Paste the results of $ cat server-key.pub
Subscription: Depends how you want to pay for the server
Resource Group: Up to you – I’m going to create a new one so I can quickly delete it.
Location: Up to you

Should look like this:
basicsconfigurationforssh

Then select OK to go to the next section.

5. Choose Virtual Machine Size
I’m going with the smallest VM for testing.
You can also view all different VM sizes to find the right one for your use case.
pickvmsize

6. Configure optional Features
Setting the Storage account name to something you’ll remember easily is good.
And if you want to configure ports now you can select Network Security group to allow ports specific traffic.
Here’s what that looks like:
optional-azure-settings
Click okay to continue to the Summary of your VM.

Here’s our summary:
summary-click-okay-to-create-vm

Select okay to start your VM.

7. Wait for it to be ready.
Dashboard will have an icon and you’ll get a notification when its ready:
waiting-for-vm-to-spin-up-from-dashboard

8. Once ready select on it to see the overview and the IP address.
Should look like this:
vm-overview-ip

Great! We have a VM and its IP address. Lets use our Private SSH key to connect.

C. Connect to VM using SSH Keys

1. Open bash to file location you created the keys in.
Make sure they’re there:
$ ls | grep server

2. Enter this command to use SSH to connect:
$ ssh -i server-key Ubuntu@52.183.31.11 -v
or more generally
$ ssh -i keyname username@ip.address -v
Make sure you’re using server-key and not server-key.pub
Tip: -v is the verbose option. Not necessary, but it helps to see if the key is being accepted

3. Great, now accept the certificate, and enter your memeroablePassphrase
Whole thing should look like this:
ssh-using-key-to-inbash

And you’ll be in the terminal of your VM:
in-the-terminal-of-the-vm

Yay!
You’ve got the key, you’ve got the VM, now put it to work!
Flask on Ubuntu
Node on Ubuntu
Mongo on Ubuntu
Connecting to VMs from Azure Web Apps

Let me know if you have any questions by posting in the comments below!

These people just want High Fives!
These people just want High Fives!

Python with Ubuntu on Windows

Now that bash is on Windows, I wanted to try and make all the other guides I’d writen for Python on Windows irrelevant.

So here’s how to setup an effective environment for Python on Ubuntu on Windows.

1. Install Bash on Windows
2. Check for updates
3. Check out the REPL
4. Install Pip
5. Install VirtualEnv
6. Install VirtualEnvWrapper
7. Create your first virtualenv
8. Configure bashrc to keep it working
9. Install some packages
10. Test Flask

1. Install Bash on Windows:
Here’s the announcement blog for context.
How to Geek has a good breakdown of making it happen.

Make sure you remember your password.

Now that its installed try opening a command prompt and typing bash.
The prompt should change like this:
bashtomnt

Notice that path?
/mnt/c/Users/TimReilly

That’s your user directory for windows where your OneDrive, Documents, Desktop, etc. exist.

You can go in there now and run python scripts that might already exist, but your probably won’t have all the necessary packages installed.

Before we move forward we want to make sure Ubuntu is up to date.

2. Check for updates
From another command prompt:
lxrun /update

And inside bash
sudo apt-get update

Thanks reddit for the tips!

3. Check out the REPL

Now run python!
$ python

Should look like this:
pythonrepl

4. Install Pip

Now we’ll install Pip:
sudo apt-get install python-pip

If you have permission issues try starting an elevated prompt:
$ sudo -i
$ apt-get install python-pip
$ exit

Use exit to return to the regular prompt.
Should look like this:
sudoi
Yay we’ve got pip!
Try pip list to see what comes standard.

5. Install VirtualEnv
Now we’re basically following along with the guide presented at hitchhikersguidetopython.com

Again, you might need to start an elevated prompt to install virtualenv.

$ sudo -i
$ pip install virtualenv
$ exit
$ cd my_project_folder
$ virtualenv venv

Then to use the VirtualEnvironment

$ source venv/bin/activate

You should now see a little (venv) before your prompt.
Like this:
virtualenvfolder

Now you’ve created a virtualenv inside of your my_project_folder directory. Which is cool, but can be confusing with git, sharing code, and testing package versions.
So we use VirtualEnvWrapper to keep our virtualenvs in the same place.

Before we move on make sure you deactivate your env
deactivate

6. Install VirtualEnvWrapper

http://virtualenvwrapper.readthedocs.io/en/latest/index.html


$ pip install virtualenvwrapper
$ export WORKON_HOME=~/Envs
$ source /usr/local/bin/virtualenvwrapper.sh

$ export WORKON_HOME=~/
Can be customized to whichever directory you’d like to place your virtualenvs

7. Create virtualenv using virtualenvwrapper

$ mkvirtualenv venv
$ workon venv
$ deactivate

Here’s an example of what it looks like to remove our venv directory and instead use venvv which will be stored in the directory underlined in red.

venvv

8. Configure bashrc to keep it working

This might not happen to you, but when I opened a new bash terminal I had to re-source my virtualenvwrapper.sh and WORKON_HOME.

So instead I added those lines to my bashrc script.

$ sudo nano ~/.bashrc
-- type in password --

This is what it looks like in nano for me.
Ctrl+X to exit and y-enter to save.
bashrc

Then either:

Source ~/.bashrc

Or start a new command prompt->bash and try “workon” or “lsvirtualenv”

See the next image for a simple workflow.

9. Install some packages

Now lets install ‘requests’ into our newly created virtualenv:
pipinstallrequests

Isn’t that nice!

10. Test Flask
Finally we’re going to test this with flask.
First we install the required files using pip into our activated ‘venv’
Then runserver -> navigate to the designated address -> and see our site.

Here’s what it looks like:
flaskrunning

Have fun building with Python, on Ubuntu, on Windows!

Bike with pizza tied to the back
Sometimes you gotta tie a pizza to your bike.

W10 Core IoT Workshop

IoT and Windows are Better than ever with the new IoT Core for Raspberry Pi.

In this workshop we’ll have deploy Universal Windows Platform Code to a Raspberry Pi and begin communicating with the cloud and cloud services in the form of an Azure IoT Hub.

The steps include:
1. Gathering the materials
2. Preparing the Raspberry Pi
3. Installing our software
4. Connecting our LED and PushButton
5. Connecting to our raspberry pi
6. Deploying our push button app
7. Connecting our app to IoT Hub
8. Connecting our app to weather data

1. Gathering the materials

For this workshop you’ll need about $55 worth of hardware, but all the software is free.

Hardware:
1 Raspberry Pi 3 (It has built in Wifi!)
1 Micro USB to USB Cable
1 Breadboard
4 Female/Male Jumper Wires
1 Push Button Switch
1 led
1 200 ohm resistor for said led
1 Monitor with HDMI out

Software:
Windows 10 Machine version 10.0.10240 or better.
Visual Studio 2015 Update 2
The Windows 10 IoT Core Dashboard
Git

Here's my little setup
Here’s my little setup

2. Preparing Our Pi

The windows developer site has very clear instructions for setting up your device with the proper operating system so lets hop over there.

developer.microsoft.com

If you follow these instructions all the way to Step 4 of 4 you’re ready for step 5 on our workshop. So skip ahead if you followed along there.

I’m working with a raspberry pi three so my selection screen looks like this:

selection

3. Install the dashboard and Flash the OS
Next we’ll download the dashboard as prompted by the site

Then we’ll download the ISO of the raspberry pi image we want to use, then click through installer.

Once installed we can use the IoT Dashboard to flash the image onto our SD card in the form of a .ffu

Then we’ll connect the device to the network by selecting configure device.

Really though the instructions are super clear RIGHT HERE

4. Install/Update Visual Studio

We need Visual studio Update 2 to build our IoT Application, so make sure you’re up to date!

Or go here to install it: https://www.visualstudio.com/vs-2015-product-editions

Seriously though, they did an awesome job with the documentation.
If you followed along to their step 4 you’re ready for our step 5.

5. Connecting our LED and PushButton

Now that we have our pi configured and Visual Studio up to date, let’s plug in our neat hardware!

Here’s an overview of the pin layout for the raspberry pi 3:
gpiopins

And the wiring diagram for the led + push button looks like this:

wiringdiagram

Sweet, lets light it up!

6. Connecting to our raspberry pi

We need our raspberry pi’s IP address before we try to deploy our code.
Power it up with a micro USB cord and connect it to a monitor with HDMI and see the landing page for your machine.

With the Windows IOT Core Come a super helpful web portal that allows you to configure your machine through a browser.

Navigate to that IP:
http://you.have.an.ip:8080/
https://192.168.1.145:8080/ is the IP address of my machine when I tried this

You’ll be prompted with a login panel.
The default user name is:
Administrator
The default password is:
p@ssw0rd

Here’s what you should see in the portal:
coreportal

From here you can configure the name/password, get network info like the MAC address under Networking, and even test out some samples.

Sweet! This is one of my favorite Window IoT Features.

7. Deploying our push button app

The pi is setup, our computer is updated with the newest build tools, now its time to deploy some code!

Go here and clone this repo to a dev directory:
https://github.com/timmyreilly/RaspberryPiWorkshop

And setup visual studio debugging by right clicking on PushButton project like this:
properties

Then under debug set the remote machine ip to the ip you collect from the IoT Dashboard or from the raspberry pi itself by plugging in a monitor.
findip
You will then need to rebuild your solution, and restore nuget packages.

Poke around for a minute, put a break point in the buttonPin_ValueChanged method and step around to see what’s going on with the push button.

8. Connecting our app to IoT Hub

Next we’re going to turn on the IoT Hub Connection.
Go into the azure portal and create a new IoT Hub like this:
iothubone
Then create a new device called MyDevice in the IoT Hub.

More information about the IoT Hub can be found RIGHT HERE.

Then we’ll want to add our connecting strings to the app at the very bottom of MainPage.xaml.cs


static string iotHubUri = "YOURHUB.azure-devices.net";
static string deviceKey = "TOKENasQOPUesD1BmSOMETHINGCOMPLICATED";
static string deviceId = "MyDevice"; // your device name

Next we’ll uncomment this line of code on line 78:

SendDeviceToCloudMessagesAsync();

To see what’s happening in the event hub there is a small console application that we’ll run alongside to see what’s making into the cloud.

You can find that code here:
https://github.com/timmyreilly/IoTHubConsoleReader
Open that in visual studio and replace the connection string with the one provided in the Azure Portal.


string connectionString = "HostName=YOURHUBNAME.azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey=YOURSECRETOKENqf"

Sweet, now run both those apps at the same time, push the button, and see the glory that is Internet of things.

9. Connecting our app to weather data

Now that we’ve got it talking to the cloud, lets listen to what the clouds have to say!

We’re going to use forecast.io to provide weather data to our app, then use Speech. Synthesis to read it out over a the audio jack.

Navigate to forecast.io and signup register an account, then copy the complicated token highlighted here:

forecast

And replace what you see at line 168:

private const string FORECAST_URL = "https://api.forecast.io/forecast/YOURSECRETOKEN/";

Then if you want to be more specific about where you’re getting weather data replace the string on line 76.

var words = await GetWeatherString("37.8267,-122.423")

Make sure that the code in lines 72 through 81 are uncommented.

Deploy the app, press the button, and listen to the weather like never before!

It’s all very simple code and ready to be spun into lots of fun projects.
Here’s a list of all the ones that me and my friends could thing of:
Tap into the band app cloud
Morse code
Dance party
Send a random act of kindness
Tap into yammer
Time to finish breast feeding start and stop button
Random stats button
Gives you weather, or distance walked
Morse code each other
Send bro to someone random – twilio
Launch a middle
Listener recognition and ignore
Competitive button clicking
Obscure metadata
Best reflexes tester

Hope you had fun getting started with Windows IoT!

This workshop wouldn’t be possible without the help provided by the community. Here are some of the helpful posts that help me learn:
Windows 10 IoT Core Speech Recognition
Windows 10 IoT Core Speech Synthesis
All The ms-iot samples

Feel free to ask me questions in the comments or on twitter @timmyreilly

TOMATOES IN PROGRESS
TOMATOES IN PROGRESS

Setup a virtualenv for Python 3 on Windows

It’s essentially the same as Unix!

Especially, if you’ve followed my other guide to getting setup virtualenvs and virtualenvwrapper-win on Windows. And you’ve also installed python3!

Here’s the Script I run:

mkvirtualenv --python=C:\Python35-32\python.exe pythonthreeEnv

‘pythonthreeEnv’ is the name of my environment.

Now I can run:

workon pythonthreeEnv

Here’s a screenshot of a workflow:
pythonthreeenv

Bonus: To efficiently delete an env:

rmvirtualenv pythonthreeEnv -r

Happy Hacking!

THESE THINGS ARE AMAING. Thank you Alejandro and Argentina!
THESE THINGS ARE AMAZING. Thank you Alejandro and Argentina!

Python, Pip, virtualenv installation on Windows

No more struggles Windows Python development! I’ve found this is the best way to configure your dev environment.
This has made things much easier to get started and less of a headache overall.

We use Virtual Environment so we can test python code in encapsulated environments and to also avoid filling our base Python installation with a bunch of libraries we might use for only one project.

But Virtual Environments can be tricky if you don’t establish a good workflow. I’ll show you how to setup your python environment from Scratch and then do a very simple workflow using Flask.

SETUP
4 Steps:
Install Python
Install Pip
Install VirtualEnv
Install VirtualEnvWrapper-win

Install Python:

First Go to the Python Downloads Site.

As of March 2015 the download you want for a standard windows machine is Windows x86-64 MSI installer (The other download is for servers). Its circled here:

Download

Run the installer!
You’ll come across this page in the installer:

PythonInstaller

You’ll want to scroll down and add it to the path. If you don’t that’s okay. You can add it later.
Adding Python to the PATH will allow you to call if from the command line.

After the installation is complete double check to make sure you see python in your PATH. You can find your path by opening your control panel -> System and Security -> System -> Advanced System Settings -> Environment Variables -> Selecting Path -> Edit ->

Now you’re looking at your Path. Be Careful, if you delete or add to the path accidently you may break other programs.

You need to confirm that C:\Python27; and C:\Python27\Scripts; is part of your path.

If you do not see it in your path you can simply add it at the beginning or end of the variable value box. As you can see in the image below.

AdvancedSettings

Install Pip:

As of Python Version 2.7.9 Pip is installed automatically and will be available in your Scripts folder.

If you install a later version of Python I would recommend installing it according to this helpful stackoverflow post.

Pip is a Package manager for python which we will use to load in modules/libraries into our environments.

An example of one of these libraries is VirtualEnv which will help us keep our environments clean from other Libraries. This sounds really confusing but as you start using it you’ll begin to understand how valuable this encapsulation of modules/libraries can be.

To test that Pip is installed open a command prompt (win+r->’cmd’->Enter) and try ‘pip help’

You should see a list of available commands including install, which we’ll use for the next part:

Install virtualenv:

Now that you have pip installed and a command prompt open installing virtualenv to our root Python installation is as easy as typing ‘pip install virtualenv’
Like so:

pipinstallvirtualenv

Now we have virtualenv installed which will make it possible to create individual environments to test our code in. But managing all these environments can become cumbersome. So we’ll pip install another helpful package…

Install virtualenvwrapper-win:

This is the kit and caboodle of this guide.

Just as before we’ll use pip to install virtualenvwrapper-win. ‘pip install virtualenvwrapper-win’
Like so:

virtualenvwrapper-win

Excellent! Now we have everything we need to start building software using python! Now I’ll show you how buttery smooth it is to use these awesome tools!

USAGE
7 Steps:
Make a Virtual Environment
Connect our project with our Environment
Set Project Directory
Deactivate
Workon
Pip Install
Flask!

Make a Virtual Environemt:

Lets call it HelloWold. All we do in a command prompt is enter ‘mkvirtualenv HelloWold’
This will create a folder with python.exe, pip, and setuptools all ready to go in its own little environment. It will also activate the Virtual Environment which is indicated with the (HelloWold) on the left side of the prompt.

mkvirtualenv

Anything we install now will be specific to this project. And available to the projects we connect to this environment.

Connect our project with our Environment:

Now we want our code to use this environment to install packages and run/test code.

First lets create a directory with the same name as our virtual environment in our preferred development folder. In this case mine is ‘dev’

See here:

mkdir

HelloWold will be the root folder of our first project!

Set Project Directory:

Now to bind our virtualenv with our current working directory we simply enter ‘setprojectdir .’
Like so:

setprojectdir

Now next time we activate this environment we will automatically move into this directory!
Buttery smooth.

Deactivate:

Let say you’re content with the work you’ve contributed to this project and you want to move onto something else in the command line. Simply type ‘deactivate’ to deactivate your environment.
Like so:

deactivate

Notice how the parenthesis disappear.
You don’t have to deactivate your environment. Closing your command prompt will deactivate it for you. As long as the parenthesis are not there you will not be affecting your environment. But you will be able to impact your root python installation.

Workon:

Now you’ve got some work to do. Open up the command prompt and type ‘workon HelloWold’ to activate the environment and move into your root project folder.

Like so:

workon

Pretty sweet! Lets get working.

Pip Install:

To use flask we need to install the packages and to do that we can use pip to install it into our HelloWold virtual environment.

Make sure (HelloWold) is to the left of your prompt and enter ‘pip install flask’
Like so:

pipinstallflask

This will bring in all the tools required to write your first web server!

Flask:

Now that you have flask installed in your virtual environment you can start coding!

Open up your favorite text editor and create a new file called hello.py and save it in your HelloWold directory.

I’ve simply taken the sample code from Flask’s website to create a very basic ‘Hello World!’ server.

I’ve named the file hello.py.

Once the code is in place I can start the server using ‘python hello.py’ this will run the python instance from your virtual environment that has flask.

See here:

webserver

You can now navigate with your browser to http://127.0.0.1:5000/ and see your new site!

Sweet. You have everything you need to start working through tutorials on Flask without worrying about gunking up your Python installations.

Let me know if you have any questions! Happy Developing!

Art Deco From Afar
Art Deco From Afar

Quick Edits Using VS Code

I’ve been working in Visual Studio pretty heavily in the last two weeks, but every once in a while I need to make quick edits to my .gitignore file, which isn’t in my project directory.

I usually open up a small text editor right from PowerShell and now that VS Code is out I thought ‘why not use that?’

Here’s how you can easily open files using code from PowerShell in three steps:

1.Find the path to VS Code
2. Edit your PowerShell profile
3. Open Files!

1. Find the VS Code Path

First thing we need to do is find where VS Code is in our directory.

If you have Code pinned to your start menu or on your desktop simply right click the icon and ‘select open file location’.

File explorer should now open to the location of the .exe.
Right click the Code.exe file and select ‘properties’.

If you selected a Shortcut Icon you should see a screen like this:

vscodeshortcutpath

If you navigated to the actual location in directory of VS Code it should look like this:

vscodelocationpath

Now right click and copy the path.

In my case: C:\Users\tireilly\AppData\Local\Code\app-0.1.0

2. Edit our PowerShell profile

To edit our profile we need to find the Microsoft.PowerShell_profile.ps1 file.

My file is located here:

profilelocationpowershell

I open the file in notepad to make my edits:

notepadpowershellprofile

Now that we have our profile open we’ll create an alias for labeled code followed by the path to our .exe
eg: Set-Alias code ‘C:\Users\user\AppData\Local\Code\app-0.1.0\Code.exe

noticed how I added the Code.exe to the path so the program will launch!

Here’s a photo of my current PowerShell profile for reference:

powershellprofile

Now we can save and close this file and open a new PowerShell window!

3. Edit some files!

Let’s edit our PowerShell profile with Code this time!

symmetryisgood

Something oddly satisfying about getting exactly what you want with words.

codeeditorpowershellprofile

And there we go. The brand new Code editor at your fingertips whenever you need it!

Let me know if you have any comment or questions!

Amazing Dude
Professor Chang Yun is an excellent man with an amazing imagine cup record. His mentorship has led teams to US finals for 8 years straight. With 6 teams making it into the World Finals.

Python Flask Windows Development Environment Setup

No more struggles Windows Python development! I’ve found this is the best way to configure your dev environment.
This has made things much easier to get started and less of a headache overall.

We use Virtual Environment so we can test python code in encapsulated environments and to also avoid filling our base Python installation with a bunch of libraries we might use for only one project.

But Virtual Environments can be tricky if you don’t establish a good workflow. I’ll show you how to setup your python environment from Scratch and then do a very simple workflow using Flask.

SETUP
4 Steps:
Install Python
Install Pip
Install VirtualEnv
Install VirtualEnvWrapper-win

Install Python:

First Go to the Python Downloads Site.

As of March 2015 the download you want for a standard windows machine is Windows x86-64 MSI installer (The other download is for servers). Its circled here:

Download

Run the installer!
You’ll come across this page in the installer:

PythonInstaller

You’ll want to scroll down and add it to the path. If you don’t that’s okay. You can add it later.
Adding Python to the PATH will allow you to call if from the command line.

After the installation is complete double check to make sure you see python in your PATH. You can find your path by opening your control panel -> System and Security -> System -> Advanced System Settings -> Environment Variables -> Selecting Path -> Edit ->

Now you’re looking at your Path. Be Careful, if you delete or add to the path accidently you may break other programs.

You need to confirm that C:\Python27; and C:\Python27\Scripts; is part of your path.

If you do not see it in your path you can simply add it at the beginning or end of the variable value box. As you can see in the image below.

AdvancedSettings

Install Pip:

As of Python Version 2.7.9 Pip is installed automatically and will be available in your Scripts folder.

If you install a later version of Python I would recommend installing it according to this helpful stackoverflow post.

Pip is a Package manager for python which we will use to load in modules/libraries into our environments.

An example of one of these libraries is VirtualEnv which will help us keep our environments clean from other Libraries. This sounds really confusing but as you start using it you’ll begin to understand how valuable this encapsulation of modules/libraries can be.

To test that Pip is installed open a command prompt (win+r->’cmd’->Enter) and try ‘pip help’

You should see a list of available commands including install, which we’ll use for the next part:

Install virtualenv:

Now that you have pip installed and a command prompt open installing virtualenv to our root Python installation is as easy as typing ‘pip install virtualenv’
Like so:

pipinstallvirtualenv

Now we have virtualenv installed which will make it possible to create individual environments to test our code in. But managing all these environments can become cumbersome. So we’ll pip install another helpful package…

Install virtualenvwrapper-win:

This is the kit and caboodle of this guide.

Just as before we’ll use pip to install virtualenvwrapper-win. ‘pip install virtualenvwrapper-win’
Like so:

virtualenvwrapper-win

Excellent! Now we have everything we need to start building software using python! Now I’ll show you how buttery smooth it is to use these awesome tools!

USAGE
7 Steps:
Make a Virtual Environment
Connect our project with our Environment
Set Project Directory
Deactivate
Workon
Pip Install
Flask!

Make a Virtual Environemt:

Lets call it HelloWold. All we do in a command prompt is enter ‘mkvirtualenv HelloWold’
This will create a folder with python.exe, pip, and setuptools all ready to go in its own little environment. It will also activate the Virtual Environment which is indicated with the (HelloWold) on the left side of the prompt.

mkvirtualenv

Anything we install now will be specific to this project. And available to the projects we connect to this environment.

Connect our project with our Environment:

Now we want our code to use this environment to install packages and run/test code.

First lets create a directory with the same name as our virtual environment in our preferred development folder. In this case mine is ‘dev’

See here:

mkdir

HelloWold will be the root folder of our first project!

Set Project Directory:

Now to bind our virtualenv with our current working directory we simply enter ‘setprojectdir .’
Like so:

setprojectdir

Now next time we activate this environment we will automatically move into this directory!
Buttery smooth.

Deactivate:

Let say you’re content with the work you’ve contributed to this project and you want to move onto something else in the command line. Simply type ‘deactivate’ to deactivate your environment.
Like so:

deactivate

Notice how the parenthesis disappear.
You don’t have to deactivate your environment. Closing your command prompt will deactivate it for you. As long as the parenthesis are not there you will not be affecting your environment. But you will be able to impact your root python installation.

Workon:

Now you’ve got some work to do. Open up the command prompt and type ‘workon HelloWold’ to activate the environment and move into your root project folder.

Like so:

workon

Pretty sweet! Lets get working.

Pip Install:

To use flask we need to install the packages and to do that we can use pip to install it into our HelloWold virtual environment.

Make sure (HelloWold) is to the left of your prompt and enter ‘pip install flask’
Like so:

pipinstallflask

This will bring in all the tools required to write your first web server!

Flask:

Now that you have flask installed in your virtual environment you can start coding!

Open up your favorite text editor and create a new file called hello.py and save it in your HelloWold directory.

I’ve simply taken the sample code from Flask’s website to create a very basic ‘Hello World!’ server.

I’ve named the file hello.py.

Once the code is in place I can start the server using ‘python hello.py’ this will run the python instance from your virtual environment that has flask.

See here:

webserver

You can now navigate with your browser to http://127.0.0.1:5000/ and see your new site!

Sweet. You have everything you need to start working through tutorials on Flask without worrying about gunking up your Python installations.

Let me know if you have any questions! Happy Developing!

Art Deco From Afar
Art Deco From Afar

Pin Putty.exe to Start Menu In Windows 10

When working with the cloud a any remote device being able to quickly SSH into a box is important for maintaining focus.

So, I was pleased to find a way to keep putty two clicks away by placing it in the start menu.

Here are the steps I took to keep putty handy.
And an alternate way below if you’re familiar with downloading .exe’s.

1. Download putty.exe

Notice save and the small black arrow next to it?
Notice save and the small black arrow next to it?

2. Save it to your download files
3. Go to downloads folder
Now you can navigate to the downloads folder from the downloads bar
Now you can navigate to the downloads folder from the downloads bar

4. Right click and select pin to start menu
5. Then right-click -> cut putty.exe from your downloads file and move it someplace more permanent like you’re program files.
6. Go find putty in your start menu!

Alternatively you can also save putty directly to your program files.
1. Download putty.exe
2. When the download bar appears select “save as” under the black arrow next to save.

Notice save and the small black arrow next to it?
Use the small black arrow in the circle to find “save as”

3. Navigate to your program files.
This is the folder I have chosen for putty
This is the folder I have chosen for putty

4. Select save.
Here is the save button. Notice the file path. You need to navigate here to find putty in the next step.
Here is the save button. Notice the file path. You need to navigate here to find putty in the next step.

5. Open file explorer to the file you saved putty in
6. Right click on putty and select pin to start.
7. Go find putty in your start menu.

You can resize and move the putty icon to your hearts content and never go searching for your SSH client again!

After Frisbee Chow Town
After Frisbee Chow Town

First Login with Raspberry Pi using Windows 10

Since I’m now running full steam with Windows 10 I have run into a couple understandable documentation issues for the raspberry pi B+.

I’ll be doing my best to fill them out as I learn about this device.
So far no major issues, but one thing to clear up.

Consider this a Windows 10 companion article to Adafruit’s Console Cable guide.

The raspberry pi made it to me faster than the HDMI cord did, so I had no way to see what was happening on the device.

Luckily I purchased the Pi as part of a kit from Adafruit and it contains a console cable. A cool way to get to your Raspberry Pi’s console and start learning about the device.

So I was following along with this tutorial from Adafruit. And found this warning.
Capture

But I went ahead and gave it a shot.

  • Going to this site
  • Clicking on the PL2303_Prolific_DriverInstaller_v1.10.0.zip
  • Saving it and extracting it to a folder on my desktop
  • Running the PL2303_Prolific_DriverINstaller_v1.10.0.exe
  • Plugging in the GPIO leads*
  • Plugging the USB end into my computer
  • Finally Viewing the device in my device manager**.

CaptureDevice

There it is under COM3!

I continued with the instructions given by Adafruit for PuTTY configuration***.

Remember the default username is ‘pi’ and the password is ‘raspberry’

*
I found this diagram and site helpful for understanding what the differences were between the B and B+ GPIO ports. Its from Raspberry Pi Spy.
Raspberry-Pi-GPIO-Layout-Model-B-Plus

** You can view exactly which port to use in the device manager which can be found by right clicking on the start menu.

***I would suggest pinning PuTTY to your start menu because I tend to lose it and it is great to have on hand when needing to SSH in Azure, Linux Server, or any other place you need to get Console/Terminal access.

Merry Retro Christmas from my Mom and her Brothers and Sisters from long ago!
Merry Retro Christmas from my Mom and her Brothers and Sisters from long ago!