Wednesday, December 17, 2014

Coding in the cloud

I have found myself using a number of different computers both on the move and at home. This is a pain. The Chrome browser has helped me bring together bookmarks and browsing history across my devices - it has worked flawlessly so far - except on a 7 inch tablet where the tabs are a little too small and the keyboard too large. But what I have wanted for a little while now is a development environment that can be accessed from any machine and anywhere.

There are of course the hosted full blooded virtual instances in Amazons and Microsoft's cloud. So far the MS Azure instances look to be the easiest to use. Remote desktop access may be blocked from certain locations. Another gotch with Azure is that if you select an Azure VM with a paid for product such as Oracle then your account will be blocked the next day and you will have to drop out of the free trail period to continue. AWS looks a little more complex to set up. Watch this space. There are web based coding environments such the Koding web based IDE using Python. See this earlier post. But these are only point solutions.

I spent some time selecting the 'best' Chromebook for me to use as a portable machine, I can not afford a MacBook Air, and small and light Windows machines are either too expensive or not worth the bother. I eventually settled on a Acer C720 I am very happy with this purchase. It is almost perfect for use on the train. The network teathering to a phone works well. So far EE have proved to provided better and faster coverage than giffgaff (O2) on the great western mainline out of Reading.
Next I'll look at the ssh client and Crouton.

Thursday, December 4, 2014

git - Version control

git , implemented as a service by gitlab and github, offers DVCS - distributed version control - which has a number of advantages over previous approaches using CVS, SVN or older proprietary approaches such as PVCS. Gitlab and Github differ mainly in there focus with Gitlab aimed at corporate's that might want continuous integration features 'out-of-the-box'. Github is bigger and has recently been acquired by Microsoft.

Git's basic advantages are that it:
- allows developers to version locally, although I am currently using onedrive to backup active files and folders
- allows sharing, backup and version-ing to the cloud via github
- provides a fast and efficient toolset
- it is either free or very cheap, depending on how it is used.

These advantages are better described here

github is free for a single user, if you don't mind anyone seeing the contents of your repository.

If you understand the principals of version control then this text will bring you up to speed with the product and the key differences with SVN.

Then try the on line interactive tutorial here.

If you understood that the next step I would recommend, assuming you have some basic Linux command line knowledge and are on a Windows machine, is to create a free github account and install git locally within Cgywin. Installing and using git this way does not impact the rest of your Windows installation like using an extension to Windows Explorer would. It also installs everything you need in one process.

For Ubuntu install using sudo apt-get install git-core

If you do not have a github account create one here. My example is 'https://github.com/colfraser/'

Install Cygwin from the project page. Follow the install defaults until you get to the Select Packages dialogue . Type 'git' in the search field and install from the devel category. The package is call 'git: Distributed version control system' or something close to it. In a similar fashion also install ssh, take this from the net category, it will be called something like openssh. The current version of Cgywin references git version 1.7.9 which works fine. The installation may take up to 5 minutes depending on connection speeds.

Check the install at the Cgywin command line with the following command,

git --version

#set up local variables to match how you have set up github.
git config --global user.name "Colin Fraser"

git config --global user.email "address@domain"

#Check the config just entered
more ~/.gitconfig

#This commands generates the security keys which will will ignore for the moment
ssh-keygen -t rsa

create a new repository on github, for example PET_Names. Use the '+' button the top of the screen. Check the box next to 'Initialize this repository with a README'.

env GIT_SSL_NO_VERIFY=true git clone https://github.com/colfraser/PET_Names
#This command allows the SSL security to be ignored so it is not recommended for normal use but it allows the remote repository that we have just created to be instantiated on our local machine.

cd PET_Names # Move into the folder created in the clone process

#Add some files and change the readme
echo 'new line 04/12/2014' >> README.md

git status
# shows modified files

echo "new file" > another_file.txt


git status
# shows modified file and new files

git add .
#add the files to the local 'staging area'

git commit
#commit those files to the local git repository. Add comment in the vi editor box that will pop up. Type 'I' to insert, ':wq' to save.

git status
#will show nothing to commit

git push
#This uploads the committed changes in the local repository to the github repository that was cloned locally previously. The github account name and password will need to be entered. These entries are not echoed to the screen.

#change the xml file using vi or via Windows.

git diff
#will show changes

git add *.xml
git commit
git push

There is a good overview of getting started with git and the GUI local git repository tool tortoise here.

This tool provides an extension to the Windows explorer and was inspired by the SVN tool.

Git for Windows provides a Windows App and 'Git Bash' a command line emulator to access git on Windows like you would on Linux.

A cheat sheet for command line git is here