Setting up Git and Github on Windows

Recently I’ve needed to set up a number of Windows XP machines with Git and github access.  It turns out this is not an easy problem, certainly not as easy as SVN.  Most of the problem stems from the fact that all transfers/pulls/pushes to github are done through SSH.  So we have two different apps (Git & Putty) trying to work together and it’s just not as clean as on a *nix based system.  But once things are set up, it works very well.  The first time I did it for myself, it was a wild adventure of trying changes to the PATH, environment variables, keys, etc.  Thankfully, I have it down to a quick and fairly painless science, which I present here for anyone else needing help.

  1. You probably already have a github account. If you don’t, sign-up at least for the free account now.
  2. Obtain the necessary software.  Note that we’re using a pseudo-unofficial version that does not require cygwin.  It works great and supposedly will be merged with the official version soon.
    1. MSYS Git – Used here specifically is preview20080413
    2. Putty 0.6.0 – Download the Windows Installer
  3. Install both packages of software.  They are very simple installs and all the defaults work fine.
  4. Generate your key. This is your personal key that will allow you access to github (and you’ll probably want to use it for accessing servers as well. Much better than passwords). If you already have a private key you’d like to use, then open PuttyGen, click the ‘Load‘ button in the middle, and skip to substep #6.
    1. Open PuttyGen, click ‘Generate‘, and follow the instructions to generate randomness
    2. Add some info to the key comment. I like to put my name in addition to the default
    3. Highly Recommended: Add a key passphrase
    4. Click ‘Save Public Key‘. I named my main key ‘key.pub’
    5. Click ‘Save Private Key‘. I named mine ‘key.ppk’ Save this in a SAFE place. If someone gets this file, they have your identity, just like a password!
    6. Right-click on the box at the top labeled Public key for pasting into OpenSSH… and click ‘Select All‘. Then right-click again and select ‘Copy
    7. On the gihub.com site, click ‘account‘ in the upper-righthand corner and paste the public key into the SSH Public Keys box and click ‘Update Keys‘ (is it all making sense so far?)
  5. First tricky step – Setting up your environment variable. This is what allows Git to find your private key and use it to connect to github.
    1. In Windows (XP) Press WindowsKey + Pause/Break or double-click System in the Control Panel
    2. Under the Advanced tab click Environment Variables
    3. Under user variables (the top set) click New. Set the name to GIT_SSH and the value to C:\Program Files\Putty\plink.exe
    4. Click Ok a few times and close out of that junk
  6. Second tricky step – Accepting github’s identity. Whenever you first connect to a server via SSH, you must confirm that the server you are attempting to connect to is the right one. The server will provide a hash string that (in theory) should be validated some other way. In reality, this is just the ‘leap-of-faith’ step. Here’s a great read for more info on this security step.
  1. Open putty
  2. In the Hostname box, type github.com and click Open
  3. You’ll receive a prompt The server’s host key is not cached in the registry. Click Yes then close Putty (don’t bother trying to log in
  4. Github’s host key will now be cached
  • Launch Pageant – This step must be repeated any time you restart your computer. Pageant must be running anytime you want to connect to github! It’s advisable to close it when you’re not using it, as any other program on your computer could use your private key for any purpose while Pageant is running.
    1. Run Pageant (in the Putty directory on the start menu)
    2. In your system tray you now have an icon of a computer with a black top-hat. Double-click it
    3. Click Add Key, find your private key that you saved above and open it. If you password protected it, you’ll enter the password here
    4. Click Ok. Pageant will remain in the system tray ready to provide your private key to Git

    You’re now all set up to use Git! You may interact, upload, download, etc with any private github repositories that you have access to. As long as Pageant is running, you should have no problem with Git BASH or Git GUI. If you ever receive a message that ‘The remote end hung up unexpectedly‘ it means Pageant isn’t running. In theory, Plink/Putty is supposed to prompt you for the key/passphrase if Pageant isn’t there (at least that’s how it works when tunneling SVN), but this doesn’t happen for some reason. If anybody knows the fix, please let me know!

  • Presenting Overloadr: The Great Rails Host Shootout

    or: How I learned to stop worrying and love scaling Rails.

    There has been an explosion in Rails hosting providers: Boxcar, Mosso, MorphLabs, EC2, Heroku, etc. To make matters even more difficult for the typical Rails developer, many of these new providers have very unique properties: scaling/clustering/cloud computing/and more. It’s no longer as simple as Shared/VPS/Dedicated.

    Therefore, I have started a new pet project: Overloadr. The goal of Overloadr is to test two things:

    1. The ease of deploying a basic Rails app to a hosting provider
    2. The relative performance of ‘specialized’ hosting platforms.

    To start this off, I’ve written a Rails app that can be used with ab (Apache Benchmark) to test the performance of the Rails engine and the database behind it. The project is available on GitHub, as is fashionable… Feel free to fork, contribute, etc. Eventually I may set up bug tracking, discussion groups, etc. but for now, this is what I’ve got:

    http://github.com/isotopetech/overloadr

    My list of prospective hosts so far is:

    VPS

    • Boxcar
    • Slicehost
    • RailsMachine

    Cloud

    • MediaTemple
    • MorphLabs
    • Mosso
    • Heroku

    Shared

    • Phusion Mod_rails (Dreamhost?)

    EC2 (Testing ease of deployment with different gems)

    • PoolParty
    • ec2onrails
    • rubyworks-ec2
    • Rubber

    A Dedicated server

    You can expect the first of the posts of the deployment experience and performance shortly.

    RailsConf 2008 – Final Summary

    Birds of a Feather

    BoFs were a great part of RailsConf. I didn’t get a chance to write about them elsewhere, so I’ve tacked them on here:

    BoF: PoolPartyRb

    Saturday night, I sat in the BoF talk on pool-party. It’s a gem for automating deploying to Amazon EC2. It can handle a lot of things:

    • Automatic scaling based on demand
    • Starting/stopping instances
    • Provisioning and bootstrapping initial software
    • Setting up S3Fuse
    • Load balancing with HAProxy
    • Built in monitoring
    • Extensible with plugins (coming soon?)

    The software is very new, but Ari Lerner already has a ton of functionality that I’m pumped to use. It also seems to fill a lot of the same niche as RightScale (at least for Rails) and it’s open source. His presentation slides are also available if you’re looking for more info.

    BoF: Annoying IT

    We sat down and had a great talk about how Rails developers should work within the IT system of a medium or large company. There is a often a large gap between the developers and the system administrators. It is important that developers communicate with the IT department from a very early stage to make the unique requirements of a Rails application known. It begets a bigger question that a ‘Rails’ developer is truly many different things: They are a developer, a sysadmin, a DBA, and a Business Analyst. The nature of the product, the Agile development methodology, etc means we must be jacks-of-all-trades in order to succeed.

    This raises an interesting corrallary: We turn out to be better developers and better engineers just because the idiosyncrasies of Rails force us into working with all these other ‘puzzle pieces’ that previously were the domain of specialists. Now obviously not every Rails coder is a ninja or rockstar, but I’d say on the whole, our group is certainly cream-of-the-crop, thanks in large part to the requirement that we branch out and work on the ‘big picture’ of web app development and not just being ‘code monkeys’.

    Vendors/Expo

    There were a fair number of vendors in the Exhibit hall highlighting their latest projects and products. Nearly everyone gave away a t-shirt (for next year, if anyone needs an idea for schwag: how about soft cloths/screen cloths for laptops? I sure could have used one!). Most of the vendors were demoing/pitching their normal, well known product (RightScale, EngineYard, Amazon WS, etc). There were a few new releases too though:

    • FiveRuns released their Tune-Up tool. I didn’t really ‘get’ TuneUp at first when visiting the website, but after talking with Brian about it, I learned what an awesome product this is. It’s available for free and will make developing in Rails an even greater pleasure. If you’re using NewRelic RPM, it has much the same functionality minus the social-performance-sharing.
    • Pivotal Labs demonstrated their software for tracking stories/tasks looks incredibly cool (and pretty). I got to watch a little of it and talk to the guys. Unfortunately, now I can’t find any web info about the product, when it will be released, etc. If I find more info, I’ll be sure to post it.

    Final Summary

    The event as a whole was extremely well organized and absolutely amazing. Thanks to Chad Fowler, Rich Kilmer, Dave Black, O’Reilly, etc. for the great job. Some people complained about the ‘commercialization’ of the conference, but given the size, that should be no surpise. It’s not a bad thing…if you want tiny community conference go to MtnWest or Hoedown. I came expecting a very large forum for sharing ideas and talking about how to make Rails put food on the table, and I wasn’t disappointed.

    The Conference ‘Theme’

    The vast majority of RailsConf2008 was centered around improving yourself as a developer/engineer. All the keynotes and many of the talks were great insights and provided a ton of inspiration to the mantra I try to live by: The best way to be a Rails developer is to know about everything else besides Rails. I think for a lot of people at the conference this was a mind-blowing concept and I’m sure many of them were upset/angry/confused that we spent so much time talking about things other than Rails. The key to remember is that, just like good programming techniques, these styles of development and a thirst for knowledge is key to our way of life. These ideals transcend any given language or framework and will last us for years to come.

    The MVC commercials

    Easily one of the most talked about parts of the conference. These commercials were hilarious. I hope to see them posted online very soon!

    Presentations

    Many presenters had very good powerpoints. It’s nice to no that even though we are not all master designers, practically ever presenter had clear and concise presentations. There were basically three types of slides: One Sentencers, Full of Code, and Comedy. No un-readable gobbeldygook and no reading from slides here. All very good, nice job guys.

    The InterWebs

    Network access at the conference was the best ever. It was fairly reliable and amazingly responsive. For this type of conference, good internet access should the the absolute top priority, and the Ruby Central guys definitely gave it its due.

    Complaints

    No tables in the conference halls. Maybe this is a logistical issue (although the Portland convention center probably has capacity for twenty times as many people, I’m sure they can find/rent some tables).

    Talks Format

    I missed out on a LOT of talks I wanted to see. This is just how things work: there are only a certain number of hours in a day, so you have to pick and choose. Some conferences have been known to schedule every talk at two different times so that there are more ways to schedule your day and make sure you don’t miss any talks that you really want to see. This may or may not work for RailsConf, but I’d like to see them explore some alternatives for how to organize the talks.

    Help me out

    On Friday, I heard of a great Rails plugin that provides a suite of rake tasks for starting and stopping memcache/sphinx/etc. If anyone knows the name of this plugin, please put it in the comments.

    Rails doesn’t scale: It does now!

    This was without a doubt the year of scaling: There were 31 talks about deploying/hosting/scaling rails and 50% of the vendors were focused on hosting and scaling Rails apps. It became very clear that the true fact is that Rails now scales better than any other language/framework out there.

    Some more quotes

    • “Screw the databases, why would you want to use a relational database” – Chad Fowler
    • “[On GitJour] People were trying to find out how to make 28 lines of code [turn into] not 28 lines of code” – Evan Phoenix
    • “I had a great time, so I assume it was awesome.”
    • Joel Spolsky:

    • “If Brad Pitt is an Apple iPod, then Ian Somerhalder is a Microsoft Zune”
    • “Ian Somerhalder gets a free gift certificate for SuperCuts”
    • “Take a digital picture and upload it to icanhazcheezburger”
    • “‘In order to serve you better’ should just be part of the message box API”
    • “The message there [Abercrombie site] is if you buy these clothes, you will get a girlfriend”
    • “The iPhone is sleek and stylish and you get the feeling that if you swallowed one, it’d go right down!”
    • “Contributing to open source projects is like networking for people with no social skills”
    • “I vaguely resemble TVs Burt Reynolds and that makes me somewhate of an authority”

    See you all at RubyConf2009!!!!

    RailsConf 2008 – Sunday Afternoon Summary

    Advanced ActiveRecord Techniques

    Chad Pytel

    Chad’s talk was about refactoring your Rails code to use ActiveRecord the way it was meant to be used. It was a perfect example of a more advnaced (though still easy to understand), technical, & code-heavy talk. As such, I don’t have much in terms of notes (His slides will be available from Smashing Robots into Other Giant Robots at some point soon). He mentioned that in order to refactor effectively, you must have a good solid test suite or you will break things you never knew could break! He talked about moving code from the controller to the model, he talked about using callbacks, modules, and mixins where appropriate. I can’t really go into depth on the path he took to refactor a bunch of code, but it was a terrific opportunity to validate how I write code and know that what I do is sanctioned by others (or at least one other person). He had this nugget of wisdom that I thought sums up the talk quite well:

    A great metric for your controllers (and code in general) is ‘can you put it up on a slide’. If you can’t, something’s wrong.

    Keynote – Rails Panel

    Chad opened the panel by announcing that RailsConf2009 will likely not be held in Portland next year. He mentioned Las Vegas as a possibility, but I don’t know if he was joking. He also said that RailsConf will be sponsoring CabooseConf next year for free. Just example #10001101011 of why the Ruby/Rails community is so amazing.

    The core team started by answering a question about the roadmap of the framework. They said that although they want to do some cleanup and refactoring in ActiveRecord, there is no roadmap for what’s coming up. Then they answered a question addressing plugin support (breaking compatibility with popular plugins) and DHH pointed out that they have really had to start dealing with an issue where “Many people don’t want to build against edge because things can change or be added or removed, but edge can’t be released until it is tested“.

    DHH plugged the docrails branch on github that makes it much easier for developers for contribute documentation about Rails. They also pointed out that github pull requests on the Rails core do not go anywhere, they just disappear. I thought that was good to note, as I was curious how they handled pull requests. DHH also mentioned that he isn’t happy with a log of the view helpers such as ‘error_messages_for’ and a few others, so if anybody was looking for something to work on in Rails core.

    I got up and asked about how moving to git and lighthouse has impacted their work. I got a good response that both git and lighthouse have improved their process because they can better track issues using lighthouse and that git makes merging patching much easier. There was also a great question about handling security issues. When Rails had a major security issue discovered the first time, they were unprepared for the process they had to go through. They are more aware of that process now and have a more formal security handling protocol in place. Awww…Rails is growing up!

    And that’s the end of the conference! Look for my final notes shortly!

    RailsConf 2008 – Sunday Morning Summary

    Dispelling the Myths about Rails performance

    Lewis Cerne – NewRelic

    This was another vendor talk that I decided to attend. I’ve been betatesting the New Relic RPM system for awhile. I decided to attend to see if they would talk about upcoming features that may change my opinion on what NewRelic has to offer. Lewis started by comparing a lot of the FUD about Ruby & Rails performance/scaling to the same statements made about Java and other technologies 10 years ago. He noted the key truth that Rails developers are always using to back up their product: “It’s okay that Ruby is slower. We make up our gains in other areas”. He also highlighted some key observations that I’ve heard myself say many times before: You need data to know what optimize. Otherwise you’re wasting time and money and often just making things worse.

    Lewis moved on to describe the the systems that power RPM. Nothing surprising, but it looks to be a solid and scalable architecture (as it should be since their goal is to help you scale your app). Of course, none of this is a surprise given that their cluster is run by EngineYard. He highlighted a great point about putting Rails apps into production: “Testing is important but not enough – You can’t predict or reproduce what will happen in production”. This is an important lesson to remember because good testing/test coverage has nothing to do with how your app will handle load. Bugs and load are very different issues and you must handle them in different ways.

    I really started to get interested when Lewis mentioned that you can build your own custom data handling for targetting performance that is very specific to your app. This starts to sound a lot like plugins for ScoutApp, munin, etc. It’s not clear just what kind of custom data you can collect (are you able to run any Unix command for data collection, or are you limited to something inside Rails?), but it certainly sounds like a step forward.

    Lewis concluded by noting that they really eat their own dog food and use nothing but Rails for both their collectors and their ui. The collector portion was especially surprising given how easily this type of data collection function lends itself to using a much more specialized setup instead of Rails. So good for them.

    Ward Cunningham, of the original WikiWiki and now AboutUs.org came up to talk about his experience in switching from PHP to Rails and using NewRelic to monitor their performance. He relayed a great story about doing a 10 minute live switch from PHP to Rails and then using the data collected by RPM to find out what the problems were with their deployment. After fixing those problems, they were able to run the site effectively and easily. Although I believe AboutUs could have done the same thing with FiveRuns or ScoutApp, the key is that this style of performance monitoring is critical to deploying any Rails app.

    Overall, a good presentation and I’ll still be watching NewRelic closely because performance monitoring continues to be a critical part of developing Rails apps.

    Oh the Fail I’ve known

    Adam Keys

    Adam produced absolutely one of the best talks of the conference. He presented a lot of ideas about how best to use fail, accept that it is the best way to learn, and protect yourself when you do fail. He started by mentioning some different types of failure:

    • Learning failure – The knowledge was out there already and you didn’t know about it.
    • Technological Failure – Not having a tool that can do what you need to do, or not choosing the correct tool.
    • Solve the right problem – Yak shaving. Adam specifically mentioned extracting pieces out as a framework when there is no need to: 3 strikes before you refactor.
    • Inappropriately applying the wrong technology – There’s a better tool out there and you’re not using it.

    Adam then keyed in on the core of his talk: Learning. He said there are only kinds of learning: Learning from others & Learning by doing. You only learn by falling down. Nobody gets everything right the first time. Set yourself up to rapidly trying things until you find what’s right. Just like you don’t play hockey without padding: don’t develop without padding. Unit tests, exception notifier, cheap branching/merging in git, fast deploy with capistrano are all padding that mean you fear less and can try things that might hurt you because you can fix them fast.

    Adam then moved on to some ways to ‘supersize’ your learning by mistakes:

    • Make bigger mistakes – Because you’re going to make mistakes anyway, you mind as well swing long so that when you do succeed: it’s spectacular (This is a great sentiment that I think applies very well to running a business too).
    • Getting into the groove – We all have issues with getting into the groove when programming without being distracted. Adam recommended that you need a jumpstart, because once you get started, you are likely to continue coding. Set small goals or fix a few small bugs to get the ball rolling.
    • Layer up, Layer down – Adam also mentioned that the best way to expand your learning scope is to work with things adjacent to your main area of work. He addressed specifically other parts of the Rails production stack: SQL, Web servers, etc. Again we find ourselves talking about being jack-of-all-trades by knowing about more than just our tiny little slice of the computing stack.
    • Learn a new language every year – The grass is always greener on the other side, so explore that ‘other side’. Know if there is a better way of doing something, or at least be sure that you’re still using the best tool out there
    • Passive Mentors – Adam talked about ‘shadowing’ many great developers, in IRC, on blogs, whatever. Learn what they have to share, how they operate, the mistakes they’ve made, etc.

    “Beside writing code, learning is what we do as software developers” – Adam Keys

    “Hurry up and lose your first 50 games.” – Go proverb presented by Adam Keys