Hosting Git repositories through WebDAV on Snow Leopard Server
This will be quick and dirty; the necessity comes from a particular source code that I can't trust to host online to a third party vendor/provider.
I have a Snow Leopard Server, so I will make use of the tools provided, there's little information about the subject, so here it is.
Also I choose WebDAV since my SSH is blinded to the outside world, in order to access it I require a VPN connection, but since I want to share some repo to the outside world, WebDAV comes handy.
I host my repositories in a subdomain, so before anything, open up your DNS Server Admin section and start editing by adding your new shiny hostname as you please by adding a new record there.
I assume you are using a subdomain along the lines of repositories.yourdomain.com; you don't have to do this step if using an ip address, this is up to you.
Login into your server through ssh or the way you like and create a repositories index directory somewhere.
In my particular setup I have this structure for my websites:
/Sites/kain/mydomain.com/[www, macruby, etc]
So go where you like and create a directory, I'll use repositories
mkdir /Sites/kain/mydomain.com/repositories
Assign this directory to the _www user
chown -R _www:_www /Sites/kain/mydomain.com/repositories cd /Sites/kain/mydomain.com/repositories
Start creating a new directory that will host the git repository:
mkdir myproject.gitAfter that go in the Web section, and create (or copy) a new website.
Relevant General setup:
Host name: repositories.yourdomain.com
Web folder: /Sites/kain/mydomain.com/repositories
Relevant Options setup:
Folder listing: enabled (not really necessary but useful for testing what you see in index later)
WebDAV: enabled
Rest disabled
Relevant Realm setup:
create a new realm by clicking the plus sign
Realm name: myproject
Authentication: Basic (will try Digest/Kerberos in future)
Select Location for the select widget instead of Folder and write
/myproject.gitIn the right section now add your users that will have access, after that change their permissions.
Since my repos are private I only keep the users that have write access there by setting their permissions to Browse and Read/Write WebDAV, None for Everyone.
Relevant Logging setup:
enable logging as you please
Relevant Security setup:
I choose to use SSL for this tutorial, so you are going to use a certificate and port 443.
Save and close Server Admin.
Let's go back to our SSH server session.
Enter your project directory and exec those commands:
cd /Sites/kain/mydomain.com/repositories/myproject.git sudo git init --bare sudo chown -R _www:_www . sudo mv hooks/post-update.sample hooks/post-update sudo git update-server-info
Now switch to your client.
Edit your ~/.netrc file with those informations:
machine repositories.mydomain.com
login myusername
password mypasswordEnter your project dir and exec those commands:
cd myproject git config --global http.sslVerify false # If you don't own a valid SSL certificate on your server, skip --global to enable this option only for this project git init # gitify the directory git add . # add files to git repo git commit -m "hi" # first commit git remote add origin https://repositories.mydomain.com/myproject.git/ # end slash is important git push origin master --force -v
Now edit this file, always in your project root dir:
mate .git/configAnd add
[branch "master"] remote = origin merge = refs/heads/master
This way you can do git push and git pull normally.
Done.
Creating a Cappuccino application with capp
![]()
This is the second part of the Cappuccino bits series.
- Installing Cappuccino from source.
- Creating a Cappuccino application with capp.
- Playing with a Cappuccino project (TBA)
If you missed the part 1 I suggest reading it now before proceeding. If you don't at least be sure you did understand the meaning of CAPP_BUILD and have it correctly setup.
capp is a dual utility that can help in generating your application and setting some environmental variables that Cappuccino will use. It's part of Cappuccino's Tools.
First, let's take a look at the config options it can set:
user.nameuser.emailorganization.nameorganization.urlorganization.emailorganization.identifier
You can get a view of what config options are already set with:
capp config -lStart setting your config options with command:
capp config key "value"where key is one of the values shown above, and value is actually what you want to be in the chosen key.
capp config user.name "Claudio Poli" capp config organization.name "iCoreTech Research Labs"
Those will be used, for example, in the comments when an application gets generated by the capp command.
While config options' description is pretty straightforward it should be noted that organization.identifier is the less recognizable; it's the reserved domain identifier, commonly used when creating Mac applications.
You can set it to the format "com.mycompany" or "org.bestcompany", then if you create a project called MyApp its identifier becomes "com.mycompany.MyApp".
It's worth noticing that you can see a single option value by running:
capp config --get keywhere key is one of the options I wrote above, even though you may just well want capp config -l (or --list).
Once we setup our capp environment, we can go hands down in creating a whole new application.
If you run
capp -hyou can see a helpful guide on how to use capp.
Now, instead of using "capp config" we are going to use the generator part, namely "capp gen".
In the small usage banner after gen PATH we can see some options we can use, so pick the one you need, explained below:
capp gen MyWebSite
This will create a directory MyWebSite in the current directory you are currently in when you executed capp.
Of course you can also supply a full path instead of MyWebSite.
The generated application is a bare-metal Cappuccino/Objective-j application, called by the templating system "Application".
No xib/nib/cib files here, the initial code in Application.j is instructed to just show the basics.
Also note that in the MyWebSite directory there's a folder called Framework. That's right, capp gen PATH without further parameters copy the entire frameworks from a previous Cappuccino installation (see the part 1 of the tutorial) to your project.
This may be desiderable when working on a stable version, however we would like to have the entire framework symlinked to a special directory that we are interested in keeping up to date with recent Cappuccino changes.
In order to accomplish that, run:
capp gen MyWebSite -l
This will be still a bare-metal application, but if you go into Frameworks directory you'll notice that AppKit, Foundation and Objective-J folders are simbolic links:
22:51 ~/Sites/MyWebSite/Frameworks $ ls -lha total 24 drwxr-xr-x 6 kain staff 204B 21 Ott 22:50 . drwxr-xr-x 11 kain staff 374B 21 Ott 22:50 .. lrwxr-xr-x 1 kain staff 51B 21 Ott 22:50 AppKit -> /Users/kain/src/cappuccino_framework/Release/AppKit drwxr-xr-x 5 kain staff 170B 21 Ott 22:50 Debug lrwxr-xr-x 1 kain staff 55B 21 Ott 22:50 Foundation -> /Users/kain/src/cappuccino_framework/Release/Foundation lrwxr-xr-x 1 kain staff 56B 21 Ott 22:50 Objective-J -> /Users/kain/src/cappuccino_framework/Release/Objective-J
This explains why the CAPP_BUILD env variable is so important even before trying to install Cappuccino Tools.
If instead of generating a whole application we only need to put Frameworks files in place we can run:
capp gen MyWebSite -f
Instead of -f you can use the verbose --frameworks, add -l for some extra, already explained, fun.
Ideally if you want to keep Cappuccino up to date you should follow the instructions in part 1 to git pull and recompile the framework.
This is the last option we will be covering for today, and it's the one used to generate a project by using a Template.
You can see the actual list of templates by listing the contents of a specific directory:
ls -lha /usr/local/share/narwhal/packages/objj/lib/capp/Resources/Templates
You will see three templates:
ApplicationNibApplicationThemeDescriptor
When creating your application you can choose your template by using the -t switch, so for example:
capp gen MyWebSite -t NibApplicationApplication is the code generated when the -t switch is omitted.
NibApplication is an application skeleton that already implements code for running a nib/cib/xib based application, included in Resources. Also the Application.j and other files' code is different.
For example Application.j contains a member variable that references a CPWindow, already in the nib file, and awakeFromCib is instructed to make the window go fullBridge, meaning full browser window. In this kind of application the graphics user interface is left in the nib file.
ThemeDescriptor is a special project for creating custom Cappuccino themes.
Tutorials ends here, thanks for reading. As usual feedback is appreciated.
Next: playing with a Cappuccino project.
Cappuccino logo used with permission. Cappuccino is a trademark of 280 North.
Installing Cappuccino from source

