29 Oct 2010 Ferado

Cloud Servers & iptables

When working with Rackspace Cloud Servers you’re given a vanilla box with nothing on it. This is known to anyone with experience using Rackspace’s Cloud Servers.Which means, when you create a cloud server that hasn’t been spun from your default cloud image, you need to setup a few things. You need to install Apache, MySQL, PHP, etc. All of this depending on how you’re going to use your cloud server. In this article, I’ll be talking to Linux servers instead of Windows (for Windows, contact me).

One thing that many people forget to do is open up the firewall and then finally, save the firewall settings.


The most basic thing you need to do is open up port 80 (the WWW port):

[cc lang=”ini”]
iptables -I INPUT 1 -p tcp –dport 80 -j ACCEPT

For those using SSL, you’ll need to open up port 443:

[cc lang=”ini”]
iptables -I INPUT 1 -p tcp –dport 443 -j ACCEPT

Finally, when you’re done making all your iptable changes, be sure to SAVE what you’ve done:

CentOS and Fedora

[cc lang=”ini”]
/etc/init.d/iptables save
# as ROOT
# service iptables save


[cc lang=”ini”]
iptables-save > /etc/iptables.rules

All other Distros

[cc lang=”ini”]
iptables-save > /etc/sysconfig/iptables


Remember, with Rackspace Cloud Servers, you need to install all your software because you’re given by default, an empty server. After you’ve installed all your software, you need to open up your firewall ports (using iptables) and then finally, save what you’ve done.

28 Oct 2010 Ferado

How to be a good web developer

I recently added live chat to my site in hopes of helping my readers and picking up more business. Adding live chat is easy when you use a service. I’m using Olark. They offer different plans, depending on your budget; I’m using their free version.

When implementing the code, I had a few different, easy to implement, options:

  1. Copy and paste the code, as is, without change (most slackers do it this way).
  2. Put the code in a theme function with a descriptive function name using the wp_footer hook.
  3. Put the code in a plugin, existing or new, using the wp_footer hook.

I’m sure the quickest and easiest way would have been to use option #1. It’s easy to implement and it takes 2 seconds. Right? Well, here’s my problem with that approach. You have ugly, loose code in your theme. That right there should scare you away from that approach; however, your average developer will do it this way. It’s sad, really. What you need to understand is that being a good developer does not necessarily imply that you’re the fastest. Remember the story about the tortoise and the hare? This approach is horrible. Having un-organized code just laying around is bad. What happens when you need to make changes? What happens when you forget what the hell that code is? Forgive my cursing, sometimes I forget where I am.

The second approach is better; however, what happens down the line when you need to change the theme and you want to keep live chat on your site? You’d have to move the code over to the new theme.

My approach, #3 from the preceding list, is better and only takes a few moments to think about what you’re doing before doing it. What I’m suggesting here is creating a new plug-in or using an existing one that matches what you’re trying to do. In my situation I had to create a new plug-in named “Barton Enterprises” because of the new company I’m forming. I’ll be putting my live chat code on many sites. Therefore it makes sense to put it in a plug-in like this. Even if I wasn’t putting this code on multiple sites, it still makes sense to put the code in a plug-in for reuse. This is EXACTLY what your teacher in school would have told you. Unfortunately, in the business world, I’m one of the few people to do it the proper way.

The code using the wp_footer hook

[cc lang=”php”]

//… preceding code

add_action(‘wp_footer’, ‘bartonenterprises_livechat’);
function bartonenterprises_livechat() {
echo ‘…code…’;

// … other code


Moral of the Story

What I’m trying to teach here is that it’s better to take a moment and think about future use cases before working on a project or developing anything. Lots of people out there are just there to knock things out and do things quickly (the first time) without thinking about future implications. Time and time again these people have to go back and fix their work.

I’m merely suggesting that you write your code to last. Is that too much to ask?

9 Jul 2010 Ferado

Drupal 6 Module: Status Messages Alter

In January 2010 I released Status Messages Alter, my first Drupal module released to the community. I’ve created many modules over the years, I finally had the time to give something back to my fellow Drupal enthusiasts. I’m very excited about this.

What does this module do?

The module provides developers with a new hook called hook_message_alter. This hook comes handy when you have annoying messages being displayed and you want to get rid of them, or if you want to have your own custom code fire off when specific messages occur. This is an api module and does not offer any kind of theming. You’re allowed to override that yourself. I’ll explain that later.

How do I install the module?

Simply place the module in your modules directory and enable the module. If you’re upgrading from a previous version, you may see a warning message. This warning message is there to notify you that you may have to check your other enabled modules that implement hook_message_alter for compatibility. This isn’t really going to be an issue because only a few people downloaded that first release :)


How do I use the module?

Normally when I create a Drupal site I dedicate a specific module for implementation specific code. That way I can create other modules that are reusable. Drupal makes this a great approach. I’m not your boss, so if you want to put this hook in whatever module you want, go for it.

