Ruby on Rails 3: The future of online web applications.

Posted: November 27, 2010 at 6:04 pm | (10) Comments

At the moment, PHP is undoubtedly the leading development language of online applications. It’s simplistic syntax and the prevalent amount of tutorials for it makes it a perfect starter language for online developers. The ability to include miniature chunks of code on any ordinary HTML web page makes getting started with PHP exceptionally easy.

However, there’s a new player on the block, Rails. With the recent release of Rails 3, building the next new killer application seems much easier and faster to accomplish. Rails 3 facilitates the development of online applications by providing developers with a powerful, scalable & expandable framework. Rails 3 has arguably introduced web developers with one of the finest object oriented programming languages.

There are a fair amount of powerful PHP frameworks that can be named. However, they all lack the powerful OOP features that Rails 3 provides. Models can be created as objects, then can be modified/saved into a database and destroyed at anytime. The powerful framework handles sessions, security, XSS, SQL injections and secures everything. However, the best part of this is the ActiveRecord ability to make optimized SQL queries without spending up all your time.

The workflow of creating a blog would be the following:

  1. Create a new Rails 3 application
  2. Create a post model (using a built-in simplistic scaffold application) with the following values
    • ID
    • Title
    • Content
  3. Create a comment model (same scaffold application) with the following values:
    • ID
    • Content ID
    • Related Post ID
  4. Use the automatically generated Post controller and write the following in it:
    1
    has_many comments
  5. Use the automatically generated Comment controller and write the following:
    1
    belongs_to post

There is much more to it, however, everything just makes sense. I strongly suggest taking a look at Rails for Zombies which is a simple introduction to Rails. Also, watching the Rails 3 screencasts won’t take more than a couple of minutes of your time but you will undoubtedly be interested.

Frankly, here’s a small comparison of a little query that gets the 5 latest comments for a blog, both in PHP and Rails. You be the judge.

PHP:

1
mysql_query(“SELECT * FROM comments WHERE id=1 LIMIT 5”);

Ruby:

1
comments = Comment.where(:id => 1).limit(5)

Also, if you have nested objects, you can obviously do the following with Ruby:

1
hard_drive = Client.where(:id => 50).computer.hard_drive

I don’t even want to start thinking of how complex and time consuming writing a query for the above code, where it’s all done and completed within minutes. I personally think that any advanced (or beginner) programmers should give it a shot. Nothing but advantages so far here, I’ve yet to run into a Rails issue. I’d love to hear others constructive output regarding this, I know I might sound a bit biased however I have been very impressed by Rails.

-DS

Servers, meet Ksplice. Ksplice, meet servers. Clients, forget about downtime.

Posted: November 6, 2010 at 10:56 am | (1) Comment

After a great deal of rigorous testing in our server development labs with countless hardware and software combinations, we are proud to finally bring a new solid cutting-edge technology for our clients, Ksplice.

Ksplice is one of the latest innovations in server technologies. It allows us to update and patch important security updates on our servers without rebooting the server, therefore, no downtime at all.

Ksplice uses some magic to update the kernel while it’s running by making modifications to parts of it that require updating and dynamically reloading them.

We hope that you see the service improvement and we look forward to introducing new features on our web hosting service. Also, be on the lookout, Rails 3 developers, we have some cool upcoming features.

PHP programming shortcuts: save time and lines of useless code.

Posted: August 12, 2010 at 5:14 pm | (23) Comments

Before I even started writing this, I am sure that the comments will be filled about how consolidating code makes it hard to understand, more braces makes it easier to read, etc. This is for those who think it’s better to have less code, such as yours truly. I like seeing less code; I find it more efficient and much better.

Short-hand mathematical operators
Those are known by most programmers however missed by a lot, the following can be shortened by it’s alternative next to it.

1
2
3
4
$int1 = $int1 + $int2;  -- or alternatively:  $int += $int2;
$int1 = $int1 - $int2;  -- or alternatively:  $int -= $int2;
$int1 = $int1 * $int2;  -- or alternatively:  $int *= $int2;
$int1 = $int1 / $int2;  -- or alternatively:  $int /= $int2;

Counters
Here is another very simple one, but good to know for those who don’t know about it.

1
2
$int = $int + 1; -- or alternatively: $int++;
$int = $int – 1; -- or alternatively: $int--;

Short-hand print statements
Ever find yourself have to write so much just to be able to echo a variable in HTML? No more!

1
<?php echo $string; ?> -- or alternatively,  <?=$string?>

Braces: you don’t always need them.
You don’t always need to use the braces in any if or while statement if it only containers one directive.

1
2
3
4
if ($x)
{
echo "is x";
}

Could just be

1
if ($x) echo "is x";

Ternary operator
My personal favorite, saves a lot of time and I still think it makes readable code

1
2
3
4
5
6
if ($type == 'human')
{
echo 'human';
} else {
echo 'robot';
}

Or why not..

1
echo ($type == 'human') ? 'human' : 'robot';

You can even set variables using that method

1
$type_of_person = ($type == 'human') ? 'human' : 'robot';

Verifying zero values not being false
Sometimes we deal with a function that can return a number and we want to make sure it returns a number, but if it returns 0, PHP will consider it as false.

1
if (getNumber()) { …. }

The number can return 0 and be as false, where as the following will not consider the integer 0 false

1
if (getNumber() !== false) { … }

Alternative control structure syntax
This is a great feature to do when you’re trying to do a lot of PHP work with HTML, it would be hard to list all of them but you can refer to it here: http://www.php.net/manual/en/control-structures.alternative-syntax.php.

Feel free to post any other ones in the comments section.. we all have that one trick we always use!

Green Web Hosting: Going the extra mile

Posted: June 13, 2010 at 12:01 pm | No Comments

There are plenty of hosts out there claiming to be green only by buying renewable energy credits and not by taking the correct measures of decreases their power usage. Sure, renewable energy credits sound like a smart idea of “fixing” what you have caused, however, the consequences of what has been created have already been done.

We think of green web hosting in a different matter. We believe that we can provide a great service and also truly and literally reduce our environmental impact, not just by getting credits. Inside our offices and our datacenter, we are constantly looking for ways of reducing power usage (the biggest issues when working with a lot of computers and servers!)

To start everything, electricity is provided to both our datacenters and offices from Hydro-Quebec. Hydro-Québec is a government-owned corporation that generates, transmits and distributes electricity in the entire province of Québec. With sixty hydroelectric stations, Hydro-Québec is the largest electricity generator in Canada and one of the world’s largest hydroelectric generating companies.
What this means is that all the power that we utilize is renewable hydroelectric energy that causes almost no pollution when being generated. However, we don’t just stop there, just because we get power from a renewable source doesn’t mean we can do whatever we’d like with it.

Inside our offices, we don’t use desktops anymore. On every desk, there is a Apple MacBook Pro installed with a 24” LED Cinema Screen. The amount of power that a laptop uses compared to a regular desktop is much less as well as it gives the ability for our representatives to grab their workstation anywhere they can go.

Instead of running Ethernet inside the entire office, we’ve opted for a 802.11N wireless network, they can reach speeds of up to 108Mbps and that’s more than needed for an office (no, we don’t use wireless networks on our servers ;]) therefore, less wiring, less mess and less environmental impact. Our telephone system is entirely VoIP and connected to each workstation, so there is no need for phones, we have softphones installed on every Macbook Pro.

However, most of our power savings come from our datacenters. Our datacenters are extremely well cooled therefore after experimenting with servers, we found that there is no increase in server temperature when setting the fan setting to “Acoustic”. The acoustic setting lowers fan speeds (and there are a lot of fans in a server!). Also, we have opted to use Intel’s SpeedStep technology that underclocks the CPU’s frequency when it’s idle, when there is load, it will clock it back to default speed to process with no performance difference. We have also made some experiments and we have seen a big decrease in power when using Intel’s LV (low voltage) series of CPUs, they have the same exact power however run at a lower voltage.

One of the biggest power saving methods we have is virutalization, we are a certified and authorized Citrix XenServer partner and using their virutalization services has permitted us to consolidate multiple physical servers to one or two virtualized physical servers for all of our internal services.

All this is done to lower energy costs to provide you a much affordable service and decrease our environmental impact. We hope you enjoyed reading this article and if you have any suggestions on how we can decrease power in our daily operations, feel free to do so! :)

How synonyms affect Google search results?

Posted: January 26, 2010 at 7:12 pm | No Comments

Google announced a big change in how to handle the search results via adding synonyms for words that can be used in search. This should affect the position of web pages in Google’s search results.

It is important that Google can deal with synonyms.
Google wants to show the best results for search. Because of that, it is vital that Google’s algorithm get to know the words which are used in the search. The best way to understand these words is to check the synonyms of them.

What are synonyms: They are words that have the same meaning, for example “pictures” and “photos”. People searching for “sunset pictures” are probably also interested in web pages that contain the words “sunset photos”. A problem is that words that can have different meanings. For example, the word “case” can mean “occurrence”, “instance” or “example”. It can also mean “box” or “container”. The word “guitar box” might be a synonym for “guitar case” but “O.J. Simpson box” is not a synonym for “O.J. Simpson case”. Google’s measurements show that synonyms affect 70 percent of user searches across the more than 100 languages Google supports.

The Changes Google made
Google’s official blog posted that they have improved the way that they detect synonyms. For example, the algorithm can now find 20 possible meanings of the search term “GM”.

GM can mean General Motors, George Mason in [gm university], gamemaster in [gm screen star wars], Gangadhar Meher in [gm college], general manager in [nba gm] and even gunners mate in [navy gm], etc.

Google also made a change to how the synonyms are displayed. The searched words and the synonyms are now displayed in bold in the search results. Web pages that contain only synonyms of the searched word can also be displayed in the search results.

Newer Entries »
« Older Entries

What our clients are saying — Read More →

When I found Vexxhost I was pleased because I had located a Canadian web hosting company that was priced competitively, and offered everything I needed. I didn't realize just how excellent it would turn out to be! I have watch in amazement as feature after user-friendly feature is added to my service, the control-panel interface keeps improving (and it was very very good to begin with), the service never slows down, and the price stays the same excellent rate. I have come to appreciate that Vexxhost is not just the best web hosting company in Canada, Vexxhost is quite likely the best web host in the world. I realize that sounds like hyperbole, but it's not - seriously, if you don't believe me, try it yourself. Thanks, guys!


Gabriel Abney
Awards — View More →

Technology Partners