The Road to Elysium

March 27, 2008

Simple Directory Listing Script

Filed under: Snippets — jorge @ 08:07

Place the following lines of code in a index.php-file and that’s it. :)

<?php
 
/*
 *   Dili 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; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *   Dili 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 Dili; if not, write to the Free Software
 *   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
********************************************************************************
 *  
 * This is the Dili (DIrectory LIsting) script v0.0.1.
 * Place the index.php in the directory you want listed, simple as that. :)
 *  
 * Jorge Barrera Grandon <jorge@atlantiscrew.net>
 * Atlantiscrew <http://www.atlantiscrew.net>
 *
 */
 
 
$title = basename(dirname(__FILE__)).'/'; 
 
        echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
        echo '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">';
        echo '<head>';
        echo '<title>'.$title.'</title>';
        echo '<meta http-equiv="Content-Type" content="text/html" />';
        echo '</head>';
        echo '<body>';
        echo '<h2>Directory listing of '.$title.'</h2>';
 
        $dir = opendir(".");
 
        while(FALSE !== ($file = readdir($dir))) {
            if($file != "." && $file != ".." && $file != "index.php") {
                $myFiles[] = "$file";
            }
        }
 
        closedir($dir);
        sort($myFiles);
        reset($myFiles);
 
        foreach($myFiles as $value) {
            if (is_dir($value)) {
                echo '<p style="margin: 0">[d] - <a href="'.$value.'">'.$value.'/</a></p>';
        } else {
                echo '<p style="margin: 0">[f] - <a href="'.$value.'">'.$value.'</a></p>';
            }
        }
 
        echo '<hr />';
        echo '<p>';
            echo '<a href="http://validator.w3.org/check?uri=referer">';
                echo '<img src="http://www.w3.org/Icons/valid-xhtml10-blue" alt="Valid XHTML 1.0 Strict" height="31" width="88" style="border-style: none" />';
            echo '</a>';
            echo '<a href="http://www.atlantiscrew.net">';
                echo '<img src="http://jorge.ulver.no/files/acrew-mini-logo.png" alt="Atlantiscrew Open Source Development" style="border-style: none" />';
            echo '</a>';
        echo '</p>';
        echo '</body>';
        echo '</html>';
?>

March 20, 2008

Easter Holiday and VirtualBox

Filed under: Linux — jorge @ 10:25

Finally! The holiday is here, and we’re pretty much packed and ready to go. As I’ve mentioned countless times during my last posts, I’ve an upcoming RHCT-exam after easter, and though I was planning on spending my days off work studying, I never really planned to bring a laptop to the cabin. We’re heading to a place where there’s no tv or radio, just the cabin and nature. Should give me the peace of mind I need to focus properly on my studies. Anyway, the RHCT-exam is all about hands-on experience, and I wasn’t going to get that without actually tampering with a RedHat installation (or CentOS in this case). Trying to install both VirtualBox and Paralell on my Powerbook G4 was plain impossible, as both only support Macs with an Intel processor, not PPC. And QEMU, sheesh – I’m sure I would’ve grown a long gray beard before the system even managed to boot up properly. I had to discard the idea of bringing my PowerBook, being that it was such crap. That experience (and some other ones) have made me dislike Mac greatly, so now I’m just hoping that my workplace will provide me with a laptop, which I can use both privately and for work-purposes. Needless to say I’ll be installing VirtualBox there as well. ;) If you don’t know what VirtualBox is, read on.

My co-worker has been a great influence on me lately. I used to despise the eyecandy that Fedora and Gnome provided, and now I’m using Fedora 8 at home, with Gnome, thanks to him. A week back or so we came upon the subject of virtualization, and he spoke about some open source software called VirtualBox, that supposedly did the same (if not more) as the famous VMWare. I’ve now been using VirtualBox for almost a week, and let me tell you, it’s just insane how good it is. I can highly recommend it if you would like to give other operating systems a try without having to repartition your hard drive, or even format it. Every OS that you install through VirtualBox is stored in its own unique file, thus enabling you to make the changes necessary on your local machine, and just bring the file with you to another location (provided that there is a VirtualBox installation on the remote machine), and fire it up there. Here’s a nifty little screenshot of VirtualBox running in Fedora 8, with CentOS installed. Nice huh!

Fedora 8 and VirtualBox with CentOS

I’m off to get the final things done for the trip, happy easter to whomever is reading this. ;)

March 18, 2008

Closing in on Easter

Filed under: Day to day — jorge @ 15:23

In about two hours my workday ends. I’ve spent the day studying for the RHCT-exam, and spent some time reading/exploring Limacute and Bifrost. Quite fun I have to say. :) I’ve yet to learn a good deal about RedHat, but things are finally starting to sink in. I’ll use the holiday for everything it’s worth, and study like mad, hopefully passing the RHCT-exam.

Changing to another topic, I spoke with my friend Kenneth the other day, and we came upon the subject of movies and books. I mentioned the lack of a good movie and book database. Don’t get me wrong, I know IMDB exists, but I meant for more personal use, to index and list all of your movies and books. He suggested that I make one then, and I said sure, why not. Most likely to be made in PHP and MySQL, I’ll have to find the time soon to (try) to make it.

Enough ramble – on to more reading!

March 14, 2008

How To Display UTF-8 in your Putty Bash Shell

Filed under: Linux — jorge @ 22:28

My girlfriend was having some problems displaying the correct characters while talking on IRC through irssi, and putty. Eventually I came to the conclusion that it wasn’t my server or irssi that was configured badly. Searching the internet I found this:

echo -ne 'e%Ge[?47he%Ge[?47l'

Simply put that into your .bash_profile or .bashrc and relog to your server. It’s a collection of terminal escape codes that together means ESC %G – “switch to UTF-8″.

The end of this week and foxmarks

Filed under: Day to day — jorge @ 09:19

Friday today (yay!), the last day of the working-week. I actually don’t feel as tired as I usually do at this hour, which is pretty odd. Next week I work only three days, being that Thursday and Friday is a part of the Easter-Holiday here in Norway, and lasts till Monday. It’s been a pretty interesting week, I’ve done quite a bit of work, and even had time to study for my RHCT-test that’s coming up after Easter. Pretty nervous about that to be honest, and being that I’ve never really touched a RedHat-type of OS, I’m even more shook up. But still, having worked with Linux for these past few years should count for something. :) Having glanced over the pages in the book I’m reading, I pretty much know most of the stuff. So, a good luck to me!

Now, my co-worker has again informed me of a little miracle-addon called Foxmarks. Quoting their website:

The Foxmarks Bookmark Synchronizer automatically synchronizes your bookmarks between two or more computers running Firefox. It also lets you access your bookmarks from any computer anytime via my.foxmarks.com. An easy-to-use wizard guides you through the quick startup process. Then Foxmarks works silently in the background to keep your bookmarks up-to-date on all your computers.

I’ve been using it for the past week, and loving it! Give it a try you too. And download Firefox! 

« Newer PostsOlder Posts »

Powered by WordPress