WebRTC Presentation

Here are my slides from the talk that I presented at the Software Society about WebRTC.

The Demo Application I used during the talk is here: Drywall Application with WebRC enabled.

The source code is available from my Gitlab account here.

On 3rd July 2014 I presented a talk about WebRTC (Real Time Communication): what it is, how to get started and how to generate ideas to begin rapid prototyping.

I created a hybrid project using the Node.js user management system Drywall and mashed this with Google Chrome WebRTC and EasyRTC, providing a working app which is WebRTC enabled to allow rapid prototyping and learning of the WebRTC APIs.

The Software Society meets every fortnight, at 7pm on Thursdays, in the Burgh Coffeehouse in Dundee.

Membership is open to anyone and carries a small annual fee to cover running costs. Members discuss technology related subjects: from security (Ethical Hacking), FOSS (Linux, Android, Unix and other Open Source Software), Windows, web-programming, PGP encryption, Django and even Tennessee Fainting Goats.

Members range from Tech Industry Professionals, Hacker Students, Geeks and Tinkerers, Software Fascists and Hardware Gurus.
 

 

Original Slides from GitHub


 
Use your keyboard arrow keys to move down through the presentation and then right for each new section.

Bootstrap, Node and some magic fairy Dust.

Here are my slides from the talk that I presented at the Software Society about Bootstrap, Node.js and Dust.js.

On 7th November 2013 I presented a talk about the front end framework Bootstrap; what it is, how to get started and how to generate ideas to begin rapid prototyping your retirement project.  I touched on Node and some of the JavaScript modules you need to get you up and running.

The Software Society meets every fortnight, at 7pm on Thursdays, in the Burgh Coffeehouse in Dundee.  Membership is open to anyone and carries a small annual fee to cover running costs. Members discuss technology related subjects: from security (Ethical Hacking), FOSS (Linux, Android, Unix and other Open Source Software), Windows, web-programming, PGP encryption, Django and even Tennessee Fainting Goats.

Members range from Tech Industry Professionals, Hacker Students, Geeks and Tinkerers, Software Fascists and Hardware Gurus.

 

Recovering a Corrupt MapMyTracks Activity

I have used various tracking apps to monitor my Running and Mountain climbing.  I currently use RunKeeper, which offers great functionality with their free account, with an upgrade option for Pro features.  I have also used MapMyTracks as they offer a live track option for free.  Your Friends and Family can watch you competing or training live on the web!

MapMyTracks.com Corrupt File

During the Six Peaks challenge I mapped all 6 Mountains on my iPhone with the MapMyTracks app, however, one Mountain file was corrupted during the upload to the server.  I was left with the correct data for the Activity on my iPhone, but could not get it to sync with the website.  I tried everything, from exporting the data, re-syncing, checking FAQs, forums, but nothing helped.  The iPhone displays the correct activity info, but it exported a GPX file with data missing.

Unfortunately, either the developers have abandoned the app, or they don’t answer calls from non-premium subscribers as they don’t reply to queries through their site.

I was keen to try out a new app Strava.  I wanted to upload all my activities I have on RunKeeper and MapMyTracks.  I had them all but this one corrupt file and it bugged me that I did not have the full Six Peaks suite.

I decided to extract the data from my iPhone and and write a Python script to recreate the GPX file.  That way I could upload my file to Starva and I would have the complete set.

Getting the Data from the iPhone using iFunbox

There is a free app available that allows you to browse the file system on your iPhone.  The app is called iFunbox.  I managed to browse to the MapMyTracks data folder and copy the MapMyTracks.sql file to my desktop.  From there I created the Python script below, which shows the activities contained in the data file and allows you to save the data to a GPX file.

It worked a treat and my Activity was correct and I could upload it to the MapMyTracks BV Lions 6 Peaks team web site and to Strava.

Screenshot of MapMyTracks Database

Screenshot of MapMyTracks Database

Python Recovery Script

This is a quick and dirty script for extracting a single Activity at a time.  It can do with refactoring and polishing up, but it does the trick  If you require more functionality, drop me a line.

Save the script and data file into a folder.  Ensure you have Python installed on your system and open a terminal or command prompt in the same folder and run:

python recover.py

You will be presented with a screen

------------------------------------------------------------------------------------
 WELCOME TO THE MapMyTracks.com ACTIVITY RECOVERY SCRIPT
