Archive for category How-To

Shellinabox Gentoo Init Script

I’ve been playing around with ShellInABox and I think it is quite neat. From the website:

Shell In A Box implements a web server that can export arbitrary command line tools to a web based terminal emulator. This emulator is accessible to any JavaScript and CSS enabled web browser and does not require any additional browser plugins.

So basically it gives you a shell to your local system wherever you go (as long as you have a browser that was released since the turn of the century). This can be especially handy if you are on a public machine without permissions to install software (such as putty). The only dis-advantage is that the remote machine has to be running shellinabox, so this will not work for shared hosting environments. However, if you setup a shellinabox machine, you can then SSH into other boxes that aren’t running the daemon.

I’m running Gentoo Linux on my utility machine, and shellinabox doesn’t ship with a gentoo init script. Please enjoy the one I have written below. Basically, you install shellinabox normally, then I copied its generated certs to /var/lib/shellingabox to be used for ssh connections.

Corrections and improvements are appreciated.

/etc/init.d/shellinaboxd:

#!/sbin/runscript
# Copyright 1999-2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
 
CMD=/usr/local/bin/shellinaboxd
CERT_DIR=/var/lib/shellinabox
PIDFILE=/var/run/shellinabox.pid
 
depend() {
        need net
}
 
start() {
        ebegin "Starting Shellinabox"
        start-stop-daemon --start --pidfile $PIDFILE --exec $CMD -- --cert $CERT_DIR -b=$PIDFILE
        eend $?
}

No Comments

Inject Dojo Bookmark

Sometimes it can be handy to inject Dojo into pages that would not otherwise have it. I’ve used this so I can use dojo.query() on a page to select DOM objects while testing a parser in a different language.

Use drag this link into your bookmarks and have Dojo at your fingertips no matter where your browser takes you:
Inject Dojo v.1.3.2

, ,

No Comments

Zend Framework Doctrine Model Autoloader

There have been several tutorials outlining how to autoload Doctrine Models using the Zend_Loader_Autoloader. However, none of these have permitted Zend / PEAR style naming conventions for models. I prefer to use these conventions because, although it makes my model names longer, the “name-spacing” gives a certain degree of organization and order to the application.
Read the rest of this entry »

, , ,

No Comments

Building a PHP Publish / Subscribe System

First post in a while. I have been busy working on some large application and finishing up my Computing Science Degree. Now that the piece of paper is safely secured above my fireplace, I’ve been trying to find time to do a new post.

I have been building a large application and one of the requirements is to trigger a certain action when an event happens. For example, trigger the sending of an alert email when a database row is updated. Some programmers may be tempted to simply hard-code this functionality into the model class, however this doesn’t give very strict class encapsulation, and can quickly become un-maintainable.

I use the Dojo Javscript toolkit for most of my dynamic front-end functionality. It has implemented a publish/subscribe system using dojo.publish() and dojo.subscribe(). This article will describe the implementation of a similar system using PHP. Read the rest of this entry »

, ,

No Comments

Per Module Zend_Layout

Sometimes when you are building a web application, you want to use different layouts for different parts of the site. For example, in a content management system, you may want one layout for normal users and another, completely different layout for site administrators. Read the rest of this entry »

, , ,

14 Comments