This is a series of tutorials about Cappuccino framework and they are based on my findings, especially the ones that often aren't well documented or confusing.
Table of contents:
- Installing Cappuccino from source.
- Creating a Cappuccino application with capp.
- Playing with a Cappuccino project (TBA)
We are going to install Cappuccino from source, using git and github.
You need to install Git prior to this task, I covered the installation on Snow Leopard here or you can download some packages here.
The environment I'll use is Snow Leopard, running stock Ruby.
We are going to use rake to build Cappuccino, se be sure it's up to date with:
sudo gem install rake
You can install rake without sudo, and it will install itself in a gem directory under your home folder, you will have to add the bin directory to your PATH though.
Before you do anything you will have to setup a CAPP_BUILD environment variable.
This variable represents a directory that will store your Cappuccino framework copy.
I usually use a directory ~/src to store source code (or /SourceCache on a server) and ~/Sites to store my web projects.
So please keep this in mind and change the code represented here accordingly.
We are required Terminal usage, so open up a new Terminal and write:
mkdir ~/src/cappuccino_framework
Then open up your ~/.bash_profile or ~/.bash_login with your favorite editor and add:
export CAPP_BUILD="/Users/kain/src/cappuccino_framework" export PATH=$PATH:/usr/local/bin # if you don't have it already
Of course replace kain with your username.
Save and close the file, run:
source ~/.bash_profile
in order to reload the changes without launching a new Terminal tab/window.
Now that our CAPP_BUILD is in place we can start downloading Cappuccino itself.
git clone git://github.com/280north/cappuccino.git ~/src/cappuccino_source
Please note that I'm not downloading Cappuccino from Git in CAPP_BUILD.
This directory have another purpose: as already said it stores our Cappuccino framework copy.
Once the download is over, cd into cappuccino_source directory and execute the install command:
cd ~/src/cappuccino_source && rake install
This will install Cappuccino Tools and Framework from source asking for superuser password when needed.
In order to keep our Cappuccino source up do date if we see that an important commit on GitHub have been done, we can cd into our cappuccino_source directory and run:
git pull # to update our tree from GitHub rake clobber-all install # or only rake install
Extra bit for TextMate users, install Objective-J bundle:
open ./Build/Cappuccino/Tools/Editors/TextMate/JavaScript\ Objective-J.tmbundle
For non-TextMate users, have a look into ~/src/cappuccino_source/Build/Cappuccino/Tools/Editors directory.
Currently there's support for Emacs, SubEthaEdit, TextMate, Vim and Xcode.
If you want to install Xcode support, double click on install.command, this will create a "~/Library/Application Support/Developer/Shared/Xcode/Specifications" directory if it does not already exist and copy the ObjectiveJ.* files to that directory.
Another bonus I tried but doesn't seems up to date: Cappuccino Developer Tools.
Restart Xcode for the changes to take effect.
Tutorials ends here, remember, set your $CAPP_BUILD env variable before doing anything, this is important. If you keep the same directory structure when working or updating Cappuccino you don't need to touch it again.
If you find this information useful or want to leave some feedback just use the comments form. Thanks.
Update:
Online API documentation is old. In the meantime you can generate your own on your local machine by installing Doxygen.
The fastest way is to have ports install Doxygen, and then run in cappuccino_source this command:
doxygen Tools/Documentation/Cappuccino.doxygen
or more simply:
rake docs
in your cappuccino_source directory.
Next: use capp to generate a Cappuccino application.
Cappuccino is a trademark of 280 North.
Thanks to #cappuccino (irc.freenode.net) people: tolmasky, nciagra, boucher, saikat for feedback.
Rails vs. Tarantula
There are times when you, as a lone developer, simply don't have time to write tests.
It's bad but can happen, but I can guarantee that even if your application is small or simple it probably does contains some bugs, especially if you are forced to write it on the fly and fast (which should be the only reason to excuse your lack of tests).
Sending an application straight into production without running tests is bad, I can't stress it enough.
However there's a solution to have some little tests running prior in distributing your app: Tarantula.
Snow Leopard server FAQs, part 1
Snow Leopard server is a good system, however it does still suffer nasty bugs and you have to learn small gotchas to make things work as expected.
Here's a roundup on what I found.
Install Passenger (mod_rails) in Snow Leopard 64 bit
Update: passenger 2.2.5 release notes states that there are know issues with Snow Leopard, but developers didn't had chance to test them out yet. I personally found no problems on 2.2.4. To upgrade simply run:
sudo gem install passenger sudo passenger-install-apache2-module
and change apache config according to new version. Follow me on twitter for up to date info.
The installation works out as usual and it's pretty straightforward, version 2.2.4 2.2.5 and using stock Apache which comes with Snow Leopard as default.
Install Xcode from Snow Leopard DVD, and it would be also wise to upgrade rubygems before doing this operation, search older posts.
Install the gem:
sudo gem install passenger sudo passenger-install-apache2-module sudo mate /etc/apache2/other/passenger.conf
passenger.conf doesn't exists on a vanilla installation (of course), therefore create it or look below. I'm also using the "mate" command, which fires up TextMate, replace "mate " with your preferred text editor, like vi, nano, etc.
If you want to use your personal configuration file instead of passenger.conf:
sudo mate /etc/apache2/users/username.conf
Replace username with your username in Snow Leopard.
Paste those lines in:
LoadModule passenger_module /Library/Ruby/Gems/1.8/gems/passenger-2.2.5/ext/apache2/mod_passenger.so PassengerRoot /Library/Ruby/Gems/1.8/gems/passenger-2.2.5 PassengerRuby /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby RailsEnv development # or production, but anyway production it's the default value if you don't specify.
Now edit the main file:
sudo mate /etc/apache2/httpd.conf
Around line 465 you will find the commented line:
465 | #Include /private/etc/apache2/extra/httpd-vhosts.conf |
Remove the # and save the file, this will make Apache pickup extra vhost configuration file.
Open up your Control Panel, go into Shares (Condivisione in Italian), Web share, toggle the checkbox and leave it enabled to reboot Apache and let it pickup those changes.
I'm refraining from installing the complementary PassengerPane at this time since it still uses RubyCocoa instead of MacRuby and its last update is dated 2008, therefore open up:
sudo mate /etc/apache2/extra/httpd-vhosts.conf
and paste a similar code to deploy your rails application:
<Virtualhost *:80> ServerName www.yourhost.com DocumentRoot /somewhere/public # < -- be sure to point to 'public'! </VirtualHost>
Reboot again Apache as described above, as an extra as usual you can edit /etc/hosts to add your ServerName mapped to 0.0.0.0 or 127.0.0.1 or what you prefer by writing a simple line:
127.0.0.1 www.yourhost.com
There's another method of adding custom hostnames by not tampering with /etc/hosts, but I'll leave it for another blog post.
Install Git from source on Snow Leopard 64 bit
There are many methods to get git running on Snow Leopard, this is the source approach.
Go to http://git-scm.com/ and download the latest package (1.6.4.3 as of writing).
Decompress it in a directory, and run this command:
make prefix=/usr/local all
kain-osx:git-1.6.4.3 kain$ lipo -detailed_info git input file git is not a fat file Non-fat file: git is architecture: x86_64
seems good, issue:
sudo make prefix=/usr/local install
to install.
test:
kain-osx:~ kain$ git --version git version 1.6.4.3 kain-osx:~ kain$ which git /usr/local/bin/git
Of course be sure that /usr/local/bin is in your $PATH.
How to install pg (postgresql) gem on Snow Leopard, 64 bit
Install PostgreSQL from source/port for this, does not currently build against binary package.
PATH should be /usr/local/pgsql.
export PATH=/usr/local/pgsql/bin:${PATH} env ARCHFLAGS="-arch x86_64" gem install pg
Or if you are using macports:
export PATH=/opt/local/lib/postgresql83/bin:${PATH} env ARCHFLAGS="-arch x86_64" gem install pg
How to mirror a SVN repository on GitHub
Start by creating a project on github.
In this example we will mirror Sphinx search engine.
On your server or local machine create a new git repository, with the same name of the github repo.
mkdir ~/src mkdir ~/src/sphinx cd ~/src/sphinx git init
Now setup the SVN repository as a remote source to track.
It should be noted that the '-T' switch points git directly to the trunk, which is fine for our purposes.
git svn init -T http://sphinxsearch.googlecode.com/svn/trunk
Perform the initial pull.
git svn fetchThis will take some time, based on the size of the remote repository.
After the first pull is finished, go ahead and run the garbage collector, this will help to speed up things and reduce size.
git gcI'm going to use a different public key for pushing to github, with no passphrase.
ssh-keygen -t dsa -f ~/.ssh/id_dsa_github_for_mirroring
Now, edit '.ssh/config' and add
Host githubmirror User git Hostname github.com IdentityFile /home/yourusername/.ssh/id_dsa_github_for_mirroring
Now, copy and paste your public key into your github account.
cat ~/.ssh/id_dsa_github_for_mirroring.pub
Add the origin, do the first push.
git remote add origin git@githubmirror:yourgitusername/sphinx.git git push origin master
To keep stuff in sync we need to do
git svn rebase
git push origin masterThis is an operation you should do every X minutes or so.
Better setup a cronjob to handle that.
mkdir scripts cd scripts nano mirror.sh
and add the following:
#!/bin/sh cd /home/yourusername/src/$1 git svn rebase git push origin master
Save and close the file.
Now edit a crontab entry:
crontab -ePress 'i' and start pasting this line:
*/15 * * * * /home/yourusername/scripts/mirror.sh sphinx >/dev/null 2>&1
Press 'ESC' and digit ':wq!' to exit.
How to install Sphinx search engine in Snow Leopard, x86 and x86_64

Sphinx is a free and open source SQL full-text search engine.
I assume you already have installed Xcode from Snow Leopard DVD.
First step is to download Sphinx, for this little guide we are going to use a beta.
cd into your favourite directory, mine is 'src' in my homedir.
cd src curl -O http://www.sphinxsearch.com/downloads/sphinx-0.9.9-rc2.tar.gz
Decompress:
tar zxvf sphinx-0.9.9-rc2.tar.gz cd sphinx-0.9.9-rc2/
For 32-bit users:
./configure --prefix=/usr/local
For 64-bit users:
LDFLAGS="-arch x86_64" ./configure --prefix=/usr/local
Remember that you can also specify sphinx to use MySQL this way, by appending this string to ./configure:
--with-mysql=/usr/local/mysql
or/and PostgreSQL
--with-pgsqlAll users:
make sudo make install
We are done.
If you encounter some errors, be sure to search for 'mysql' in this website, and follow the guide.