FreeNAS: Quick, Easy Fileserver

August 26th, 2008

FreeNAS (Network Attached Storage) is a BSD-based file server. It features a web GUI for easy configuration, a small footprint, and a whole bunch of features. Plus, it has quite reasonable community documentation. It’s easy and quick to install and boot. If you have a spare computer sitting around somewhere gathering dust, and that computer happens to have at least 96 MB of ram and a 300 MHz processor, you might just have the makings of a full-featured file server in your basement.

Why Have a File Server?

There are a myriad of reasons to maintain a file server, although this all depends on who you are and what you want to do with it. Myself, I enjoy having one for the sake of having one, although the backups sure are nice.

Backups

This is the primary reason for having a fileserver, and with this in mind FreeNAS comes with built-in support for rsync and unison, two popular backup tools. Both will mirror your files, and have the noteworthy advantage of only copying changes to your files, meaning that while your first sync will be slow while you copy everything over, subsequent ones will be really fast, as only files you’ve edited or created will be uploaded. I only have experience with rsync, but it definitely seems to do everything I ever dreamed of in a backup server. You can even set it up to back itself up!

Linux users are obviously at an advantage with rsync, but Windows users have access to a number of rsync implementations too, I’m told. Unison apparently works perfectly well on both.

Sharing Network Files

If you have more than one computer in your home, even if it’s just a desktop and a laptop, you will enjoy the benefits of having a single place for (at least some of) your files. Multimedia, music and movies and the like, strike me as something user-agnostic enough to benefit from being shared throughout your house. This will provide a centralized place to store all your really big files that would otherwise be taking up space on your laptop.

Remote Access

FreeNAS also boasts an SSH and an FTP server, which means you can share your files no matter where you are, as long as you have internet. SSHFS, a way to mount ssh connections as drives in linux, provides a particularly appealing way of doing this. You can also backup files over the network

If you have cable internet, you’ll probably need a DNS service like dynDNS to keep your ip up to date and provide a domain. However, FreeNAS will even do that for you!

How-To

I just installed the thing yesterday, I’m not nearly qualified to help you with that. Fortunately, a pretty decent setup and user guide exists already, which certainly saves me some time.

Don’t Use JS’s for(i in object) in Internet Explorer

August 13th, 2008

Just don’t do it. Use for(i=0;i<object.length;i++), please!

I spent about 30 minutes trying to figure out why IE wouldn’t recognize instanceof HTMLElement or nodeType, only to realize that my for(i in object) loop was just spitting out garbage.

ARGH! I HATE YOU INTERNET EXPLORERRRRRR!

Blueprint.css: You’re Just Fooling Yourself.

August 9th, 2008

Blueprint.css is a “css framework” which makes it easy for you to lay out your page with however many columns you like, without even looking at the css. It works by instituting a 950px wide container around your page, and then dividing this into 24 columns. You can add a ’span-x’ class to any div to make it span x columns.

The Good

Blueprint makes it really, really easy to add columns to your page. You just decide how many columns you want the area to span, and add that class (keeping in mind to add the ‘last’ class to the last element in a row).

Blueprint also sets many sensible options for line spacing, fonts (arial), lists, and other things, making the defaults a bit prettier. It also includes an ie.css file of its own, to include in your page to correct some IE bugs, which is convenient.

The Bad

Blueprint marries you to a 950px fixed-width layout, which may or may not be ok with you.

I did notice one IE bug where list elements in an <ol> had the numbers cut off, which a client complained about. It just needed a bit of extra left margin is all.

The Ugly

The real evil of blueprint.css is that it tricks you into thinking you’re being a good designer, seperating content and behavior and layout in html, js and css like a good designer should. However, all the column-defining classes live in the HTML, and have names with no semantic meaning; just, ’span-24.’ In reality, blueprint.css is table-based design with a different syntax.

If you were to do the right thing, and call the left sidebar ‘left-sidebar,’ the content ‘content,’ the header ‘header,’ and the menu ‘menu,’ you could reorganize everything without having to change any HTML, which is doubleplusgood if you have a lot of pages to change.

Instead, in a few years, when you want to redesign your site, you’re going to have to change each of the elements you told to span-x to either span something different, or remove it.

I know it seems easy now, but so do tables. Do the right thing, and you’ll be happier later.

I’ll keep using blueprint though, I do my separation using PHP. Thanks, blueprint guys!

Imagine This.

August 9th, 2008

An online service that would remain connected to MSN/AIM/Jabber networks whenever you’re not online (With some sort of different status), delivering messages sent to you to your email inbox every 10 minutes or so.

That would be cool. I should do that.

My Open-Source Web Development Workflow

July 31st, 2008