------------------------------------------------------------------------------------
1. Select Database
2. Check Available Activities
3. Export Activity
4. Quit
-----------------------------------------------------------------------------------
Enter your choice [1-4] :
  1. Select 1 and enter your database name. The default is MapMyTracks.sql, which is the default database in the iPhone
  2. Select 2 and find the corrupt activity and find it’s id
  3. Select 3 and enter the activity id. Select a name for your file and save it.
  4. Select another activity or database or exit
  5. Your recovered data is saved in the folder containing your database and this script

Enjoy, I hope this helps someone else out. Download Script Here

#!/usr/bin/python
#########################################################
#
# Recover an Activity from a corrupt MapMyTracks Database
# Paul Sutherland
# mail@paulsutherland.net

####################### 
# The MIT License (MIT)
#
# Copyright (c) 2013 Paul Sutherland mail@paulsutherland.net
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

##############
# Instructions
#
# MAKE SURE YOU HAVE PYTHON INSTALLED ON YOUR SYSTEM: www.python.org
#
# 1. Save you database in the same folder as this script
# 2. run python recover.py from the command line
# 3. Select 1 and enter your database name.  The default is MapMyTracks.sql, which is the default database in the iPhone
# 4. Select 2 and find the corrupt activity and find it's id
# 5. Select 3 and enter the activity id.  Select a name for your file and save it.
# 6. Select another activity or database or exit    
# 7. Your recovered data is saved in the folder containing your database and this script

import os
import sqlite3
import time

database = ""

## Show menu ##
def menu():
    global database
    print (61 * '-')
    print ("   WELCOME TO THE mapmytracks.com ACTIVITY RECOVERY SCRIPT")
    print (61 * '-')
    print ("1. Select Database")
    print ("2. Check Available Activities")
    print ("3. Export Activity")
    print ("4. Quit")
    print (61 * '-')

    is_valid=0

    while not is_valid :
        try :
            choice = int ( raw_input('Enter your choice [1-4] : ') )
            is_valid = 1 ## set it to 1 to validate input and to terminate the while..not loop
        except ValueError, e :
            print ("'%s' is not a valid choice." % e.args[0].split(": ")[1])

    ### Take action as per selected menu-option ###
    if choice == 1:
        get_database()
        menu()

    elif choice == 2:
        available_activities(database)
        raw_input('Enter to continue: ')
        clearScreen()
        menu()

    elif choice == 3:
        get_activity(database)
        menu()

    elif choice == 4:
        print "Thanks, Goodbye"
        exit()

    else:
        print ("Invalid number. Try again...")
        raw_input('Enter to continue: ')
        clearScreen()
        menu()

def get_database():
    global database
    try:
        default = 'MapMyTracks.sql'
        user_database=str(raw_input('Enter Your Database Name [%s]:' % default))
        database = user_database or default

        print (50 * '*')
        print "Database set to: " + database
        print (50 * '*')
        raw_input('Enter to continue')

        clearScreen()

    except ValueError:
        print "Check Your Database Name and it is in the same location as this script"

def available_activities(database):
    try:
        conn = sqlite3.connect(database)
        cursor = conn.cursor()
        cursor.execute("SELECT id, title FROM track")
        lines = cursor.fetchall()

        print '*' * 61
        summary_format = '%-*s%*s'
        print summary_format % (4, 'ID', 5, 'Activity')
        for activity in lines:
            print summary_format % (4, activity[0], 5, activity[1])
        print '*' * 61
        get_activity(database)

    except sqlite3.OperationalError:
        print "Check Your Database Name and it is in the same location as this script"

def get_activity(database):
    try:
        activity=int(raw_input('Enter The Activity ID to Recover:'))    
        conn = sqlite3.connect(database)
        cursor = conn.cursor()
        cursor.execute("SELECT * FROM location WHERE track_id=%s" % activity)
        lines = cursor.fetchall()
        cursor.execute("SELECT title FROM track WHERE id=%s" % activity)
        activity_name = cursor.fetchall()
        recover_activity(lines, activity_name)
    except ValueError:
        print "Could not find that ID"
        raw_input('Enter to continue: ')
        clearScreen()
    except sqlite3.OperationalError:
        clearScreen()
        print "Check Your Database Name and it is in the same location as this script"
        raw_input('Enter to continue: ')
        clearScreen()

