2009 July | stratos.me


The VPS neighborhood

The past couple of days i’ve been bugged with an idea. I saw a new hosting company come around called “EcVPS”. They offer VPS plans for very low, and extremely affordable prices. I know that there has always been a gap between shared hosting, which is as low as $3/month, to the next step for a blog / site, the VPS hosting starting at $10-15/month. I know that many people decide to go on with it, and in my opinion they make a very good decision. But there are always people that are not comfortable administering their own boxes. Then they have two options, stick with shared or pay extra for managed hosting. Fortunately, nowadays, hosting is not expensive, even managed. But, still, jumping from $40 a year to, more or less, $120, is something that boggles.

(more…)

What’s an API for a web service?

You all must have heard of the term “API” but all of the non techy out there should have drowned in trying to understand what it is. First of all, a general definition of the term can be found on Wikipedia. But here i will concentrate on web services, as the mass of people out there know it. So what do Twitter, Technocrati, Google and the same mean when they say they have an “API” at the developers’ disposal? What is this magical term that enables many developers to deliver the product to the end user in a more pleasant way?

In order to grasp the idea more clearly i will focus on Twitter which, i believe, we have all used. You must know that there are various ways to check your timeline or tweet, through the official website or through the desktop applications (Tweetdeck, Seesmic etc) or other websites that are frontends to it (TwitterFeed, Hootsuit etc). But what’s the main difference? Well take a look at the diagram below.

(more…)

Efficient or non-efficient?

All of you out there that know me, know that i am an efficiency freak. Most of the times, when someone flashes a plugin to me, i stop and say “is that really necessary?” instead of “this looks cool!”. I know, it’s mostly annoying but you got to admit, i have a point. But, first things first. I will concentrate on WordPress, since, most of my readers are bloggers using the platform and many don’t really get why i nag all the time about performance and plugins. To give you a good taste of the complexity here is a small diagram.

wordpress

This actually is a rough representation of what’s going on when a client request on your blog is in progress. Let’s take it one step at a time:

  1. A client makes a request on your blog. This starts on the Apache level.
  2. Apache realizes that it’s a php script that has to be executed (index.php).
  3. Gives the PHP module the script as a parameter and kicks it off.
  4. Then, it’s WordPress’s time. It starts loading the core.
  5. On various steps of the process of rendering the requested page the plugins are loaded.
  6. Just like a special plugin, the theme of the site is loaded as well. WordPress decides if it needs to load single.php for instance (when rendering a single post) or index.php (when rendering the homepage) etc.
  7. Each time a plugin or a theme wants to make a query it uses the wpdb global variable. This actually channels the query through WordPress, which channels it to the PHP module, which channels it to the PHP MySQL module, which channels it to MySQL server, which runs the query and creates the result set, which is finally channeled back all the way to the plugin.

Do you see how painful it is to make a query? Now take that and multiply it by 50-60 which is the average query count on a WordPress blog (not the default installation but an established one). You can see now how your memory and CPU get clogged up when a few requests come along together.

(more…)

Search feature on static HTML sites – The smart way

You all must have stumbled on static HTML sites. Either you created them or you found them around. The purpose of those sites today is simplicity. Not everybody needs dynamic content and thus not everybody needs complex CMS’s with huge back end administration panel. So, what is more easy than putting together a few simple HTML pages. But what if you want to incorporate a search feature into that? Well, when a developer first thinks of search, the second thing that hits his mind is “database“. If you fall for that, then there goes simplicity and fast loading. You are already on a war path.

I’ve been challenged to that and here is what i came up with. I created a small PHP script that actually searches the HTML files! The simplicity in the thought is what makes me happy about this. You just get a search term, open the HTML files up, pattern match for it and then echo the results with links back to the original static files. So, you have a dynamic search feature with static content! And what’s even better is that if you make any changes in the HTML files, those will be reflected on your search just like it would happen using the classic database way.

I have created the script and included it with a small example here: Dynamic search for static HTML (2278) The only requirements to run this example is a web server with PHP installed. Here is how to check it out:

  • Download and extract the folder “search_test” into a place accessible from the web.
  • Hit the URL “http://place.of.folder/search_test/search.php?s=ipsum

As you can see, the above URL will search for “ipsum” in the .htm and .html files and show you the results. If you want to play a little bit with the parameters of the script you can open it and check the global variables on the top (recursive search, highlight etc).

One thing that could be improved is cached search. This would decrease the load on the server for each search. I can help you do it if you need to. I just didn’t go on with it because i didn’t want to over-complex my script.

As you can imagine, this is just the skeleton of the script. You should configure it to fit your needs. If you have any problems or need any help don’t hesitate to leave a comment or contact me!

EDIT: I forgot to mention that this will work for text that is wrapped around a “<p>” (paragraph) tag. In order to make it work with more or be more flexible, you will need to edit the regular expression at the “preg_match_all” call on the script.

The acrobatic balance of price and quality on freelancers

Most of you know that for quite some time now I’ve raised the “for hire” flag. As a freelancer I haven’t had much luck, except for a few jobs I’ve taken and for which i have to tell Kim a great thanks. She always puts a good word out for me and i am very, very grateful for this. I don’t want to sound wrong, I think that the problem is I haven’t pursued it as much, in terms of hooking my self up with social networks and the blogosphere in general. I am not complaining. I think though, that there is one more aspect on my failure.

A few years back, a very big source for a freelancer’s income were sites like Scriptlance, where people would just post projects they wanted done, then coders and designers would bid for that. The trend that I have noticed happening the last couple of years, on all of those sites, is mediocre coders bidding extremely low on projects. For instance, they would bid on a two day job as low as $20-$50. That price is not competable by any serious freelancer.

(more…)

« Previous Entries