Posts tagged "Code"

Picasa to Flickr

Since i use Picasa to Upload my Photo's these days, i needed something to keep Flickr updated as well. Being the lazy ass i am, i built this little tool to do it automatically.

Put it on Github, as other people might find it useful too.

CBeerta/Picasa-To-Flickr - GitHub

Picasa-To-Flickr - Copy Public Photos from Picasa to Flickr

Behavior driven Infrastructure and Monitoring

While I’m busy getting acquainted with Chef I’m starting to wonder why the topic of “Behavior driven Infrastructure” hasn’t picked up more momentum than what appears to be the case right now. (Or I’ve just been living under a Rock, and missed all of it).

Behavior driven Infrastructure

BDD Has been around in Software Development for a while now, but coverage for it’s use in a Systems Administrators life has been pretty vague from what i can tell.

I’ve found a few interesting posts, but not much beyond this.

I’ve read Test-Driven Infrastructure with Chef which touched a bit on the subject.

Behavior Driven Monitoring?

With growing Infrastructure, Monitoring becomes a major Pain. Especially if you do it the “classic” way, that focuses on monitoring Components rather then Services. If your system checks thousands of hosts, chances are on some of them something is broken. Broken disk maybe? MySQL Slave that is causing high loads because a batch Job is running some statistics? Apache that is running low on Childs?

But really, does it matter? As long as the Service is up and running and performing? Do we need to monitor every little cog in our infrastructure if there is a way to do “Top Down” Monitoring?

I certainly don’t enjoy being woken in the middle of the night by Monitoring that tells me that a Database is chocking somewhere.

And now?

cucumber-nagios seems like the only project touching on that Subject.

As PHP is my language of choice, and I’m not quite convinced that learning Ruby is going to make me a happier person, I’ll stick to that.

Behat is Cucumber for PHP, installation is done quickly:

pear channel-discover
pear channel-discover

pear install behat/gherkin
pear install behat/behat

(Remind me to build a Chef Cookbook for this.)

Time to explore…

Bliss Demo

I’ve setup a little Bliss Demo Installation for you to look at here

It Only pulls my own feed, and added feeds will get wiped on each update.

rssReader is now Bliss


Time to revive an ancient project: rssReader

It’s been a while since i last worked on my own little Feed Reader project (7 Years).


I’ve recently started using Google Reader as i got myself a fancy Android Phone with a data flat rate, and i didn’t get TT-RSS running properly on it (probably totally my fault).

The only thing i didn’t want on Google Reader were all my authenticated and NSFW feeds, i needed something different for those.

I remembered that i had this little project way back when, and decided to have a look at it. Unfortunetly it has grown quite old. Still based on PHP4, not very web2.0’ish, and generally not really pretty to look at.

So i just rebuilt the thing from Scratch.

The only thing it has in common with the old version is that it uses Smarty as Template engine. I commited the old thing, if you want to have a good laugh.


First: May I suggest you try TT-RSS. Or if you don’t care much about privacy: Google Reader is quite awesome. It’s even more Awesome with this extension installed.

If you still want to have a look, you can get it on Github. Installation should be very straight forward.

The only advantage it has over TT-RSS, is that it doesn’t need a database whatsoever (It’s also somewhat easier to configure, but with the difference in features that’s not much of a surprise)

It has plenty of disadvantages though.

First Post via Posterous

So, how do you build an interface to post content for your selfmade Blog app if you actually don’t really want to?

Easy: You don’t!

I’ve been looking around for inspirations on how to build a interface to put posts on my selfmade website. Thing is though: Input validation is tedious and error prone. Even if i am the only person who will ever use this interface, i’ll still manage to trick myself. Encodings, Character Sets, HTML Editing etc, then i’d like to post Images and Photos and other Media stuff. Building a frontend for that is a tedious task.

So, why bother?

Posterous to the rescue