def recover_activity(lines, activity_name):
    default = str(activity_name[0][0]) + '.gpx'
    output_name=str(raw_input('Save File As [%s] or enter custom name:' % default))
    output_name=output_name or default
    f = open(output_name,'w')
    f.write('\n')
    f.write('\n')
    f.write('\n')
    for line in lines:
        lon=line[3]
        lat=line[2]
        elv=line[4]
        acTime=time.strftime('%Y-%m-%dT%H:%M:%SZ',time.gmtime(line[7]))
        f.write('\n' % (lat,lon))
        f.write('\n' % acTime)
        f.write('%.1f\n' % elv)
        f.write('\n')
    f.write('\n')
    f.write('\n')
    f.write('\n')
    f.close()

    print "File Saved at: ", os.path.abspath(f.name), f.name
    raw_input('Enter to continue: ')
    clearScreen()

def clearScreen():
    import os
    os.system("clear")
    menu()

if __name__ == "__main__":
    clearScreen()

Create an Amazon EC2 Ubuntu Instance connect by SSH and Mount the file directory on your Ubuntu desktop PC

Amazon Web Services (AWS) are one of the pioneers of the Cloud Computing epoch.  Setting up a server and connecting to it is no walk in the park.  The security is stronger than a username and password and requires a good bit of effort to get right.  AWS use public key infrastructure.

Setting up an account

Firstly you need to set up an account with Amazon’s Web Services. Now press the sign up now button here and sign your wallet away ;-P

HEALTH WARNING: You have now registered for Amazon Web Services to bill your credit card for resources you use.  Be very careful and make sure you stop or terminate instances you do not want to run permanently.  If you are trying something out and forget, and especially if you don’t check the account activity often, you may end up with a large unexpected bill.  You have been warned and I wear the scars :-/

Once you have an account set up you will now have access to the AWS Management Console.  This console allows you to create new EC2 instances, set-up Simple Storage ServiceElastic Beanstalk and manage many more of AWS’ products, with the capability to launch these in the US, Asia and Europe.

Security Credentials

Create a Cloud Folder

Let’s create a folder in your home folder, which we will use to keep our security certificates and private keys in.

cd ~/ 
mkdir .cloud

Make sure you can see it by listing all files in the directory

ls -a

Get your Certificate and Private Key

On your account page select the security credentials option and under the Access Credentials select X.509 certificates.  Here select “Create a new Certificate”.  You will now create your security certificate and your private key.  Download both and save it your new .cloud folder. You only get one shot at downloading your private key, so keep it safe!

image
AWS’ Management Console for controlling your EC2 instances and much more.

From the Command Line with EC2 API Tools

Launching instances from the AWS Management Console is fine, however, if you want to take it a step further and you want to SSH into your instance or programmatically launch and control instances, perhaps in a load–balancing scenario, you will need to install EC2 API Tools.

Open a terminal and run:

sudo apt-get install ec2-api-tools

Set Environment Variables

We need to set some environment variable to let EC2-api-tools work.  We do this by setting the variable in your .bashrc file in your home folder.  Add the following to the bottom of your file:

cd ~/
nano .bashrc
.........
 export EC2_PRIVATE_KEY=$HOME/.cloud/pk-XXXXXXXXXXX.pem
 export EC2_CERT=$HOME/.cloud/cert-XXXXX.pem
 export JAVA_HOME=/usr/lib/jvm/java-7-openjdk/
 ........

Commit the changes

source ~/.bashrc

Run the tools to list the available images to see if we are working.

ec2-describe-images -o self -o amazon

Take Stock

Ok at this point you should have a large amount of data on your terminal, resembling something similar top the extract that i received when I ran the command:

..............
IMAGE    ami-db20c3b2    ec2-public-windows-images/SqlSvrExp2003r2-i386-Win-v1.07.manifest.xml    amazon    available    publici386    machine            windows
IMAGE    ami-d920c3b0    ec2-public-windows-images/SqlSvrExp2003r2-x86_64-Win-v1.07.manifest.xml    amazon    available    publicx86_64    machine            windows
IMAGE    ami-0535d66c    ec2-public-windows-images/SqlSvrStd2003r2-x86_64-Win-v1.07.manifest.xml    amazon    available    publicx86_64    machine            windows
..............

If you have an error, you need to go back and follow the above steps.  Make sure you have registered correctly with AWS, make sure the files are in the .cloud folder and the Environment Variables are correct.

