Wednesday, May 23, 2012

How @font-face Works

The great news about CSS3 support of the @font-face selector, is that - unlike work-a-round techniques - it's easy to use. Yay! Fonts without hoops!
Just upload the font file you want to use to your server - making sure that you're not violating any copyright rules
In example here I am using font name Ubuntu. you can download this font from here
 - then embed it, using the following CSS:
Code:
 <html>
    <head>
        <title>
            Test font embeded
        </title>
    <style type="text/css">
            @font-face {
              font-family: yourFontName ;
              src: url( /ubuntu_title/Ubuntu-Title.ttf ) format("truetype");
            }
    
            /* Then use it like you would any other font */
            .yourFontName { font-family: yourFontName , verdana, helvetica, sans-serif;
            }
    </style>
    </head>
    <body>
        <h1 class="yourFontName">ubuntu title</h1>
    </body>
</html>

The CSS code above defines a font called "yourFontName". You may use the actual font name - or - for testing purposes a unique, made-up name. Whichever you use, all you need to do is reference it again in the CSS, wherever you want to use it.
That's it! Note: the CSS3 specification provides for several font formats: "truetype" (ttf), "opentype" (ttf,otf), "truetype-aat (ttf), "embedded-opentype" (eot) and "scalable-vector-graphic" (svg,svgz).

The result:
more references here


Tuesday, May 22, 2012

Connecting to a Remote Oracle Database with PHP


1, Download Oracle Instant Client package that match with Oracle Database version
    Example: http://www.oracle.com/technetwork/topics/winsoft-085727.html
2, Unzip file to directory C:\Program Files\Oracle Instant
3, Create a new file in that same directory named tnsnames.ora
     This is an important configuration file that allows you to create kind of a local reference to a remote Oracle database server. Paste the following into that new file:
YourServiceName =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = YourHost)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = YourServiceName)
    )
  )
4, Add Environment Variable to your system
-          User variable: variable name: Path , variable value:  C:\Program Files\Oracle Instant
-          System variable: add new variable name: TNS_ADMIN , variable value C:\Program Files\Oracle Instant
This environment variable ensures that PHP will be able to find your tnsnames.ora file when it tries to connect via oci_connect(), so it's important.
5, To get your PHP scripts talking to the remote Oracle server, you'll use the oci_connect() function. you'll need to enable support for the oci8 module. To do this, open up your php.ini file and uncomment (remove the leading semicolon from) the line that reads:
;extension=php_oci8.dll 
it might be possible to only restart Apache (or whatever web server you're running), so you might give that a shot first just to see if you're lucky.


Then try code connect
<?php
$db = "(DESCRIPTION=(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = YourHost)(PORT = 1521)))(CONNECT_DATA=(SID=ServiceName)))";$conn = oci_connect("UserName","Password",$db);

if ($conn) {
            echo "Connected<br>\n";
} else {
            echo "Connected fail<br>\n";
}

Note: if you still see the message Fatal error: Call to undefined function oci_connect()
Copy all files from directory Oracle Instant to directory apache/bin

Reference:
http://www.bernzilla.com/item.php?id=784

How to create Virtual Host in Apache













The term Virtual Host refers to the practice of running more than one web site (such as company1.example.com and company2.example.com) on a single machine. Virtual hosts can be "IP-based", meaning that you have a different IP address for every web site, or "name-based", meaning that you have multiple names running on each IP address. The fact that they are running on the same physical server is not apparent to the end user.
Apache was one of the first servers to support IP-based virtual hosts right out of the box. Versions 1.1 and later of Apache support both IP-based and name-based virtual hosts (vhosts). The latter variant of virtual hosts is sometimes also called host-based or non-IP virtual hosts.

You can configure in your Apache server step by step below:

1, Enable LoadModule rewrite_module modules/mod_rewrite in file httpd.conf in apache/apache_v_x/conf directory

2, Enable Virtual hosts
Remove # in this line Include conf/extra/httpd-vhosts.conf in file httpd.conf in apache/apache_v_x/conf directory

3, Add virtual host in httpd-vhosts.conf in apache/apache_v_x/conf/extra directory
Add following script

<VirtualHost *:80>
ServerAdmin webmaster@angkordigitalsolutions.localhost
DocumentRoot "C:\wamp\www\angkordigitalsolutions"
ServerName angkordigitalsolutions.localhost
#ServerAlias www.dummy-host.localhost
#ErrorLog "logs/dummy-host.localhost-error.log"
#CustomLog "logs/dummy-host.localhost-access.log" common
</VirtualHost>

4, Create host in C:\Windows\System32\drivers\etc
127.0.0.1 angkordigitalsolutions.localhost

Last, you need to restart your server

Related post: How to increase web app performance better