tag:blogger.com,1999:blog-337658262024-03-04T21:34:32.835-08:00The Code and the FuryDid you read the title? I think it explains itself.Matthew Storyhttp://www.blogger.com/profile/02014497165373476263noreply@blogger.comBlogger27125tag:blogger.com,1999:blog-33765826.post-39555729157320430162008-11-21T13:55:00.001-08:002008-11-21T13:56:37.476-08:00LOLGreenspan<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJnd5SDrLzZsIKlc-DFn6j9Crof7fSGi92UJqqxF9lbkOc8xliTaP-j56uovMI2tkjrw4wJ8PN4wbzdSGph8PXgWoEfpSV5ea4IlIGw0FpuJA8FbW4LCvybG_uBMIFNRAwm1TMNw/s1600-h/lookinvizible.jpg"><img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 320px; height: 228px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJnd5SDrLzZsIKlc-DFn6j9Crof7fSGi92UJqqxF9lbkOc8xliTaP-j56uovMI2tkjrw4wJ8PN4wbzdSGph8PXgWoEfpSV5ea4IlIGw0FpuJA8FbW4LCvybG_uBMIFNRAwm1TMNw/s320/lookinvizible.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5271232911988548658" /></a><br /><br />I did this little 'lolgreenspan' for a friend of mine who works at the fed. Enjoy!Matthew Storyhttp://www.blogger.com/profile/02014497165373476263noreply@blogger.com0tag:blogger.com,1999:blog-33765826.post-42344570654691051452007-10-31T11:27:00.000-07:002007-10-31T11:30:56.334-07:00Development Grep Wrapper ScriptThis is a cute little script I wrote on my friend Sean's suggestion. Basically it performs a grep -r on a directory which you specify, and then trims out any Binary Swap matches, any subversion responses, and any compiled smarty template responses. It will then open the resulting values in vim. Perfect for the LAMP developer.<br /><br />This bad boy takes 3 arguments:<br /><br /><ol><br /><li>Regular Expression (no spaces . . . or bounded by double quotes)</li><br /><li>Direcory to search on</li><br /><li>Ouput file</li><br /></ol><br /><br /><code><br />#!/bin/bash<br />###############################################<br />## grepSVN.sh<br />## Script that grep -r a directory and removes all unwanted mateches<br />## (svn and binary swap files, and also compiled smarty templates)<br />##<br />## Author: Matthew Story<br />## Date: 10/31/2007<br />## All Contents Released Under the LGPL v1.0<br />###############################################<br />grep -r ${1} ${2} | sed s/^.*[.]svn.*$//g | sed s/^Binary[[:space:]]*file.*$//g | sed s/^.*templates_c.*$//g > ${3}<br />vim -c "%s/^$\n//g" ${3}<br /></code>Matthew Storyhttp://www.blogger.com/profile/02014497165373476263noreply@blogger.com0tag:blogger.com,1999:blog-33765826.post-80825926005074694462007-03-09T20:27:00.000-08:002007-03-09T20:40:22.619-08:00My First Experience With Head-HuntersI'm looking for work, and I've signed up on a plethera of websites and so I get lots of calls from placement firms . . . a.k.a. head hunters. Today I had my first encounter with these headhunters and it was wierd. Technically I'm not supposed to say who they are or who the firm they will place me with is . . . so i'll tell you exactly what he told to me about the firm I am to be placed in: it's either CBS or NBC or ABC and it's owned by GE . . . yeah, have fun unraveling that riddle.<br /><br />Just for the record . . . I am not a graphic designer, or a web-designer, My specialties are administering LAMP and writing rich web-applications with scripting languages, not designing the look and feel of things. I don't have anything against designers persay, it's just that I don't have the talent for that kind of thing, my talent lies elsewhere.<br /><br />So the conversation went quite well at first, we talked shop, salary, relocation benefits, regular benefits etc, and skills: he was pleased with my DHTML, AJAX, PHP, XHTML and CSS skills. Then things get interesting . . . the job requires Dreamweaver. Now I have used Dreamweaver . . . once, literally once, but it was in a production environment, so I guess that has to count for something. I conveyed this to him, and he says:<br /><br />"Well it says here 'knowledge of Dreamweaver' you have knowledge, not experience but knowledge."<br /><br />ok, I guess, but then it requires photoshop, which i have used . . . twice, and I tell him this and the same exact thing happens. So here we are, with my resume way over-beefed up, but it gets worse. I send him my resume (which he already has), and he proceeds to go through and edit every title on the thing to XHTML/CSS developer, as opposed to what I actually did. I tolerate this, because I did use XHTML/CSS in all these jobs, but i mean, that's really not the point.<br /><br />So I'm sick of this before I've even had my telephone interview . . . and it's only a 5 month deployment. I have to question ABC, NBC or CBS (owned by GE i remind you) for choosing this type of firm, and hope that this isn't indicative of all placement firms.Matthew Storyhttp://www.blogger.com/profile/02014497165373476263noreply@blogger.com0tag:blogger.com,1999:blog-33765826.post-78073943138182305222007-03-09T20:19:00.000-08:002007-03-09T20:27:10.728-08:00Festival: Making Your Scripts SpeakI was just reading through some old issues of SysAdmin magazine, of which I am a subscriber, and I came accross a cool article entitled: "Making Your Monitoring Speak." The basic premise of this article is that this guy wrote a python script that had his servers make a phone call to his cell, and actually speak the problem to him. His script uses the festival text to speech converter, which is available for linux and OS X (it comes standard on Ubuntu . . . awesomely enough). If you have a mac, don't bother, the mac "say" program is vastly superior to festival, so just use that instead. I've been playing around with this . . . (notably because having your computer say dirty things to you is just one of those things that doesn't get old . . . ever . . . i'm seriously) . . . only with BASH and not python:<br /><br /><code><br />#!/bin/bash<br />########################################<br />## talktome.sh<br />##<br />## An example script using festival<br />########################################<br />SPEECH="Good morning Dave."<br /><br />## on linux<br />echo $"SPEECH" | festival --tts<br /><br />## on mac<br />#say $"SPEECH"<br /><br />exit 0<br /></code><br /><br />The reason we use echo/pipe with festival, is that when festival is run with the --tts (text-to-speech) option, it can only take a text file or STDIN as it's input, whereas say takes a string as it's argument. If you want to make an audio file you can use texttowave utility that comes with festival . . . which will convert from text to wave, and then just use LAME or your favorite audio encoder to re-encode the audio if you so desire.<br /><br />Enjoy!Matthew Storyhttp://www.blogger.com/profile/02014497165373476263noreply@blogger.com0tag:blogger.com,1999:blog-33765826.post-21920412316918482552007-02-28T15:02:00.000-08:002007-02-28T15:20:07.218-08:00Anger With Firefox Anger With the W3CSo I posted <a href="http://codeandfury.blogspot.com/2007/02/anger-with-firefox-15x-and-maybe-more.html">here</a> about a firefox bug with rendering margin-top and margin-bottom based on the width of the parent div. Well I was wrong . . . yes I freely admit it. There is no bug in firefox 1.5, or 1.0 or 2.0 or IE 5-7 or Safari or Opera or Linx or any of these. There is a bug with the W3C CSS 2 and 2.1 specification. That's right, you heard me, a bug with the W3C specification.<br /><br />I went on without reporting the bug to firefox, but told my friend Sean about it, and he didn't believe me, so I demonstrated it to him, and he suggest it I report to firefox. Well I love open source, but I'm lazy you see, and so any bugs I've found in Firefox in the past I've let go, just did a work around, published my work around on here or in a forum, and moved on with life. But i decided to listen to Sean and talk to these so-called "firefox developers." Got a Bugzilla account, and went to work giving good examples, and a lengthy explanation of the bug and providing HTML and javascript to reproduce the error. Top-notch bug reporting by me (see the bug report <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=371971">here</a> if you hae an account, if you don't it's bug 371971). <br /><br />In any case, I started testing other web-browsers: firefox 1.0, 2.0, Opera, IE, Safari and low and behold . . . they all had the exact same bug. Not wanting to file bug reports at so many places I decided to look up the W3C specification for margins in CSS 2 . . . and what did I find . . . I found the bug:<br /><br /><a href="http://www.w3.org/TR/CSS2/box.html#margin-properties">http://www.w3.org/TR/CSS2/box.html#margin-properties</a><br /><br />That's the CSS2 spec, the CSS2.1 Spec of the same thing can be found here:<br /><br /><a href="http://www.w3.org/TR/CSS21/box.html#propdef-margin">http://www.w3.org/TR/CSS21/box.html#propdef-margin</a><br /><br />So . . . explain this to me then . . . if you set top and bottom margins of any element not layed out in a table, the top and bottom margins . . . in percentages . . . are calculated based on the width of the parent element. Hmmmmm, that makes next to no sense . . . so I thought about it a while, and i figured out why they must have decided this.<br /><br />It makes some sense if you think about it in 2 ways. First If I'm setting an overall margin (using the CSS2 margin shorthand: margin:) and I set it to 10%, I'm expecting to see even margins on both sides. This is a pretty intuitive assumption, if you don't stop to think things through. If you want an even margin, you should set the margin in cm, or em, and if you want an even margin that's relative to the size of the object, you can even you em . . . yes that's right em.<br /><br />The other reason would be that you might be setting margins to be relative in size to one another: such as 10% for left and right, but only 5% for top and bottom. This could give some odd results if you had . . . let's say, a 10px by 500px div, where the left and right margins calculated to 1px each and the top and bottom margins calculated to 25px each. That would be kind of weird I guess, and a bit unexpected for your average webdesigner.<br /><br />None the less I think it's weird to do it this way, and I would formally protest to the W3C, except they don't care about me, or what I have to say, because . . . well . . . they are important, and I'm not. I accept this as my fate, and will resign myself to muffled screams and muted anger as I curse their name from the hilltops, and it falls on their deaf ears.<br /><br />Anyway, that should cover the "fury" part of the blog for awhile.<br /><br />Enjoy!Matthew Storyhttp://www.blogger.com/profile/02014497165373476263noreply@blogger.com0tag:blogger.com,1999:blog-33765826.post-11469609218852333062007-02-28T14:40:00.000-08:002007-02-28T14:59:38.089-08:00Various BASH Installation ScriptsLast week I posted about the bash.zedzone.com CommZone for BASH hackers that I set up. Well late last week I posted a bunch of installation scripts up there, some for Ubuntu and Debian Linux, others are *nix agnostic, and I'll write about them a bit here as well. These are all pretty basic, but they make installing the program that they install a one-liner, as opposed to a several-liner:<br /><br /><h3>PACPL installer Script - </h3><br /><br />Perl Audio Converter (PACPL) is a gnarly program that boasts that it can convert from everything to everything . . . and it does not boast falsely. This bad mofo does everything, but the program is just a front end for a lot of other programs, all of which need to be installed for this bad mother to work. This installation is a bitch (no seriously it warrents profanity on the Internet, and I used a lot more in real life), as it doesn't do any of the installs automatically aside from the CPAN Perl upgrades. It depends on a myriad of Perl modules, and a whole lot of external applications (LAME, Musepack to name a few), some of which are repository-arized and some of which are not. This script will do everything for you, except that you'll have to fill in the requested CPAN info by yourself . . . if you don't already have CPAN configured on your box (and if you don't than you are obviously not a PERL guru . . . which makes you lame . . . or awesome . . . depending entirely on the circles that you travel in). This script uses aptitude, and so it will require Debian or Ubuntu . . . though I know a guy who installed apt with Redhat (why?). The wiki page in the BASH Hackers CommZone for this script is here:<br /><br /><a href="http://bash.zedzone.com/wiki/view_entry.php?wikiEntryId=18052">http://bash.zedzone.com/wiki/view_entry.php?wikiEntryId=18052</a><br /><br /><h3>Ruby 1.8.5 Install Script -</h3><br /><br />This script is almost specifically for Debian, because alot of cool Ruby scripts require v 1.8.5 or at least 1.8.4 and Debian . . . well, if you're using Debian, you know exactly what I mean. I think Ubuntu is on 1.8.4 in their repository-arized version of Ruby, so if you really need 1.8.5 this'll do it for Ubuntu too. This script is actually *nix agnostic, as it doesn't use apt at all (whereas PACPL uses apt). This thing is simple enough, but it does require make . . . but doesn't install that for you . . . The wiki page in the BASH Hackers CommZone for this script is here:<br /><br /><a href="http://bash.zedzone.com/wiki/view_entry.php?wikiEntryId=18352">http://bash.zedzone.com/wiki/view_entry.php?wikiEntryId=18352</a><br /><br /><h3>LAME 3.97 Install Script -</h3><br /><br />This script is for *nix agnostic, but I did it for Debian. LAME doesn't meet the necissary license standards for the Debian requirements, so it's not in the repos. Grrrr, Ubuntu has it in the multiverse Repos, but it's 3.96 not 3.97 . . . so if you really need 3.97 this'll work. And also running this thing is easier than using yum or RPMs or YAST or any of that crap I used to waste my time with . .. (sorry RPM people, but if ESR finally decided to ditch Redhat because RPMs suck terribly, than I can publically diss RPMs for the personal Hell that Suse/Fedora has put me through, and the hours of my life using yum and Yast that I will NEVER GET BACK!). Anyway, you can find this install script here:<br /><br /><a href="http://bash.zedzone.com/wiki/view_entry.php?wikiEntryId=18372">http://bash.zedzone.com/wiki/view_entry.php?wikiEntryId=18372</a><br /><br /><h3>HandBrake 0.7.1 Install Script -</h3><br /><br />This script is Debian/Ubuntu/Anything with apt specific, as HandBrake has a few uncommon dependancies and they need to be installed first. Call me lazy but I don't like to compile from source when the repository has a copy. So yeah, if you're running an apt-based distro this will work fine. The HandBrake install is notoriously tricky, because it's long and arduous, and it uses jam (an awesome tool like apt, but for source-code not binaries, bascically a developer makes a jam file for a program, which lists dependancies and places where the source is available, and compile options for those programs, and then jam goes and downloads and compiles all the dependancies and then compiles the app itself . . . pretty friggin' sweet huh?). So yeah, this is a hard build for those reasons, and also because the handbrake documentation forgets a step (./configure for jam much?). In any case . . . here's the stuff . . . :<br /><br /><a href="http://bash.zedzone.com/wiki/view_entry.php?wikiEntryId=18832">http://bash.zedzone.com/wiki/view_entry.php?wikiEntryId=18832</a><br /><br />Enjoy!Matthew Storyhttp://www.blogger.com/profile/02014497165373476263noreply@blogger.com0tag:blogger.com,1999:blog-33765826.post-51819845866486755562007-02-24T17:21:00.000-08:002007-02-24T17:57:09.370-08:00Microsoft's Marketshare and the US GovernmentI'm a Unix user, anybody who reads this blog knows that, and so I am charged with being the non-microsoft user amongst my friends, the guy who has to defend linux, os X, and every other Unix flavor against microsoft in one fell swoop everytime this argument starts . . . (and it starts plenty). One of the arguments most frequently waged in favor of Microsoft is:<br /><br />"Microsoft has a huge marketshare in the personal computing market . . . that many people can't be wrong"<br /><br />Aside from the fact that popularity and quality are mutually exclusive, yes, in fact, taht many people can be wrong. The largest consumer of microsoft products is also the largest employer in the United States. Guesses . . . anyone? That's right, the United States Federal Government. So alot of their marketshare comes from US government purchases, which is not a choice that any single user can make. But when it comes time for that user to make a decision about an operting system, there are going to choose the operating system that they are most comfortable with . . . the one that they were trained to use at work . . . Microsoft Windows.<br /><br />This is true of anything really, my first PC (not the one my dad got, but my actual first PC, my very own) was a DELL Inpsiron 8200 running Microsoft XP Home Edition. The reason for this choice was 2-fold: My father had Windows in the house since it was a baby . . . all the way back to 3.1, and also my school's computer lab (where i spent alot of time) ran Windows with Turbo C++ (yeah baby). I felt very comfortable with Windows, and so I bought a windows machine. Contrarily I started using Mac in College, and worked as a Mac Systems administrator for a year with the Humanities division, and my next computer was . . . you guessed it . . . a Mac. Linux came in between, but that's another story for another time.<br /><br />The point is that people buy what they know, not what's the best. Microsoft is successfull for the same reason that McDonald's is successful. When you're in a new town, driving accross the country, are you going to take a chance on that local greasy spoon for a burger that might be great, or are you going to get McDonald's because you know exactly what you're getting. You're going to get McDonald's, and most people who work for the government are going to get Windows in much the same way.<br /><br />The reason that people try to make an argument about marketshare is simple . . . most people who use windows have never used OS X or linux or solaris or free/net/openBSD, and so if they want to argue about which is better, they have to argue something that has nothing to do with the abilities or technical specifications of the operating system. Which is hard if you've never used it, or have only used it sparingly. I have a better idea, use them. No wait, I have an even better idea, it doesn't matter, you've made your choice, stop talking about it. I have stopped prostelatizing for Mac or Linux, the only thing I do now is when my Windows friends ask for computer help I tell them the truth . . . "I don't know windows very well anymore . . . given some time I could probably figure it out, but i'm not going to. If you want help from me switch to unix and I'll be more than happy to help anytime." And I would expect my Windows admin counterparts to provide the exact same response to unix users.<br /><br />I believe it's an utter travesty that the federal government uses Windows. Not just in the voting booth . . . which is completely unforgivable . . . but also in the workplace. I don't hate windows, windows is fine, windows is good even for what they need to do. But with the dawn of Ubuntu linux, and Open Office 2.0, Linux is ready. And the government should be criticized for Windows from now on, not because it sucks, or it's insecure or any of that . . . but becaue it's expensive.<br /><br />In any case, stop saying that a market share is an argument for goodness, unless you want to argue with me that McDonald's cheeseburgers are better than 7/10 cheeseburgers, or In and Out Burgers because they have a bigger marketshare. Didn't think so.Matthew Storyhttp://www.blogger.com/profile/02014497165373476263noreply@blogger.com0tag:blogger.com,1999:blog-33765826.post-10210809279078066702007-02-24T17:09:00.000-08:002007-02-24T17:20:50.073-08:00The War on Drugs = The War on PovertyThe basic premise of this post is in no way a new idea: the war on drugs is predominantly a war fought against the poor population of the nation. This is obviously the case as by and large most convicted drug offenders - either dealers or users - are poor. When matched against the fact that there are as many or more drugs flowing through the middle class suburbs (such as the one that I grew up in) as there are in the inner city (such as where I live now) the absurdity of this conviction statistic is revealed.<br /><br />None the less I feel I have a few things to add to this discourse. If you will take note of a few staggering statistics since Reagan began the "War on Drugs." The prison population in the United States has doubled since the initiation of this program, skyrocketing our prison population to heights never before seen (not even in the Soviet Union). This happened for a variety of reasons, but mostly because drug crimes became much more heavily prosecuted and there were stiffer penalties placed on drug offenders. With the birth of the "War" we also saw the birth of manditory minimum sentances and 3 strike laws, and it is these two factors that have most influenced the size of the prison population. All of these things have also been documented. And also since this war on drugs we've seen a decrease in unemployment, a decrease in the number of people living below the poverty line in the USA and rises in Gross Domestic and Nation Product per Capita.<br /><br />One might think, based on these stats, that the war on drugs is doing very well, convincing people not to do drugs, and to live healthy and successfull lives. One would be wrong, as drug use in the USA has increased exponentially since the war on drugs began as well. The good improvement we see in these statistics, I believe can largely be attributed to the fact that alot of poor and unemployed people are now in prison. People who are incarcerated are not considered to be "unemployed" and are also not tabulated in the GDP and GNP per capita calculations. I think what's happened here is that we have merely "juked" the stats, to make the USA look stronger on paper, when in fact it has gotten weaker.<br /><br />In addition to that, the war on drugs costs alot of money. Lots of new prisons need to be built, we need more prison guards, more wardens, more everything. To inforce the war on drugs we also need more intelligence agents, a larger federal intelligence infrasturcture, larger police budgets, more local officers and more training for officers. All of this means jobs, and lots and lots of money. This is considered to be good, because here we actually see the creation of new jobs and wealth, but at what cost? Is it worth giving jobs to millions of american's at the expense of locking up millions of americans? Is more jobs worth freedom?Matthew Storyhttp://www.blogger.com/profile/02014497165373476263noreply@blogger.com0tag:blogger.com,1999:blog-33765826.post-19935661564163630162007-02-23T22:09:00.000-08:002007-02-23T22:21:29.424-08:00Anger with Firefox 1.5.x and Maybe MoreAt home, I have perhaps the crappiest setup for a web-developer to test on. I code exclusively on my Ubuntu Breezy Badger Box, which features all of 1 web-browsers: Mozilla Firefox 1.5 (which i only recently upgraded from Firefox 1.0). In any case I'm working on a dynamic resizing library, and It turns out that Firefox 1.5 is severely boned in at least one category. My basic qualm is with what appears to be a lazy CSS rendering mistake. If you set the margin property with a percentage:<br /><br /><code><br />margin: 10%;<br /></code><br /><br />Then firefox will extrapolate this out to all of the margin properties individually, which can be read in Javascript with:<br /><br /><code><br />element.style.marginTop;<br />element.style.marginBottom;<br />element.style.marginRight;<br />element.style.marginLeft;<br /></code><br /><br />So all of those values will also be 10% after the element with the 10% margin is created and appended to the document object. The only problem is that all of these values in actual pixels are calculated solely based on the width of the parent object. So a marginBottom of 10% is actually 10% of the total width of the parent object, as opposed to being 10% of the total Height of the parent object. This is fairly intolerable.<br /><br />This became noticable to me, while I was in the process of writing functionality to resize all of the children of a dynamic resizable element, and I noticed that when Y-Scaling would turn off, the top and bottom margins would grow/shrink, but when Scaling on the X-axis was turned off, the margins wouldn't change for either the X or Y axis. I hope this is fixed in FireFox 2, and also that I don't discover similar mistakes in IE, Opera, Safari et all.<br /><br />Enjoy! (angrily)Matthew Storyhttp://www.blogger.com/profile/02014497165373476263noreply@blogger.com0tag:blogger.com,1999:blog-33765826.post-13207157983596975062007-02-22T19:43:00.000-08:002007-02-22T20:10:29.862-08:00Ubuntu: Christian and Satanic EditionsI am a member of the Ubuntu Forums, and while I was waiting for a turorial of mine to be approved for posting I began to peruse some of the more obscure subforums. And while I was doing this I discovered a 3rd party subforum on the canonical hosted forum site for a Ubuntu flavor called Ubuntu CE. CE, as it turns out, stands for Christian Edition, and as soon as I discovered this, I discovered a thread in this subforum about Ubuntu SE, where SE stands for Satanic Edition, and I was utterly baffled.<br /><br />Ubuntu SE, after further inquiry, turns out to be a joke on the absurdity of Ubuntu CE. Ubuntu SE is regular old Ubuntu, with red and black themes and pictures of Satan everywhere. This is hardly enough to justify it's own flavor, and I think that the creator of Ubuntu SE is fully aware of this fact. When I discovered that this was a hoax, I hoped that Ubuntu CE was also a hoax. But in fact it is not. A brief trip to <a href="http://www.whatwouldjesusdownload.com">WhatWouldJesusDownload.com</a> proved that these guys were serious (and also sporting trendy and stylish "Christian Geek" t-shirts).<br /><br />The main boasts of the Christian Edition of Ubuntu are:<br /><br /><ul><br /><li>It looks more like windows</li><br /><li>It acts more like windows</li><br /><li>It features a robust web-content filter</li><br /><li>This web-content filter has been rigged to content filter the file system</li><br /><li>It comes pre-installed with WINE</li><br /><li>It features a Bible Memorizer Program</li><br /><li>It comes pre-installed with a virtual rosery</li><br /></ul><br /><br />I was baffled upon reading this list. Certainly the last two features are Christian, but I'm unaware as to how looking like windows is in any way Christian. Apparently Windows is the operating system of the discerning Christian. Are they not aware of the widely publicized deal with the devil that Steve Baumer and William Gates made (yes, I like Paul Allen, so I left him out). And while certainly the content filtering is something that your average bible-thumping, book-burning, abortionist-torching, heartland Christian would love, it also seems like the kind of thing that your average american-flag-burning, AK47-wielding, burka-wearing Muslim would love as well. And of course anyone with children. So . . . I did what any rational human being would do . . . I started a flame war.<br /><br />My primary argument going into this flame war was 2-fold:<br /><br />1. This "edition" violates the non-discriminatory clause of the open source definition and is therefore not open source.<br /><br />While Ubuntu CE is released under the GPL, and is therefore technically non-discriminatory (as the definition requires only the license to be non-discriminatory), Ubuntu CE seems to defile the spirt of the Open Source movement. A movement started as a way to distance the Open Source guys from the communist Free Software guys, and to seperate politics from source code. And indeed politics should be seperate from source code, and so should religion.<br /><br />2. This "edition" is not really all that Christian, and calling it so means that a lot of people who would love this software will stay the hell away from it.<br /><br />Yeah, that's right, like most things called "Christian" this too isn't all that Christian when you get right down to brass tax. This distribution makes an honest effort to ease the pains of transition from Windows to Ubuntu, something that most distros don't do at all. That's great, that's wonderfull, that's . . . Christian? In addition to that this distribution helps people with kids, or with an insatiable appitite for Porn, to not allow their kids to be exposed to the horrible truths of porn sex untill much later . . . something that I know my dad tried to do with me . . . (he should've known more about computers than me . . . god it's so easy to get around that, hide your tracks, or just straight crack the shit out of that software). But this is something that lots of people want, and lots of people includes lots of non-Christian heathens. So why would you call it Christian . . . is it like a church? Is this so you and all your Christian friends can have your own operating system and it's your own exclusive little club? I just don't get the reasoning here at all. Not to mention, only Catholics use rosary beads, and most protestants find them to signify a disgusting practice . . . so it's not even proper to call this a "Christian" edition, CE should stand for "Catholic" edition.<br /><br />My suggestion to the CE developers:<br /><br />Take out the overtly Christian programs, and your jesus themes, and do what everybody else with a non-essential program does . . . put it in an apt repository. If Ubuntu won't let you put it in their multiverse, than make a christian repository, and teach your sheep how to edit the /etc/apt/sources.list file as part of bible study. Once you've done this, then change goddamned name (you might want to put a 10 commandments application in the repository while you're at it) to something better . . . like Child Friendly Ubuntu, or Web Friendly Ubuntu or something like that. Then I would be happy.<br /><br />And to answer your question of what would Jesus download, he'd probably download Ubuntu Jewish Edition, or just straight Ubuntu. If he downloaded Ubuntu CE he'd have his either his picture or a cross on his desktop . . . and a. Jesus isn't that lame kind of dude who puts his own picture on his desktop or wears the shirt of the band to their concert, and b. he probably doesn't want to be reminded of his time on the cross . . . ever again . . .<br /><br />Enjoy!Matthew Storyhttp://www.blogger.com/profile/02014497165373476263noreply@blogger.com0tag:blogger.com,1999:blog-33765826.post-90731976292914567952007-02-22T13:36:00.000-08:002007-02-22T13:40:08.941-08:00bash.zedzone.comSo I took all the BASH Hacks posts and moved them into the wiki of a new site I just created for BASH Hackers to get together and trade scripts and tricks and stuff. The basic idea I had was that I've spent alot of time with BASH and alot of time writing about BASH, and I thought it would be pretty cool to put that on in a more interactive place and get a community together focused solely on BASH.<br /><br />I have spent alot of time surfing around linux forums and various distro forums and OS X forums, and there are always questions popping up about scripting that by and large go unanswered. <a href="http://bash.zedzone.com">bash.zedzone.com</a> is an attempt to fix that problem, and to provide a place for people with various levels of BASH expertise to come and learn BASH, or get help, or just talk about whatever they want.Matthew Storyhttp://www.blogger.com/profile/02014497165373476263noreply@blogger.com0tag:blogger.com,1999:blog-33765826.post-1171947430715628112007-02-19T20:37:00.000-08:002007-03-01T14:20:48.904-08:00Overriding Scriptaculous DraggingScriptaculous is a fantastic javascript library that lets a developer do alot of very cool things very easily. I've been playing with the Scriptaculous drag&drop library for a while now and have come up with a snippet of code that is very usefull if you are dealing with the dragging of complex objects. Sometimes you want the object to drag, but other times the awesome dragging effect might get in the way of another action we want to take place. Let's say I have a dynamic resizing class (which I do), and using this I make this Object resizable by handles, which are children of a wrapper object that I have made Draggable through scriptaculous. While I'm resizing the object, I don't want it to move around the screen with the mouse . . . so i'll need to kill the scriptaculous dragging. The only problem is that I want the object to be draggable again once I'm done with the resize, and I also want the draggable object to be invoked with the same options as it was invoked before. This bit of code is designed to help you do just that:<br /><code><br />ExampleClass = Class.create();<br /><br />ExampleClass.prototype = {<br /><br /> initialize: function(elementId,dragObject) {<br /> this.element = $(elementId);<br /> this.dragObject = dragObject;<br /> this.dragElement = this.dragObject.element.id;<br /> this.dragOptions = this.dragObject.options;<br /> this.someEvent = this.eventHandler.bindAsEventListener(this);<br /> Event.observe(this.element, 'mousedown', this.someEvent);<br /> },<br /><br /> eventHandler: function(event) {<br /> this.killDraggable();<br /> this.someEndEvent = this.endEventHandler.bindAsEventListener(this);<br /> Event.observe(this.element,'mouseup',this.someEndEvent);<br /> },<br /><br /> endEventHandler: function(event) {<br /> Event.stopObserving(this.element,'mouseup',this.someEndEvent);<br /> this.makeDraggable();<br /> },<br /><br /> makeDraggable: function() {<br /> this.dragObject = new Draggable(this.dragElement,this.dragOptions);<br /> },<br /><br /> killDraggable: function() {<br /> this.dragObject.destroy();<br /> }<br />}<br /></code><br /><br />So we pass as an option to the class creation, the drag object . . . for instance if we had the drag object:<br /><br /><code><br /><br />testExampleDiv.draggableObject = new Draggable('elementid',{options});<br /><br /></code><br /><br />We would pass testExampleDiv.draggableObject to our class. The initialization function then grabs the elementId and the options passed in the initial Draggable object creation from the draggable object and saves it. At the beginning of the event, the script kills the draggable object, and then at the end of the event the script reinvokes the draggable object, passing the elementId of the original object, and the original options object to the Draggables initialization function.<br /><br />The above example uses prototype, which is a safe assumption if you're using scriptaculous . . .<br /><br />Enjoy!Matthew Storyhttp://www.blogger.com/profile/02014497165373476263noreply@blogger.com0tag:blogger.com,1999:blog-33765826.post-1169591252757696602007-01-23T14:27:00.000-08:002007-01-23T15:15:17.226-08:00ZedZone Brings Communities and the Internet TogetherThis is a bit out of the ordinary for my blog, but this digg post requires me to blog about it. I have to recuse myself a bit here, because this is the company that employs me . . . but the website <a href="www.zedzone.com">www.zedzone.com</a> is totally sweet, and anyone who finds themselves reading this should check it out: <a href="www.zedzone.com">www.zedzone.com</a>. This is our first press release, and today marks a milestone in ZedZone's development as today it has come out of it's beta phase. So if you love me, visit this website and digg the article to share the sweet goodness of ZedZone with the world.<br /><br />The website that we have put together is essentially a new idea for the internet born out of a real need for collaborative group tools online, especially in the face of several social networking websites that seem to be focused solely on individuals. The building block of society is the community, wether that be the community at large, or sub-communities comprised of limited sets of individuals. For all of these communities we designed a website around functionality that is specifically designed to enhance communications within and between groups. The site can serve as a communications hub for people within a group to organize, talk, brag, and have fun online, and also as a way for a group to present itself to the world. In doing this we also have created - in my humble opinion - the first website designed to facilitate real world interaction through electronic communication. This of course does not preclude ZedZone.com from being used for solely electronic groups, but merely allows for both electronic and real world groups.<br /><br />We've put together some really cool stuff to be used in CommZones . . . which is an area for a group. If you don't like the name you can comment on my blog, because I came up with the name, and I think it's pretty sweet. A Commzone has a bunch of awesome stuff: a wiki, a forum, and an album for pictures and files, and there is lots more sweet stuff on the way. But what this allows you to do is create dynamic content for your group, have conversations amungst your group, and store files for your group all on our dollar . . . oh yes . . . it's free . . . did I not mention that before? Well on Mike's dollar - the CEO of ZedZone.com, and one of my favorite people . . . largely because he puts food on my table, and neat gadgets in my hands (see <a href="http://codeandfury.blogspot.com/2007/01/2006-this-year-in-gadgets.html">this post</a>).<br /><br />If the few readers of mine who expect the standard nerd fare are not satisfied, I'll tell you that I mostly handled the architecture of the infrastructure on this bad mother of a website, and this thing runs on the coolest Open Source Software around today. We use Linux Virtual Server, and Apache and MySQL Cluster/Circular Replication, and a whole lot of other stuff that allows us to scale very quickly, very cheaply . . . so I hope that you all enjoy our website, and my infrastructure.<br /><br />So check it out.<br /><br /><a href="http://send2press.com/newswire/2007-01-0123-002.shtml">read more</a> | <a href="http://digg.com/business_finance/ZedZone_Brings_Communities_and_the_Internet_Together">digg story</a>Matthew Storyhttp://www.blogger.com/profile/02014497165373476263noreply@blogger.com0tag:blogger.com,1999:blog-33765826.post-1169527524424928712007-01-22T19:44:00.000-08:002007-01-22T20:48:29.433-08:00BASH Hacks: Scripting With SSHBackup scripts are key to any setup, and the bulk of the scripting that most systems administrators end up writing are backup scripts. It's nice to do a tar or rsync type backup locally, but it is much nicer to do a tar or rsync backup to a remote machine. To do this securely it would be really nice if you could use ssh in a script, but for automatic scripts this becomes problematic as you are challenged for a password by ssh. This post will walk you through how to set up a pair of dsa keys in order to allow you to automate your remote backups. Having said that, this will have very little to do with actual scripting, and everything to do with configuring SSH properly for id_dsa keys. As per most things on this blog, this has been tested on Debian and Ubuntu Linux and Mac OS X, i doubt very much that this will work for Windows, but if it does it would be some other way.<br /><br />To start, you'll need to generate a master key. To do this you'll need to use the ssh-keygen utility:<br /><br /><code><br />matt@$ ssh-keygen -t dsa -b 2048 -f ~/.ssh/id_dsa<br /></code><br /><br />This will generate a 2048 bit dsa key pair and put it into two files: id_dsa which is your private key, and id_dsa.pub which is your public key. You'll need to take the public key and put it into a file called authorized_keys:<br /><br /><code><br />matt@$ touch ~/.ssh/authorized_keys<br />matt@$ chmod 600 ~/.ssh/authorized_keys<br />matt@$ cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys<br /></code><br /><br />You'll then need to edit the /etc/ssh/ssh_config file and uncomment the following line:<br /><br /><code><br /># IdentityFile ~/.ssh/id_dsa<br /></code><br /><br />If you don't feel like opening the file you could use sed . . . :<br /><br /><code><br />matt@$ sudo sed 's/^\#\ IdentityFile\ \~\/\.ssh\/id_dsa$/IdentityFile \~\/\.ssh\/id_dsa/g' /etc/ssh/ssh_config > /etc/ssh/ssh_config<br /></code><br /><br />We now need to upload the authorized_keys file to the server that you will be connecting to. Every server you will connect to will need this authorized_keys file, and each client you will connect from will need the id_dsa and id_dsa.pub keys:<br /><br /><code><br />sftp > mkdir .ssh/<br />sftp > put ~/.ssh/authorized_keys .ssh/authorized_keys<br /></code><br /><br />Once you've done this, than you will be able to connect via SSH or SFTP without having to authtenticate via a password challenge. You can test this by trying to ssh or sftp to your server:<br /><br /><code><br />matt@$ ssh <Server FQDN or IP><br />matt@$ sftp <Server FQDN or IP><br /></code><br /><br />If you are logged directly into the server without a password prompt, then you have succeeded. If not, you may not be able to authenticate via dsa key pair to your SSH server, though this is turned on by default. If you are unable you should check the /etc/ssh/sshd_config file on your SSH server to see if dsa key pair verification is enabled.<br /><br />To use SSH in a script now, you just need to know how to execute commands remotely with SSH from a BASH script. To do this you merely need to use your standard ssh command followed by the command(s) you wish to execute in quotes:<br /><br /><code><br />ssh <Server FQDN or IP> "command1; command2; command3;"<br /></code><br /><br />For SFTP it gets a little more complicated, as SFTP requires the use of a batch file to execute commands. Create a batch file with the list of commands you want to execute, one command per line:<br /><br /><code><br />put /path/to/file<br />get /path/to/file<br />lcd /local/path/change/<br />cd /remote/path/change/<br />put file<br />get file<br />bye<br /></code><br /><br />The line bye at the end will terminate the SFTP session. To execute a batch file with SFTP use the -b option like so:<br /><br /><code><br />sftp -b /path/to/batchfile.bat <Server FQDN or IP><br /></code><br /><br />Enjoy!Matthew Storyhttp://www.blogger.com/profile/02014497165373476263noreply@blogger.com0tag:blogger.com,1999:blog-33765826.post-1168828975137865782007-01-14T18:03:00.000-08:002007-01-14T18:42:55.153-08:00Twinview With Xorg and Nvidia using TVOut, CRT and DFPLinux has come a long way since the early days, and along with it, so has the X server. Add to this the fact that Linux has come so far that Nvidia now writes drivers for their hardware for linux, and all of a sudden you can do some really sweet stuff with X and multiple displays. This post is the combination of many different experiments with X that I've played around with for the last several years, and will cover how to set up TwinView (dual monitors) using a Television, CRT or DFP (digital flat panel) as a second monitor.<br /><br />For this post I will assume that you have a working X configuration for 1 monitor, that you have a nvidia graphics card, and that you have the proprietary nvidia drivers for linux installed. If you don't have the drivers installed I will offer an assist here for ubuntu and debian linux. The installation is as simple as:<br /><br /><code><br />sudo aptitude install nvidia-glx nvidia-kernel-common<br /></code><br /><br />We will be working extensively with the xorg.conf file (found on most linux distros in the /etc/X11/ folder). This file seems daunting and may certainly put the beginner off their game, but have no fear, this file is easy to work with once you understand how it works.<br /><br />To start with the config file is split up into sections noted by starting and ending section tags like so:<br /><br /><code><br />Section "<section type>"<br /># section stuff<br /># more section stuff<br />EndSection<br /></code><br /><br />The first section germaine to our current task is the "Module" section. This section loads the various modules that X uses, such as the nvidia driver you've installed. In this section you will need to make sure that you have X load at least the following modules:<br /><br /><code><br />Section "Modules"<br />Load "glx"<br />Load "int10"<br />EndSection<br /></code><br /><br />And also make sure that the old drivers are commented out:<br /><br /><code><br />#Load "GLcore"<br /></code><br /><br />The two modules we added to the "Modules" section will allow us to use TwinView, and now all we have to do is configure our second monitor. My setup will assume that you only have one graphics card with multiple outputs, if you have the luxury of multiple graphics cards, you will need to adjust the value of the BusID option to the proper value for each individual graphics card. Each monitor that we configure will need three sections, a "Device" section, a "Monitor" section and a "Screen" section. The device section tells X which graphics card to look for the monitor in, and what type of monitor it is (TV, CRT, or DFP). The monitor section configures various hardware specific values for your monitor. The screen section links the monitor and device section together and sets the values for resolution for the attached monitor. I will go through these three sections for each of TV, CRT and DFP. Before you edit this file, make sure you make a backup:<br /><br /><code><br />cp /etc/X11/xorg.conf /etc/X11/xorg.conf.back<br /></code><br /><br />To use a traditional (non-HD) TV as a second monitor, these three sections will look like this:<br /><br /><code><br />##TVOut Setup<br />Section "Device"<br /> Identifier "nvidia1"<br /> Driver "nvidia"<br /> BusID "PCI:1:0:0"<br /> Screen 1<br /> Option "TVOutFormat" "SVIDEO"<br /> Option "TVStandard" "NTSC-M"<br /> Option "ConnectedMonitor" "TV"<br />EndSection<br /><br />##TVOut Setup<br />Section "Monitor"<br /> Identifier "Monitor1"<br /> Option "HorizSync" "30-50"<br /> Option "VertRefresh" "60"<br />EndSection<br /><br />##TVOut Setup<br />Section "Screen"<br /> Identifier "Screen1"<br /> Device "nvidia1"<br /> Monitor "Monitor1"<br /> DefaultDepth 24<br /> SubSection "Display"<br /> Depth 24<br /> Modes "800x600"<br /> EndSubSection<br />EndSection<br /><br /></code><br /><br />Some things to note here, before I go on. First in the "Device" section, the "BusID" value should be the same as the BusID value in the Device section for your primary monitor if you are using the same graphics card. Second, the "TVOutFormat" option here is specifically for using S-Video for TVOut, if you are using some other format, such as "Composite" you will have to adjust the value here accordingly. Thridly, the "TVStandard" option "NTSC-M" will work for american make TVs, but if you're not in the states or somewhere else that uses "NTSC-M" you'll need to adjust the value to whatever it is you are using. A complete list of these by region can be found here: <a href="http://gentoo-wiki.com/TV-Out_with_GeForce">http://gentoo-wiki.com/TV-Out_with_GeForce</a>. The HorizSync and VertRefresh values are the standard values for CRT Televisions, and if you're using a HDTV you should set up TV-Out using the DFP set-up that can be found later.<br /><br />Now for the CRT setup, the three sections should look like this:<br /><br /><code><br />##CRT Setup<br />Section "Device"<br /> Identifier "nvidia1"<br /> Driver "nvidia"<br /> BusID "PCI:1:0:0"<br /> Screen 1<br /> Option "UseInt10Module" "1"<br /> Option "ConnectedMonitor" "CRT"<br />EndSection<br /><br />##CRT Setup<br />Section "Monitor"<br /> Identifier "Monitor1"<br /> Option "HorizSync" "31.5-70"<br /> Option "VertRefresh" "50-120"<br /> Option "DPMS"<br />EndSection<br /><br />##CRT Setup<br />Section "Screen"<br /> Identifier "Screen1"<br /> Device "nvidia1"<br /> Monitor "Monitor1"<br /> DefaultDepth 24<br /> SubSection "Display"<br /> Depth 24<br /> Modes "1600x1200"<br /> EndSubSection<br />EndSection<br /></code><br /><br />You can see that some of the values have been changed . . . and some have been added. Specifically the Monitor section includes the directive: Option "DPMS," this option is a powersaving option unavailable for TVs, but available for CRT and DFP monitors that turns the screen off after a certain amount of idle time. Aside from that you should be aware that the values of the HorizSync and VertRefresh vary from monitor to monitor, and if you get these wrong there is the possibility of destorying your monitor. So, google the make and model of your monitor, and these values should be relatively widely available. For common monitors you will easily find these values in any linux forum as well.<br /><br />On to these sections for DFP:<br /><br /><code><br />##DFP Setup<br />Section "Device"<br /> Identifier "nvidia1"<br /> Driver "nvidia"<br /> BusID "PCI:1:0:0"<br /> Screen 1<br /> Option "ConnectedMonitor" "DFP"<br /> Option "UseInt10Module" "1"<br />EndSection<br /><br />##DFP Setup<br />Section "Monitor"<br /> Identifier "Monitor1"<br /> Option "DPMS"<br /> HorizSync 28-80<br /> VertRefresh 43-60<br />EndSection<br /><br />##DFP Setup<br />Section "Screen"<br /> Identifier "Screen1"<br /> Device "nvidia1"<br /> Monitor "Monitor1"<br /> DefaultDepth 16<br /> SubSection "Display"<br /> Depth 1<br /> Modes "1600x1200"<br /> EndSubSection<br /> SubSection "Display"<br /> Depth 4<br /> Modes "1600x1200"<br /> EndSubSection<br /> SubSection "Display"<br /> Depth 8<br /> Modes "1600x1200"<br /> EndSubSection<br /> SubSection "Display"<br /> Depth 15<br /> Modes "1600x1200"<br /> EndSubSection<br /> SubSection "Display"<br /> Depth 16<br /> Modes "1600x1200"<br /> EndSubSection<br /> SubSection "Display"<br /> Depth 24<br /> Modes "1600x1200"<br /> EndSubSection<br />EndSection<br /></code><br /><br />Again a few values have changed, and while the Screen section is quite a bit larger, it merely supports more depths than the previous two screen sections. Like the CRT, be carefull with the HorizSync and VertRefresh values as they vary and you could destroy your monitor if you mess this up. Use google and forums to find these values for your monitor.<br /><br />Once you have defined these three sections for your TV, CRT or DFP we now have only to edit the "ServerLayout" section to tell the X server to use the second monitor and to tell X where it will be placed relative to your primary monitor. Add the following line to your "ServerLayout" Section:<br /><br /><code><br />Screen 1 "Screen1" leftof "Screen0"<br /></code><br /><br />This assumes that your primary monitor is titled Screen0, and that the secondary monitor is located to the left of your primary monitor. You can swap in rightof, above, or below for the value of leftof, depending on where the secondary monitor is located in physical relation to the primary monitor. Once this is done you need to restart the X server, the easiest way to do this is simply to restart the machine, but you can restart it if you like by using CTRL-ALT-F1, and then once you're in the command line CTRL-D or /etc/init.d/xorg-common. But this may vary from flavor to flavor, and so your safest bet is to just restart the computer. Should you have problems, hard reboot the machine, and boot into recovery mode, then copy your backup config file back to it's original location and hit CTRL-D and you should be good to go again.<br /><br />Enjoy!Matthew Storyhttp://www.blogger.com/profile/02014497165373476263noreply@blogger.com0tag:blogger.com,1999:blog-33765826.post-1168643570775923162007-01-12T14:59:00.000-08:002007-01-12T18:08:03.650-08:00BASH Hacks: Error HandlingThe reason we use bash in the first place is to execute a lot of external programs in a script. Alot of times however we'll want the script to act differently if one of our commands fails, and unfortunately the standard behavior of the script is to keep chugging along in the face of errors. So we will want to implement error handling in our script to catch and report errors to the end user, and also to stop our script, or change actions if any of the external commands fail in their execution. For alot of *nix programs, the standard behavior is to output nothing unless the command fails, and to handle this type of output is very easy:<br /><br /><code><br />#!/bin/bash<br /><br />if /path/to/command -options<br />then<br /><br /> #command has failed, actions here<br /><br />else<br /><br /> #command has completed without errors<br /><br />fi<br /></code><br /><br />In this case the command is executed in an if statement, and if there is any value outputted from the command at all then we assume it has failed. This is the simplest case. If the program is more complicated, and outputs different types of output for success and error, then you will have to trap the output of the command for analysis. There are many ways to do this . . . here I will discuss two:<br /><br />The first way to do it is to redirect the output of the command into a file and then use cat to read the file:<br /><br /><code><br />/path/to/command --options > .file.txt<br /><br />if cat .file.txt | grep <Pattern><br />then<br /><br /> #has failed<br /><br />else<br /><br /> #has passed<br /><br />fi<br /></code><br /><br />The second way to do it is to trap the output in a variable:<br /><br /><code><br />VAR=$(/path/to/command --options)<br /><br />if echo "$VAR" | grep <Pattern><br />then<br /><br /> #has failed<br /><br />else<br /><br /> #has passed<br /><br />fi<br /></code><br /><br />To match the pattern you will have to examine the error output of the specific command and create a regex for it . . . for example the subversion client program starts its error output with "svn:" so . . . :<br /><br /><code><br />if echo "$VAR" | grep ^svn\:<br /></code><br /><br />Sometimes you'll want to look for other things aside from error messages in the chatter, so always read your output and then form your pattern to match the specific program. <br /><br />Enjoy!Matthew Storyhttp://www.blogger.com/profile/02014497165373476263noreply@blogger.com2tag:blogger.com,1999:blog-33765826.post-1168550858139961832007-01-11T12:46:00.000-08:002007-01-11T13:27:38.153-08:00In Defense of Open SourceSo . . . I shouldn't have to be writing this, as open source has proved itself in every way that it needs to, in that the code quality is good and it is financially viable, but there are still several people out there . . . generally foolish people . . . who insist on bashing open source. I bring this up because of recent conversations I've had with friends and family about computers, where they insist on trying to bring me back into the Windows fold . . . how Microsoft manages to get such an army of evangelical end-users is beyond me, but they have.<br /><br />I will start by saying that I am not really anti-microsoft, and that I do believe that Windows is the best operating system for certain things. Windows still has the highest volume of niched software, and is certainly the platform for computer gaming. It just so happens that I really don't need either niched software or the ability to play rediculous games on my computer. But if you need to use software for something that only exists for windows, or you want the best possible gaming experience and the ability to update your hardware frequently and have drivers for that hardware, than I fully respect your decision to use microsoft windows. The problem, as I see it, is that most people have one computer and this one computer is a very large expense, and when they buy it they have to make a choice of Operating Systems. When you only have one box, and you're running one operating system on that box, and that box cost you a relatively large amount of money, you are going to defend the decision you've made on that box. For me it's a little different, as I work in computers and therefore have lots of hardware at home and at work, and in my apartment I run several boxes with several operating systems . . . notably I run Ubuntu Linux, Debian Linux, OS X, and yes . . . Windows. I use whatever box and whatever OS is best for whatever I happen to be doing at that particular time, and I have an all purpose type machine, which is my Mac. And so I don't feel particularly attached to one particular operating system, and I don't feel the need to defend any of them as "The Best." To be quite frank, the idea that there is one "Best" operating system is foolish, it's like claiming that there is one "Best" program. While there may be one best program for a given task . . . for example I find OpenOffice.org 2.0 to be "The Best" word processor . . . I would hardly claim that this was "The Best" program ever, as while it's quite good at word processing, it certainly isn't a good software firewall, or a good video game or any number of other things.<br /><br />Different Operating Systems are designed to excel at different things, or perhaps aren't designed this way, but rather end up being better at different things. For example . . . Windows (throughb XP) is a single user operating system, and it doesn't have robust support for multiple users on one box - notably it's permissions system isn't designed to handle this at all - whereas all of the *nix Operating Systems are designed as multiple user operating systems, and handle multiple users very well. This makes Windows better for some things, and Unix better for other things. If you're just going to have one person use a machine, and play games and etc etc, it doesn't really matter if you have more than one user. However if multiple people are going to have access to a box, multiple user support becomes very important very quickly. Likewise, because Windows has a large marketshare, the hardware vendors write windows drivers for everything, whereas there are only a handfull of vendors who write linux drivers, and so installing the hot new graphics card in a linux box results in hours and hours of frustration, and then if you can get it to work, it will only work on the same level as an older card, if it works at all.<br /><br />I feel I have made my stance very clear, and so at this point I will stop making concessions to windows, and counter the frequent and ill-informed claims of the masses when it comes to saying that windows is "The Best" operating system. A good operating system needs to do a couple things: it needs to provide a manner of executing programs, support for end-users to execute these programs, and security while end-users execute these programs. So let's see how windows does compared to it's brethren in these three categories.<br /><br />As far as providing access to system resources to programs goes, windows appears to be pretty good, as there are a lot of programs for windows. Yet windows crashes far more frequently than any other production quality operating system on the market, and I can't count the number of times that Windows has run out of memory or virtual memory or both on my windows box. In addition to this windows isn't very good at scheduling or allocating processing power to a program, and will often swiftly allocate large chunks of processing power to a program that doesn't really need it, this results in too frequent crashes and hard-crashes.<br /><br />As far as providing support to end-users to execute programs is concerned windows, pundants claim, allows for easier installation and execution of programs than anyone else. Appologies, but this claim is completely false . . . in reverse order. As far as execution goes, the double click interface is fine and good, and common to all GUIs, but it's the inability to monitor program usage due to the single-user design of windows that is entirely absurd. If you install a program anyone can do anything to it, and there's no real way to stop it without installing some third party software on top of your existing software, like McAfee Privacy Guard. It's absurd that you have to install a third party program to get windows to do something that every Open Source operating system does by default. Next, installation . . . I can't tell you how many people claim that installing programs in windows is easy and intuitive, and that installing programs in mac and linux is counter-intuative and difficult. Well, this is also false, Scrounging the internet using a program is all fine and good, and you do it sometimes in mac and linux, but the most elegant solution i've seen yet for this is the apt software suite for Debian Linux. Apt blows anythign else out of the water, it's a simple one command solution that downloads installs and configures a program to your specific setup, it's hot. But even allowing for the internet scrounging, the wizard solution is less inuitive than mac's installation process. In mac you download the file, open the .dmg and then drag the program into the applications folder . . . done. This is far more elegant than the wizard solution that windows uses. Claiming that windows is intuitive is something that I have always found to be funny, as I first started using linux in 2000, and used it very briefly and then left it for about 3 years. In 2003 I stopped using Windows for a period of 6 months, and began using Linux again. It took me all of 6 hours to get back into linux, and this held true of mac a year later, but when I began using Windows again it took me weeks to relearn everything. The fact that I can put linux down for 3 years and then pick up essentially where I left off, shows that linux is highly intuitive, but windows is highly counter-intuitive .. . and before you say oh, well you learned on Unix so it makes more sense to you, stop yourself, because my first operating system ever was windows 3.1, and the first command line interface I learned was the MS-DOS prompt for windows 3.1, not the bash shell for *nix.<br /><br />As far as the third requirement of security is concerned, well alot has been said, and I believe the stats speak for themselves. Unfortunately many of my micro-friends do not, and claim that windows gets hacked more often because of it's marketshare, and why would anyone spend the time to crack a *nix box when they control only a very small portion of the marketshare. Fair point gentlemen, but . . . *nix controls a majority marketshare in the serving market, and anyone who wants to do real damage should be hacking these machines, not windows clients. A *nix proponent buddy of mine used the following analogy . . . if it was just as easy for you to break into a bank and steal a million dollars, or to steal a dollar from one million people, what would you do? I think the answer to this is clear, and it shows the weakness of the argument made by the windows proponents. <br /><br />In any case, I grow weary of the claims of windows users to their superiority, and to the idea that there is such a thing as a "Best" operating system. Can't we all just get along?Matthew Storyhttp://www.blogger.com/profile/02014497165373476263noreply@blogger.com0tag:blogger.com,1999:blog-33765826.post-1168469177711534592007-01-10T14:32:00.000-08:002007-01-10T14:47:49.913-08:00BASH Hacks: Prompting For Data With a Text Editor and a PromptOften times your BASH script will require additional data to be passed via parameter to the script, if the user doesn't pass data to the script, the traditional way of handling this is to check for the paramater and then if it doesn't exist or doesn't match the proper format to quit with an usage message:<br /><br /><code><br />#!/bin/bash<br />if [ -z $1 ]<br />then<br /><br /> echo "Usage: {x|y|z}"<br /> exit 0<br /><br />fi<br /></code><br /><br />Sometimes this is appropriate, whereas other times, the user might just not know how to use the script, or might have forgotten. In my work I end up having to write a lot of scripts to help my developers do what they need to do on a daily basis, alot of times these scripts will only be called once a week, and require data input that they might just forget about. So . . . to help them with this i use a text editor and a prompt at the beginning of a file to get the data from them after the script has started. Here is a template of the code I use:<br /><br /><code><br />#!/bin/bash<br /><br />#######################################<br /># textedit.sh<br />#<br /># A template for prompted text editor<br /># data entry from a bash script<br />#######################################<br /><br />##########VARIABLE DEFINITION############<br /><br /># This needs to start with a #, the reason for this will become clear later<br />PROMPT="################INSERT DATA HERE#################"<br /><br /># Set DATA equal to the parameter<br />DATA=$1<br /><br /># command for your favorite text editor<br />TEXTEDITOR="vim"<br /><br /># name of text file<br />TEXTFILE=".bash.script.text.txt"<br />######################################<br /><br />while [ -z "$DATA" ]<br />do<br /><br /> # add PROMPT to beginning of file<br /> echo "$PROMPT" > ~./$TEXTFILE<br /><br /> # add a trailing line<br /> echo 1>> ~/$TEXTFILE<br /><br /> #open file in favorite text editor<br /> $TEXTEDITOR ~/$TEXTFILE<br /><br /> #check to see if they added anything<br /> DATA=$(cat ~/$TEXTFILE | grep ^[^#])<br /><br /> #delete the file<br /> rm ~/$TEXTFILE<br /><br />done<br /><br />## actions here<br /><br />exit 0<br /><br /></code><br /><br />So basically what this does is it checks to see if $1 was passed as a parameter, if it's not it puts the prompt and an extra empty line into the text file that you specified and opens up the text editor with the prompted file in it for editing. After this, it checks to see if any lines without the opening # are in the file, if there are then the loop is satisfied, if not it keeps at it untill the user puts something in the file.<br /><br />Enjoy!Matthew Storyhttp://www.blogger.com/profile/02014497165373476263noreply@blogger.com0tag:blogger.com,1999:blog-33765826.post-1167772740241082932007-01-02T11:57:00.000-08:002007-01-02T13:19:00.256-08:002006: This Year In GadgetsWelcome all to my first annual "This Year In Gadgets" post. Aside from loving coding and *nix and stuff, I'm also a major gadget junkie . . . and this post will cover my gadget purchases in the last year, and review all of them based on two seperate criteria. The first category of ranking is the Gadgetiness rating on a scale of 1 - 10, this is how much the purchase of the gadget tickled my gadget bone. This ranking will combine how gimicky and rediculous the gadget is. The second category is Usefullness, and this rating will cover how usefull the gadget actually is. So in the order in which they were purchased in 2006 here we go:<br /><br /><h3>Nokia 770</h3><br /><br />Gadgetiness Rating: 9<br />Usefullness Rating: 7<br /><br />List Price: $359.99<br />Price Paid: $175.99<br /><a href="http://europe.nokia.com/770">http://europe.nokia.com/770</a><br /><br />Technically I picked up this bad boy at the end of 2005, but as this is my first gadget year in review, this thing needs to be in here. My friend Sean and I got these at half price with a developers license, and we had them overnighted to us in anticipation of playing with the first ever "Web Tablet." My first concern was that the screen was so small as to make the product useless for viewing actual web pages, but when I navigated to gmail to play around everything was fine. The tiny screen (about 4 in by 3 in) features an 800 x 600 px display making the screen easily viewable even when set to the dimmest setting.<br /><br />Unlike a cell phone, the 770 uses wi-fi to browse actual web pages, and so you're not stuck with the restrictions of the mobile web. The Nokia 770 runs a flavor of Linux specially developed for it called "Maemo" and this thing is exceedingly usefull. Aside from being able to view web-pages, once you complete the firmware upgrade and OS upgrade, you can also install a miriad of applications from SSH to GAIM, making the Nokia 770 a tiny versitile Unix client machine that allows you to do pretty much everything a sys-admin needs to be able to do. In addition to this the battery life on this baby is huge, I get about 8 hours when listening to music, and about 10 hours of use when simply browsing the internet.<br /><br />The 770 also can connect to your computer via Bluetooth or USB 2.0, and when you plug it in via USB 2.0 the flash memory card in the 770 appears as an external hard drive to your computer . . . as far as I can tell this works equally well for all operating systems (having tested on Ubuntu, Debian, Suse, OS X, and Windows XP). All in all the 770 is the perfect little toy for the serious computer user on the go, it's much more robust than a smart phone, and much much smaller and lighter than a laptop. In a word: Awesome.<br /><br /><h3>Olevia 527V HDTV</h3><br /><br />Gadgetiness Rating: 4<br />Usefullness Rating: 9<br /><br />List Price: $699.99<br />Price Paid: $499.99<br /><a href="http://www.olevia.com/jsp/products/detail.jsp?pid=527v">http://www.olevia.com/jsp/products/detail.jsp?pid=527v</a><br /><br />This isn't really a gadget, so much as it's a HDTV, but it is very gadgety as far as TVs go. I bought this in anticipation of purchasing a new computer, and stumbled upon the 527V while looking for a monitor. The 527V is a HDTV/Monitor and features a wide variety of inputs including one SVGA and one DVI input for computer monitors, these in addition to 2 Composite and 2 Component ports. As far as the usefullness rating goes, it gets a 9 not because it's a particularly good HDTV, indeed the 527V is at the very low end of the HDTV spectrum, but it is can be used for so much more than just your typical HDTV. I currently have a computer, 2 gaming systems, a DVD player, a Cable Box, and a VHS player hooked up to this bad boy.<br /><br />The 527V supports 1080i and 720p, and has a fairly high contrast ratio and response time for a low end HDTV. All in all for the money, this is a great all around monitor/TV, I would highly recommend it to anyone.<br /><br /><h3>Intel Core Duo Mac Mini</h3><br /><br />Gadgetiness Rating: 7<br />Usefullness Rating: 10<br /><br />Retail Price: $1199.99<br />Price Paid: $1199.99<br /><a href="http://www.apple.com/macmini/">http://www.apple.com/macmini/</a><br /><br />This fully functioning computer is just . . . well . . . it's sexy. It has an extremely small footprint, and it just looks so damn hot . . . mmmmm. Where do I start with this thing. Firstly, the retail price seems a bit high, but that price includes the cost of necessary upgrades (specifically upgrading to 1GB of RAM, a 100GB Hard Drive, and the cost of an Apple Bluetooth keyboard and Mouse). This thing is hooked up to my Olevia 527V via DVI and it works very well for a variety of reasons. First the machine runs very very fast, and can be used extremely well as a Unix Client, as OS X is a unix varient. So i can sit on my couch and do everything I need to do for my job. But why is this a gadget? Well my friends I will tell you.<br /><br />The Mac mini is pretty much designed to be a fully functioning Mac, that also can function as the ever popularizing "Living Room Computer." This thing is . . . as Apple calls it . . . a "Multimedia Hub." The Mini comes with a IR remote control that can be used to control iTunes, DVD Player and also front row. Front Row is the key though, Front Row is Mac's answer to Windows Media Center Edition, and it comes standard on all Macs. By pressing the "Menu" button on the remote control you can bring up an interface that will allow you to view pictures, watch films, listen to music or (not sure about this) watch TV. God is this thing cool, I can navigate to my films through front row using a remote control, and the preview window is totally sweet. This thing is an all around great computer with a fast enough processor to encode video or be used as a unix client, and with enough cool shit to be used as a Multimedia Hub. And in addition to this, the Mini is silent, you really can't tell if it's on aside from the light on the front, which means that your viewing or listening pleasure is never interrupted by the not-so-gentle whir of processor or power supply fans . . . awesome.<br /><br /><h3>NetGear SPH101 Skype Phone</h3><br /><br />Gadgetiness Rating: 10<br />Usefullness Rating: 4<br /><br />Retail Price: $230<br />Price Paid: $200<br /><a href="http://tools.netgear.com/skype/">http://tools.netgear.com/skype/</a><br /><br />This thing is a gadgetphiles gadget. I couldn't wait to get my hands on one of these, and had been following the development of the project for quite some time before the actual hardware was released. The SPH101 is the first of it's kind, it is a wi-fi skype phone with the skype software embeded on the phone. This means that the SPH101 is a stand alone skype client, and is used without interfacing with any computer. I bought this thing for the gadgetiness of it, and also because the number of skype accessories for Mac OS X is small, and for Linux is none, and as these are my primary operating systems I was stuck using Skype on my Mac with a microphone and my TV speakers, huddled 2 feet from the TV . . . it sucked.<br /><br />It's not surprising that NetGear released the first of this breed, as NetGear (partnered with eBay) owns Skype, but NetGear's hardware really has a long way to come. This thing is hilarious, It's made of some really low grade plastics, and it feels like it could come apart in your hand at any time. I will say that the call quality on it is pretty freaking sweet, and that the size and look of the thing are roughly similar to that of cell phones from about 3 years ago. There are a few real problems with this thing though: First, the wireless card inside of it is shit, you have to be within about 20 feet of your router for it to work, but inside that 20 feet it works very well. The battery life is about 1.5 hours of talk time, and about 8 hours of not talk time, which is nasty, especially when you consider that it doesn't warn you before it dies. The phone also overheats from time to time during extensive (1 hour plus) periods of use, resulting in the phone shutting off and an inability to turn it back on untill it reaches a suitable temperature . . . also this hurts the side of your face . . . no really . . . it hurts. The software also doesn't track calls accross sessions, so you can only view your calls in the current session that you've logged on, if you miss a call and you lose your network connection and sign back in you'll never know that you missed a call unless they left a voice mail. All in all I show this thing off to my techie friends, because it's a hilarious piece of hardware, and I use it to Skype with my friends, and for a local chicago number . . . but I wouldn't recommend it to anyone but the most serious gadget freaks.<br /><br /><h3>Samsung M610 (Sprint PowerVision)</h3><br /><br />Gadgetiness Rating: 7<br />Usefullness Rating: 9<br /><br />Retail Price: $329.99<br />Price Paid: $329.99<br /><a href="http://www.sprintspecialoffers.com/thin/">http://www.sprintspecialoffers.com/thin/</a><br /><br />I just got this for Christmas, so this review will be less complete than the others, but here goes. This thing is "the thinnest clamshell in the world" and I believe it, this thing is thin enough to give Kate Moss an eating disorder . . . I mean . . . give her another eating disorder. It gets a high gadgetiness rating because key to this rating is the show-off-ishness of a electronic device . . . and this thing is something that you can proudly show to anyone . . . sexy. This is not a smartphone however, so it can't get a truly astronomical gadgetiness rating.<br /><br />The main boast of the M610 is how thin it is, but it also features a 2 Mpx camera with 180 degree rotation on the vertical axis . . . pretty sweet for snapping pictures of yourself . . . if that's your thing. The only problem with this is that the camera doesn't flip the picture so if you take a picture of yourself with it, it will be upsidedown, and in phone there is no way to rotate the picture. In addition to this it also features Mp3 player software and comes with NFL mobile (if you like that sort of thing). The M610 is designed to access the Sprint "PowerVision" network, which is expensive and sucks horribly, though it has lots and lots of sucky content. But with a gnarly-awesome screen that is very bright, very clear and large for a clamshell you can browse the internet with much more ease than your average phone.<br /><br />While this thing is totally kick-ass, it does have a few annoying problems. Due to the brightness of the screen, unless you signifigantly turn down the brightness from the factory settings, you're looking at very low battery life for internet browsing or TV watching. In addition to this, they cut down on thickness by excluding an external speaker on the phone, so there is no speaker phone for it, and also the ringer uses the earpiece speaker, and so you will most likely miss a lot of calls, as the maximum volume of the ringer is still quite quiet. You also don't get a larger external screen, as is common on most clamshells, so if you're a big fan of seeing a picture of your friends on the outside of your phone when they call . . . well . . . don't expect this out of the M610 because it can't handle it. The phone also only features a single I/O port which is new to the M610 and so the accessories for the phone (wired headsets, datalinks etc) are rare, but it does boast bluetooth, so this shouldn't be a real issue. The only other problem i've had with it is that it is so new that quite a bit of usefull software doesn't work for it yet . . . including gmail.app, so if you need lots of software for your phone, go with the Samsung A900, as apps will be sure to work for it.<br /><br />All in all though, this phone is great, it has a hot screen, and a sleek profile, I would highly recommend this to all sprint users.<br /><br />Untill Next year . . . gadget on!Matthew Storyhttp://www.blogger.com/profile/02014497165373476263noreply@blogger.com0tag:blogger.com,1999:blog-33765826.post-1166874600492656162006-12-22T23:51:00.000-08:002007-01-02T13:27:43.783-08:00BASH Hacks: Using 2 Comma Delimited Lists to Replicate Simple 2D ArrayAs we have stated, the data stuctures in BASH are extremely limited. BASH has just introduced a single dimensional array data structure, but it is tricky and hard to use. They have yet to implement a multi-dimensional array data structure, and therefore we are forced to do a lot of trickery in order to replicate the functionality of multi-dimensional arrays. A very simple type of 2 dimensional array that is highly useful for writing test scripts, is a 2 dimensional array with on dimension holding any type of data, and the second dimension relating a boolean value to the values in the first dimension of the array. Say for example we have a bunch of IPs that represent webservers in a cluster, and we're writing a script to test to see if the webservers are up or down. It would come in handy to know wether the last time through the loop the servers were up or down, so we might want an array like this:<br /><br /><table border="2" frame="border"><br /><tbody><tr><br /><td><code>192.168.1.1</code></td><br /><td><code>192.168.1.2</code></td><br /><td><code>192.168.1.3</code></td><br /></tr><br /><tr><br /><td><code>1</code></td><br /><td><code>1</code></td><br /><td><code>0</code></td><br /></tr><br /></tbody></table><br /><br />Unfortunatly with BASH, this isn't possible. To replicate the simple two dimensional array of this type I have developed a little bit of code that makes extensive use of the Comma Delimited list code that I wrote about in a previous post: <a href="http://codeandfury.blogspot.com/2006/12/bash-hacks-comma-delimited-list.html">BASH Hacks: The Comma Delimited List</a>. For this solution we implement 2 of these lists, the first list holds all of the variables that you are going to run a series of actions on. The second list will be populated by values from the first list that fail these actions or tests, and each item in this list will be equivilant to having a value of "0" in the boolean dimension of the simple 2D array, and conversely a lack of a value on this list is equivilant to a "1" in the boolean dimension. This is a template of the code that I use:<br /><code><br />#!/bin/bash<br />###################################<br />## 2commas.sh<br />##<br />## A template for implementing 2 comma<br />## delimited lists to replicate the functionality<br />## of a simple 2D array<br />###################################<br /><br />#######VARIABLE DEFINITIONS########<br />LIST=1,2,3,4,5<br /><br /># We just initialize this variable here, it won't be used untill much later<br />DOWNLIST=''<br />###################################<br /><br /># loop continuously<br />while [ 1 ]<br />do<br /><br /># At the beginning of every cycle, tack a trailing comma to the end of the list<br />LOOPVAR=${LIST},<br /><br /># Loop through the contents of the comma delimited list<br />while echo $LOOPVAR | grep \, &> /dev/null<br />do<br /><br /># grab the first server name out of the comma-delimited list<br />LOOPTEMP=${LOOPVAR%%\,*}<br /><br /># remove the first server name from the LOOPVAR comma-delimited list<br />LOOPVAR=${LOOPVAR#*\,}<br /><br />if <your test><br />then<br /><br />## possibly some actions here<br />## possibly not<br /><br /># if it's on the downlist, take it off and do some stuff<br />if echo $DOWNLIST | grep $LOOPTEMP &> /dev/null<br />then<br /><br />## Some actions<br />## maybe no actions<br />## who knows?<br /><br /># Initialize the NEWDOWNLIST variable,<br /># which is a temp var that will hold the downlist minus the now up server<br />NEWDOWNLIST=''<br /><br /># This loop will take the now up server off the downlist<br />while echo $DOWNLIST | grep \, &> /dev/null<br />do<br /><br /># grab each value in the downlist from the comma delimited list<br />DOWNLOOPTEMP=${DOWNLIST%%\,*}<br /><br /># trim the value we just grabbed from the downlist<br />DOWNLIST=${DOWNLIST#*\,}<br /><br /># This variable will be empty if the DOWNLOOPTEMP<br /># variable is different than the LOOPTERM variable<br /># if they are the same the variable will contain the value of DOWNLOOPTEMP<br />CONDITION=$(echo ${DOWNLOOPTEMP} | grep ${LOOPTEMP})<br /><br /># If the variable is empty the value stays on the downlist<br /># and we add the server to the new list<br />if [ -z $CONDITION ]<br />then<br /><br /># add the server to the new list<br />NEWDOWNLIST=${NEWDOWNLIST}${DOWNLOOPTEMP},<br /><br />fi<br /><br />done<br /><br /># Set the downlist variable to the value of the New downlist variable<br />DOWNLIST=${NEWDOWNLIST}<br /><br />fi<br /><br /># If the test fails then<br />else<br /><br /># This variable will be empty if the DOWNLIST variable<br /># doesn't contain the LOOPTEMP variable<br /># otherwise the value of the variable will be the value of the DOWNLIST variable<br />CONDITION=$(echo ${DOWNLIST} | grep ${LOOPTEMP})<br /><br /># If the above variable is empty, the value needs to be added to the DOWNLIST<br /># and some actions performed, otherwise we already noted that it's down, you might<br /># still want to do some actions here though<br />if [ -z $CONDITION ]<br />then<br /><br /># Add the value to the downlist<br />DOWNLIST=${DOWNLIST}${LOOPTEMP},<br /><br />## maybe do some more actions here if you want<br /><br />fi<br /><br />fi<br /><br />done<br /><br />done<br /><br />exit 0<br /></code><br /><br />For some reason Blogger doesn't respect any attempt on my part to use tabbing, so this code looks like crap, appologies for this. Unless i use the pre tags it won't work, so when i get an elegant solution for tabbing with blogger my script code is going to look pretty nasty. Appologies.Matthew Storyhttp://www.blogger.com/profile/02014497165373476263noreply@blogger.com1tag:blogger.com,1999:blog-33765826.post-1166508471546779592006-12-18T21:20:00.000-08:002006-12-18T22:19:29.216-08:00BASH Hacks: The Comma Delimited ListBASH is by no means a complete language, and for all but a very few things it's not the right one to go with. But for scripts that make intense use of external programs it's really the best, and so this will be the first article in a series of many that deals with simple BASH hacks to make your scripting life easier.<br /><br />One of the biggest problems with BASH is that the data structures are fairly primative, and so writing a script that expands with your infrastructure is often times very hard. You end up having to do massive hacks to the script every time you add a new server, or customize the script per server etc. I've developed a bit of code that I use in any script that deals with potential areas for growth using a comma delimited list to perform a set of actions on each member of that list. This makes the code much more portable and transparent, and as your infrastructure grows or shrinks all you have to do is edit a variable definition at the beginning of one file, and the script is ready to go again. Here's the basic template:<br /><br /><code><br />#!/bin/bash<br />#################################<br />## commadelimited.sh<br />##<br />## A template for implementing a comma<br />## delimited list in BASH<br />#################################<br /><br />######VARIABLE DEFINITIONS#######<br />LIST=1,2,3,4,5<br />#################################<br /><br /># Add a trailing comma to the list variable<br />LOOPVAR=${LIST},<br /><br /># Loop as long as there is a comma in the variable<br />while echo $LOOPVAR | grep \, &> /dev/null<br />do<br /><br /> # Grab one item out of the list<br /> LOOPTEMP=${LOOPVAR%%\,*}<br /><br /> # Remove the item we just grabbed from the list,<br /> # as well as the trailing comma<br /> LOOPVAR=${LOOPVAR#*\,}<br /><br /> # some action with your variable<br /> #<br /> # echo $LOOPTEMP<br /> #<br /> # for example<br /><br />done<br /><br />exit 0<br /></code><br /><br />So what exactly does this do . . . well, here we go in detail. After defining the comma delimited list in a variable:<br /><br /><code><br />LIST=1,2,3,4,5<br /></code><br /><br />We have to add a comma to the end of this list, because we grep for a comma in the loop, and the loop would therefore terminate before processing the last item in the list, as there would no longer be a comma, because we trim the trailing comma from the list with the item itself:<br /><br /><code><br />LOOPVAR=${LIST},<br /></code><br /><br />Now we're ready to rock. If you havn't had the pleasure of using an if grep or while grep statement, then I would suggest you start to use it, this is one of the more usefull features of BASH:<br /><br /><code><br />while echo $LOOPVAR | grep \, &> /dev/null<br />do<br /><br /></code><br /><br />This will loop for as long as the loopvar variable contains a comma in it.<br /><br /><code><br />LOOPTEMP=${LOOPVAR%%\,*}<br /></code><br /><br />This grabs the first item from what's left of the LOOPVAR list. The way this works is the % in the ${} indicates that we want to trim the string from the end. The fact that there are two of them (%%) tells it to trim greedy, and match as much as possible. The regular expression that follows the %% says to chop from the furthest comma to the right, followed by anything.<br /><br /><code><br />LOOPVAR=${LOOPVAR#*\,}<br /></code><br /><br />This statement is similar to the last one, but this one takes out the first value and the trailing comma and shortens the list by one. The # tells it to trim the string from the beginning, and only one # tells it to be non-greedy and grab everything up through the first comma from the left, as defined by the regular expression that follows.<br /><br />So as we loop, the list gets shorter by one item per iteration, and eventually cycles down to an empty string, where the grep \, fails and the loop breaks.<br /><br />The following script is an application of the comma delimited list idea that I use in my everyday work:<br /><br /><code><br />#!/bin/bash<br />################################<br />## sendadminmail.sh<br />##<br />## This script is called by monitoring scripts<br />## to send mail to all of the administrators<br />## of our company should something go<br />## wrong. Which given my skills, should<br />## never happen.<br />################################<br /><br />#######VARIABLE DEFINITIONS########<br />#<br /># Comma Delimited List of Administrative E-mail addresses<br />ADMINLIST=test@test.com,test@test2.com,test@test3.com<br />#<br />###################################<br /><br /># initialize the loop variable, the trailing comma is<br /># so that the last entry will be honored<br />LOOPVAR=${ADMINLIST},<br /><br /># this loop loops through each individual entry on the list<br />while echo ${LOOPVAR} | grep \, &> /dev/null<br />do<br /><br /> # Grab the first e-mail address out of the comma-delimited list<br /> LOOPTEMP=${LOOPVAR%%\,*}<br /><br /> # Remove the first e-mail address from the<br /># LOOPVAR comma-delimited list<br />LOOPVAR=${LOOPVAR#*\,}<br /><br /> # send the e-mail<br />echo "$1" | mail -s "$2" "$LOOPTEMP"<br /><br />done<br /><br />exit 0<br /></code>Matthew Storyhttp://www.blogger.com/profile/02014497165373476263noreply@blogger.com2tag:blogger.com,1999:blog-33765826.post-1166503804430615122006-12-18T19:59:00.000-08:002006-12-18T20:50:04.446-08:00A Hate Letter to MySQLNormally I just throw up code snippets and cool stuff, but having to work with MySQL on a daily basis behooves me to throw up a rant to the MySQL developers here. I was strongly in the PostgreSQL camp, as that's what I learned on, and it had nice features that MySQL lacked . . . like referential data integrity for example. But with MySQL 5.0.x they announced that MySQL had matured and was ready to be a real SQL server with the purchase of the InnoDB storage engine.<br /><br />So I switched to MySQL for 2 reasons: the first being that MySQL 5.0.x seemed to be up to snuff and ready to compete with the big boys (namely Oracle and PostgreSQL), and 2, unfortunatly it's called the LAMP stack and not the LAPP stack, and every web app out there has MySQL support, but only a few have support for PostgreSQL, and as my job forced me to deal with these programs, I was forced to migrate. So here I will bring my complaints against MySQL, and suggest directions for improvement.<br /><br />1. Kill Off MyISAM<br /><br />It would be a mercy killing. For fuck's sake, this thing doesn't adhere to much of anything in the SQL 95 or SQL 99 standard, so stop claiming that it's a storage engine. Despite the fact that InnoDB has nice features like referencial data integrity and Transaction handling, the majority of database designers out there (if we may even call them that) don't take the time to write InnoDB databases. Aparently that ENGINE=INNODB is just too much strain on the wrist to type, and in addition to this, the default storage engine in the my.cnf file is . . . you guessed it: MyISAM.<br /><br />MyISAM is a disgrace to SQL, it doesn't support FOREIGN KEY constraints, which is, by the way, like the key feature of SQL, and it doesn't support transactions, which means if you write a web app with a complicated series of inserts, and the clown end user hits the stop button a half second into this, your data set is completely fucked. I realize that most web developers don't put transaction support in their code even when it's available, but let that be their mistake, don't make the lowly DBA . . . me . . . tell my hot shot developer that he can't put transaction support in because we're running MyISAM. You can of course specify a FOREIGN KEY in MyISAM, but as it notes in the manual, this does not enforce the constraint, it merely serves as a mental note to the database designer. ARE YOU KIDDING ME?! It's time to put this baby to bed . . . permanantly. I'll tell you what you do MySQL, you take the only good feature of this thing: full text indexing, and you fold it into InnoDB and turn out the lights.<br /><br />2. Kill phpMyAdmin<br /><br />If anyone intelligent is reading this, you can imagine my disgust when i walk into my first day on the job and see my first developer using phpMyAdmin to interact with the database. The idea behind this is pretty cool I'll admit, but it's this nasty little program that lead to the rise of the MyISAM storage engine, and we should put it to bed along with it's progeny.<br /><br />Aside from the fact that this program is the single most notorious security hole since portmapper, and putting it on the front of your DB is like giving a stranger the keys to your car and hoping he doesn't steal it, this program sucks. If you know MySQL, it's about a hundred times faster to use the mysql CLI client program to build your database and query it. This thing is terribly slow and terribly insecure. I have no problem with the novice database designer using it for playing around, or for putting up a personal website, but I have personally seen this thing used all over the place in production level deployments. Luckily enough I killed it at my current job, but I can assure you that the University of Chicago uses it for it's mega-database, so if you want to change your grade . . . well, get inside the UofC network and find the phpMyAdmin folder, and do what you want.<br /><br />This program is the number one reason why there are so many crappy databases around, and why they are mostly for MySQL. This thing allows a novice database designer to design a MySQL database, without knowing anything about SQL at all. If you want to design a database, pick up the PostgreSQL book by Bruce Momijian, or read the MySQL 5.0.x documentation from cover to cover . . . I've read both, and I assure you they are compelling reads, and you'll never make the clown mistakes that these phpMyAdmin designers make, and you'll code your database in 10% of the time.<br /><br />3. MySQL Cluster Is Not, I repeat NOT Ready For Deployment<br /><br />So stop claiming that it is. First of all the NDB storage engine is a big pile of trash, and they need to do a complete rewrite. NDB has several problems the first of which being that it is an in memory storage system. Yes, this does lead to faster query execution, but it comes at a costly price. Firstly, to scale this thing takes a lot of money, once your data set gets over about 5 gigs, which can happen very quickly indeed. Secondly, the system works by storing stuf in memory and periodically writing down to the hard drive, which means if you have a hard crash in between those two point your data is fucked, and have fun recovering from memory . . . I assure you that this is no picnic. <br /><br />The next problem that comes from this are that limits on memory usage are hardcoded in the my.cnf file, in order to make changes to this, you are required to do a complete restart of the cluster . . . which means downtime, and avoiding downtime is the sole purpose you went with the cluster in the first place. And there are no utilities that easily track what kind of space you're using, so you'd better be a master of perl or python, because you have some nasty scripting ahead of you, to keep track of your data set . . . otherwise you'll max your memory usage and the database will refuse further updates to the dataset . . . oh yes it's fun.<br /><br />In addition to this NDB seems to fail for a lot of the reasons that MyISAM fails, and more. NDB doesn't support foreign key constraints, nor does it support transaction handling, and in addtion to this it doesn't support multi-column unique indexes, or multiple auto_increments on a table. NDB also requires each table to have a primary key, which isn't so bad, but it's rediculous that this is required by the engine itself. NDB does not support full text indexing either, so as the bastard child of MyISAM it even lacks the one feature that is good about MyISAM. Please for the love of God do a rewrite, make it a non-memory based storage engine with transaction handling, and referencial data integrity and multi-column unique indices. I'm so tired of reading all these articles basking in the glow of MySQL cluster, these articles convinced me to deploy it, and really, for all it's faults, this is not nearly as good a solution as MySQL circular replication, which is sad.<br /><br />4. InnoDB's Future<br /><br />The reason for switching to MySQL in the first place is InnoDB, but this baby has a long way to go before i'm pleased with it. Firstly . . . the defining of a foreign key constraint is so unbelievably annoying it's absurd. The only way to define a foreign key is to do it at the end of a table definition with FOREIGN KEY (id) REFERENCES table(id). This kills me, allow us to do it the way PostgreSQL and Oracle and even MSSQL does it . . . id INTEGER NOT NULL references table(id). See how nice that is . . . see how you just do it when you define the column, so that you're not forced to look back and find out what the column name was and write a bunch of rediculous nonsense at the end. All of us DBA's and architects would give you a big kiss if you would just do this bit of syntatic tom-foolery for us.<br /><br />Fold in Full Text indexing and make InnoDB the default storage engine in the my.cnf file. So what . .. an army of terrible database designers will have to learn InnoDB, oh my god that would be so terrible. Syntactically the basic functionality is no different, it just adds some sweet stuff so do it, for the love of code. Make anyone who wants to write MyISAM databases strain their wrists with the extra ENGINE=MyISAM, they deserve carpul tunnel if they're going to write databases with that nonsense storage engine anyway.<br /><br />Finally, beef up PLmySQL, it sucks. For those of you unfamiliar with PLSQL it means Procedural Language SQL, and it's a language for triggers and such. Triggers are widely considered to be bad practice . . . but at the same time, they are very useful for administrative data collection and for lots of other things too. PostgreSQL has a robust PLpgSQL that works amazingly well and makes coding triggers really easy. PLmySQL sucks and could use a lot of beefing up. Specifically you need a much better system of passing data into the trigger, as the system right now is almost indeciferable and a lot of data just isnt' available to the trigger or procedure.<br /><br />If you do all of this, you might just have me on your side of the debate because I want to be there . . . as opposed to having to be there because of your marketshare.Matthew Storyhttp://www.blogger.com/profile/02014497165373476263noreply@blogger.com0tag:blogger.com,1999:blog-33765826.post-1166481642965468032006-12-18T14:00:00.000-08:002006-12-18T14:40:42.976-08:00BASH Script Background MusicSo I was sitting here at work, writting a massive script to handle the increasing complexity of our subversion repository for my co-worker Sean (of <a href="seancode.blogspot.com">seancode.blogspot.com</a> fame), and the script did so much I didn't know what to call it. For the sake of naming it, I just named it the most rediculously epic sounding thing I could think of . . . ultramega.sh, which, as it happens, is also the name of a PowerMan 5000 song. Sean and I went out for a smoke and I told him that the name of his script was ultramega.sh, after the PowerMan 5000 song, and I joked that i should have my script play the song in the background while it was chugging along . . . as this bad mother of a script takes a long time to do everything that it does. Sean was like . . . AWESOME! Have it start with the script and stop with the script . . . but we need something more epic than UltraMega, have it play "The Final Countdown" by Europe on repeat. Sweet god I thought . . . that is awesome, let's do it! So I did, with an assist from sean, who figured out how to put VLC into quiet mode, crank the volume and have it repeat. So if you've ever wanted epic background music for a script, or wanted to fuck with one of your programmers . . . here's how we pulled it off:<br /><code><br />#!/bin/bash<br />##########################################################<br />## FinalCountdown.sh<br />##<br />## A template for adding background music to your script<br />##########################################################<br /><br />#########VLC VARIABLES###########<br />VLCFILE=~/finalcountdown.mp3<br />VLCCOMMAND="vlc ${VLCFILE} --volume 500 -q -L"<br />GREPCOMMAND=$(echo "$VLCCOMMAND" | sed 's/\ /\\ /g')<br />##################################<br /><br /># Start VLC<br />$VLCCOMMAND &<br /><br /># PUT THE CONTENTS OF YOUR SCRIPT HERE<br />#<br /># do some crap<br />#<br /># some more crap<br />#<br /># finally back to VLC<br /><br /># stop VLC<br />GREPRESULT=$(ps aux | grep "$GREPCOMMAND")<br />GREPRESULT=${GREPRESULT#*\ }<br />GREPRESULT=${GREPRESULT%%\ *}<br />kill ${GREPRESULT}<br /><br /># end script<br />exit 0<br /></code><br />In case you havn't figured it out yet . . . this is for linux, but it should work equally well for all *nix's. I'll go over the script in detail for those of you not fluent in the language of the gods . . . BASH. <br /><br />First - the variables:<br /><br /><code>VLCFILE=~/finalcountdown.mp3</code><br /><br />This is the location of the song you want to play with VLC.<br /><br /><code>VLCCCOMMAND="vlc $VLCFILE --volume 500 -q -L"</code><br /><br />This is the command we want to execute . . . this is here in case we want to use a non-vlc audio program, it makes the code transparent enough such that you just enter in the command of whatever audio program you want and it will work. Specifically for VLC the volume directive tells VLC to put volume to 500%, which is the max VLC volume, the -q tells VLC to not output much to the terminal, and the -L loops the audio output, so that if our script takes longer than the song, we're not left with an awkward silence.<br /><br /><code>GREPCOMMAND=$(echo "$VLCCOMMAND" | sed 's/\ /\\ /g')</code><br /><br />This variable is less obvious than the first two, but what it does is it optimizes the command string for a grep by replacing all of the spaces with \spaces, so that it works regular expression-wise.<br /><br />We then simply start VLC in the background by executing the VLCCOMMAND variable followed by the trailing &.<br /><br />When we want to kill VLC we use ps aux with our optimized GREPCOMMAND variable to grab the one process that we're looking for . . . afterall you don't want to issue killall vlc and kill all the other VLC processes running too . . . that would suck:<br /><br /><code>GREPRESULT=$(ps aux | grep "$GREPCOMMAND")</code><br /><br />We then need to trim all the extra stuff off the result of this to get just the PID . .. we do that with the following two commands:<br /><br /><code><br />GREPRESULT=${GREPRESULT#*\ }<br />GREPRESULT=${GREPRESULT%%\ *}<br /></code><br /><br />Then kill the process with the PID that we just grabbed:<br /><br /><code><br />kill ${GREPRESULT}<br /></code><br /><br />Pretty friggin' sweet huh? We think so . . . for a real laugh, put this in a script on a machine in your data center . . . and drive those techs crazy with the seemingly random Europe rips coming from your boxes at all hours.Matthew Storyhttp://www.blogger.com/profile/02014497165373476263noreply@blogger.com1tag:blogger.com,1999:blog-33765826.post-1157774403143184942006-09-08T19:35:00.000-07:002006-09-10T08:45:29.026-07:00SSH, HTTP And SAMBA Tinkering With ParrallelsSo I know what you're thinking . . . you're thinking I have a new intel mac, and I bought a copy of <a href="http://www.parallels.com/">Parallels</a> (offsite) and installed Ubuntu 6.06 Dapper Drake into a virtual machine, but now that I've combined these two majestic operating systems how do I go about sharing files between the two?<br /><br />Well I'll tell you how. I was hoping that parallels was using something like chroot to partition the drive, mount it with the requested file system and then virtualize the OS in a jail. This is, rather unfortunately not the case. What parallels actually does is creates an 8.4 GB file in the /users/<username>/Library/Parallels/<name of virtual machine>/ folder named <name of virtual machine>.hdd. Crazy.<br /><br />So there is no way you're going to copy and paste files in and out of the jail locally, not even with the terminal and the old standard cp command. So how do I share or access files in between Mac OS X and Ubuntu? Well there are three ways depending on what you want to share or access.<br /><br />1. SSH<br /><br />If you actually want to move files from Ubuntu to OS X, or from OS X to Ubuntu you'll need to do it through SSH's SFTP program. This is actually relatively easy to set up, though my set up will require that you have a router (I think you can get around this by editing the hosts files in Ubuntu and OS X to resolve to the proper IP without any routing, but I havn't tested that).<br /><br />First you'll need to bring down the active network device. If you are connected to your network via a wired ethernet connection, your primary connection device is most likely eth0, if connected by your airport card it is most likely ath0 (though possibly eth1, and definitely eth1 if you're still running Breezy Badger).<br /><br />To bring down the wired connection:<br /><br /><code><br />shell~$ sudo ifdown eth0<br /></code><br /><br />To bring down the wireless connection:<br /><br /><code><br />shell~$ sudo ifdown ath0<br /></code><br /><br />Then We're going to set Ubuntu up with a static IP. Edit the /etc/network/interfaces file:<br /><br /><code><br />shell~$ sudo nano /etc/network/interfaces<br /></code><br /><br />For a wired connection, find the section for eth0, should look something like this:<br /><br /><code><br />auto eth0<br />iface eth0 inet dhcp<br /></code><br /><br />We need to modify this to give it a static IP:<br /><br /><code><br />auto eth0<br />iface eth0 inet static <br /># this defines the interface eth0 to have a static IP<br />address 192.168.0.150 <br /># this defines the static IP of the interface<br />gateway 192.168.0.1 <br /># this defines the default gateway (its the IP of your router)<br />netmask 255.255.255.0 <br /># this is the subnet mask of the device (probably 255.255.255.0)<br /> # if your setup is so advanced that it isn't 255.255.255.0 you<br /> # then you probably know what this value is anyway<br />broadcast 192.168.0.255<br /># if your netmask is 255.255.255.0, your broadcast is the first<br /> # 3 values of the IP address of the router followed by<br /> # 255, X.X.X.255 if its not this, see the above netmask comment<br /><br /></code><br /><br />For a wireless interface you'll need to find your wireless section, which should look something like this:<br /><br /><code><br />auto ath0<br />iface ath0 inet dhcp<br /></code><br /><br />And change it to have a static IP:<br /><br /><code><br />auto ath0<br />iface ath0 inet static <br /># This defines the interface ath0 to have a static IP<br />address 192.168.0.50 <br /># This defines the static IP of the interface ath0<br />gateway 192.168.0.1 <br /># This defines the default gateway of ath0 (Router IP)<br />netmask 255.255.255.0 <br /># Subnet mask of ath0<br />broadcast 192.168.0.255 <br /># Broadcast address of ath0<br />wireless-essid BEER <br /># Name of Wireless Network Connected to<br />wireless-mode managed <br /># mode of wireless network connected to<br />wireless-key H3X1SFUN <br /># WEP-key for wireless Network connection (or ASCII key)<br /></code><br /><br />Then bring the connection back up with the new configuration.<br /><br />For a wired connection:<br /><br /><code><br />shell~$ sudo ifup eth0<br /></code><br /><br />For a wireless connection:<br /><br /><code><br />shell~$ sudo ifup ath0<br /></code><br /><br />To see if your static IP is working properly you'll need to perform a couple of tests. First check to make sure the proper device is representing the ip.<br /><br />For a wired connection:<br /><br /><code><br />shell~$ sudo ifconfig eth0<br /></code><br /><br />For a wireless connection:<br /><br /><code><br />shell~$ sudo ifconfig ath0<br /></code><br /><br />A working device will output the values that you set in the interfaces file for each of the address, netmask and broadcast fields. Next you'll want to ping the router to make sure you're connected to the LAN:<br /><br /><code><br />shell~$ ping <router ip><br /></code><br /><br />Then ping a site on the internet to make sure you have proper WAN access (assuming you have WAN access at all):<br /><br /><code><br />shell~$ ping www.google.com<br /></code><br /><br />Awesome, now we have a static ip on our ubuntu OS running inside of the parallels. To SSH to the ubuntu OS, you'll next have to install SSH on ubuntu:<br /><br /><code><br />shell~$ sudo aptitude install ssh<br /></code><br /><br />After the installation, make sure the ssh daemon is up and running:<br /><br /><code><br />shell~$ ps aux | grep sshd<br /></code><br /><br />At this point you should be able to use SFTP from Mac OS X to Ubuntu, in order to put and get files. To make sure, switch over to your OS X partition and open a terminal:<br /><br /><code><br />shell~$ sftp <ubuntu-ip><br />sftp-> get testfile.sh<br />sftp-> put testfile.sh<br />sftp-> exit<br /></code><br /><br />To be thoughrough you should also start up the ssh daemon on OS X. To do this go to System Preferences -> Sharing and turn on personal file sharing. To test this switch back to your Ubuntu OS and run the same commands above only using the OS X ip instead of the ubuntu ip. If you don' know the OS X ip, just switch back to OS X and use ifconfig to get it:<br /><br /><code><br />shell~$ ifconfig<br /></code><br /><br />That about wraps it up for SSH.<br /><br />2. HTTP Sharing<br /><br />For some stuff SSH just doesn't make sense. For example if for some reason you want to listen to your music, or watch your movies from the OS X area in the Ubuntu area, or vice versa, you just don't want to have to copy those large files from one OS to the other, especially with the movies. So for this purpose we're going to set up HTTP servers to stream media from one OS to the other. Incidentally, as a cool side-effect of this you'll be able to stream this to any machine on your LAN, virtual or otherwise. Though this is because anyone on the LAN will be able to stream or download any file that you share via HTTP, and therefore if you want to securely share files, make sure you do it with sftp, not http.<br /><br />Before we continue, I should point out that I am assuming you are on a LAN for this, and understand that if you stream copyrighted content (even legally aquired) over the WAN you are in violation of several laws, however bogus they may be.<br /><br />Onward . . . you will most likely be streaming from OS X into Ubuntu, so we'll start there. To turn on your apache server just go to System Preferences -> Sharing and turn on personal web sharing. With one click of a button apache is up and running (though it apache 1.3 unfortunately) and they even poke a hole in the firewall on port 80 and 443 for you as well. Lets all just take a minute here to thank the folks at apple for being so friggin' awesome . . .<br /><br />The document root for the apache server is: /Library/WebServer/Documents/ and you'll need to put all of your files into this folder in order to serve them. But of course we don't want to take up unnecissary space so just soft link the files or folders you want into the document root.<br /><br />For example, my movies are in /Volumes/FATMATT/Movies, so . . .<br /><br /><code><br />shell~$ ln -s /Volumes/FATMATT/Movies /Library/WebServer/Documents/<br /></code><br /><br />Make sure the permissions are ok for the www user to read the files that you want to stream:<br /><br /><code><br />shell~$ ls -l /Library/WebServer/Documents/Movies/<br />shell~$ chmod -R 755 /Library/WebServer/Documents/Movies<br /></code><br /><br />Now we need to switch to Ubuntu and use a web browser to browse to the folder that we just set up, found at <ip of OS X>/Movies. If you want to download the files shared over HTTP, you can just browse to the folder and click on the file to download and save it. If you want to stream the files however (if they are media files) you'll need to download and install VLC. To install VLC in Ubuntu you'll first need to edit the /etc/apt/sources.list file:<br /><br /><code><br />shell~$ sudo nano /etc/apt/sources.list<br /></code><br /><br />And uncomment all of the universal repositories. Then perform and apt update, and install the program:<br /><br /><code><br />shell~$ sudo aptitude update<br />shell~$ sudo aptitude install vlc<br /></code><br /><br />To stream with VLC, browse to the shared folder and right click on the file, copy the link location. Then open VLC, go to open file, and paste the link location into the MRL text bar. And now you stream files to your Ubuntu OS wihtout having to take up vital disk space on that 8.4 GB file system.<br /><br />To share files via HTTP from Ubuntu to OS X we'll need to set up an apache server on the Ubuntu OS. To do this install apache2:<br /><br /><code><br />shell~$ sudo aptitude install apache2-mpm-prefork<br /></code><br /><br />This will take a little while, but while it goes just sit back and enjoy the glory of apt, and take a moment to thank the developers at debian for allowing us to never have to hand-resolve dependancies ever again. Once this has finished apache should be running, but make sure:<br /><br /><code><br />shell~$ ps aux | grep apache2<br /></code><br /><br />The document root for apache in ubuntu is /var/www/, so linkng files in will look like this:<br /><br /><code><br />shell~$ ln -s /target/directory/ /var/www/<br /></code><br /><br />Once you've done that switch to OS X and browse to the folder: <ip address of ubuntu OS>/<folder name>. You can again download the files by clicking on them, or stream them in VLC using the same technique discussed above. To get VLC for mac go to their <a href="http://www.videolan.org">website</a> (offsite) and download it.<br /><br />3. SAMBA<br /><br />The third option will allow you to read and write files on a samba share, without having to move the file from one to the other. This option will also allow you to copy files in and out of your samba shares on either OS and you'll be able to move files in between the two using this.<br /><br />Most likely you'll be accessing the files on OS X with Ubuntu, so first we'll go through how to mount a samba share in Ubuntu. First you'll need to initialize the Samba server on OS X. You do this by going to System Preferences -> Sharing, and then you turn on Windows File Sharing. Doing this will prompt you for a user name and password, and OS X will conveniently let you know that the way Samba stores your password is less secure than the way the OS X stores your password, but it is still sufficiently secure for a LAN. Once you've done this your home directory in OS X will be up on a network Samba share, you can verify this in the finder, in the network section.<br /><br />To mount the share in Dapper Drake go to Places -> Network Servers and then click on the share that has the name of your OS X box. My box is called MINIMATT, so I go to Places -> Network Servers -> MINIMATT to access my Samba share. If you need to configure additional samba shares on OS X, please refer to my previous post <a href="http://codeandfury.blogspot.com/2006/09/setting-up-external-hard-drive-samba.html">Setting Up External Hard Drive Samba Shares On OS X</a>.<br /><br />There is no real need to configure a samba server on your Ubuntu machine, as you can copy and paste what you need into and out of Ubuntu using the OS X samba server share. However to be thorough I should probably put this information up here as well. Unfortunately I don't have the desire to do this at the moment, so at some point in the future I'll put up a post covering how to set up a samba server in Ubuntu.<br />Enjoy!Matthew Storyhttp://www.blogger.com/profile/02014497165373476263noreply@blogger.com0tag:blogger.com,1999:blog-33765826.post-1157304109599058682006-09-03T09:30:00.000-07:002006-09-03T10:21:49.626-07:00Setting up External Hard Drive Samba Shares on OS XI have a large USB 2.0 external hard drive (300GB) connected to my brand spanking new mac mini, loaded with files that I wanted to be able to access on my Ubuntu box, which is all the way on the other side of the room. Initially I was just unmounting the volume, unplugging it and carrying it all the way accross the room to my Ubuntu machine. Well after doing this once, my arms got tired, and I thought to myself there must be a better way.<br /><br />My initial thought on this was to create an alias in my home directory, and then open it up for sharing. So to do this I created an alias of the drive in my home directory (right-click on the folder -> create alias of "FATMATT" -> drag the alias into my home directory) and then allow my home directory to be shared with samba (system preferences -> sharing -> windows sharing). This all seemed to work fine, except that linux (and windows for that matter) doesn't know what the alias is.<br /><br />Well I have a solution for this I thought, I'll just soft link the directory into my home directory, certainly Ubuntu can understand that. So I opened up my trusty terminal window and went to work:<br /><br /><code><br />ln -s /Volumes/FATMATT /Users/matt<br /></code><br /><br />I go back to my Ubuntu box and it understands the soft link, and I can go into the folder and browse the contents. When I try to open anything in the samba share however, it won't do it. Well it turns out that since the actual files are ouside of the samba share, and also because OS X prevents sharing USB drives over samba shares, you're unable to open the files despite the fact that you can see what files are on the volume. Though I would recommend using soft links instead of aliases whenever possible, as through this process I discovered that a soft link is actually much faster in file browsing than an alias is (especially when using front row).<br /><br />So I'm left with my final option, the one I didn't want to go with: configure an extra samba share for the USB drive. As OS X is nice enough to come with samba installed and configured for the home directories, I didn't have to install a samba server on the machine (a task that is quite daunting in Linux), all I had to do was reconfigure samba a bit.<br /><br />In OS X samba's primary configuration is stored in the /etc folder as the file /etc/smb.conf, to add extra samba shares you need to configure this file by hand, so I went once again to my trusty terminal and opened the file with sudo and nano (that's right I use nano . . . just leave it), backing the file up first of course:<br /><br /><code><br />sudo cp /etc/smb.conf /etc/smb.conf.bak<br />sudo nano /etc/smb.conf<br /></code><br /><br />Samba's configuration is quite simple and easy to understand, it is comprised of sections denoted by starting tags of the form [start tag]. To define a share you just think of what you want the share to be called and then create a section with that name, for example my drive is called "FATTMATT" so I create the following section with the tag [FATMATT]:<br /><br /><code><br />[FATTMATT]<br />comment = FATMATT<br />path = /Volumes/FATMATT/<br />browsable = yes<br />read only = yes<br /></code><br /><br />The configuration options in the section tell samba the following:<br /><br /><code><br />comment = FATMATT<br /></code><br /><br />This option gives samba the name of the share as it will be displayed to the samba client.<br /><br /><code><br />browsable = yes<br /></code><br /><br />This value allows the samba client to browse the contents of the folder.<br /><br /><code><br />read only = yes<br /></code><br /><br />This disallows the ability to write to the share from the client, to allow the share to be written to from a client merely exchange that line with the following line:<br /><br /><code><br />read only = no<br /></code><br /><br />Once you've added your section you need to make sure of a few things. Check the ownership and permissions of the USB drive to make sure that the user you will be accessing the share as has read permission to the drive (for read only) or read/write permission on the drive (for not read only)<br /><br /><code><br />ls -l /Volumes/<br /></code><br /><br />Then finally you'll have to reload samba with the new configuration file<br /><br /><code><br />sudo killall -HUP smbd<br /></code><br /><br />Enjoy!Matthew Storyhttp://www.blogger.com/profile/02014497165373476263noreply@blogger.com3