This is a concoction of geeky posts, programming posts and just general stuff that is in my brain.

It might be updated often but then again it might not...

 

 

Pushing a local Git repository to a new remote repository

For reasons completely unknown I find it *really* difficult to remember the syntax in Git to push a new local repository to a remote destination.

So to stop from scratching my head about it, I am going to put it here. Two reasons:

1. so I know I can find it

2. it might help someone else looking for it

So, you've create a local git repository on your machine and what to push it to a remote server? (In this example I am going to use http://BitBucket.org)

Firstly, log in to BitBucket and create a new blank repository.

Once that is done, using git bash in your local repository execute the command

git remote add origin git@bitbucket.org:{BITBUCKET_USERNAME}/{REPO_NAME}.git

Obviously, replacing {BITBUCKET_USERNAME} & {REPO_NAME} with the real values!

This will add the the BitBucket URL as a local remote alias called "origin" to your local repo.

Now you need simply need to push your local repository (usually called master) to your remote repository. Which is called origin as we have just given it that alias!

To be clear, you can call your remote alias anything you like it doesn't have to be origin. In this instance calling your alias bitbucket would make sense.

git push origin master

And that is all you need to do! Really simple but for some reason I can never remember it.

As a side note, there is also a really handy git reference guide on GitHub

Posted by codingbadger at 13:28

Stack Overflow Careers - not just for the Stack Overflow hardcore

Pretty much every developer in the world knows about Stack Overflow, searching for a solution to a development problem in Google will almost certainly throw up a pretty damn good answer on Stack Overflow.

Along will many other Q&A sites that are now available on Stack Exchange there is a Careers site too.

Careers 2.0 is a place to show off your awesomeness. And I don't mean your awesomeness on Stack Overflow - I mean everywhere! 

As Careers 2.0 is tied to Stack Overflow there are certain aspects of it which are designed to promote your activity on Stack Overflow.

Such as the tags you are active in:

Tags

Your Stack Exchange accounts:

SE Accounts

Along with any "top answers" you feel that are exceptionally good you need to show them off.

And that is it - the rest of your profile is up to you.

 

I will go through and show you some of the main sections that are on your Careers 2.0 Profile to demonstrate that most of this is nothing to do with Stack Overflow.

A personal statement

personal_statement

Add whatever you like here - it's entirely up to you. Just make it good!


Tech

Add the technologies you are interested in and if you want, the technologies you aren't interested in.

A number of the sections that relate to technology allow you to choose the same tags that Stack Overflow uses when you post a question. I am guessing this makes it easier for Employers to search through candidates who like a particular technology.

Experience & Education

Fairly self explantory to be honest. You add your previous roles along with a short description, time frames and the technology you used.

OpenSource

This is where it can get interesting. You are able to to add links to any open source projects that you have worked on. This allows you to put your real projects out there on display and make it easy for potential Employers to find and immediately see how you would normally write code. Remember, this is code that you have written properly, not some pseudo crap that you have quickly knocked together so you can earn a quick 20 or 30 rep on Stack Overflow.

Apps

Again more opportunities for you to show off your real acheivements.

Writing & Reading

The Writing section allows you to link to Amazon for any books that you may have written and also to any articles or blog posts you may have written that you feel will make you stand out from everybody else.

The Reading section is pretty similar and lets you link to Amazon for any books you have read and again any blog posts that you have read.

Obviously, you should pick and choose the relevant books that you have read. I'm pretty sure potential Employers do not need to know that you have read the "Shoot Annual" from 1983 :)

 

There are other sections that you can complete on your profile along with some other nice pieces of functionality but I don't want to spoil all of the surprises!

I get the impression that a lot of people think that Careers 2.0 is very closely tied to Stack Overflow and more specifically to the reputation that you have on Stack Overflow. This is simply not the case and I hope you can now see why your reputation on Stack Overflow is a pretty small factor when it comes to your Careers 2.0 profile.

It seems I am in good company as Joel Spolsky blogged about why reputation on Stack Overflow isn't what Careers 2.0 is about.

Oh, and here is a link to my Careers profile should you wish to have a look :)

Posted by codingbadger at 09:36