Try the following to make sure you are pointing to the correct files:

paul@solar:~$ $EC2_PRIVATE_KEY
bash: /home/ubuntu/.cloud/pk-********************.pem

paul@solar:~$ $EC2_CERT
bash: /home/ubuntu/.cloud/cert-******************.pem

paul@solar:~$ $JAVA_HOME
bash: /usr/lib/jvm/java-7-openjdk: is a directory

If you are following me at this point congratulations.  You have a working account, installed the API tools and have your certificates working with your account and your PC.  lets crack on.

Create a Key Pair

Log into your Amazon Management Console and navigate to the ‘Key Pairs’ option under ‘Networking and Security’ (bottom left of the console).  Here you need to create a key pair to allow you to use Public AMIs.  Add a key pair and call it aws-key.  You will then download your private key, which you should save to your .cloud folder.

Launching your First Instance from the Command Line

Ok lets launch an Ubuntu Precise 12.04 LTS Server in the Europe Region:

ec2-run-instances ami-66cf2a11 --instance-type t1.micro --region eu-west-1 --key aws-key
RESERVATION    r-0463da72    176146590799    default
INSTANCE    i-ae8bf3d8    ami-379ea943            pending    aws-key    0        t1.micro    2011-06-22T20:27:13+0000    eu-west-1b    aki-4feec43b            monitoring-disabled

So what has happened here? Well we have launched a t1.micro instance of an Ubuntu Precise server in the eu-west-1b region.  Check out your running s instances in your Amazon Management Console.

SSH into you new instance

First change the permissions of your private key:

chmod 600 ~/.cloud/aws-key.pem

Now allow port 22 access:

ec2-authorize default -p 22

Now try logging into the Instance

ssh -i ~/.cloud/aws-key.pem ubuntu@<instance address>

SSH Agent

Set-up  your desktop machine to prevent having to enter your password every time you log in:

mkdir ~/.ssh/
cd ~/.ssh/
ssh-keygen -t dsa
cat ~/.ssh/id_dsa.pub | ssh -i ~/.cloud/aws-key.pem ubuntu@<instance address> "cat - >> ~/.ssh/authorized_keys"

Now use an agent to keep authenticated

ssh-agent
ssh-add

Now try logging in to the remote server and you do not have to enter your password

ssh ubuntu@<instance-address>

Finally mounting the file system

On your Ubuntu desktop Go to Places > Connect to Server

Select ssh,

user: ubuntu

folder: /home/ubuntu

Bookmark name: whatever you want to call this instance

All done.  Now remember:

HEALTH WARNING: You have now registered for Amazon Web Services to bill your credit card for resources you use.  Be very careful and make sure you stop or terminate instances you do not want to run permanently.  If you are trying something out and forget, and especially if you don’t check the account activity often, you may end up with a large unexpected bill.  You have been warned and I wear the scars :-/

Terminate through the AWS Management console or the command line:

ec2-terminate-instances --region eu-west-1 <instance id>

Hope you enjoyed,

Cheers………..

Paul

Emmet Livestyle and Chrome

Although in Beta, the new bi-directional livestyle editor is a promising tool for live CSS editing.  Simply install the livestyle plugin for the Sublime Text Editor from Package Control then download the Chrome addin.

Sublime Text Setup

Step 1: Open Package Manager in Sublime Text:

Open from the menu

On the Sublime Text Menu bar select:

  • Tools > Command Palette

Open with the Keyboard Short Cut

The most important keyboard shortcut to remember for Sublime Text is getting to the command palette.  Here they are for Linux, Windows and Mac:

  • Ctrl-Shift-P for Windows and Linux
  • Cmd-Shift-P for Mac OS

Step 2: To install a package, type: Package Control: Install Package

Step 3: Type: Livestyle to install the Livestyle plugin

(Install Instructions are here if package manager is not installed in your Sublime Text Editor)

Chrome Browser Setup

Step 4: Download the Livestyle plugin for Chrome, or browse the extensions from the Chrome Menu:

  • Tools > Extensions > Get More Extentions

Step 5: You now have a Livestyle panel in your Chrome DevTools.

Wow. You can now do this:

 

Check out the Livestyle usage on their website.

Google Glass, the future of app development and the totalitarian tiptoe!

Here are my slides from the talk that I presented at the Software Society about Google Glass.

