Getting set up to code… again

I previously wrote about getting my Snow Leopard installation set up to run Git. I’m going to do the same thing here, except with a fresh Mountain Lion installation.

Install Xcode

Since we’ve done this before, I know Homebrew will yell at me if I don’t have Command Line Tools for Xcode installed. Go to the App Store, download the latest Xcode (since we’re on the latest OS). Once that’s downloaded and installed, open Xcode and go to Xcode -> Preferences and open the Downloads tab. Now install Command Line Tools.

Install Homebrew

Here we go! Pop this into Terminal:

ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"

Install Git

Big surprise here.

brew install git

Set Up Git

I followed the instructions at Github for the rest (including setting up your SSH keys!). After that, you should be good to go!

I’m finding this super useful because a) I’m a designer, and b) I need to use SVN. :)

I’m perusing through this article at the moment, so I thought I’d share. For a coding nub like me, this is really helpful. :)

An excellent article I found Googling around while looking for advice on how much of users’ information I should store as hashes. If you don’t know what I’m talking about, that’s okay; Matt Gemmell explains it very well.

If you want to get s bit more technical, check out Coding Horror: You’re Probably Storing Passwords Incorrectly.

Installing Eclipse and such

Hey guys! Sorry I haven’t posted in awhile. Work and life and such have been pretty busy. But hey, I filed my taxes today! So I think that’s a start towards finishing some of the necessities before getting into the nitty gritty of learning how to code. :)

I just installed the Eclipse IDE on my iMac so I could get back into Java. Java was the first “real” programming language I learned (I don’t think the BASIC I learned back in the day has stuck with me at all). If you’re interested, I used this Mac guide for installing Eclipse to make sure I wasn’t doing anything crazy wrong, but it’s straightforward enough that you could install it just like any other application.

I know this blog has been slow-going but we’re all really swamped with life. I’m sure you know how it goes. :) Hopefully things will pick up soon now that the weather is getting nicer and we’re getting used to the strains of new jobs, new living arrangements, etc. Hope everyone had a good St. Patrick’s Day and I hope to write again soon!

Hey guys! I frequently come across articles that help me figure out problems I’m having while trying to write code. I want to share these articles but I don’t think they warrant a copycat article written on this blog. :) SO, I instead created a Delicious stack for all of you to enjoy. If you’re an author of this blog, sign up for Delicious and I can invite you to contribute articles/blog posts to the list.

The posts I will write for <code></code> will usually be multi-step process for setting things up or more personal coding that I’ve discovered myself or is more relevant to the work we’re doing here and elsewhere. This is, after all, just a project for sharing stuff about coding. It’s not supposed to be a wildly successful blog and we make no claims that we know what we’re doing. (:

Setting up my Windows box

In my last post I set up my iMac with Git and MacVim. (Which you should read because I didn’t want to repeat a lot of those steps here.) Well, it’s not easy for me to code on the move with my iMac, so it’s time to set up my laptop which runs Vista! (I know I know, I should use Windows 7…)

Installing gVim

ANYWAY, first I want to install gVim. Following this guide, I went with the default options on the installer except I additionally checked “Create .bat files for command line use”. This way I can access Vim and gVim from the command line.

Installing Git and using Github

I then followed the Git installation guide for Windows Github wrote up. The only changes I made were a) checking “Git Bash Here” and “Git GUI Here” for installing those context menu entries (right click menu), and b) choosing “Run Git from the Windows Command Prompt” because, you know, that can be useful down the road. :P

Following the guide, I ran into the same setup steps I took on my iMac. When I had to add my Github API to the Git config through Git Bash, I did a quick Google search to figure out you can press “Insert” to paste whatever is on the clipboard right into Git Bash. Since the Tumblr template repository already exists, we can just do the following from the root:

$ git clone git@github.com:bergren2/codeendcode.git

