Well, mostly fueled by my lack of anything interesting to say this week, here’s a post abut me. Below are 5 things that you may no (or may) know about me:
- I am a huge fan of Pink Floyd. They happen to be my favourite band ever. I love how the music is just… different. Nothing that you hear on the radio or television can compare to the creative genius of Pink Floyd.
- I play the bass guitar. Sparingly, but I do play. I started about four years ago, I never became really good, but I can play a few tunes. It’s a good way to relax on a weekend.
- I am addicted to Sci-Fi. I have been a fan of Science Fiction since I was kid in grade school. I think it was when I first got my hands on “20,000 Leagues Under the Sea” by Jules Verne that I really got into the genre. Now my collection of Science Fiction, mostly of the Star Wars Space Opera variety take up the majority of my book shelf real-estate.
- I used to work as a Visual Basic programmer. It’s sad but true.
- Before being lured into Computer Science, I secretly wanted to be an artist. I have always been a creative fellow, and all through grade school and highschool I was greatly involved in the Visual Arts. There’s a mural in my old school cafeteria with my name on it still (at least, I hope it’s still there. I should check it out now). Now my only artistic outlet is my beautiful code
And my bass of course, if you can call the sound this amature makes “art”
And there you have it. I’ll be back next week, with some fresh material (I hope). Thanks for reading!
Tags: Life
There’s an old Unix tradition: programs should do one thing, one thing well. You don’t need a mail program that also balances your checkbook, plays music, and serves coffee! The Unix world is made up of small, quiet programs that do their thing, and they do it well. Take, for example, grep. Grep takes some text (usually piped from a file, but text from the command line will work too), and a regular expression. Grep prints out the lines which match the given regular expression! Something this simple has many uses, and since it is quiet (i.e. doesn’t badger the user with useless information) grep is the perfect tool for pretty much any type of searching. Whether it be from file, or from the output of another program.
I guess an example is in order here. Say I have a file “phonebook” which keeps a record of my phone contacts, one per line. If I wanted to scour this phonebook for a certain entry, say, by last name, if the file is large enough, I’d be in for some trouble. However, with the power of the simple app grep by my side, as well as the ‘cat’ command for displaying file contents, I can search with ease! Watch how easy it is for my to search every phonebook record with last name “Smith”:
cat phonebook | grep “Smith”
And the output might looks something like this:
Smith, John 519-555-0073
Smith, Amy 519-555-1482
You see, by following the simple rule of doing one thing, and only one thing well, grep is one of the most useful programs on any Unix system. It can be used in conjunction with other programs to extend its power. And this model of simplicity is one which we as programmers should strive for. Now, not every application we develop can lend itself to being as simple as grep, but the lesson still stands. Your program has a scope: it is being written to solve a problem (I would hope so, programs that create problems are a completely different animal). Make sure your program can solve its problem. Basically, don’t add coffee-serving features to your mail program. Write the coffee-serving application by itself (and then send it to me, please).
I hope you enjoyed this little article. If you would like to learn more on how to program more simply, you should check out The Art of Unix Programming by Eric S. Raymond. Even if you aren’t a Unix programmer, it is still a good read, and you can definitely get a lot out of it.
Tags: Code · Unix
I need more sleep. Hence, I’m going to bed early tonight. I don’t have much to write about today, sadly. And to think I was doing so great too… writing every day.
I started a few test projects today, mostly to play around with the Eclipse C++ Editor. What can I say… It’s nice, very nice. Though it will never replace my vim for awesome nights of blissful hacking, Ecplise may come in handy for organizing large projects. Maybe vim should be saved for me less important coding. Heh.
Tags: Code · Life
I guess I’ve com down with “Theme schizophrenia”, because I downloaded and installed another Wordpress theme today. I don’t know… I’m pretty fussy, but very lazy. I work full time right now, and at night I just like to relax, and sometimes write a little code - nothing substantial. So using Wordpress takes away a lot of hassle for me. I don’t have to worry about maintaining my own CMS with my own themes and whatnot. I can simply come home after a good day of coding PHP for monies, grab a cold drink, and start writing.
Would I someday like to roll out my own custom CMS? Sure, why not. I have a codebase that is in some quazai state of complete/incomplete, but I just don’t want to dedicate the time to finishing it when there are already so many good blogging solutions out there. What I need is a new project… something fresh… and definitely something NOT Webdev. I had this old perl script that I whipped together to use as a phonebook, but then I reformatted my laptop, forgetting to save the phonebook data file. Maybe that’s a sign that I should rewrite the phonebook. And this time maybe I’ll use C++ or something fun.
Tags: Code · Life
I was reading my good old copy of “The C++ Programming Language” when I stumbled upon something really cool that I must have overlooked before, the awesome adapter mem_fun. Basically mem_fun takes a member function and turns it into a global function so that algorithms like for_each stop complaining. Here’s a little snippet of this guy in action:
#include <vector>
#include <functional>
#include <iostream>
using namespace std;
class Shape {
public:
void draw() { cout << “In draw!” << endl; }
};
int main() {
vector<Shape*> shapes(10);
…
for_each(shapes.begin(), shapes.end(), mem_fun(&Shape::draw));
…
}
I’m sure you can find some real cool uses for this. The above is just a simple example.
Tags: Code