Mason Staugler's Web Log http://www.staugler.net/ This is what I'm posting on my site. Some people call it a blog; I call it nothing. en-us Copyright 2010, Mason Staugler A bump map for Tilt. Tilt is a plugin for Firefox that renders a page in 3D. The levels are based on element nesting in the HTML. I wrote some JavaScript to take an image and, based on the value of the pixels (aggregate of all channels), spit out (alot of) nested divs into the page. It's kind of like a bump map. Thu, 27 Oct 2011 04:28:59 +0000 http://www.staugler.net/article/a-bump-map-for-tilt Canvas test pattern. My former boss is a really good artist, but he likes Flash more than is quite right. When he did this cool test pattern based on something he saw in Times Square, I decided to do a version with the canvas. It probably doesn't work in IE. I did this for fun, so I won't cow to that garbage. This is the link, if you missed it above. Wed, 25 May 2011 21:41:19 +0000 http://www.staugler.net/article/canvas-test-pattern animan: A small JavaScript abstraction for animations. I've had to create some DOM animations in the past where the jQuery animations flickered when moving and resizing two different (but related) DIVs or properties on those divs. Manually adjusting them in the same function solved the problem, so I made this small abstraction for animations. There's a demo page here. It's not the box that's significant, but the way it's animated. Fri, 24 Sep 2010 20:16:19 +0000 http://www.staugler.net/article/animan-a-small-javascript-abstraction-for-animations Monstrous in Appearance, Monstrous in Spirit A former classmate was recently hired at my new job. He reminded me of my thesis animation for my B.F.A in Computer Art and so I'm posting it again. Thu, 29 Jul 2010 04:28:25 +0000 http://www.staugler.net/article/monstrous-in-appearance-monstrous-in-spirit preg_router: A simple PHP router. I just released a very simple PHP router. It uses an INI file for route definitions and plain regex (via PHP's preg_match) to get from an HTTP request to a handler PHP function. It's called preg_router and it's on GitHub. Sun, 27 Jun 2010 18:10:49 +0000 http://www.staugler.net/article/preg_router-a-simple-php-router Additive coding. I recently came across a bit of code with a comment that stated that this hack was being made quickly for the launch of a site but that it was important to figure out a permanent solution. The comment was from 2008 and I came across it because I was porting the logic to a global area of our site. The hack was still necessary, so I left it in. I'd planned to at least update the comment with something snarky, but I scrolled down further and found another temporary piece of code from 2007. I'd wrapped some QA code and deployed it to live so that a vendor could test some work they were doing for us. I actually removed this hack, but I pasted the former hack into the new global area with the comment unchanged. I started noticing problems everywhere in our page code. There are <div>s wrapping other <div>s to add new styles when it'd be more appropriate to add another class name to an existing <div>, fix the bug in the current styles, or write a new selector. Our styles often have selectors with one class name and are peppered with !importants to override selectors targeting a parent node (a good time to use the 'cascading' in cascading style sheets). Our scripts gradually acquire more global variables to maintain an ever more delicate application state. Some variable names suggest that they do the same thing but they were added by different people and so they do slightly different things. Older files have larger and larger blocks of commented code and we have many files, under version control, with copies of older files in the same directly suffixed with .bak, _OLD or even a person's name. I call this Additive Coding. I've been guilty of this because: I'm working with other people's code that I may not have the time or inclination to understand. I'm trying to be polite, as if I would be offending someone by rewriting their code. In the case of commenting out old, broken bits of code, I've done it because it took me a long time to figure it out. I don't want to go back and dig through an API when my reasoning takes me in circles and I think it might have worked. When pressed for time, I felt like adding to something almost working was most expedient. I once had a coworker ask me for an explanation about why I wrote a couple of lines. Just two lines above where they were looking, I had written a comment explaining, which they hadn't read because they'd trained themselves to 'ignore comments because it's usually commented code'. We need to delete and refactor. When you're working through the first iteration of your own code, especially, it's important to keep it clean and easily understood. You'll be able to rewrite it and the next draft will be better. If you have to keep going back to the API, you'll learn the API. You may find documentation by the author that will suggest a better way or tell you that the function was deprecated two minor versions ago and not to rely on it any longer. Version control ought to be enough to avoid commenting large blocks of old code and creating backup files. Even though it might be quicker now to just add another <div>, an !important or to check for a specific condition in rickety code, it's painful in the long run. It results in a chaotic situation in which everyone is fine with their own code but disgusted with the amalgam. Tue, 25 May 2010 23:59:20 +0000 http://www.staugler.net/article/additive-coding Added comments. I noticed that modern blogs don't require user accounts for comments. I don't know why I was thinking that OpenID needed to be involved. You can comment on my posts now. I've seen some CAPTCHAs fail recently, so I'll be moderating the comments for now. If I don't get any spam, I'll probably stop bothering. I have some real content that I'll post in the next couple days. That means I should probably implement tags. Tue, 25 May 2010 03:46:03 +0000 http://www.staugler.net/article/added-comments 39 days later, a redesign. The new site's been live for over a month, so I decided to redesign it. I thought the old colors were bold, but maybe they were garish. Sat, 15 May 2010 04:34:12 +0000 http://www.staugler.net/article/39-days-later-a-redesign RSS Feed I made an RSS feed for these posts. I don't expect any praise; it was just the right thing to do. Sun, 9 May 2010 22:58:56 +0000 http://www.staugler.net/article/rss-feed Hello, world. Welcome to my new site with nothing on it. My sites used to host a portfolio and a gallery with my drawings and doodles. Now it has nothing except this crippled blog. This blog has no comments. It has no pagination. It has no media. It has no archive. For all you know, this is a text file. For me, it has all the basics to grow what I need. I don't want to install software with all the features I could ever need. I want to write all the features I do need. If I need pagination or an archive or comments, I'll write those. (Actually, I would have written comments, but I'm waiting for the App Engine to support OpenID.) Tue, 6 Apr 2010 01:18:27 +0000 http://www.staugler.net/article/hello-world