While looking around i stumbled over tumblr and posterous both providing a blogger like service that:

  • Doesn’t run on Wordpress. I’ve grown old and tired of it.
  • Both have slick looking and quick interfaces.
  • Neither want to know when your mothers, best friends niece had it’s last teeth pulled while signing up.
  • Both allow posting Markdown content via Email, and they both obviously have rich text editors to edit your posts afterwards.

What Posterous also has is the ability to distribute content to various other sites.

That and Posterous didn’t present the site in german to me unlike Tumblr. I know german, sure, but i don’t want to. My browser says “Give me English Please”, so why send me a german page? I absolutely HATE it when sites do that.

My Content is Mine

Posterous has a simple, yet usefull API that allows me to get my Content back and put it on my site. It also has a comments API where i can feed the comments from posterous back into my database. That way everything i create is under my control, and i can do with it as i see fit. If for some reason the site starts to bother me, i can just delete my account. I will keep my content.

Punch line is: I can use Posterous wonderful interface and features to produce and distribute content, and then just pull it back into my Site.

Here’s the Code to it. It lacks importing comments, but that’s not that urgent.

Triggering the importer

Once posted, Posterous sends a mail back to confirm that something went live. Why thank you, I can use that!

A little procmail action:

 * ^From: .**
     :0 c # Trigger an Update
     ! USER=cbeerta PASSWORD=thoughshallnotknow php index.php --import-posterous

     :0 # and store it (for now)

And the post will be added to my page immediatly. Nifty.

Upgrading Wordpress through Subversion diffs

Upgrading Wordpress through the supplied ZIP files on their website has been a constant annoyance to me. But there is an easier way through the Public Subversion Repository from Wordpress:

  1. Pull a Diff between the Version you have locally installed and the latest:
    # svn diff > wordpress.patch
    In this case my installed version is 2.8.3 and i want to upgrade to 2.8.4
  2. Apply the patch to your installation:
    # cd <wordpress directory>
    # cat ~/wordpress.patch | patch -p0

This will unfortunetly only work for code changes though, should there be changes to binary files like Images, you will have to manually pull those from the new release and add them.

Reading other people's Code

I don’t know if i just suck at understanding other people’s (php mostly) code, but i frequently find myself slapping my forehead while reading code other people produce. I don’t say i’m a lot better at it, and i know that, that”s why i would never ever put my crap code online for other people to use and work with.

I”m on the search for a Wiki Software (more a Wiki Class) that i can use to start writing something that is in my head, and i don’t currently want to write my own Wiki just for that. (I wonder how long i can withstand that urge though). While going through the numerous PHP Wiki’s that are available, i’m getting more and more frustrated.

Just an example of what i feel is just bad:


Please don't do that, it will drive poor Admin's insane trying to figure out why the settings in your precious php.ini don't seem to work. (Especially enabling display_errors inside the code somewhere is just a no-go, and who knows what the software does if i forbid ini_set in my php setup)

Having a full page of require's, that point to 5 line classes is bad. Having everything just in one single file is not the way to go either, and having 50 lines of Documentation for an absolutely obvious function that is exactly one(!) single line of code, against having not a single line of comments for a 50+ line function is just silly. Either document properly, or don''t document at all!

Writing entire functions in a single line that even grows out of my editor window (which is 200 chars wide) is bad. Having 10+ functions of those beneath each other makes me sad.

After opening another php file, and seeing this:

foreach($_GET as $key => $value){if(in_array($key,$export_vars)){$$key = $value;}}
foreach($_POST as $key => $value){if(in_array($key,$export_vars)){$$key = $value;}}

i immediatly quit my editor and rm -rf the thing. You know Spaces don't cost extra money to use in Sourcecode.

    Yes, most of the formatting used in this file is HORRIBLY BAD STYLE. However,
    most of the action happens outside of this file, and I really wanted the code
    to look as small as what it does. Basically. Oh, I just suck. :)

At least they’re honest with that statement. AND OH BOY IS HE RIGHT! (rm -rf)


The ErfurtWiki engine is fully contained in one script file, but almost 200 feature enriching plugins and extensions modules are available.

