Saturday, 12 September 2015

Using Cloud9 with BitBucket

Free online version control and IDE: Bitbucket & Cloud9 using Git

If you know how to program, and want to version control a project online this might help.

I wanted to develop a Python program and run everything online because my main computer is now a chromebook, and I want to access it from wherever I am.  This is a step by step guide to how I did it.

Looking around on the Internet it looks like Bitbucket and GitHub are the obvious choices for actually storing, and version controlling the project files in a 'repository'.  

Both of these are also integrated with the Cloud9 IDE (Integrated Development Environment) which allows you to see the code you edit, run, and debug it.

Whilst Git may be fast for large repositories (the set of files under version control), it doesn't have an intuitive user interface. However I know how to use it so I chose that option rather than mercurial.

Cloud9 and Bitbucket: Step by step guide

You need to create an account for both of these.  I used google to login to Bitbucket and then I used Bitbucket to login to Cloud9, so no new passwords to create!
  • Create Bitbucket Account
    • bitbucket.org
    • Get Started
    • Get Started with your Google account
    • Sign into Google and allow BitBucket permission to access Google
    • Select Personal or 5 member team account for free usage
    • Set a password later
  • Create a repository in Bitbucket.  
    • You should already be logged into bitbucket.org
    • On the Get Started page it already have a button to create a repository, otherwise "Create / Create Repository"
    • Choose a name and the default options, including git
  • Create Cloud9 Account
    • c9.io
    • Try it now
    • Bitbucket
    • Grant access
  • Create a Cloud9 Workspace linked to your Bitbucket Repository
    • Repositories
    • Hit 'Clone to edit' on the Bitbucket repository you just created
  • Create and run a simple python file
    • File / New file
    • Paste this code into it
#!/usr/bin/python
print ("Hello World")

    • File / Save / hello.py
      • You should now see the hello.py appear in the workspace directory structure on the left
    • Hit the Run triangle to run it!
      • It should say hello world in a window at the bottom of the screen
  • Save this file in the repository
    • Select the 'bash -"cloning ..."' tab, and enter these commands:
    • git status
      • Shows state of the repository. Should show hello.py isn't tracked
    • git add hello.py
      • Add file to list of files to be stored in the repository
    • git status
      • Show file is now added
    • git commit -m "first commit"
      • Save the file in the version of the repository on cloud9 (not on bitbucket though which is where we really want it saved eventually)
    • git status
      • File is not
    • git push --set-upstream origin master
      • type 'yes' to confirm connection to bitbucket at the scary looking 'are you sure you want to connect?' message
      • This is a 'Magic' command and does this:
        • pushes the files in the cloud9 version of the repository to the bitbucket version of the repository
        • 'origin master' tells the git the exact details of the repository it needs
        • the '--set-upstream' bit means you never need to add the 'origin master' bit ever again :-)
  • Check the file has made it to bitbucket
    • bitbucket.org
    • click on the repository in the 'overview' pane
    • navigation / source
      • hello.py should be there!
    • click on hello.py to see the source code!
  • Edit file and update it on the repository
    • c9.io
    • open workspace
    • click on 'hello.py' to edit it
    • add a line so it reads like this
#!/usr/bin/python
print ("Hello World")
print ("Hello Again")
    • hit run (which also actually saves it)
    • Select the 'bash -"cloning ..."' tab
    • git status
      • shows we haven't added it yet, but it has changed
    • git add hello.py
    • git status
    • git commit -m "testing repo again"
    • git status
    • git push
      • no need to add the 'origin master' bit this time
And you're done.  You can check it's made it to Bitbucket correctly in the same way as above.

Happy coding!

    Thursday, 10 September 2015

    Create a shortcut for each different profile on Chrome

    The whole family use Chrome as their browser.  On Windows machines we like to all have a browser open each with our own profile on it.  To launch each profile we single click on our shortcut in the Quick Launch toolbar.

    I had to reinstall windows (HDD fail), but I couldn't work out how to get the shortcuts back.  The Internet wasn't very helpful and had lots of mediumly hard sounding solutions.  So I had to work it out myself.  Here it is:

    How to create a shortcut for each profile on Chrome:

    1. Login to the profile you wish to create a profile for (left click on the current profile name at the top right of the browser and follow your nose)
    2. Hit the customize and control button in the top right hand corner (3 horizontal lines)
    3. Settings
    4. People
    5. Double click on the profile you want to create a shortcut for which is labeled as 'current'
    6. Choose a picture (or photo) so you can identify which profile shortcut is which.
    7. Click on the 'Add desktop shortcut' button << money shot
    You can now drag the shortcuts onto the quick launch bar.