This clones the repo into the folder codeendcode in my root, which is excellent. Sadly, though, I had to type in my SSH key again. :/ This wasn’t a problem on the Mac because they stored the passphrase for us with Keychain. But hey, we’re on Windows now. Let’s fix that!

Setting up ssh-agent

Edit: I made another attempt at setting up ssh-agent which you should check out below. (“Setting up ssh-agent… again!”) I think it’s a better approach!

Using this UCLA guide as a reference, I recognized I had to get bash to use ssh-agent when I booted it up for the first time. To fix that I just added the following to ~/.bashrc:

export SSH_AUTH_SOCK=/tmp/.ssh-socket
    ssh-add -l 2>&1 >/dev/null
if [ $? = 2 ]; then
    # Exit status 2 means couldn't connect to ssh-agent; start one now
    ssh-agent -a $SSH_AUTH_SOCK >/tmp/.ssh-script
    . /tmp/.ssh-script
    echo $SSH_AGENT_PID >/tmp/.ssh-agent-pid
fi
function kill-agent {
    pid=`cat /tmp/.ssh-agent-pid`
    kill $pid
}

I did this using Vim, but you might want to try out the shiny gVim we installed earlier so you have an easier time using copy and paste. :) Next I added an environment variable by going to Control Panel > System > Advanced Settings > Environment Variables. There I added a variable with the name SSH_AUTH_SOCK and value /tmp/.ssh-socket. After that you’ll want to reopen Git Bash and do the following:

$ ssh-add ~/.ssh/id_rsa

You’ll be asked to enter your passphrase one last time and then tadaa, you’re good to go!

Setting up ssh-agent… again!

Apparently Github had a guide too on using ssh-agent, which I decided to follow instead. So now my ~/.bashrc instead contains the following:

 SSH_ENV="$HOME/.ssh/environment"

# start the ssh-agent
function start_agent {
    echo "Initializing new SSH agent..."
    # spawn ssh-agent
    ssh-agent | sed 's/^echo/#echo/' > "$SSH_ENV"
    echo succeeded
    chmod 600 "$SSH_ENV"
    . "$SSH_ENV" > /dev/null
    ssh-add
}

# test for identities
function test_identities {
    # test whether standard identities have been added to the agent already
    ssh-add -l | grep "The agent has no identities" > /dev/null
    if [ $? -eq 0 ]; then
        ssh-add
        # $SSH_AUTH_SOCK broken so we start a new proper agent
        if [ $? -eq 2 ];then
            start_agent
        fi
    fi
}

# check for running ssh-agent with proper $SSH_AGENT_PID
if [ -n "$SSH_AGENT_PID" ]; then
    ps -ef | grep "$SSH_AGENT_PID" | grep ssh-agent > /dev/null
    if [ $? -eq 0 ]; then
    test_identities
    fi
# if $SSH_AGENT_PID is not properly set, we might be able to load one from
# $SSH_ENV
else
    if [ -f "$SSH_ENV" ]; then
    . "$SSH_ENV" > /dev/null
    fi
    ps -ef | grep "$SSH_AGENT_PID" | grep -v grep | grep ssh-agent > /dev/null
    if [ $? -eq 0 ]; then
        test_identities
    else
        start_agent
    fi
fi

During my switch, though, I ran into an issue where ssh-agent had problems using the correct port because it was being used by… ssh-agent. 0_o Not a problem! I simply looked up the other ssh-agent’s PID using ps and then called kill <PID> to put it out of its misery.

Beginning work on the Tumblr template

Install Homebrew

First thing I wanted to do was install Homebrew. So I pasted the following into Terminal:

/usr/bin/ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)"

The rest of Homebrew’s installation instructions can be found here but the only really important part was above. Trying to to anything else in the Terminal tells me what I need to do next — install Xcode.

Install Xcode 3.2.6

I haven’t made the move to Lion yet, so it looks like it’s an older version for me. :/ Since the Apple website is hard to navigate for finding any version but the latest and greatest (supposedly), you can grab 3.2.6 here (you’ll need an Apple Developers ID to get it, FYI).

