Archive

Archive for June, 2008

Practical PHP and MySQL

June 26th, 2008

I’m taking a summer course in Building Data Driven Websites – not that I thought I’d learn much in such a course at SCILS, but I’d like to graduate on time, and need the credits, and Bill Crosbie is just the type of rare teacher that can keep even me awake and interested. Our book is Practical PHP and MySQL: Building Eight Dynamic Web Applications (Amazon by Jono Bacon. Now, I know it’s not a real book like, say, ESA3 by Frisch, which has a healthy web presense. But this thing is all code and doesn’t even have a web site, let alone easy code downloads!

The book does come with a heavily customized Ubuntu LiveCD. However, when I popped it in my OpenSuSE workstation, I couldn’t really make much out of the CD – there was certainly no easy-to-find “this is the code” directory. Well, after some exploring, I mounted the SquashFS filesystem and poked around a bit. Strange… seems to only have one real user (root) and, though they claim this is a fully-functional LAMP server, no Apache or MySQL. Really weird. Well, after poking for a few minutes, I found the holy grail – /root/.bash_history was intact! Just a quick look through it with less and I found what I was looking for: /opt/lampp. It appears that the install is actually ApacheFriends’ LAMPP, or XAMPP for Linux (gotta wonder if the guy writing this book doesn’t even know how to install Apache… I’m sure XAMPP for Linux is more bloated than a customized build of Apache/MySQL/PHP from source, especially since it’s only being used to host 8 sample projects, so a lot could be left out).

Anyway, it appears that LAMPP is running in a chroot’ed environment. The actual sample code is rooted at /opt/lampp/htdocs/sites. It seems that all of the PHP files are also owned by root and chmod’ed 777! And the top-level index.php file makes use of absolute links, so obviously he never thought that someone may want to copy the sample code and use it on a real box.

I just can’t imagine someone who’s a beginner with Linux, let alone a Windows person, trying to get this source code onto a machine where they can actually play with it. And… to make the situation worse… the LiveCD has vi and vim, but no Emacs!!!! Eeeek!!

For anyone who needs it, I have the archive available on my site. For non-*nix people, you’ll need Gzip or an equivalent program to extract it.

Reviews , , , ,

Interesting Links for 2008-06-20

June 21st, 2008

Custom MediaWiki Sidebar; New Blog?

June 18th, 2008

As you may have noticed, some Firefox 3 buttons have popped up not only here on my blog, but also on my wiki. While adding the buttons to Blogger was a simple addition to the template, getting them in the sidebar of MediaWiki wasn’t exactly as easy (yeah, I’m considering the arduous project of moving my whole 102+ page wiki to Drupal or another good F/OSS CMS).

After some serious grepping through the source, and adding HTML comments to see where they appeared, I finally found a solution to add the button to the MediaWiki sidebar – though I’d really like it to appear below the search box (I guess that’s something for my to-do list). I’m using the MonoBook skin (though somewhat modified). I’m using “MonoBook nouveau”, and it should be the version that shipped with MW 1.10.1. In this version, I added the code around line 166. Specifically, this was added before the <div id="p-search" class="portlet"> line, and after the end of the foreach ($this->data['sidebar'] as $bar => $cont) loop. This threw the button in a box directly above the search box, and below all of my sidebar links.

The code looked something like:

      <?php } ?>      <!-- firefox link added to MonoBook.php by jantman 2008-06-18 -->      <div class='portlet' id='p-logos'>          <h5>Cool Stuff</h5>          <div class='pBody'>              <ul>                  <li><a href="http://www.spreadfirefox.com/node&id=238326&t=305" target="_blank"><img border="0" alt="Firefox 3" title="Firefox 3" src="http://sfx-images.mozilla.org/affiliates/Buttons/firefox3/110x32_best-yet.png"/></a></li>              </ul>           </div>      </div>      <!-- end firefox link -->      <div id="p-search" class="portlet">

In other news, I’m taking a Data Driven Websites class this summer (PHP/MySQL, but for some reason they switched to a Windows server… endless problems, and I can’t even edit with Nano on the server, let alone emacs). Our first project was to build a blog engine, which I’m working on right now. Anyway, it got me thinking… the one thing that Blogger is missing is the ability to post to a given category, and allow users to view or subscribe to a specific category (or everything). So I think I may look into writing something like that myself, if I can’t find a good alternative that’s already done and is F/OSS. Regardless, I’ll probably be keeping the Blogger template as well as (ugh) moving over all of my current posts, which Blogger chose to store in raw HTML. So there’s going to be a lot of parsing on my future…

PS – When I get a new blog engine, I’m also going to go for a slightly modified template that uses relative widths and placement – so that code, like the snippet here, fits the screen correctly.

Projects , , ,

Firefox 3!!!!

June 18th, 2008

Well, Firefox 3 is here. And it’s wonderful. I’ve had it running all day, and absolutely love it. I just got FFX 3 running on my laptop (my primary workstation). The memory management does appear to be better – nowhere near as much of a strain on the laptop (a mere 1GB RAM), and better page load time. I’m not sure how I feel about the UI changes, but those can be dealt with…

For everyone who downloaded Firefox 3 today – good job! Over 8 Million downloads in 24 hours, and inching up to 580 Million total downloads of Firefox!!!

Want to hear a figure even more amazing, from Mozilla’s Blog of Metrics? It’s only been a little over twenty four hours since the launch, and “According the live tracking from Net Applications, Fx3 has been hovering around 4% worldwide market share.”