Connecting to BitBucket with more than one account

 

This is a short follow up to my previous post, on how to setup an environment so that you can connect to GitHub or BitBucket on the same machine using different user accounts.

A few people have asked how they can create multiple user on one machine that point to the same host e.g. BitBucket.org

Well, you will be pleased to know it is really simple!

You need to follow the same steps as my previous post, apart from some small changes in the Config file.

So you need to:

  1. Create a new SSH key pair remembering to give each key pair unique names
  2. Add the SSH Key to your BitBucket account
  3. Add the SSH Key to the SSH Agent

And now for the Config file!

I will assume that you have created one SSH Key pair called id_rsa_work and one SSH Key pair called id_rsa_personal and both of these accounts are held on BitBucket.

Last time we used the config file to ensure that Git used the correct Key file depending on whether we were connecting to GitHub or BitBucket. We will do pretty much the same here but we will assign different Host names so that Git knows which Key file to use.

 

# Work user account for BitBucket
Host bitbucket.org
 
HostName bitbucket.org
  
PreferredAuthentications publickey
 
IdentityFile ~/.ssh/id_rsa_work
  
  
# Personal user account for BitBucket
Host bitbucket-personal
 
HostName bitbucket.org
  
PreferredAuthentications publickey
  
IdentityFile ~/.ssh/id_rsa_personal

See how we have used change the Host value to bitbucket-personal, it works pretty much the same as changing the hosts file on your PC.

So now if we wanted to clone a Git repo from BitBucket using our Work account we use this:

git clone git@bitbucket.org:MY_WORK_USER_NAME/MY_WORK_REPO_NAME.git

And now, I want to clone a repo from my personal BitBucket account...

git clone git@bitbucket-personal:MY_PERSONAL_USER_NAME/MY_PERSONAL_REPO_NAME.git

All you need to do is change the host from bitbucket.org to bitbucket-personal - Git will work out which key file to use.

 

Note: This approach will also work for GitHub.

Posted by codingbadger at 11:15
Tags :

Setting up multiple user profiles in Git

This post should hopefully help you setup multiple user profiles when using Git on Windows.

I had already set up my Git installation to connect to GitHub using my personal email address. I then wanted to add another profile to connect to BitBucket using my work email address.

So, how did I do it?

Create a new pair of SSH Keys

The first step was to create a new pair of SSH keys using my work email address so I can connect to BitBucket. I am going to backup my current SSH keys just incase anything goes wrong. So open up your Git Bash console and type:

cd ~/.ssh
mkdir key_backup
cp id_rsa* key_backup

 

This will copy any SSH keys in the the "key_backup" directory we just created.

Now we need to create a new SSH key pair for my work email 

ssh-keygen -t rsa -C "MyWorkEmailAddress"

It will prompt you to give the key file a name:

Enter file which to save the key (/c/documents and settings/USERNAME/.ssh/id_rsa):

You need to specify a new name or it will overwrite your existing keys - which you don't want.

Enter a name of your choice - I used

id_rsa_work

You will then be prompted to enter a passphrase and your new key will be created.

 

Adding the Key to your BitBucket account 

You will need add the newly created SSH Key to your BitBucket account.

Naviagte to your /.ssh/ directory and open up the newly created key file in a text editor. It will be called what ever you name you gave it in the last step, so in my case it is called id_rsa_work.pub

Copy the entire line as it is, to your clipboard.

Log in to your BitBucket account and navigate to your "Account > SSH Keys" section.

Paste your key in to the text box and click Add Key


Adding the SSH keys to the SSH Agent

Now we need to add to the SSH Agent so it knows about the new key pair we have just created.

Still in your Git Bash console type:

ssh-agent.exe bash

Then type

ssh-add.exe ~/.ssh/id_rsa_work

I called my new key pair id_rsa_work but if you have given it a different name then use that one here.

Then type

exit

 

Configuring your config

In Windows Explorer navigate to your .ssh directory (usually in your profile directory)

