Keeping It Real Safe And Real Easy

Subversion logo

OK, I've fallen in love with putting my home directory in Subversion. The benefits are enormous. They include (but are not limited to):

  • ease of setting up environment on new system
  • backup
  • ability to go “back in time” using Subversion tags

Mind you I don't put everything in there, just the important stuff like my shell configuration files and my vim configuration files. Other important files (like pictures and music I spent ages ripping) are backed up in other ways.

Here's what I currently have saved in svn:

$ svn ls http://my.svn.server/svn/home-dir/trunk/
.Xdefaults
.antrc
.bash_profile
.bashrc
.dircolors
.inputrc
.irbrc
bin/
vim_local/

So now when I'm on a system, I'll have the same look and feel and same functionality as the utilities I use will be available in my ~/bin directory.

For those astute readers, you'll notice that I don't have a .vimrc file in there. That's because I'm using an excellent tip from Amir Salihefendic about taming your vim config. Basically on each system I have a specialized but simple .vimrc that sources the vim_local for what it needs.

I've found this setup works great on the many different systems I use throughout a given week (e.g. Windows, Mac and Linux). And I'm safe in the knowledge that my configuration files won't disappear should my machines suddenly implode.

Add a comment
Category: tools Tags:

Debugging Is Sexy Good Times

I love me some JSON. The problem with it is that it's not too human readable when you need to see what it's returning. Sure you could litter your code with alerts or console.debug (if you are using Firebug and Firefox to figure out what values are you getting back.

But if you've got the Firefox/Firebug setup (and why don't you if you don't?) then you can just use the Firebug console to display the JSON data. Say for instance you have the following data returned from your service (but imagine it's a bazillion lines long):

{"SomeObject":{"Attrib1":"foo",
               "Attrib2":"bar",
               "SubObject": {"SubAttrib1":"bar"}
              }
}

Just wrap that in an eval function, plug it into the console and you get back a nice little tree of your data in the DOM view.

console screencap

Now isn't that sexy?

Add a comment
Category: programming Tags:

Welcome

Hello and welcome to sethmason.com. This site is basically an experiment to set up a site that's a resume of sorts. It will feature articles about technology that reflect my depth of knowledge.

The site itself is set up using TextPattern. Normally, I would eat my own dog food and use a Java based content management system but I wanted to give PHP and Textile a test. So far, I'm impressed.

For more information about myself, check out my about page. And feel free to leave a comment.

Add a comment
Category: personal Tags:

Writing Tests For Fun And Profit

Learning a new programming language historically starts off with the classic “Hello World” example. I've probably written a variation on that a bazillion times. From there you take more steps into advanced parts of the language. If you are smart, you save your example programs to refer back to them later. But there's a better way. And that better way is to write test cases that exercise the capabilities of the language you are trying to learn. This also works for new libraries within a language you are trying to learn.

The advantages of writing test cases are plentiful. It gets you writing actual code which helps you remember, they can be usually be run easily, they serve as an extra source of documentation about what you are trying to do (e.g. “How do I use gsub again? Oh yeah, it's in that string test I wrote?”) and finally writing tests is fun.

An Example

After ignoring it for way too long, I recently started trying out the Yahoo! User Interface Library. It's a JavaScript library with scads of useful utilities for buidling web applications. So, I pulled up the documentation and started writing a tests based on what's documented. Since it's JavaScript, I used JsUnit since I'm used to JUnit on the Java side of things. And voila we have our first test:

<html>
    <head>
    <title>Test Yahoo</title>
    <script type="text/javascript" 
        src="jsUnitCore.js"></script>
    <script type="text/javascript" 
        src="yahoo.js"></script>
    <script type="text/javascript">
    <!--
        function testIsArray() {
            assertTrue(YAHOO.lang.isArray([1,2]));
        }
    //-->
    </script>
</head>
<body>
    A test document.
</body>
</html>

(I know it's very simple but I just wanted to get a feel for the first method in the global library and type it so my brain remembered it.)

So, now I drop the test file into my test runner and here we have the results:

It's all green!

Can't you just feel your brain expanding with the possibilities?

Add a comment
Category: programming Tags:

© Seth Mason 2014

Themed using aboutwilson

Powered by Pelican