I’ve Run Away!
October 6, 2007
I guess a more appropriate title would be ‘This Blog has Moved’ or ‘Self-hosting for the Win,’ but I liked the dramatic effect of the title I’ve chosen.
So come along my dedicated reader! Run with me to http://www.robertpeaslee.com! You bring the interest, I’ll bring the content :)
Converting a Relative Path to an Absolute Path in Bash
September 29, 2007
This really shouldn’t have taken me as long as it did to figure this out, but it was a big enough of an annoyance that I decided to share it.
How to convert a relative path to an absolute path in linux/unix/bash script:
#!/bin/bash
# Assume parameter passed in is an absolute path to a directory.
# For brevity, we won't do argument type or length checking.
echo "Absolute path: `cd $1; pwd`"
For those unaware, you don’t have to ‘cd -’ because the backticks perform command substitution and don’t modify the working directory of the script.
I like to think of snippets like this as an ingredient when cooking with technology. Individual ingredients may be good, but combining them with a recipe yields something far better :)
Reciprocal Traffic and the ‘Jump’
September 24, 2007
I use the StumbleUpon firefox plugin to try and find those ‘gold nugget’ webpages in things I am interested in. One of those things happens to be (surprise!) technology. Now, probably two out of every 5 sites is some ‘search engine optimization’ or ‘how to improve your blog’ blog post that offers zero-science techniques for improving your pagerank and increasing traffic.
As far as I can tell, the only people these posts appeal to are other bloggers. So the traffic these sites are attracting are bloggers, who implement the changes, who then attract the bloggers they got the idea from. All I see here is a bunch of reciprocal traffic. Kudos, blogger. Your site is a raging success among other bloggers doing the exact same thing you are.
And as far as techniques used, who invented the ‘insert advertisement in the middle of an article’ technique? And furthermore, who was the idiot that decided to call it a ‘jump’? It is not a jump, it is an advertisement in the middle of your content. I strongly believe the concept was the result of a blogger angry that the blink tag they were so fond of is no longer supported in most browsers. “Hey, I can’t annoy people with blinking text. Time to come up with something new.” Viola, the ‘jump’ is born. Bloggers: if I think your content is good, I’ll probably keep reading despite the annoyance (yay adblock). But if your content isn’t fantastic and I see the word ‘jump’ in your post, I’m leaving your site and am likely to never return.
Stop being silly.
All of you. I mean it. You are ruining my StumbleUpon experience.
Have Purpose
September 15, 2007
This isn’t a how-to or a generic “10 things you NEED to make your life better” post. It’s a post to remind everyone who reads this that you need to check yourself and what you are doing and make sure it is worthwhile.
What does it mean to do something ‘worthwhile?’ I’m going to take the easy way out and state that it depends on the person pondering the question. For some people it is trying to get laid regularly, for others it is building a corporate empire. Just make sure that whatever you are doing now works against the feeling that you’ve wasted your eighty years on Earth.
I think far too often we are pushed into our lives by some forces of our environment, and we end up realizing that we’ve been living our lives pursuing the dreams of someone else (whether that be an individual or a collective ‘someone’). I really hope that if this is the case for anyone that reads this, you discover it early enough that you have a shot at changing things.
My biggest tip? Say hi to someone on the street. Find someone sitting alone at a restaurant or a coffee shop and sit down with them. Find out what the person you are sitting next to really wishes they were doing with their lives. Pay attention.
Programmers, techies, and geeks especially: don’t place all your value in how well you can hack, or how much you know about the latest hardware specs, or any of the other silly things we convince ourselves are actually important. They aren’t, and you are worth so much more than that for so many other reasons.
Business and career types: corporate may want you to have a degree, but never give in for a second to the thought that the letters behind your name reinforce an attribute of yourself. Don’t let others trick you, either. No one that actually knows their shit has to point to a degree as support for their position, idea, or status.
And everyone, for God’s sake, be a good roommate, spouse, parent, citizen, person, or whatever role you find yourself playing. You aren’t going to get a second chance at this. (Really. Special relativity says we can move at a rate that is slower relative to the world around us, but traveling backward in time isn’t likely.) You are involved with other people, make that a positive experience for everyone. Selfishness, dishonesty, and other ‘evil’ things are contagious and toxic. Do not be the source of toxicity in someone else’s life.
Absorb the experiences of others, share your own, be a good person. Make it your life’s purpose.
Standalone Web Applications: Have it All
August 30, 2007
Ajax and the fancy “Web 2.0″ trend are causing all sorts of web applications to pop up. The most familiar examples are the many services that google is making available, and gmail especially. Gmail is, for many people, a desktop mail client replacement. And why not? It contains the functionality that one would expect in a desktop application – viewing mail, composing new messages, and creating filters to sort incoming articles of text. It is a nicely packaged application with a decent interface. It does however have one major flaw: it doesn’t control the application used to view it.
We aren’t talking cross-browser compatibility problems or the folks using text-only browsers such as lynx. The issue that spans all browsers is that they contain navigation buttons. Back, forward, and refresh, these are all elements that can make the execution of a web application occur in an order unintended by the developer. From a software engineering perspective, this presents new problems previously not encountered when designing and developing software. From a programmer’s perspective, this introduces new complexities in the code because the state of execution can change at any time. Additionally, the code monkeys have to handle sessions that may not terminate properly, half-open connections, and navigation issues that will creep up from the user jumping around your application.
A solution to this problem that hasn’t been completely explored is to combine the benefits of desktop applications with the advantages of web applications. Desktop applications are self contained, meaning the interface to that application is completely controlled by the developer. The state of execution again becomes reliable, hooks into the process’ termination can execute cleanup code, and even cross-browser issues may be ignored. Web applications need only a web browser to load them. By embedding the rendering engine of your web browser of choice (as far as I know, Mozilla’s, Internet Explorer’s, and Safari’s rendering engines can be embedded) in an application, the only thing the user see is exactly what you want them to.
The only complication that arises from this situation is the initial distribution of your application. But because the desktop ‘launcher’ application is going to be nothing more than a frame with some logic to handle any initializing or cleanup you wish to do, it is going to be a very small download. And if you are a company that produces a lot of applications, your launcher can be modified easily to support all of them from a single application. Attractive, isn’t it? This also allows for targeting an older demographic that has been slow to catch on to web trends by deploying to them something familiar: an icon on the desktop to be click clicked.
Now for the business stuff. If you already have a solid web application that conquers the navigation and other issues that plague them, you are one step away from redeploying your application to a new market. And while speaking of markets (and thus money), if your application is driven by advertisements, controlling the platform means that the user won’t be able to block your ads. Physical distribution also becomes possible at this point. Your launcher could be bundled with an installer and distributed by CD to be sold on the shelves in brick and mortar establishments. Now your application will be reaching all corners of the current software markets, bridging gaps of technical understanding, and all without your users blocking the media you want them to see. If you are just starting development with this paradigm in mind, you are going to save development time which can be refocused on implementing features for your users. The result is a better web application that is available to everyone.
The benefits gained don’t take a lot of convincing to sell. Simplified development, a cleaner application, and reaching broader markets all from changing the means of distribution?
Money.
Making .ico Icons With Paint.NET
August 29, 2007
Giving your application an icon can be that finishing touch that says “application, I love you.” Unfortunately, the icon designer in Visual Studio 2005 isn’t a very friendly tool for creating nice looking icons. Wanting to make a cow icon for a quick 12/24 hour converter I wrote for my girlfriend, I went running to my favorite image editing program – Paint.NET.
Paint.NET it turns out doesn’t support saving images in the windows-standard .ico format! Luckily, someone was as unhappy with this as I was and created a filetype plugin for Paint.NET that grants the ability to work with and save images as icons. The download link is here. The plugin is awesome, it supports editing and saving images to be used as cursors also. And both formats, icons and cursors, can be saved with multiple image sizes in one file to support multiple icon and cursor sizes. While it is overkill for my application, this feature will save time in the future by allowing icons and cursors to be designed once (as a larger image) before being automatically scaled to each of the smaller sizes. The same feature addresses large icon and cursor sizes for users that require higher accessibility (another extremely important aspect of software development that is far too often ignored) making this plugin an all-in-one hit.
So while my girlfriend will never appreciate the depth and accessibility her little cow icon provides, it makes me smile knowing that in a pinch it could be blown up to all its 256×256 32bit glory :)
The Greatest Programming Tip Ever
August 28, 2007
We’ll start this one off with a link. Don’t worry, it is just an image (safe for work, too).
The Greatest Programming Tip Ever.
I laughed when I saw that initially, then the title hit me. That really is the Greatest Programming Tip ever. Or at least it should be on the list of top 10 Great Programming Tips, if there were such a thing. Regardless of whether you are working on an assignment for a class, a personal project, or a product for your employer, it is almost certain that someone is going to look at your code. Writing readable and easily maintained code is important for this reason, but for different reasons.
If you are going to be writing code for a class, you had better put some time in making sure your code adheres to your department’s style guidelines. For the computer science department at RIT, this was actually factored into our grades on labs and projects. Even if it weren’t, your professor is going to be more frustrated than impressed with a piece of code that lacks comments and is filled with ternary operators. Comment your code to explain things that aren’t immediately obvious to a first year CS student, name your variables to be descriptive of their function, and make sure your program flows well (no spaghetti code). This will make your professor happy, thus boosting your grades.
For personal projects, it is just as important to follow the guidelines above. While there may be no one grading your work, consider that friends, future employers, and future-you may look at the code later. Embarrassingly, I can’t even count the number of times I’ve rewritten those run-once-every-three-months kind of scripts because I didn’t take the time to comment them. And if I had put those scripts on a public source repository (which I fully plan to set up soon), employers would eventually see it. I want the code I present to the world to reflect that I am a proficient, clean coder. You should want that for yourself.
Now here is the big one, your employers. If you are working for someone, that almost definitely means you are working on a team. In this case it isn’t just a matter of writing readable code so you can remember what you’ve done when you later have to fix a bug in the code. No – things have become amplified to a factor determined by the number of people on your team and the number of those team members that have to maintain your code. I know from experience the pain and delays that can be caused by terrible code, and I won’t lie: it happened way more often than I’ve blogged here. It dragged down the morale of our project team, caused huge delays in our production (on the magnitude of weeks of developer time over the past six months), and made the codebase impossible to maintain cleanly. You do not want to be the guy that is responsible for that. Best case is you lose your job, worst case is management turns a blind eye to the project team hiding organic material in the corners of your office (give it a couple of weeks, you won’t enjoy it).
Go out and do some reading on writing readable and maintainable code. Aside of learning the basics of a language, it is the single greatest thing you can do to improve your abilities as a programmer.
Your Life, Better in Eight Minutes
August 26, 2007
I won’t make a habit of posting videos (unless they help establish a point, which I highly doubt will occur given the majority of videos on youtube are useless drivel), but this was good enough to share. Just enjoy it.
Spin DJ, spin!
Kernel Development: What We Don’t See
August 26, 2007
This happened last month, so to some of you I am sure this is old news. But for those of you who just want a great read, you should check out this article on Linux kernel developer Con Kolivas, and why he quit kernel development forever.
Why I quit: kernel developer Con Kolivas | APC Magazine
Con did a lot for the kernel as far as desktop enhancements go, so anyone who has used Linux with a kernel >2.4.18 owes him some measure of thanks. I really recommend the article above, the guy had no formal training in computer science, nor did he know how to code before he started working on the kernel. He taught himself how to code by looking at other people’s patches being submitted to the kernel, and became the most well known developer-advocate for Linux on the desktop. Kudos to him – I’m sorry to see him go.
Now all we need are replacements! To anyone who may stumble across this blog, why not take an interest in the Linux kernel? A great introduction on how to get started comes from another kernel developer, Greg Kroah. This is a link to his presentation (it reads very well) on the Myths, Lies, and Truths About the Linux Kernel from his OLS 2006 keynote. All you have to lose is time with your girlfriends!
HowTo: Use Multiple Addresses in Gmail Filters
August 25, 2007
Gmail has incredible filtering, and I forward most of my older addresses to it to take advantage of its spam filtering capabilities before pulling the messages down to my box. Another cool feature is having the ability to tag messages based on some criteria, such as based on who sent a message. The only thing lacking is the user interface for creating these filters, because it doesn’t make readily obvious how to incorporate multiple addresses into one filter.
I’ve incorporated the knowledge gleamed from a google search on the topic into a Ruby script that takes multiple addresses in and returns a filter string that will work with gmail filters. I hope someone else finds it useful! (download)
#!/usr/bin/ruby -w
#
# Gmail supports filters, but the interface provided doesn't make it appear
# to support filtering multiple addresses at the same time. It does,
# and given multiple addresses, this script will return a filter string
# that matches multiple sources.
#
# Author: Robert Peaslee
#
if $*.length < 3
p "Usage: filters.rb ..."
exit( 1 )
end
case $*[0]
when "from"
# Get rid of first element
$*.shift
string = "from:("
$*.each { |addr|
string << "#{addr}) OR from:("
}
string.slice!( -8, string.length )
p "Copy this into the filter:"
p "#{string}"
exit( 0 )
when "to"
# Get rid of first element
$*.shift
string = "to:("
$*.each { |addr|
string << "#{addr}) OR to:("
}
string.slice!( -8, string.length )
p "Copy this into the filter:"
p "#{string}"
exit( 0 )
else
p "Please supply either from or to as the first argument."
exit( 1 )
end
