Posts

Showing posts from February, 2014

Tips on Creating PDF using mPDF PHP library

In this post I will describe several ways to format HTML documents that will be converted into PDF file using mPDF PHP library. 1. Change Page Orientation Use CSS3 page and sheet-size attribute to change page orientation.  <style type="text/css">     .landscape {         page: a4landscape;     }     .portrait {         page: a4portrait;     }     @page a4portrait {         sheet-size: A4;     }     @page a4landscape {         sheet-size: A4-L;     } </style> <div class="landscape"> Portrait page </div> <div class="landscape"> Landscape page </div>  2. Change page margins To change page margins, you need to give additional parameter to mPDF's constructors. The page margins are in milimeters. Note the example uses Yii pdf extension instead of calling mPDF directly.                 $mPDF1 = Yii::app()->ePdf->mpdf('', 'A4',0,'',5,5); 3. Fit a table into one p

Export and Importing data using Oracle 11

Background In the era of oracle 9-10, I usually does export and imports data using exp and imp utility. Using oracle 11g, things aren't as smooth as it used to be. Problem A - Exp doesn't export empty tables Exp no longer exports empty tables. The cause are, exp utility is processing data segments, creating export dump. The Oracle 11g has a new feature, called 'Deferred segment creation'. It means that tables with no data will occupy no segments. And these tables will be missing from the exp result. The symptom of this problem is simple, we have missing tables in the destination system whose row count in the source system are zero. Solution A-1 - Allocate segment for empty tables Alter table allocate extent; This is not so ideal, we must execute the SQL above for each empty table before doing exp command. Solution A-2 - Disable deferred segment creation Alter system set DEFERRED_SEGMENT_CREATION=FALSE; This need to be done before we even cre

Database connection pooling problems

We have some problems running Oracle and ASP.NET application in different network segments. Similar to Garreth Hooper's problem in his blog , we encountered a ORA-12571 TNS: packet writer failure during period of server inactivity. This all came from the best practice of connection pooling, which in my opinion a complex matter. The Original Problems In one side, we have application servers, hosting applications written either in ASP.NET, Java, or PHP, and on the other side we have database servers. The first problem is, opening a connection from application to db server takes time, even though this is not a certainity (a lot of factors came into play, such as database server configuration, firewall setup, etc), this fact seems to encourage application developers to introduce connection pooling system to the architecture.  The second problem comes from the fact that a connection open is a session open in the database server, and it almost always takes precious resources, so

How to compile using Visual Web Developer Express in lieu of Visual Studio Professional

When we build an ASP.NET application, usually we used Visual Studio Professional. But when we have several members of the team that want to write some code, it would be beneficial to be able to develop using free software only. That means less hassle with licenses. Missing features of the free Microsoft Visual Web Developer Express were : - No Crystal Reports designer - No plugins - means Oracle Developer Tools for Visual Studio will not be available - Unable to connect using ODP.NET in the Database Explorer - No Microsoft Report Viewer control When some of the components above were referenced in ASP.NET project, opening the project file results in missing (yellow exclamation mark) references. To fulfill those referential dependency, there are some runtime software that should be installed : - SAP Crystal Reports runtime engine, see this SAP download page . - Microsoft Report Viewer Redistributable package, see this Microsoft download page . Of course the report design tools

CORS - Cross Origin Resource Sharing using CouchDB

Recently I tried to build a simple application which creates simple math questions, and records the time taken by the student to finish one page of questions. The short story is that I finally succeeded in implementing the question generation by using Javascript without any server side programming. But what about recording the time taken? We need some database in some server for that. I want to use a database, but I don't want to  code server-side. So I guess CouchDB is a good choice, given that it supports REST-based API and all. It turned out that calling HTTP REST service from  the browser is much more complicated than calling the same service from the server. To make a long story short, here is what I found : Javascript running in a page in a web browser are not allowed to call urls outside the domain of the page.  Except, when the server serving the URL specifically allowed this by giving Cross Origin Resource Sharing header. Credentials passing is doubly difficult, bec