The world of technology is about change with the launch of Google Glass and we will take another big step forward through our technological revolution. The way we interact with our world and people will change. This talk is about how we will develop apps for Glass and how you can get thinking about that now before Glass is available to the general public. This change will bring into question, as always, the protection of our privacy and civil liberties and I will open up a discussion of what might happen and what we can do to protect ourselves.

The Software Society meets every fortnight, at 7pm on Thursdays, in the Burgh Coffeehouse in Dundee.  Membership is open to anyone and carries a small annual fee to cover running costs. Members discuss technology related subjects: from security (Ethical Hacking), FOSS (Linux, Android, Unix and other Open Source Software), Windows, web-programming, PGP encryption, Django and even Tennessee Fainting Goats.

Members range from Tech Industry Professionals, Hacker Students, Geeks and Tinkerers, Software Fascists and Hardware Gurus.

The meeting generally spills over into the pub with raging debates this week about what is the best tablet to buy, what sucks on current operating systems and generally anything else that was on our minds that required an exorcism!

These slides are available with embedded videos from here:

LibreOffice:

http://bit.ly/12ZKd3a

Power Point:

http://bit.ly/13piigi

Ben Dorain and Beinn an Dòthaidh

Ben Dorain from the A82

Ben Dorain from the A82

Erupting out of the Glen Floor at Bridge of Orchy, Ben Dorain is the archetypal triangular mountain and a familiar and imposing sight as you round the A82 a mile or so north of Tyndrum.  The slopes are weathered and scared by ice and water and they rise steeply to a bull nose summit, which at 1,076m or 3,530ft high, it is Scotland’s 64th Highest Munro.

As part of my ongoing training for the 6 peaks Challenge, I climbed these Mountains on Saturday 8th June 2013.

The ‘V’ shaped ridges on the rear of Ben Dorain extend north along a ridge that connects it to Beinn an Dòthaidh, at the Col of Coire an Dòthaidh, which is visible from the A82 driving towards and through Bridge of Orchy, and a north east ridge connecting it to Meall Garbh.

The start point for my ascent was from the Bridge of Orchy railway station, which is reached via the access road directly opposite the Bridge of Orchy hotel.

Walking through the station, and under the underpass below the West Highland Railway Line, you pass through a gate and onto the slopes of Coire an Dòthaidh. The route in fairly obvious as the path extends steeply up to the Col that connects Ben Dorain’s North Ridge and the slopes of Beinn an Dòthaidh.

The path is very badly eroded, it could benefit from a project that organisations such as the National Trust for Scotland have carried out on other popular Mountains and create a narrower path to allow the route to regenerate and recover from the damage.

Once you reach the top of the Col, the views open up with Coire a’ Ghabhalaich in front of you, the path to the summit of Ben Dorain on your right and the path to the summit of Beinn an Dòthaidh on your left.

Follow the winding path to the summit of Ben Dorain, but look out for a fork on the path marked by a small cairn. The left hand path across the Knoll takes you across the ridge to the summit, and the right hand path skirts along the southwesterly face of the North Ridge. I took the right hand path to the summit, which skirts around a bouldery path that tightens and snakes up the southern side of the summit. There was no great difficulties on this path.

Fork in North Ridge path to summit of Ben Dorain

Fork in North Ridge path to summit of Ben Dorain

The position of Ben Dorain offers outstanding views with a panoramic of ranges including: the Crainlarich Range, Tyndrum Hills, the Ben Lawers Range, Glencoe, Glen Etive, The Cruachan Range, Ben Nevis and more.

I descended the path along the North Ridge and back down to the Col, where I picked up the North East path onto the slopes of Beinn an Dòthaidh.  There are three peaks on this hill with the middle being the highest and the summit of the Mountain, at 1,004m or 3,293 ft, it is Scotland’s 129th highest Munro. Whilst the ascent is fairly mundane, as you walk up steep grass slopes, the summit offers stunning views across Rannoch Moor and Loch Tulla from its north face, which has a very steep cliffs. It is well worth the climb.

The descent home is back down to the Col and then down Coire an Dòthaidh back to the railway station.

 

Lochan on North Ridge of Ben Dorain - Taken in April 2010

Lochan on North Ridge of Ben Dorain – Taken in April 2010

Summary

Total walk was: 14.19km and took 4hr 25min.
Weather: Dry, Sunny, Very Hot, 24c
Visibility: Good
Clarity: Good
OS Grid Reference: NN32573786