Archive for December, 2008

Perl Syntax Highlighter

Sunday, December 14th, 2008

SyntaxHighlighter is turning out to be the web standard for displaying source code in blogs. I’ve developed a brush for that most excellent, yet recently neglected language, Perl. This contribution has not yet been included in the SyntaxHighlighter distribution, so I’m also posting the source code here. Enjoy!

I’ve posted the full source code for the brush to the syntaxhighlighter site. This brush is based on a couple of earlier Perl brushes:

http://opticalgarbage.com/sh/js/shBrushPerl.js

http://nevstokes.com/includes/syntax/scripts/shBrushPerl.js


/**
* Perl brush for Code Syntax Highlighter
* by Marty Kube, http://beavercreekconsulting.com/
*
*  This program is free software: you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation, version 3 of the License.
*
*  This program is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  You should have received a copy of the GNU General Public License
*  along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
dp.sh.Brushes.Perl = function()
{
var funcs =
'abs accept alarm atan2 bind binmode chdir chmod chomp chop chown chr ' +
'chroot close closedir connect cos crypt defined delete each endgrent ' +
'endhostent endnetent endprotoent endpwent endservent eof exec exists ' +
'exp fcntl fileno flock fork format formline getc getgrent getgrgid ' +
'getgrnam gethostbyaddr gethostbyname gethostent getlogin getnetbyaddr ' +
'getnetbyname getnetent getpeername getpgrp getppid getpriority ' +
'getprotobyname getprotobynumber getprotoent getpwent getpwnam getpwuid ' +
'getservbyname getservbyport getservent getsockname getsockopt glob ' +
'gmtime grep hex index int ioctl join keys kill lc lcfirst length link ' +
'listen localtime lock log lstat map mkdir msgctl msgget msgrcv msgsnd ' +
'oct open opendir ord pack pipe pop pos print printf prototype push ' +
'quotemeta rand read readdir readline readlink readpipe recv rename ' +
'reset reverse rewinddir rindex rmdir scalar seek seekdir select semctl ' +
'semget semop send setgrent sethostent setnetent setpgrp setpriority ' +
'setprotoent setpwent setservent setsockopt shift shmctl shmget shmread ' +
'shmwrite shutdown sin sleep socket socketpair sort splice split sprintf ' +
'sqrt srand stat study substr symlink syscall sysopen sysread sysseek ' +
'system syswrite tell telldir time times tr truncate uc ucfirst umask ' +
'undef unlink unpack unshift utime values vec wait waitpid warn write';

var keywords =
'bless caller continue dbmclose dbmopen die do dump else elsif eval exit ' +
'for foreach goto if import last local my next no our package redo ref ' +
'require return sub tie tied unless untie until use wantarray while';

this.regexList = [
{ regex: new RegExp('#[^!].*$', 'gm'), css: 'comment' },  // comments
{ regex: new RegExp('^\\s*#!.*$', 'gm'), css: 'preprocessor' }, //shebang
{ regex: dp.sh.RegexLib.DoubleQuotedString, css: 'string' },
{ regex: dp.sh.RegexLib.SingleQuotedString, css: 'string' },
{ regex: new RegExp('(\\$|@|%)\\w+', 'g'), css: 'vars' },
{ regex: new RegExp(this.GetKeywords(funcs), 'gmi'), css: 'func' },
{ regex: new RegExp(this.GetKeywords(keywords), 'gm'), css: 'keyword' }
];

this.CssClass = 'dp-perl';
this.Style =
'.dp-perl .vars { color: #996600; }' +
'.dp-perl .func { color: #006666; }';
}

dp.sh.Brushes.Perl.prototype  = new dp.sh.Highlighter();
dp.sh.Brushes.Perl.Aliases  = ['perl', 'Perl'];

JoomlaPack Rocks!

Sunday, December 14th, 2008

I’ve been working on Beaver Creek Consulting’s latest product (Simply Schedules) and had a chance to use JoomlaPack.  Story short — it rocks.

I’m using Joomla for this site as I’ve decided that a CMS is the way to go.

I spent many hours configuring the site.  I did all of this work live on my shared hosting account.  Late today, after many hours of trial and tribulations, the site started to look good enough that I was happy with it.  My next thought was, I need a back up!

Joomla keeps stuff on the file system of the web server and in a MySql database.  That’s a pain to back up.

So, I found JoomlaPack, which you can just install in as a Joomla 1.5 component and then create a complete backup of the file system and database.

After I made the backup, I used kickstart to restore to my local development server.   No Problems!

I have to say that JoomlaPack is a great tool.  You can backup your production site, restore production in case of serious issues, and use JoomlaPack to move your site between environments and/or servers.

Rock away JoomlaPack!