AddThis

Wednesday, May 30, 2012

Ruby in Cygwin


I have to write a note to myself b/c I keep forgetting.
When running ruby in cygwin (assuming ruby is installed using the windows installer), don't do:

#!/usr/bin/ruby

instead ruby to the path (using the installer or by hand) and then in the ruby script put:

#!/usr/bin/env ruby

Tuesday, May 29, 2012

Setting up Git with Mac and Windows


The last time I setup a git server, I setup Gitosis on a machine running Ubuntu (can't remember the version for the life of me).  But seems like all the hoopla is now with Gitolite, so I decided to try my hand at that.

My challenge this time though, is to set up Gitolite on a Mac running Lion and do it from my Windows 7 machine.  Doesn't sound so tough, but there were a couple of gotchas I think worth mentioning here.  Let's go through this thing step by step.


Client Side

1.  My windows tools IMO are sorely inadequate and the first thing I always do is to install cygwin.
Make sure you include vim and open-ssh (and optionally keychain, I think I talk about this in a previous post) packages and whatever else you want.

2.  Next go ahead and grab git for windows and install it.  Use whatever configurations you want.

3.  Open up a cygwin terminal and run
ssh-keygen -t rsa
And optionally set a password when prompted.

4.  mkdir ~/.ssh using cygwin if that directory does not already exist

5.  vi ~/.ssh/config and put the following:

Host gitolite
HostName your.hostname
User git
IdentityFile ~/.ssh/id_rsa

6.  Heres a bit of the trickyness, run the "Git Bash" shell.  Now vi ~/.bashrc and put in the following:
export HOME="C:\cygwin\home\USER" 
replacing USER with your username of course
Why did we have to do this?  The Git Bash for whatever reason decided to put your home directory at '/Users/USER'.  Then when git uses ssh to connect to the remote repository, it was looking in the wrong place for the ssh config :(.  Changing the home like we did enables git (using ssh) to find the ssh config in the right place.

7.  Go ahead and close and reopen your git bash shell.  Now let's set some basic git configs:
git config --global user.name 'Jonathan Keam'
   git config --global user.email 'your_email@whatever.com'


Server Side

1.  Go sit at your Mac and make sure that you have an account (for me it was jkeam, and I'll refer to your user name either as jkeam or USER from here on in) on the machine.  Additionally create another user 'git'.

2.  Ensure they both have remote access.
System Preferences > Sharing > Remote Login

3.  Now create a directory where we will install gitolite.  (I created a /Library/Source and allowed my git user to have total permission in that directory)

4.  cd to said directory and make sure you are now the git user.

5.  Lion should have git already installed for you, so go ahead and just:
git clone git://github.com/sitaramc/gitolite

6.  Run ./gitolite/install


Client Side

1.  Sucks I know, we have to go back to the client.  But from here run
scp ~/.ssh/id_rsa.pub jkeam@mac-host:~/jkeam.pub
replace jkeam with yourself (in both places, before the @ and before the .pub) and mac-host with the real hostname of the mac


Server Side

1.  Ensuring that you're still the git user, run
/Library/Source/gitolite/src/gitolite setup -pk ~/.jkeam.pub
This installs your public key as the key to be used for the gitolite admin.


Client Side

1.  Now the test.  Run:
git clone gitolite@gitolite-admin
This is the special gitolite that we setup in our config from step 5 from the first client setup.  This is a must because otherwise you would get this error.

2.  From here you should have gotten the special repository where configuration settings can be made.
vi gitolite-admin/conf/gitlite.conf
and add whatever repos and users you want.  For more, info click the link.

3.  After adding the repos and users in the conf file, you can simply clone them and there they are.


Hopefully this wasn't too confusing and works for you!

Thursday, May 24, 2012

Codeschool's in Session

I was recently introduced with Codeschool and have fallen in love with it.  For those of you who don't know, codeschool is a neat way of learning some fun stuff interactively...as in, you get a nice looking console thing in the browser where you can actually hack out some code.  Granted, you don't get total freedom, and the code you see is always based around a challenge/problem that you need to solve.  But this is fine as the challenge is based on some video tutorial that serves as a fun lecture.

Check them out!

And for fun, heres my profile.

Wednesday, May 16, 2012

Checking in

I haven't posted in years...ok hyperbole, maybe only a month.  But feels like years.  Guess I been busy??  Doing all sorts of randomness.  Diablo 3 came out just a few hours ago.  That's pretty big.  I'm scared to get it lest I lose my life in it haha.

But I stumbled upon this interesting post on Dart, a very curious language, that forever whatever reason has gained 0 followers (hyberbole again).

Someone's Dart thoughts