Guys, THAT IS NOTHING TO BE PROUD OF! 130KB of Code! That's a whopping 4000 Lines! Aaargh!

I've got a headache now, and i still don't have anything that i can use. It''s not all bad though. Take a look at the source of coWiki. It is nicely structured, has _usefull_ comments in the code, and is beatifully indented. I think i will just use the Markdown class, and start writing code around that.


The quote

although I’ve since learned that the actual purpose of PHP isn’t dynamic websites so much as bringing the security levels of Linux boxes in line with Windows-led industry standards
(From: Brane Dump – The Thoughts of Matt Palmer) Sums up pretty well how i’ve been feeling about PHP alot lately.I know it’s not PHP’s fault, but rather the programmers, but it seems PHP attracts sloppy and unsecure coding. Time to take a look at Ruby.

Quest for silence

So, my Quest for silence in my “Office” is coming along nicely. My Server is now quietly running in the corner, my Linux Desktop got a new CPU Cooler, my Mac Mini is built by pro’s and completely silent. That leaves my Gaming Computer, but i tiink i can live with that one. (Yes, i do have to much Hardware)

Been reading a little on all the Ruby on Rails fuss that is going on at the moment. Looks nice, the installation on Debian was pretty easy. (Running lighttpd and Ruby on Rails and PHP via fastcgi. If anyone is interested in how to do it, drop me a line).

I’ll need some time to look into Ruby (After my tries in Python and C# i’m not too optimistic about that though, i’m too much of a PHP whore these days). Also been looking for something similar in PHP, but that wasn’t successfull so far.

Update: Found 3 PHP on Rails Projects so far that i should look into as an alternative to learning Ruby

Template Engines

Why people still avoid Template engines in their projects is a absolute mistery to me. I download some random PHP script/app, put it onto my webserver at home, and take a look at the source.

If i see a single print/echo line spewing out html, i’m always immediatly tempted to rm -rf the thing. I have no problem customizing a PHP script, but people need to keep content + code apart from each other. It is so much nicer to fire up your random HTML editor with the template and customize it, without worrying to break some random line of php code.


Ill today. Sucks to be at home, bound to my bed. The only good thing is, i was able to read some more in my new C# book, but i’m not too sure if anything stuck in my head. C# is a nice Language, but the book i currently own is a little to windows centric, time to find one that is more Mono Specific.
Firebird f.k.a Phoenix is now Firefox. That name sounds … weird, but i don’t really care much about the name, as long as the app itself is good, which it is of course.

Private CVS Server

You can browse my cvs server with some of my projects (This page, rssReader, etc) here. The CVS server is located on my dialup at home, so be nice to my bandwidth ;) Maybe there is some usefull stuff for you.

rssReader- New Version

Released version 0.0.4 of rssReader, which adds support for opml (Thanks to Fabian), and a rss output template. (Just call rssReader.php?template=rss and you will get a rss feed out of it.) Have fun.

rssReader 0.0.3

Uploaded a new version of rssReader, wich fixes some trouble with a couple of feeds. I Have not yet had any major problems with the tool. Grab it in the code section of my page.


Inspired by Planet Gnome i build rssReader.

A smallish PHP application which is capable of fetching a load of RSS/RDF feeds and display them in one singe page ordered by Date. Look at my Code page.

The thing is not entirely done yet, but worked on the feeds i read frequently. Patches, Requests and Comments more than welcome.

Useable release of phpDropShadow

So, here it is , a version of phpDropShadow that works, as you can see on my desktops/themes page (those screenshots are reworked with the script). Grab it from the Projects page. You’ll need the GD2 lib compiled into your PHP.

Drop Shadows with php

So, i’ve spent the last couple of hours trying to get some nice dropshadows under my images. Look on my projects page for a download. You can see the resulting image on my webcam. Unfortunetly this script does not run on the Computer my webpage ist hosted on darn, looks like i’ll be debugging the PHP running on this beast tomorrow … uhm … today :))