If you’re looking to install a different version of Xcode, you can check them out here.

Install Git (and MacVim)

A simple brew git does the job. Since I’m also a fan of MacVim (which I can go into later), I also did brew macvim. Don’t forget to link up the app with brew linkapps! Anytime you see me do mvim blahblah it means I’m using MacVim to edit the file blahblah.

For setting up Git, I followed these instructions since I’m on a Mac. There are also similar instructions for Windows and Linux. Then I did the following to set up the repository with Github (you should sign up for an account!), which is pretty standard.

$ mkdir codeendcode
$ cd codeendcode
$ git init
$ touch README
$ mvim README
$ git add README
$ git commit -m 'first commit, yo'
$ git remote add origin git@github.com:bergren2/codeendcode.git
$ git push -u origin master

My commit message was really bland, so I decided to add some color to Terminal:

$ git config color.ui true

Of course, having to type out git commit reminded me I need to define my aliases.

$ git config --global alias.s status
$ git config --global alias.ci commit
$ git config --global alias.co checkout

And last but not least, I want to globally ignore some files from being committed, such as Vim .swp files and a few Mac folder config files. (You can check out some guidelines here.) My ~/.gitignore_global looks like this, for now:

# Vim #
#######
*.swp
*.swo

# OS generated files #
######################
.DS_Store*
ehthumbs.db
Icon?
Thumbs.db

And I simply ran git config --global core.excludesfile ~/.gitignore_global to put it into effect.

So now we’ve got a template?

So I put the current template on Github for a starting point. Ideally we develop the template using something like Thimble, which is outdated. D: I’m sure we can look into some cool tools for this later, but really I’d just like to get to know Tumblr custom themes before we go too crazy with this stuff. :P I can’t wait to make this Tumblr look less boring!

I &hearts; HTML Entities

So I uploaded a quick little logo using OmniGraffle and exporting my awesome design to a 128x128 PNG. :) I got the idea from Stack Overflow, since I thought it was a cute nerdy joke and I think Jordan likes those sorts of things. Sean and I are mature enough to handle it being the battle standard for this blog, haha. Mostly I just wanted something out there quick.! Plus it looks cool when it shows up in your Tumblr feed now.

I’m going to refrain from doing any formatting on these posts aside from what I use with Markdown, so be warned if that image isn’t centered or whatever. Eventually I will be well-versed in SASS and such so this stuff will be easy peasy.

Next step for doing a layout will be getting the template code on Github, which I will explore in another post where I reveal how I set up my iMac (the second time around) and installed Git. Should be fun!

So this is the beginning

Hey all, and welcome to <code></code> which I like to pronounce “code-end-code”. I wanted to launch this on Tumblr because it uses Markdown readily and it’s pretty popular (which has added benefits you’ll see in a minute). I don’t want blogging to be this huge hassle like it’s been in the past, especially with group blogs. Tumblr is an excellent platform for what we’re trying to accomplish.

And what is that, exactly? Well, we’re a bunch of people who didn’t go to college to code. No, we all went for liberal arts degrees of various kinds. Was it a bad decision? No, I don’t think so. I know I certainly don’t regret it. But we’ve each found ourselves in an interesting position: we should learn to code.

I also want this project to be organic. The lot of us (which I think is three right now but could increase) will try our best to dynamically build this Tumblr up from the ground, as well as tackle any number of other projects. These could be simple or complex, but it doesn’t matter; if someone wants to do it, we’ll try to find out how.

I’m sure my fellow co-authors will speak for themselves at some point, so I’d like to take this opportunity to explain what I personally want to get out of this. I want to use this as a tool to document what I’ve learned and share it with people who are also as confused as I am. I also want to give myself motivation to create projects of my own, including a social media community builder I’m calling Spantasm. You can also find me at Sliding Down which should (eventually) contain links to all of my publishable social media holdouts.