Posts

Showing posts with the label Web

Hadoop at Twitter (Hadoop Summit 2010)

View more presentations from Kevin Weil

Facebook Hadoop Summit

View more presentations from Shakeel Shrestha

How to avoid POSTDATA resend warning

POSTDATA resend warning is a common problem when developing web applications. Before discussing about the solution, let's know what is the problem actually and when it arises. About the problem : We see this warning when we try to revisit a page that has accepted POSTDATA using browser's history mechanism. Usually we do it by browser's BACK button or refreshing a page. When a page in browser history requested with POST method, the browser thinks this POSTDATA is important to process this page. So, it asks the user if he wants to send the POSTDATA again or not. Different browsers show this warning differently. For example, the images below shows how Firefox and Internet Explorer show this warning. POSTDATA resend warning in Mozilla Firefox POSTDATA resend warning in Internet Explorer Now, If the user accepts the confirmation, the page is reloaded with previously sent data using POST method; otherwise some browsers don't take any action and some shows a "Webp...

Multiple Worksheets, Borders, and Images

Few months back I was searching for the php code that creates excel file, which has got the content in multiple worksheet. I couldn't get any help from the net. Today just going through the PEAR Modules, I came across this script. This script generates excel file with multiple worksheets. <?php require_once 'Spreadsheet/Excel/Writer.php'; $workbook = new Spreadsheet_Excel_Writer(\"example4.xls\"); $worksheet =& $workbook->addWorksheet();\n $worksheet->writeNote(1, 0, \"Invoice For New Customer 1\"); $worksheet->setRow(0, 50); //$worksheet->insertBitmap(0, 0, \"logo.bmp\", 0, 0); $left =& $workbook->addFormat(array(\"Left\" => 2)); $right =& $workbook->addFormat(array(\"Right\" => 2)); $number =& $workbook->addFormat(array(\"NumFormat\" =>'$####.00')); $worksheet->write(1, 1, \"Client Name:Shakeel Shrestha\"); $worksheet->write(2, ...

Extracting Information Using XPath

PYou want to make sophisticated queries of your XML data without parsing the document node by node. Solution: Use XPath XPath is available in SimpleXML <?php $s=simple_load_file('address-book.xml'); $emails=$s->xpath('/address-book/person/email'); foreach($emails as $email){ //do something with $email } ?> And in DOM <?php $dom=new DOMDocument; $dom->load('address-book.xml'); $xpath=new DOMXPath($dom); $email=$xpath->query('/address-book/person/email'); foreach($emails as $email){ //do something with $email } ?> As your XML files become increasingly complex and your parsing desires grow, using XPath is easier than filtering the data inside a foreach. PHP has an XPath class that takes a DOM object as its constructor. You can then search the object and receive DOM nodes in reply. SimpleXML also supports XPath, and it's easier to use because it's integrated into the SimpleXML object. DOM supports XPath...

Currency Conversion With foxrate.org's XML-RPC API

Foxrate.org provides XML-RPC API to convert the currency from one to another. I needed it for a project to convert from Euro to Pound and vice-versa. I had once read about such a work in roshanbh.com.np so I finally thought to follow the same API. After searching for some days, I came up with some code but had some problem for which I couldn't get any help. At last our friend from college, Sanjeev, added last two lines of code to make it run. Thanks Sanjeev. <?php require_once('lib/xmlrpc.inc');//initialize client $xmlrpc_client=new xmlrpc_client('/rpc','www.foxrate.org',80); $xmlrpc_client->setDebug(3);//turn on debugging mode //construct the request (xml-rpc message) $xmlrpc_msg=new xmlrpcmsg('foxrate.currencyConvert', array(new xmlrpcval('USD','string'), new xmlrpcval('EUR','string'), new xmlrpcval(1,'double'))); //send the request $xmlrpc_resp=$xmlrpc_client->send($xmlrpc_msg); //working...