Miscellaneous Geek Stuff

Firefox 3 Finally Out!

June 18th, 2008

It’s a wonderful day. And if you haven’t taken a swing by the Firefox Download Site yet today, shame on you! Mozilla is attempting to get the Guinness World Record for most software downloads in 24 hours – and that 24 hours ends at 2:16 PM EDT today! So run over and get it… now! (and please download from Mozilla’s site so they have an accurate count).

Anyway, I’m going to do my part by downloading the Linux tarball on every machine I have that has a graphical display – though I don’t know if my NAT will end up being counted as one download. For the Linux users out there, I was able to find an RPM on the openSuSE site though I’m not yet sure whether it’s the release or the beta version. Windows and Mac users have it easier – Mozilla packages software for you, we have to do it ourselves or wait for someone else to.

Anyway, Firefox 3 is supposed to have much better memory usage, be a bit faster, and also have some great feature enhancements.

Miscellaneous Geek Stuff, Uncategorized

Update

June 15th, 2008

I’ve been incredibly busy lately. But I have 2 quick updates-

1) tuxOstat, my thermostat project, isn’t totally finished, but is up and running. There’s still some work to do, but the code is largely complete, and in CVS. There’s also a web interface with temperature graphs, system status, and a (horrible) webcam view of the LCD control panel. I’ll probably be finishing up a first version this week, finishing the documentation next week, and releasing what I have soon.

I got an e-mail today about one of my older projects, PHP EMS Tools, a PHP/MySQL based application for fire/EMS agencies to handle scheduling, membership rosters, equipment checks, etc. The potential user was asking about running the software on Windows – which, of course, I have no experience with. I’m pretty sure there aren’t many, if any, Unix-specific calls hidden in the code, and advised him to try XAMPP (Apache/MySQL on Windows). But I did take a moment to comment on why I chose Linux. My pilot installation of PHP EMS Tools, at the Midland Park Volunteer Ambulance Corps, where I’ve been a member since 2005, has been handling our scheduling, roster, and equipment checks since June 2006. It’s running on a generation 1 Compaq Proliant DL380, running dual Pentium III 733MHz processors and 1GB memory – and even with a number of other programs on it, including ieilogd which is reading from the serial port 24×7 – the load average has never passed 1.2 and the memory usage is well under 50%. More importantly, the system has been up for 442 days without a hiccup!

Uncategorized , , ,

New Project

June 4th, 2008

Well, TuxTruck has been temporarily put on the back burner. I priced out the hardware, and it looks like a minimum of $1000, more like $1000 if I get what I had originally wanted. This is complicated by the fact that my roommates and I were just hit with a $220 electric bill. Mostly, that’s due to the central air conditioning in our apartment, and the horrible inefficiencies with it.

Inefficient? Yes. At the moment, I’m the only person in the apartment. I’m home for the weekend from 18:00 Friday through about 15:00 Monday. I have class Monday-Thursday night 18:00-21:45. I work Tuesday-Friday 0900-1700. Even though the thermostat we have is “programmable”, it can only be set for 4 time periods per day, weekdays and weekends. So, I figured that a little added efficiency in calculating when the A/C should run would go a long way towards energy savings.

My idea – tuxOstat – is to have a Linux box that has temperature sensors placed around the apartment, and a bank of relays to control the heating/cooling systems. So, even though I only got the idea last Thursday, version 1 should be up and running next week.

In terms of hardware:

  1. Originally I had planned on using a Soekris net4526 that I had lying around. However, the added cost of a MiniPCI USB card seemed prohibitive for a one-off project. Instead, I’m using an old HP OmniBook laptop that was already lying behind my servers. It’s running Debian 4.0.
  2. I’ve ordered (just 15 minutes ago) a Phidgets InterfaceKit 0/0/4, which connects via USB and provides 4 relays. One will control the fan, one for the A/C compressor, one for the heat, and one unused (for now).
  3. I already had a DS9490 Dallas 1-wire USB adapter from Hobby-Boards.com along with five DS18S20P 1-wire parasite power temperature sensors. I’ve wired those up with one in the living room near the existing thermostat, one in my bedroom, and one stuck about five feet up one of the A/C conduits, to sense when the system is actually putting out cold air. I’ve had them logging to MySQL since 0200 today.
  4. I decided to bite the bullet and order a beautiful CrystalFontz XES635BK-TMF-KU for the physical interface. It’s a little backlit LCD display, in a surface-mount box, along with four bi-color LEDs and a 6-button keypad. That should handle the interface for anyone who doesn’t want to grab a console.
  5. I’ll be looking for a eight-pin header so that the relays will plug right in to the screw-terminal block that the thermostat uses, to make for easy switching to the original thermostat if needed (or when moving out in a year).

Now, in terms of software:

  1. A Python text-based configuration/administration program. Will be accessed via SSH or KVM for the actual machine.
  2. Lots of state data stored in files under /var.
  3. A python script, run via cron every 2 minutes, that checks temperatures from the 1-wire bus, logs them to MySQL (on a remote host) and updates the temperature files in /var.
  4. A master control script, run via cron every minute, that looks at the temperatures, the current system state, any manual overrides that exist, and decides what relays should be on or off.
  5. A daemon to handle relay control.
  6. A daemon to handle the LCD display output and keypad input (including immediate manual overrides).
  7. A method of providing overrides of the programmed schedule on a single-instance basis, i.e. “system completely off from 2008-06-06 18:00 to 2008-06-08 15:00″.

Projects , , , ,