Open-source is a nice buzzword these days. Besides being free, open-source code is often of higher-quality than paid applications. Plus, you can always contribute, which gives you the warm fuzzies (I’m told).

Nowadays, my work is entirely done on free, open-source tools. Part of the reason is the fact that I use Linux on my development laptop, part of this is that I’m still a relatively poor student, and part of it is that I’m just used to it now. Anyhow, here’s the software that I use.

Operating System

On this laptop, this one right here, I use Ubuntu Hardy Heron (as I’ve mentioned before). Linux is an excellent environment for setting up sandbox servers using lampp, django, ruby on rails, and whatever else I feel like. I also enjoy navigating by command line, which is faster than the graphical way once you get used to it. The multiple desktops feature, combined with compiz-fusion, is a nice productivity boost. Plus, I get all sorts of geek cred.

Graphic Design

I use GIMP and Inkscape for all my graphics needs. GIMP is an excellent piece of free software, which despite a steep learning curve which I overcame long ago, can do just about anything that can be done in Photoshop – although usually with more steps. I’ve been meaning to write some GIMP tutorials, but I haven’t had the time. C’est la vie.

Inkscape cannot do everything Illustrator can, but it can do plenty. Unlike with GIMP and Photoshop, though, following Illustrator tutorials using Inkscape is right out; the programs are just plain different. But if anyone needs some Inkscape or Gimp help, let me know.

HTML/CSS/JS/PHP development

I’ve written about Aptana Studio before, so I won’t get too much into it, save to say that I still use it quite contently. I’ve fallen into the habit of creating a separate workspace for each client to manage projects, and maintaining an SVN connection to my mostly dormant Windows desktop for backups. I also use it to manage and synchronize FTP connections, which is very handy indeed.

Browsing

I use Firefox, and it would take some doing to convince me to do otherwise. It’s just great.

Others

I use Openoffice a lot for office tasks (I have mentioned that before), and I find it does the job just fine. I even have more luck opening Office 2007 documents than some friends who have never downloaded the compatability update for 2003.

I also use Pidgin to unify my instant messaging needs, and to post to twitter if they ever get it back up.

Open-source apps are a great way to cut costs and feel nerdy.

3-D Surround Sound With Two Speakers

July 23rd, 2008

As you probably don’t know, I am currently in the Electrical Engineering program, with a specialization in DSP. I’ve just finished a project for my Audio Signal Processing course, which let me (and you too, if you care to read my report, featuring source code) create surround sound using only two speakers.

Typical two-speaker stereo sound can only render sound sources from between the two speakers. However, using this method, sounds can be made to come from 90 degrees left or right, above, or even behind the listener. Pretty neat, eh?

How it Works

At MIT in 1995, some crazy guys decided to record the impulse response of sounds from a bunch of different angles using microphones crammed in the ear canals of a fake human head. Using the impulse responses they measured, we can simulate the frequency characteristics of sound reflecting off your outer ears and shoulders and passing through your head. Then we can apply those characteristics to any source wav file we want.

Then, we use some crazy math (detailed in the report) to use the impulse responses measured at the positions of the speakers relative to your head to cancel out the directional effect of sound coming from the speakers.

Give it a Listen

If you have headphones handy, you can listen to a short sample. If you’re crazy enough to be more deeply interested than what this post supplies have any questions about it, I practically insist that you leave a comment, or send an email to design(a)adambard period com.

One Hundred Pushups

June 26th, 2008

First post in a while – it’s hard to find time between work and school and not alienating friends.

Anyhow, I’ve just started the One Hundred Pushup Challenge. The idea is that through thrice-weekly sessions over a 6 week period, one can develop the ability to do a hundred consecutive pushups. It’s a not-so-modest number for me – my initial test put me at an astonishingly bad 7, which is quite weak for a 23-year-old 6-foot tall male. So I’m hoping this specific goal (which incidentally is a SMART objective) will be explicit enough to motivate me to complete it.

I recommend it so far, it feels good being on the path to accomplishing something, even something so modest. Does anyone else care to join me?

Christmas on Mars Review: Eat Your Own Spaceship

June 1st, 2008

Last weekend I attended the Sasquatch Festival in Gorge, Wa., and it was fantastic. 3 days, 72 bands, but one thing stood out for me, and that was being at the second showing ever of Christmas on Mars, the Flaming Lips’ movie. I would have been at the first, but the oompa-loompas in construction suits neglected to mention that we needed tickets.

The movie itself was shown in a big circus-style tent, complete with fog machines, lasers, and Wayne Coyne, the Lips’ ever-enthusiastic frontman, in attendance. In front was a large poster reading “Eat Your Own Spaceship,” and the tickets read the same. I’ll try not to spoil anything, but just in case anyone is really concerned I should put, in big letters:

MILD SPOILERS AHEAD

The movie was not at all what I expected. I had not watched any previews that existed, although the friend I went with had. I was expecting some sort of rock opera, or something of the such, or something more whimsical, and while there was arguably a great deal of whimsy, the end result is a far more jarring film than I had anticipated.

The film started with an announcement from Wayne about the film, specifically about how loud it would be. It was explained that this loudness was to increase the intensity of the film, and I must say it worked — I was in a constant state of sensory overload throughout the film, and sitting through it was actually a fairly uncomfortable experience, which isn’t to say I regretted it. The film featured many disturbing hallucinations suffered by the protagonist, accompanied by loud, dissonant synth chords, and by the end of it I was feeling rather lightheaded. It was certainly an experience I would encourage to anyone, once, but not something I’m eager to repeat, at least not at full volume. Intense is the word.

It’s difficult to critique the acting or the plot, because neither of these things were really the point of the film. It was designed for interpretation, which I will avoid at this time because I don’t want to spoil anything.

At the end of the day, I still view the movie as one big old mindfuck, a thoroughly memorable experience that I would recommend to anyone save the infirm and pregnant, just for the experience.

Javascript Tip: Use the rel Attribute

June 1st, 2008

Hello Googler

It is and always has been the popular thing to publish, um, very opinionated articles in blogs. I’m going to leave this up, but since this is the most-found page on this now-defunct blog (Although I still post from time to time at http://posterous.adambard.com/), I should say this: What follows is very bad advice.

If you ever need a hook to grab a link, just use a css class for god’s sake; jQuery et. al. make this ridiculously easy, and it was never that hard to begin with. Rel has a real meaning, if a generally-unused one, and there’s no sense using it when you really mean to use a class.

Carry on then. The rest of this post is the original in its entirity.

In HTML, <a> and <link> elements have a unique attribute, “rel.” Rel has practically no use in plain HTML these days, but with some creativity it can be an excellent hook for javascript events. This will provide you an unobtrusive way to change the behavior of these elements, without requiring “javascript:” links or onclick calls be written directly into the html.

Implementation:

var getElemsByRel = function(rel){
    aElements = document.getElementsByTagName("a");
    relElems = [];
    for (i = 0; i < aElements.length; i++) {
        if (aElements[i].hasAttribute("rel") && aElements[i].rel == rel) {
            relElems.append(aElements[i]);
        }
    }
	return relElems;
}

Case Study

Lightbox.js uses this to great effect: Any links with rel=”lightbox” activate the script, causing the image display to pop up with the target of the link as the image to display.

To accomplish this is very simple; for each element with the target rel attribute, one adds an onclick attribute that calls the function of one’s choosing, and – importantly – returns false, so that the link is not followed. As an added bonus, this technique fails extremely gracefully; if the javascript isn’t executed, the link is followed and the image is simply displayed in the browser.

Using rel in this case solves the problems of storing some relevant information in the link, forgoing the insertion of javascript into the markup, and providing some sort of semantic information in the markup as well.

“No Dashes Or Spaces”

May 11th, 2008

The “No Dashes Or Spaces” Hall of Shame is a monument to lazy programming. It exhibits a gallery of credit card form inputs, with instructions to the user to eschew dashes and spaces, either explicitly or implicitly via a 16-character limit.

The first rule of software robustness is this: “Be conservative in what you do; be liberal in what you accept from others.” What that means, among other things, is that you should never expect any particular formatting from your users. In fact, it is good practice to assume that the user is intent on crashing your program, and you should make it harder to do so than adding a few dashes (this applies to telephone numbers too, by the way.)

I wonder if the programmers who wrote these credit card processing schemes remembered to sanitize their database inputs?

For those of you who aren’t programmers, string manipulation — that is, working with letters and numbers — is, or should be, a piece of cake. It takes all of one line, in pretty well any programming language, to remove all non-numeric characters.

In Perl, as given at the hall of shame:

$ccnum =~ s/[-\s]//g;

In PHP:

$ccnum = str_replace(array('-', ' '), "", $ccnum);

In Javascript:

ccnum = ccnum.replace(/[-\s]/g, "");

In Python:

ccnum = ccnum.replace("-","").replace(" ","")

In Ruby:

ccnum = ccnum.gsub("-","").gsub(" ","")

Now, I don’t consider myself a programmer. I can pull off FizzBuzz, and I can write a web application in PHP, but I’m no C guru. I’ve never studied computer science save first year, and I’m sure people with more practice in their respective languages could come up with better ways. In fact, judging by the comments on FizzBuzz, I doubt any programmer who comes across this could help but to try to find a better way. God bless you neurotic saints.

The point is that it doesn’t take long to figure out how to do this simple operation.