Creating a Remote Git Repository

Here is a quick and dirty guide to create your own remote repository. Access is controlled through standard ssh so it’s as secure as your ssh access is.
(more…)

Installing Git on Cent OS 5

It’s pretty straightforward to install Git on a mediatemple DV 3.0 server. If you have later versions of their servers with Yum installed, you may be able to simply install it through yum.

To begin you need to download the latest version and run through the standard extraction and configure/make/make install.

(more…)

Duplicate Line/Selection in Komodo 5

Update: Trent from ActiveState (developers of Komodo) notified me that they’ve actually just completed this feature within the latest nightly builds. More information here.

Exploring the ability to create macros and bind them to key commands in Komodo IDE. I’m reposting the below macro that duplicates the lines or the current selection. Thus functionality was previously is Zend Studio 5, went missing from 6, and thanks to the macro, is available in Komodo. Enjoy!

// Duplicate Line or Duplicate Selection
komodo.assertMacroVersion(2);
if (komodo.view) { komodo.view.setFocus() };

var ke = komodo.editor;

if (ko.views.manager.currentView.scimoz.selText){
    // Copy the current selection
    new_selection = komodo.interpolate('%s');
    var pos = ke.currentPos;
    ke.insertText(pos,new_selection);
}else {
    ke.lineDuplicate();
}

Install Apache, MySQL, and PHP on OS X (10.5)

While I was at zendcon I needed to setup my macbook with a typical apache/php/mysql server, but I was unsatisfied with both the default server that apple included and with the install system provided by XAMPP. I’ve since setup a server on both my MacBook and my iMac.

In order to get support for mysql as well as tools necessary for compiling, you need to install the apple developer tools. Check your original mac disc as you may already have a copy.

Anyway, on with our install:

Apache

First, download the latest version of the apache httpd web server.

./configure --prefix=/usr/local/apache --enable-module=so --enable-module=rewrite

Then, run the standard make, sudo make install.

MySQL

Then download the latest mysql source file. Make sure you download the source “Compressed GNU TAR archive (tar.gz)” as we’ll need to custom compile it.

However, PHP5 no longer includes mysql shared libraries needed during the configure process. To get these, download the source file for the mysql version you just installed. Once downloaded, decompress it and run the following:

./configure --prefix=/usr/local/mysql --with-unix-socket-path=/usr/local/mysql/run/mysql_socket --with-mysqld-user=mysql --with-comment --with-debug

make

sudo make install

sudo /usr/local/mysql/bin/mysql_install_db --force

sudo mkdir /usr/local/mysql/run
sudo mkdir /usr/local/mysql/data

sudo chgrp -R mysql /usr/local/mysql

sudo chown -R mysql /usr/local/mysql/run /usr/local/mysql/var /usr/local/mysql/data

Then start the server with:

sudo /usr/local/mysql/bin/mysqld_safe --user=mysql &

zlib

Then, install zlib if it’s not already installed on your system. Download zlib, and it should be a basic ./configure, make, sudo make install process.

Once zlib is installed, make sure you know the path as we’ll need it during the php configure process.

PHP

Next, download the latest php package. Decompress it, and now we’re ready to configure.

./configure --prefix=/usr/local/apache --enable-cli --with-mysql=/usr/local/mysql --with-zlib-dir=/usr/local --with-apxs2=/usr/local/apache/bin/apxs

Then, run make and sudo make install to complete the process.

Restart apache and test everything out. If php didn’t do it automatically, add in AddType application/x-httpd-php .php to your httpd.conf file – commonly located in /usr/local/apache/conf/httpd.conf.

Then, start your webserver.

sudo /usr/local/apache/bin/apachectl start

And finally, once everything is done you’ll want to setup your account to properly allow access to mysql and apache commands. Just run the following to add their paths to your bash profile:

echo 'export PATH=/usr/local/mysql/bin:$PATH' >> ~/.bash_profile
echo 'export PATH=/usr/local/apache/bin:$PATH' >> ~/.bash_profile

JAR/XPI Firefox Extension Build Shell Script

I recently started work on a firefox extension, but this time I’m working on a mac rather than a pc. Below is a sample shell script for automatically building the JAR and XPI files.:

