7c0h

Random links (I)

A random collection of things I saw on the internet:

Why I'll never be rich

Let me start with two pieces of unrelated information.

Random fact number one: I'm a fan of cable-free environments, and specially when it comes to my house. I have a computer screen, speakers, a PS3 and a laptop all connected together, with no cables lying around. This presented a challenge, though, because the speakers only have one 3.5mm input (as in, the same one your headphones use) and I wanted to plug two things at the same time. The PS3 has an RCA adapter, while a male-male cable can be used for the computer (that I plug into the headphones socket). So here I have three male connectors that I need to connect together, ideally without any intervention afterwards (I don't want to plug and unplug things all the time).

Random fact number two: there's a German company which I've seen in the Mauerpark Flea Market selling something they call Pokket Mixer. This is a mixer reduced to its simplest shape, in which you plug two devices through its headphones and get one single output. It costs €90 (okay, € 89,95), and looks fairly nice.

Now, you would thing that this two pieces of information complement each other perfectly, right? Get a mixer, plug both sound inputs, and problem solved. But alas, that's not the case - I cannot justify spending that much for something that, let's face it, is more a result of lazyness than anything else. So I looked for alternatives, and lucky me, I found this simple stereo mixer that does the same thing, but with less features and is a lot cheaper. I built one of those for around € 10, and now I'm happy.

Then, an idea crossed my mind: I could add a sound control to this thing. It would still be under € 10 (let's say € 20 for the really fancy options), and I could sell it for € 60. As I'd do it as a hobby and I already have a job, I can sell it at a lot less than the other guys, and still make some easy income on the way. By not having to pay any bills nor worrying about the sustainability of my project, my definition of success is fairly reachable.

But then again, there's only so much market for pocket mixers. After all, is not the kind of thing you buy over and over. Being significantly cheaper, my project is likely to be good enough for the casual listener, so I could have a chance at capturing that market, but that niche is bound to dry up eventually. And then again, when that happens I can just sell my stock at a discount and go back to my regular job, but how about the guys who actually are making a living out of it? Is it fair for me to make their business harder just because I'd like to buy more comics per week? I know the free market is all about competition and taking every chance, but is it ethical for me to do that?

So, as you can see, I'm more worried about the consequences of my success than the consequences of my project being a dud. It is clear to me now that I'll never be rich, because in order to do so I'd have to want money for the money itself, and I just can't do it. I don't want to be the kind of person that leads a market, simply because that would require me to crush the competition, and I can't bring myself to crush someone's job just for the sake of money, not even hypotetically.

Not that I'm complaining. I just wanted to point it out.

Testing code

So, RSS is now working, which means I can focus on the important part: code.

:::bash
# Step 5: RSS
DATE=$(date -R)
cat ${TEMPLATE_DIR}/rss_header.xml | sed "s/^\(.*\)::DATE::\(.*\)$/\1${DATE}\2/" > ${RSSFILE}
# Let's add the articles
sort -nr $SORTEDFILE | head -n 10 | while read post
do
    FILE=$( echo $post | sed 's/^.*::\(.*\)$/\1/')
    TITLE=$(get_title ${FILE})
    URL=${BASE_URL}/$(echo ${FILE} |
        sed 's/^.*\/\(.*\)$/\1/' |
        sed 's/\.txt$/.html/')
    URL="$( echo ${URL} | normalize)"
    DATE=$( echo $post | sed 's/^\([^:]*\)::.*$/\1/' | normalize )
    TEXT="$(get_text ${FILE})"
    TEXT=$(echo ${TEXT} | normalize)
    cat ${TEMPLATE_DIR}/rss_item.xml |
        sed "s/::TITLE::/${TITLE}/" |
        sed "s/::LINK::/${URL}/" |
        sed "s/::DATE::/$(date -Rd ${DATE})/" |
        sed "s/::DESC::/${TEXT}/" >> ${RSSFILE}
done

cat ${TEMPLATE_DIR}/rss_footer.xml >> ${RSSFILE}

First time I tried that, it was rather dissapointing. It seems to be working better now.

Almost there!

So, I'm almost one month into this thing, and all around I'm happy about the results. So far, the posting system is up and running, so is the homepage (which you might have already seen) and the archive (which you might have not seen because it's not linked anywhere, but is here.

The categories are still not working, but then again, I'm wondering if anyone actually uses those for anything. The main reason for keeping them around so far is because they add some nice colors to the title. That's all there is to it. We'll see.

Things that really should be working but aren't: the comments, the CSS for writing code, and the RSS feed.

But I can't deny it: it's been fun so far :)

Setting everything up

Ok, so here's the deal: I made my mind about moving to a different blogging platform for a while now. I used to have everything under Wordpress, but that proved to be a constant source of headaches.

The main problem was, I had my installation under shared hosting. That meant that all I got was access via FTP, no custom software installation and, worst of all, auto-updates for Wordpress triggered without warning. This was a problem because updating Wordpress would undo all my customizations, but not updating Wordpress left me open to several security bugs.

This, of course, led to the famed spam problem. I wrote a fairly simple spam detector that would catch around 99% of the spam, but it would break after every update. So as a result, one day I'd log into my control panel, and surprise! 900 spam comments to check. And I've also been kicked out of my own FTP several times, due to a fun IP check implemente by my soon-to-be-former hosting.

So I set myself to have a blog system to my taste.

The system in which I'm currently writing is written in Bash, and I'm typing this on ViM. This works for me because, in no particular order,

  • I can write HTML without Wordpress re-writing it afterwards. Super useful for typing code.
  • No security holes. Given that all the HTML will be static, I can forget about constant updates. Once I write the processing for comments (which will be available, in a process I'll explain in a future post) and I double check that it's secure, I'm done. No cookies, no magic_quotes, no SQL Injection.
  • Easy to backup and migrate. Porting my old blog here will be hell, but porting this one somewhere is as easy as copying a folder, and problem solved.

I guess I'll eventually open source the code, but seriously, is just Bash code (89 lines and counting). It's a shame I couldn't get myself to write it in Haskell, but there was just too much string processing. Maybe next time.

There is a good chance that this post it's completely useless for you. It is useless to me too, but if I don't write posts I can't check whether my code is working correctly or not. In no particular order, the list of bugs I squashed with this:

  • A problem with sed and newlines, solved via the tr utility

Page 1 / 2 »