Edit the file named "config" in a text editor. (If there isn't one there just create one)

You then need to add the following details to the file:

# Default GitHub user
Host github.com
  HostName github.com
  PreferredAuthentications publickey
  IdentityFile ~/.ssh/id_rsa

# Work user account
Host bitbucket.org
  HostName bitbucket.org
  PreferredAuthentications publickey
  IdentityFile ~/.ssh/id_rsa_work

 

This will tell Git that when I connect to the host github to use the id_rsa key pair but when I connect to bitbucket to use my id_rsa_work key pair.

Save and close the config file.

 

That is all that you should need to do. Now if I try to clone a repo from Github like this:

git clone https://github.com/MY_USER_NAME/MY_REPO_NAME.git

It will use my GitHub credentials and the SSH Keys created using my personal email.

However, cloning a repo from BitBucket like this:

git clone git@bitbucket.org:MY_USER_NAME/MY_REPO_NAME.git

It will use my BitBucket credentials and the SSH keys created using my work email.

 

Note:

This post is a bit rushed as I wanted to get out as soon as possible whilst still fresh in my mind!

Posted by codingbadger at 10:15
Tags :

Umbraco - How to amend uBlogsy to use Atom 1.0

I use the uBlogsy blog package for Umbraco for my blog, whilst looking at my blog posts in Google Reader I noticed that all formatting, images, links etc where being stripped out.

So after a bit of digging around on the Umbraco forums, it appears the uBlogsy strips out any HTML. This was easy to resolve but it was then pointed out to me by Rik Helsen that my RSS 2.0 feed would be invalid.

So, with a bit of tinkering I re-wrote the Razor file to use the Atom 1.0 format rather than RSS 2.0, with the advantage that you can include HTML in Atom.

The Razor file you need to amend is located in the Developer section under:

/ScriptingFiles/uBlogsyRSS.cshtml

There are certain sections that I have hard coded which you will have to change for your own site.

If you have any questions feel free to drop me an email or post a comment on this post. 

 

@{
     /*  RSS  FEED  */
}

@using  System.Linq
@using  System.Xml.Linq
@using  umbraco.MacroEngines
@using  uBlogsy.Web.Extensions
@
     //  get  all  posts
     DynamicNodeList  postList  =  Model.AncestorOrSelf(1).DescendantsOrSelf("uBlogsyPost");
     var  posts  =  postList.Items.OrderByDescending(x  =>  x.GetProperty("uBlogsyPostDate").Value);

     string  lastPubDate;
     if  (posts.Count()  ==  0)
     {
         lastPubDate  =  DateTime.Now.ToString();
     }
     else   
     {   
         lastPubDate  =  posts.FirstOrDefault().GetProperty("uBlogsyPostDate").Value;   
     }   
     //  get  landing  page   
     var  landing  =  Model.AncestorOrSelf(1).DescendantsOrSelf("uBlogsyLanding").First();   
     <feed  xmlns="http://www.w3.org/2005/Atom">   
         
             <title>@landing.uBlogsyRssTitle</title>   
             <link  rel="self"  href="{http://YOUR RSS FEED ADDRESS/}">   
             </link>   
             <author>   
               <name>{YOUR NAME}</name>   
               <email>{YOUR EMAIL ADDRESS}</email>   
             </author>   
             <updated>@lastPubDate.FormatDateTime("yyyy-MM-dd'T'HH:mm:ss'Z'")</updated>   
             <id>{http://YOUR BLOG ADDRESS/}</id>   
   
   
             @foreach  (var  p  in  posts)   
             {   
                     <entry>   
                             <id>@p.Url</id>   
                             <title>@p.GetProperty("uBlogsyContentTitle").Value</title>   
                             <author>   
                                  <name>@p.GetProperty("uBlogsyPostAuthor").Value</name>   
                             </author>   
                             <rights>@landing.uBlogsyRssCopyright</rights>   
                             <link  href="@p.Url"></link>   
                             <content  type="html">   
                                   @Html.Raw(@p.GetProperty("uBlogsyContentBody").Value)   
                              </content>                             
                             <updated>@p.GetProperty("uBlogsyPostDate").Value.FormatDateTime("yyyy-MM-dd'T'HH:mm:ss'Z'")  </updated>   
                     </entry>   
             }   
     </feed>   
}

 

Posted by codingbadger at 12:21

Authors

Recent Comments

Powered by Disqus