#!/bin/bash
mkdir build
mkdir build/chrome
cd chrome
zip -r formsaver.jar .
cd ..
cp chrome/formsaver.jar build/chrome/formsaver.jar
rm chrome/formsaver.jar
cp -R defaults build/
cp install.rdf build/install.rdf
cd build
zip -r formsaver.xpi .
mv formsaver.xpi ../formsaver.xpi
cd ..
rm -rf build
echo -n extension build successful

Here is a sample file for automatically building on windows (batch script):

Note: This requires that you have 7zip installed.

set x=%cd%
md build\chrome
md build\defaults\preferences
cd chrome
"C:\Program Files\7-Zip\7z.exe" a -tzip "%x%.jar" * -r -mx=0
move "%x%.jar" ..\build\chrome
cd ..
copy defaults\preferences\formsaver.js build\defaults\preferences
copy install.* build
cd build
"C:\Program Files\7-Zip\7z.exe" a -tzip "%x%.xpi" * -r -mx=9
move "%x%.xpi" ..\
cd ..
rd build /s/q

Moving Subversion Repository Across Machines

I recently moved my development server from a linux box to my primary machine, an iMac. I wanted to move my subversion repository while maintaining the file histories for everything inside. Worrying that it was going to be a huge issue, I was happy to discover it was completely simple:

On the existing repository machine, run:

svnadmin dump /path/to/repository > repository-name.dmp

Transfer your dump file to the new machine and then, create a repository. Once subversion is running and you have your repository created, import the dump file:

svnadmin load /path/to/repository-name< /path/to/repository-name.dmp

You're done!

Setting up Subversion on Mac OS X 10.5

I recently began working exclusively on an iMac so I decided to setup a subversion server locally and as my new machine would simply replace my local development machine, which is a Fedora Core 6 pc.

You’ll need to setup at least one repository. I’m going to need multiple repositories that I can use for different clients so I have a bit of extra admin work ahead of me. You can setup as many repositories as you need, but no matter what you’ll need at least one. Here create the folders…

# mkdir /svn
# mkdir /svn/repos

Then we need to tell subversion to make our first repository.

# svnadmin create /svn/repos/myproject

First, I need to setup a config file for svnserve.

# vi /svn/repos/conf/svnserve.conf

Then, look for variations of the following code and edit it as necessary. By default any anonymous user can access the code so to disable that you must include anon-access = none, just commenting the value out will not prevent anonymous access.

anon-access = none
password-db = passwdfile
realm = My SVN Repository
auth-access = write

The password-db is just a path to a file containing usernames and passwords. You’ll create this file especially for SVN. I create each file inside of the repository conf directory. So, save your changes and then we’ll create said user file.

# vi passwdfile

Enter in something like:

[users]
username = password

Anyway, you’ll need to start the svn server.

# svnserve -d --listen-port=3690

One side note – svnserve just runs and doesn’t have a way to stop besides killing the process. If you make changes to the svnserve.conf or user file you’ll need to restart svnserve.

# killall svnserve

Then, go ahead and test (best to do so on a different machine).

# svn co --username=myusername svn://mydomain/svn/repos/myproject

The system should then ask you for your password. Go ahead and run some tests.

MediaTemple E-mail Logs…

I’m always forgetting this command so I’m posting it here. This is the location of the mail log on mediatemple dv servers.

tail -f /usr/local/psa/var/log/maillog

MySQL Backup Shell Script

Many of my clients need a quick backup solution before we implement anything on a larger more permanent scale. I wrote this simple script that simply make a copy of a database and then created a timestamped tarball of the file.

#!bin/sh

date=`date +%Y-%m-%d_%Hh%M`

cd /my/path/for/backups/

mysqldump -umy_user -p"mypass" my_database > $date.sql

tar -zcvf $date.tgz *.sql

# uncomment this line to import the sql into another database, for example as a mirror
#mysql -umy_user -p"mypass" mirror_database < $date.sql

rm *.sql

Then, just setup a cron job to run this at whichever interval you want this to run.

Uninstall U3 System from USB Thumbdrives

I recently bought a new thumb drive that came with the infamous U3 System software. I hate this software to no end and I wanted it gone, but the typical system formatting process and the manual deletion process didn’t work. After doing some research, I found that U3 provides an uninstaller which is a pain.

Just google “u3 uninstall.exe” or visit u3.com/uninstall and follow their stupid download process.