Now, in your module you’re going to have a hook that will look similar to the following:

[cc lang=”php”]
function yourmodule_message_alter(&$messages) {
//TODO: your code here
// Example code:
$matches = $messages->contains(‘michael is awesome’);
// TODO: do something with it?
// you can even search specific types of messages
$matches = $messages->contains(‘happy’, ‘status’);
// or
$matches = $messages->contains(‘funky’, ‘error’);

The preceding code simply searches all of the status messages (warning, error, status, custom ones) for the phrase “michael is awesome.” Since I’m awesome and I wrote the code, I will see results :) After I get the results, I’m removing them. In the real world you would probably do something with the results. You’re a smart person, I’m sure you can come up with proper use cases.

Regular Expressions

Sometimes you need to do regular expression searches, here’s how to do it with the module:

[cc lang=”php”]
function yourmodule_message_alter(&$messages) {
// let’s do a simple regex search
$matches = $messages->match(‘/regex/’);
// let’s remove our matches
// now, let’s add something
$messages->add(t(‘No regex here!’));

Upcoming Features

As you can tell, this module has a lot of potential. I’m thinking of adding the following things:

  • Regular expression search
  • Find first occurrence
  • Find last occurrence
  • Triggers & Actions capabilities
  • A simple UI

Feel free to chime in and add whatever features you’d like to see. You can use my comment form below or use your Drupal login and submit a feature request through the official Drupal issue tracker.


I’ve told you about my new module and I’ve shown you how to use it. Furthermore, I’ve told you about some of my plans with the module. The only thing remaining in my mind is to let the people that stumbled onto my blog and found this page from Google know where to download the module. The link is as follows:



[source label=”Visit Project Page” href=”http://drupal.org/project/messages_alter”]

29 Jun 2010 Ferado

How to send files easily with Droopy!

There comes a time when you’re working with someone, or talking to a friend or family member on the phone, and something comes up and they want to send you a file. Now this isn’t just any old file, it’s a large file. A file that will be annoying to send via the inbox, and a file that may crash your instant messenger window.

Droopy to your rescue! Droopy is a mini Web server whose sole purpose is to let other people send files to your computer. People spend a lot of money on these types of things. Why? There’s a free one out there for you, and its name is Droopy :)

Of course, the downside is you’re going to need to know a little bit about computers to install it. Be happy, I’ll help you out for a small investment on your part. We can work out the details, use my contact form.

You may find and download Droopy by using the following button:

[source href=”http://stackp.online.fr/?p=28″]

1 Jun 2010 Ferado

The History of Hacking

History of Hacking

I came across a pretty cool image of the history of hacking from a site I like to read. I thought I’d share the image with you. It’s pretty neat. Hope you enjoy it.

[source href=”http://www.michaelbarton.name/wp-content/uploads/2010/06/history-of-hacking.jpg” label=”View Image”]

30 May 2010 Ferado

A handful of Social Monitoring Tools

Have you ever wanted to monitor your social media buzz? Maybe you have or maybe you haven’t, regardless, you’ve wanted to keep track of something, a search term, a product, etc. A great of way of doing that would be to use one of the following 5 social monitoring tools:

  • socialmention offers Real-time social media search and analysis
  • BlogPulse is a great tool to search blogs and current trends
  • Omgili is a forum search engine that lets you find communities, message boards, discussion threads about any topic
  • Google Alerts is a real-time/daily email alert tool that can be configured to track any search phrase using Google indexing
  • Twitter is very handy for tracking real-time buzz

There are more tools available if you search hard and long enough. If you’d like to have any others listerd here, just give me a shout! Thanks.

30 May 2010 Ferado

C# 4.0 & Optional Parameters

When writing a method in .NET (C# or VB), you typically have to overload that method if you want to provide default or optional parameters. Now, thanks to C# 4.0 and VB 10, you can use optional parameters.

For example, prior to C# 4.0, you had to do the following:

[cc lang=”c#”]
// Assume we’re using a class and the following stuff is from our class

// no parameters
public void myMethod()

// one parameter
public void myMethod(string str)

As you can see from the preceding code, you need to type more than one function. To each their own. Some people like doing this, some people don’t. I like how it works in PHP:

[cc lang=”php”]
function myFunc($optional=”hello world!”) {

Even better, Python let’s you do this:

[cc lang=”python”]
def myFunc(str1=”something”, str2=”something else”):
print str1, str2

# usage:
myFunc(str2=”Something new”)

# prints out
something Something new

In C# 4.0, you can do something similar to the way PHP does it, like so:

[cc lang=”c#”]
public void myMethod(int i = 1, double awesome = 3.0)


You’ve now just learned how in the new .NET (check this post’s date) allows you to use optional parameters to cut down on your code so that you don’t have to overload your methods anymore, unless you want to. You’re going to need this in your toolbox. Note, please use overloading when you need to. There might be a time when you need to overload in order to keep your code looking cleaner. The choice is yours. Use responsibly.