Archive for the ‘Howto’ Category

Installing, Configuring, and Using the XHP PHP Extension by Facebook

Authored by Calvin Freitas on February 10th, 2010

Facebook announced the release of XHP yesterday. It is an extension for PHP which provides enhancements to the PHP language syntax and gives the language some convenient capabilities.

In this post I will provide you links to the essential sources of information about XHP, show some XHP sample code, and discuss the installation process for XHP on Ubuntu with Apache and PHP5.

The Essential Information
Download XHP at GitHub
How XHP Works
Building XHP
Configuring XHP

Example XHP Sample Code (View Code in Action):

<?php
require_once('/home/cal/facebook-xhp-290b185/php-lib/init.php');
$name  = 'Calvin Freitas';
$title = "{$name} loves XHP!";
$url   = 'http://calvinf.com/';

$permalink = 'http://wp.me/pcoLC-4e';

#create a <head> element
$head =
  <head>
   <title>{$title}</title>
  </head>;

#create a div
$div =
  <div id="header">
    <h1>{$title}</h1>
  </div>;

$body =
  <body>
    {$div}
    <div>
      <p>My name is {$name} and you should go visit <a href={$url}>my website</a> now.</p>
      <p>Read my <a href={$permalink}>guide to installing XHP on Ubuntu</a>. It includes the source code for this page. Comments and corrections are welcome.</p>
    </div>
  </body>;

echo
<html>
  {$head}
  {$body}
</html>;
?>

A few syntax notes
XHP forces you to properly nest tags — make sure you close them properly or it won’t compile and it will throw errors. Because XHP auto-escapes, when you’re creating a link (such as in an a element), you don’t need to put quotes around it.

<a href={$permalink}>guide to installing XHP on Ubuntu</a>

Installing XHP on Ubuntu
Server: Ubuntu 9.10 running on a slice at the Rackspace Cloud.
Web server: Apache 2
Apache installation guide (Slicehost article, but generally applicable)

Below I will go into more detail about the installation process.
Read the rest of this entry »

HowTo: Make IE8 Display Your Website in IE7 Compatibility Mode

Authored by Calvin Freitas on March 16th, 2009

To make your website or web page look the same in Internet Explorer 8 as it does in Internet Explorer 7, include the following line in the <head> tag on your page.

<meta content="IE=EmulateIE7" http-equiv="X-UA-Compatible" />

This code tells IE8 to render the page in IE7 compatibility mode. That way you can just worry about making your site work in IE6 and IE7 and not trying to support three concurrent generations of the web browser.

Microsoft has more information about Compatibility View for IE8 on the IEBlog.

You can also tell IE8 to apply compatibility mode by setting the header in your web server. In Apache, you can do this by including the following line in your site config file (or apply it just to a specific directory or page if needed). Make sure you have the Headers module installed.

Header set X-UA-Compatible "IE=EmulateIE7"

More information is available in the Internet Explorer Compatibility Center.

(Thanks to @kevmoo (Kevin Moore) for initially answering my question about this topic.)

Wireless Audio w/ Airport Express and Airfoil for Windows or Mac

Authored by Calvin Freitas on March 9th, 2008

I recently acquired an Apple Airport Express (gracias a kamyn1) with the intent of wirelessly broadcasting music/audio from my computer (one side of the room) to my home stereo system (other side of the room) using the AirTunes functionality. This has been a good solution for me as it’s designed for iTunes and that’s what I primarily use to play music on my computer.

iTunes Preferences - AirTunesFirst, you need to install the Airport Express. This can be a difficult process depending on your level of experience with wireless networking; if you’re having trouble, visit the Apple Support page for the AirPort. To use the device, begin by running the installation software that comes with the device (or download it from Apple) on your computer. You will also need to connect the Airport Express to your stereo; for this, you can either use a 1/8″ to RCA connector or 1/8″ to Optical/Toslink connector and hook it to your stereo receiver or other audio input.

Read the rest of this entry »