Ubuntu set Static ip

Edit /etc/networking/interfaces with nano change eth0 from dhcp to static as show below ( remember to use your own net ip addresses.

auto eth0
iface eth0 inet static
        address 192.168.1.20
        netmask 255.255.255.0
        network 192.168.1.0
        broadcast 192.168.1.255
        gateway 192.168.1.1

If then Xslt Choose

If there is image/filename then use the first filename found, otherwise show image not found.

<xsl:choose>
    <xsl:when test="image/filename">
        <IMG>
            <xsl:attribute name="src">
                <xsl:value-of select="image/filename[1]" />
            </xsl:attribute>
        </IMG>
    </xsl:when>
    <xsl:otherwise>
        <IMG>
            <xsl:attribute name="src">
                <xsl:text>http://images.domain.com/NAN.gif</xsl:text>
            </xsl:attribute>
        </IMG>
    </xsl:otherwise>
</xsl:choose>

Currency Format Xslt

<div class="list_price">$<xsl:value-of select = "format-number(list_price,'#,###')" /></div>

RailsPlayground Mod_deflate Disabled on developer accounts

RailsPlayground Mod_deflate Disabled on developer accounts, can check which mods are enabled with

<?php
print_r(apache_get_modules());
?>

Rails Playground Add rails app into subdomain

Create your subdomain using your cpanel. For instance ‘staging’.

ssh into your account.

cd into your www directory

mv staging staging.back

now link your public directory from your new rails app to ‘staging’

ln -s /home/username/newapp/public /home/username/www/staging

make sure file and folder permissions are set staging should be 777.

Rails Playground kill fcgi process

From ssh ( you’ll need to ask for this to be enabled. )

pkill -9 dispatch.fcgi

Ignore the warning only your process will be killed.

Extract base64 encoded images from XML file

<?php
$this->xml = simplexml_load_file('images.xml');
 foreach ($this->xml->Listing->Picture as $picture) {
        $filename = $this->cleanBrackets($picture->PictureID) . ".jpg";
        //open file for writing
        $this->image_handle = fopen("xml/images/". $filename , "wb+") or die('error file write');
        $data = base64_decode(trim($picture->BinaryData));
        @fwrite($this->image_handle,$data);
        fclose($this->image_handle);
    } // end foreach
?>
   

Add ftp port 21 to iptables

iptables -A INPUT -p tcp -m tcp --dport 21 -j ACCEPT

Rails Eager Loading

Loading associated models together in far fewer queries using egar loading.

Each User has one state, Has many Properties each property Has many images, has many pdfs, has one state

>> u = User.find(120, :include => [:state,{:properties => [:images,:pdfs,:state]}])

Apache 2 Virtual Host Setup for Windows

Setting up Virtual Hosts with Apache 2.2 is a fairly painless process.

First I created a webroot folder to contain all the local sites.For each project i created a folder personal.blog.localhost. Inside this folder create a www folder.

Should look something like

C:\webroot\personal.blog.localhost\www

Then edit your hosts file, it can be found c:\windows\system32\drivers\etc\hosts

add a line for each of your projects

127.0.0.1 personal.blog.localhost
127.0.0.1 cakephp.localhost
127.0.0.1 codeigniter.localhost

and save the file.

Next modify your httpd.conf file in your Apache conf folder uncomment the line by removing the #

Include conf/extra/httpd-vhosts.conf

and save the file.

Open up the httpd-vhost.conf file found in the extra’s folder

and add a VirtualHost entry for each of your local sites.

<VirtualHost *:80>
 ServerName personal.blog.localhost
 DocumentRoot "c:/webroot/personal.blog.localhost/www"
 CustomLog logs/personal.blog.localhost.access.log combined
 ErrorLog logs/personal.blog.localhost.error.log
</VirutalHost>

Save the httpd-vhost.conf file, unzip your WordPress application into your www folder and restart Apache and browse http://personal.blog.localhost.