more info

Media72 Hosting Articles and Tips

Archive for the 'Technical' Category

Javascript auto include rails plugin

Tuesday, May 13th, 2008
This plugin has been updated to include additional functionality. We are very pleased to announce the javascript_auto_include plugin for ruby on rails written by our very own Jamie Dyer. This plugin automatically includes javascript code that is specific to a single view or controller which means you don't have to pass anything to your template telling it which javascript files are needed for each page. Working with unobtrusive javascript in Rails can be somewhat difficult. While Rails default javascript helpers are easy to use they produce javascript that is not unobtrusive. When writing unobtrusive javascript in Rails it's often necessary to include a javascript file that will be used by a single view or controller. This can become problematic, messy and very un-Rails like if not managed well. With the Rails philosophy "convention over configuration" in mind I decided to create a plugin to automatically including javascript files that correspond to the view or controller name mirroring the view structure within the javascripts folder. The javascript_auto_include plugin is born and is probably among the smallest Rails plugins available, aren't all the best plugins tiny? To use the javascript_auto_include firstly install the plugin:

script/plugin install http://kernowsoul.com/svn/plugins/javascript_auto_include
Or if you run EDGE rails or rails 2.1 and above:

script/plugin install git://github.com/kernow/javascript_auto_include.git
The plugin will create the directory "views" within your javascripts directory in which you can place javascript files for auto inclusion. Using javascript_auto_include is simple, in the layout file add < %= javascript_auto_include_tags %> to the header. There are two types of javascript includes, view specific, and controller specific. The first is achieved by creating a folder with the same name as a controller, inside this create a javascript file with the same name as a view. The second type, controller specific, are simply files inside the views folder with the same name as the controller. For example:

/public
  /javascripts
    /views
      articles.js # will be included in all views of the articles controller
      /users
        new.js # will be included in the new view of the users controller
The plugin will also include both controller and view specific javascript at the same time, in this example both users.js and new.js will be included when the new view is loaded.

/public
  /javascripts
    /views
      users.js
      /users
        new.js
If you have any comments or suggestions for improvements we would love to hear them. I may add a generator to make adding new javascript files easy.

Getting Real with Ruby on Rails and OS X Leopard

Monday, October 29th, 2007
So Apples new operating system comes with Ruby and Rails pre-installed along with a few standard gems. It does however lack a few things you may need to get your computer running as a development machine. In this mini tutorial we are going to cover: Updating to the latest version of Rails Installing MacPorts Installing ImageMagick Installing the Rmagik gem Installing MySQL Installing the MySQL gem Firstly lets upgrade rails to the latest version of rails, open up a terminal window and enter: sudo gem update rails --include-dependencies Next MacPorts is a package manager for OS X and is needed to install ImageMagick, you can skip straight to the MySQL install if you do not need to manipulate images. I'm not going to explain how to install this as there is excellent instructions on the MacPorts Wiki, be sure to download MacPorts-1.5.0-10.5.dmg for Leopard. After installing MacPorts we can get on with installing the rest of our software, fire up a terminal window and enter the following commands (enter your admin user password when requested): sudo port install tiff -macosx sudo port install ImageMagick sudo gem install rmagick These commands, especially installing ImageMagick, will take some time so it would be a good time to take a break. If all goes well you should now have ImageMagick and the Rmagick gem installed. To install MySQL download the MySQL package labeled 10.4 for your architecture. Then run the mysql-5.0.45-osx10.4-architecture.pkg installer package. Next run the MySQL.prefpane file to install the preference pane. At the current time the MySQL preference pane does not work without modification on Leopard so in the terminal enter: sudo chmod -R 777 /usr/local/mysql/data This gives everyone read/write/execute access to your MySQL data files, this is NOT recommend for anything other than a local development environment and is only intended as a quick fix until MySQL release and updated version for Leopard. Finally, all we need to do now is install the MySQL gem: For intel computers sudo -s ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-dir=/usr/local/mysql For PPC computers sudo -s ARCHFLAGS="-arch ppc" gem install mysql -- --with-mysql-dir=/usr/local/mysql When asked which version choose the most recent ruby version. If you have any issues getting the MySQL gem to install or run see this Mac OS Forge page. You should now have a fully working Ruby on Rails development installation Rmagick and MySQL.

Ruby on Rails 1.2 released!

Sunday, January 21st, 2007

Late last week the long awaited Ruby on Rails 1.2 was released including a whole host of new features. David's blog post talks about the new release.

And the best part? We hate to keep our customers waiting, so, we have already installed Ruby on Rails 1.2 on all of our servers and its available for use today. Just days after its release you will be able to use the new features on your Media72 hosting account.

A word of warning! Ruby on Rails 1.2 is a brand new major release and as such may still contain bugs. You should take this into consideration before deploying a 1.2 rails application. Also, if you are upgrading an application make sure to read the change notes for details on what's changed and possible incompatibilities.

Better Spam Detection

Thursday, December 28th, 2006

We have been trailing some new spam detection settings that should offer better spam detection for everyone. These new settings are going to rolled out over the next few days.

As a result you should see less spam emails being missed by our filters. Our trials improved spam detection significantly with no increase in non-spam emails being falsely marked as spam. It's our belated christmas gift to you!

Happy New Year everyone!

The Topian - Building a web application

Wednesday, October 25th, 2006
We are currently working on a web application with Chris Garrett Media. We can't tell you what it does yet, or even what it's called. What we can tell you is how we are going to build it over at The Topian. Our plan is to post about as much of the applications planning, development, marketing, and design as we can.

OpenDNS

Tuesday, October 3rd, 2006

We have recently discovered OpenDNS, a company offering free a DNS service with some very useful added features.

This service reports to being faster (that we have yet to confirm) that most other DNS services, but this is not the real gem of this service. It will attempt to block phishing scams by filtering websites involved in phishing operations using some pretty advanced methods. It will also try to correct typos in domain names.

OpenDNS is really easy to setup in just a few minutes, the site includes instructions for most network setups. We have been using OpenDNS for the last few days and have been impressed so fat

Smarty Template Engine Support

Sunday, September 3rd, 2006

Due to popular demand we have added Smarty Template Engine support to our servers. Smarty is a popular template engine written in PHP which allows you to easily separate code logic from presentation.

How to use Smarty

Using Smarty on our servers is easy. Firstly you need to FTP into your account and create some folders located outside of your website root. First make a folder called "smarty" in your user folder, inside of this create the following folders:

templates
templates_c
cache
configs

Once you have created your folders you will need to change the permissions on the "templates_c" and "cache" folders to 775 so they are writable, you should be bale to do this using your FTP client. You are now ready to start using smarty, create an index.php file with the following code and upload it to your public_html folder, make sure to replace "username" with your actual username.

<?php

require('Smarty/Smarty.class.php');
$smarty = new Smarty();

$smarty->template_dir = '/home2/username/smarty/templates';
$smarty->compile_dir = '/home2/username/smarty/templates_c';
$smarty->cache_dir = '/home2/username/smarty/cache';
$smarty->config_dir = '/home2/username/smarty/configs';

$smarty->assign('name', 'Ned');
$smarty->display('index.tpl');

?>

Now open up your browser and point it to your website address, you should now see the text "Hello, Ned!". Thats it, you now have Smarty setup and are ready to go. For more information on using Smarty we suggest starting with the Smarty Crash Course article.

Let’s Make Our Lives a Little More Secure

Friday, August 4th, 2006

We all like to feel secure, it makes us feel all warm inside. At Media72 we like to make you feel all warm and fuzzy, that's why we provide secure connections for control panel, email and data connections. Why should you use secure connections? Quite simply, if you don't, unscrupulous characters on the internet could grab your password or any information contained within the files you transmit. That means any text within an email or a file you upload or download.

In this article we show you how to secure all of your connections so that everything you transmit to and from our servers is encrypted and secure. You should be able to connect securely with any host, if you can't find details on how to do this with your host you should contact them and ask them to provide you with connection details. If you don't know the difference between POP and IMAP or why you should use one method over the other take a look at our "Which Mail Connection Method Should I Use?" article before reading on. After secure email connections we go on to cover Secure FTP to finish things off.

Secure Email Connections

Most modern desktop email applications have the ability to connect securely to an email server. We will cover the setup of Outlook Express, Thunderbird, and Apple Mail, if you use another application to view your emails you should still be able to use this guide, although the option names may be slightly different. In this article we will assume you have already setup your email account and want to change the settings to use a secure connection. Select your email client:

Outlook Express:

Step 1 (POP): To setup Outlook Express to use secure connections with POP select "Tools > Accounts..." from the menu then select the "Mail" tab. From here highlight the account you want to edit and click the "Properties" button, under the "Servers" tab change "Incoming mail (POP3)" and "Outgoing mail (SMTP)" to the name of the server you are on, in this case bingo.media72.co.uk (see fig. 1).

Outlook Express Pop Settings

fig. 1

Step 2 (POP): Select the "Advanced" tab and check "This server requires a secure connection (SSL)" under both "Outgoing mail (SMTP)" and "Incoming mail (POP3)". Make use that the "Outgoing mail (SMTP)" port is 465 and the "Incoming mail (POP3)" port is 995 (see fig. 2). Click "OK" then "Close".

Outlook Express Pop 02

fig. 2

Step 1 (IMAP): To setup Outlook Express to use secure connections with IMAP select "Tools > Accounts..." from the menu then select the "Mail" tab. From here highlight the account you want to edit and click the "Properties" button, under the "Servers" tab change "Incoming mail (IMAP)" and "Outgoing mail (SMTP)" to the name of the server you are on, in this case bingo.media72.co.uk (see fig. 3).

Outlook Express Imap 01

fig. 3

Step 2 (IMAP): Select the "Advanced" tab and check "This server requires a secure connection (SSL)" under both "Outgoing mail (SMTP)" and "Incoming mail (IMAP)". Make use that the "Outgoing mail (SMTP)" port is 465 and the "Incoming mail (IMAP)" port is 993 (see fig. 4). Click "OK" then "Close".

Outlook Express Imap 02

fig. 4

Thunderbird:

Step 1 (POP): To setup Thunderbird to use secure connections with POP select "Tools > Account Settings..." from the menu. Choose "Server Settings" under the account you want to edit from the list on the left. Change the "Server Name" to the name of the server you are on, in this case bingo.media72.co.uk. Under "Security Settings" check the "SSL" option and make sure the port is set to 995 (see fig. 5).

Thunderbird Pop 01

fig. 5

Step 1 (IMAP): To setup Thunderbird to use secure connections with IMAP select "Tools > Account Settings..." from the menu. Choose "Server Settings" under the account you want to edit from the list on the left. Change the "Server Name" to the name of the server you are on, in this case bingo.media72.co.uk. Under "Security Settings" check the "SSL" option and make sure the port is set to 993 (see fig. 6).

Thunderbird Imap 01

fig. 6

Step 2 (SMTP): Select the "Outgoing Server (SMTP)" option from the list on the left, it's at the bottom of the list. Select the account you want to edit and click "Edit...". Change the "Server Name" to the server used in step 1, make sure the "Use name and password" box is checked. Under "Use secure connection" check the "SSL" option and make sure the port is 465 (see fig. 7).

Thunderbird Smtp 01

fig. 7

Apple Mail:

Step 1 (POP & IMAP): To setup Apple Mail to use secure connections with POP and IMAP click "Mail > Preferences > Accounts", from the account list on the left select your account, under the "Account Information" tab change the "Incoming Mail Server" to the server your account is on, in this case bingo.media72.co.uk (see fig. 8). If you use your own domain for this option you will receive a security popup every time you connect.

Apple Mail Pop 01

fig. 8

Step 2 (POP): Next click the "Advanced" tab, here make sure the "Use SSL" box is checked, the port should change to 995, if not change this manually yourself (see fig. 9). Make sure "Authentication" is set to "Password".

Apple Mail Pop 02

fig. 9

Step 2 (IMAP): Select the "Advanced" tab and check the "Use SSL" box, this should change the port to 993, if not change this manually yourself (fig. 10). Make sure "Authentication" is set to "Password".

Apple Mail Imap 02

fig. 10

Step 3 (SMTP): Under the "Account Information" tab make sure the "Outgoing Mail Server (SMTP)" option is set to your media72 account and click the "Server Settings..." button. Change the "Outgoing Mail Server" to your server, in this case bingo.media72.co.uk, then check the "Use Secure Sockets Layer (SSL)" box and make sure the port is 465. "Authentication" should be set to "Password" and your account username and password should be entered into the fields below (fig. 11).

Apple Mail Smtp 01

fig. 11

Thats it, now just test your connection be sending and receiving mail, if everything works you are now using secure connections for your emails.

Secure FTP

Secure FTP is just as important as secure email connections. Files containing password in plain text are often uploaded via FTP. Using secure FTP connections is as simple as selecting the TLS/SSL, or secure SFTP option (SFTP will only work for accounts with shell access enabled) in your file transfer application. The following is a list of applications that support secure connections

After following this guide all of your communications with your website should be secure and encrypted. Now you can feel safe and secure knowing that no one can grab your data as its being transfered to and from the server.

 

hedges