2010 Archives

How To Set Up A Secure Git Server At Home (OSX)

— Category: Software Processes

In this article I’m going to show you, step by step, how to set up an OSX machine to provide secure access to git repositories over the internet via ssh. This was tested on OSX 10.6.

github provides git repository hosting with a lovely interface. If github isn’t feasible, then this article will help you set up something similar, unfortunately without the nice interface.

I assume that you already have git installed. If not, install the latest version from the git website.

We will be walking through the following steps:

  • Give the server a static IP address on the local network
  • Set up port forwarding on the router
  • Getting dynamic DNS
  • Add a user named “git” to the server
  • Setting up ssh securely on the client computers
  • Setting up ssh securely on the server
  • Making a bare git repository
  • Using your new git server

How Cocoa Bindings Work (via KVC and KVO)

— Category: Cocoa

Cocoa bindings can be a little confusing, especially to newcomers. Once you have an understanding of the underlying concepts, bindings aren’t too hard. In this article, I’m going to explain the concepts behind bindings from the ground up; first explaining Key-Value Coding (KVC), then Key-Value Observing (KVO), and finally explaining how Cocoa bindings are built on top of KVC and KVO.

Why performSelector: Is More Dangerous Than I Thought

— Category: Cocoa

I fixed a rather nasty bug today in AspectObjectiveC. One particular unit test would crash with EXC_BAD_ACCESS every time. After learning far more about registers and ABIs than I ever wanted to know (thanks, Greg Parker), it dawned on me that performSelector: was corrupting memory. It was particularly hard to track down because the crash would happen a couple of lines after the call to performSelector:, when the corrupted memory was actually accessed.

I’ve never had a problem with performSelector: before, but this time I was using it a little differently. The return value of the selector was an NSRect.

Now for the gory explanation.

For Those Who Have Never Used Objective-C

— Category: Coding Style/Conventions

There is one feature of the Objective-C language that I really love: the method naming. Let me explain with an example.

Here is a nasty call to a C function from the Win32 API that has 12 arguments:

hwnd = CreateWindowEx(WS_EX_LAYERED,
                      TEXT("Hello"),
                      TEXT("World"),
                      WS_OVERLAPPEDWINDOW,
                      10, 
                      10,
                      400, 
                      400,
                      NULL, 
                      NULL,
                      hInstance, 
                      NULL);

Pick an argument, any argument. What does it do? You can probably guess a couple of them, but basically you’re forced to look up the documentation. Sure, 12 arguments is a bit excessive, but even three or for argument functions can be ambiguous. What if you’re trying to understand a function call that is being passed three number literals as arguments? Even if you know the function, you’ll probably have to look up the documentation just to remember the order of the arguments.

Now for the equivalent in Objective C: