Aug 21

Editing a file with no tools

So I came across this interesting question on SuperUser yesterday, and it got me thinking… would it be possible to create a full text editor using only standard terminal commands?  That is, could we create a text editor using only standard tools such as shell scripts, sed, awk, grep, etc.  That way it could be completely portable, and not depend on any binaries on the target system.  The only binaries which would be required would be for the standard tools – which should already be installed.

Anyway, that would be cool.

Jul 21

New Website Software

Okay.  I think I know what I’m doing here.

WHAT HAVE I DONE?!  you ask.  Well, it’s really quite simple.  I haven’t been updating the website software much, so I decided that I’d just move to WordPress.  I really got the webspace for learning PHP, and to see what I could do with a CMS system.  However, in order to do everything that I want to do, I’m not motivated enough to finish work on it.  Also, I’m not a web developer.  So there’s that as well.  But I have migrated the website over, so that all old posts and pages are still here.  Links will have changed, but the content stays the same.  I may pick up work on the CMS system again sometime, but probably not.  If anybody wants to take it over/use it though, I have no problem with that.

Jun 10

Star Wars and Romans

So I watched Star Wars: Attack of the Clones last night, and in the middle of it I realized that it’s very similar to Rome. How? Let’s see:

  • Near the end, there’s a big fight in a Colosseum. Where people get executed. Now, a lot of that stuff would have been held in the Circus Maximus in Rome, but the Colosseum would have been used as well.
  • The Senate has become increasingly useless.
  • Different factions are vying for power.
  • The Chancellor was granted emergency powers to be a dictator; this is essentially what happened in the Roman Republic. A dictator was appointed in an emergency, and would give up his powers when the emergency was over. As time went on though, the dictators of the Roman Republic became increasingly power-hungry. Thus, the word ‘dictator’ now refers to an oppressive leader, when it was originally a great title.

The same basic things that happened to the Romans happened in Star Wars as well. The Republic crumbled, and then the emperors took over.

May 09

SVN Syncing

So I just spent a good half of the day today trying to figure out how to sync two repositories together. We’re moving repositories, and so we had to import data from one repository to the other. However, this process took a while, so once we had imported the data into the new repository it was several revisions out of date. There didn’t seem to be a way to use SVN tools to do this. So, I went and wrote a script which would take all the changes from one repo and commit them to the other one with all the data. This was needed because we didn’t have shell access to the new SVN repo, and because of how that repo has to be set-up it would be somewhat infeasible to do another SVN dump.

There are a few limitations with this; there’s no way to add new files to the repo(though you could probably do an svn add right before you commit). There’s also no way to delete any files. In our case, this is not a problem, as there have been only file modifications.

Before you do this, you must checkout both repositories into different directories.

So, without further ado, here’s the code:

#!/bin/bash

ORIG_DIR=<original directory>
NEW_DIR=<new SVN directory>
START_REV=<start revision of original SVN>
END_REV=<end revision of original SVN>
CURRENT_DIR=`pwd`

while [ $START_REV -ne $END_REV ]
do
cd $CURRENT_DIR
cd $ORIG_DIR
svn update -r "$START_REV" #update to next revision of old directry
let "START_REV += 1"

cd $CURRENT_DIR
echo "About to diff, this may take a while..."
diff -qr --exclude=".svn" $ORIG_DIR $NEW_DIR > /tmp/svn_out_orig #figure out what files changed
cat /tmp/svn_out_orig | grep Only > /tmp/svn_diff_files
cat /tmp/svn_out_orig | grep Files > /tmp/svn_out
LINES=`wc -l /tmp/svn_out | cut -d' ' -f1` #how many files changed?
cat /tmp/svn_out | cut -d' ' -f2 > /tmp/sources
cat /tmp/svn_out | cut -d' ' -f4 > /tmp/dests
echo "LINES = $LINES"
while [ $LINES -gt 0 ]
do
    SOURCE=`sed -n "$LINES"p /tmp/sources`
    DEST=`sed -n "$LINES"p /tmp/dests`
    cp $SOURCE $DEST #copy each file that changed to the new directory
    let "LINES -= 1"
done
cd $ORIG_DIR
LOG=`svn log --xml -l 1 | grep msg | sed 's/<msg>//p' | sed 's/<\/msg>//p'` #get the log message for  that commit
cd $CURRENT_DIR
cd $NEW_DIR
echo "ABOUT TO COMMIT"
svn commit -m "$LOG" #commit with message

done
Apr 17

Without a Title

A few years ago, a friend of mine gave me a draft of a book to read, called Without a Title. Well, I read it at that point, and let me tell you, it was freaking hilarious. I told my friend to tell me when it was published; he never told me, and I never found it anytime that I searched for it online.

Until the other week.

Yes folks, published two years ago, is Without a Title. Why is this book so hilarious? Well, let me reprint the first few sentences here for your reading pleasure:

Once upon a time in a far off kingdom there lived a beautiful princess who was homicidally insane. She lived in a time that never really existed. It was a time of knights and kings and damsels who caused distress. It was not the accurate historical Middle Ages where half the population walked around with rotting teeth. No, these were the Middle Ages that are featured in animated films with singing forest creatures that appear on lunchboxes in every red brick schoolhouse in suburbia. It was a time in which knights could read, peasants would bathe and the main characters always had perfect hair.

Seriously, how could that not be a great story?

Of course, what I also really love is the large number of puns in the story. Such as Mike Rosoft’s dealings with Mr. Apple. Or perhaps the various… oddball methods of torture. Really. Trust me on this one, it’s hilarious.

All in all, I would give this 5/5 stars. It’s totally hilarious, with a great number of puns and jokes that just make you want to continue on.

Oh, before I forget, here’s the book on Amazon.

Mar 24

Stripping Katos

Alright, so I’m working on an SD40 here, a Kato unit to be exact. And I tried to strip the paint off of it. First, I tried using rubbing alcohol. That didn’t work too well. Then I put it in some brake fluid, as that seems to strip other locomotives. It didn’t get fully stripped, but what I suspect is that a few rounds alternating between the alcohol and the brake fluid would strip it fairly well. These pictures might not show it too well, but the piece underneath the cab was stripped quite well; the main shell, not so much, and the deck practically nothing.

The pictures don’t show it quite well, but the paint is cracked in several places. It’s a cool effect that I would keep if I were not re-painting it; as it is, I’m just going to paint over it. If some of it shows through, I’m not too concerned about it because it will be a cool effect.

Picture 1

Picture 2

Picture 3

Jan 19

SOPA and PIPA

By this time, you have probably heard quite a lot about SOPA and PIPA, so I won’t repeat that stuff here. I will however say that these bills must be stopped. And so, until they are stopped, we will continue to fight the good fight. Yes, we may be on the side of pirates. But it’s better to have the freedom that we have today than the totalitarianism of tomorrow.

Fight the good fight!

Oct 12

Steve Jobs

So, I realize that I haven’t posted anything new here in like four months. But since nobody reads it, who cares?

Anyway, as you know, Steve Jobs of course passed away the other day, and there was a bit of controversy surrounding a remark made by Richard Stallman. Here’s the quote:

Steve Jobs, the pioneer of the computer as a jail made cool, designed to sever fools from their freedom, has died.

As Chicago Mayor Harold Washington said of the corrupt former Mayor Daley, “I’m not glad he’s dead, but I’m glad he’s gone.” Nobody deserves to have to die – not Jobs, not Mr. Bill, not even people guilty of bigger evils than theirs. But we all deserve the end of Jobs’ malign influence on people’s computing.

Unfortunately, that influence continues despite his absence. We can only hope his successors, as they attempt to carry on his legacy, will be less effective.

Now, needless to say, this caused a bit of controversy. In some regards, Stallman has a point here – that Jobs made Apple into such a closed platform that it’s impossible to do stuff. While this is definitely true, on the flip side who needs unnecessary complications in your software? Most people don’t. In that regard, the iPhone/iPod are excellent platforms for software. They’re very simple, which on a small device is exactly what you want. You can’t use a desktop environment easily when you have scrollbars on the side. You don’t have the finesse of a mouse.

This “simplicity is key” design has been dominating Apple products ever since the first iPod. While this is good for most users, what I think that Stallman was getting at was that for the more power users, they don’t have all the options that they want. Let’s take the new Macbooks for example: there are a grand total of two USB ports, and just one button besides the keyboard on it(the batter charge button). It does look very sleek, but I have a hard time using it because the edges are very sharp and cut into my hands/wrists when I am typing. Possibly that’s a good thing, because it would promote better key typing posture, but it’s annoying.

Now, having two UBS ports is perfectly adequate for most people. However, people like me, whom (for lack of a better term) I call “power users” require more than two USB ports at a time. One of my co-worker’s USB ports on his Macbook is broken and only charges. My EEE PC has three USB ports on it, and is about half the size of a Macbook.

So, what’s my point here? I don’t disagree about any particular part of Stallman’s quote, but that perhaps what has been done is at least a step in a right direction. Too often, software has seemingly hundreds of buttons and controls – Apple realized that this was not a good way to use software, as did Microsoft when they came out with Office 2007. The biggest problem is that Apple wants complete control over everything. That’s fundamentally what the problem with Jobs is. He had a vision for simplicity – but he wanted it to be too simple. When you make it too simple, you remove the capability to do more advanced tasks.

This video, from The Onion, sums it up quite nicely.