Serge's Technology View

Talk about Technologies, Software Architecture and Management

How to embed Google Docs document into your page

There are plenty of presentations, documents, and spreadsheets we may want to share with the world.

We can use homegrown document handling solutions, use commercial 3rd party solutions or… utilize power provided by Google Docs.

When storing articles on Google Docs you are provided with the option to share them with some people only or with everyone. I like to have option to link my articles from anywhere but I also like to have not just plain page, but a page embedded into my web-site pages.

What it means is that instead of external page, I want to put it in my own box.

There was time when it wasn’t as easy because of the additional code Google was injecting into articles, but time changed and now it is fairly easy and strait forward.

Goals

  • Embed Google Docs document into existing page
  • PHP. This is not really a requirement per se, it is just code below is PHP.
  • Retain copyright information

Solution

The following code snippet allows to get a desired result

// id parameter is used to pass Google Docs arcticle id
// Example: mydocview.php?id=nnnnnnnnnnnnnnnn

$id    = $_REQUEST['id'];
if ($id) {
  $started = "0";
  echo('<div class="googledocs" >Stored and managed via <a title="Learn more about Google Docs" href="http://docs.google.com" target="_blank">Google Docs &copy; -- Web word processing, presentations and spreadsheets.</a></div>');

  // Read document content, parse to normalize and output
  $file = fopen ("http://docs.google.com/View?id=" . $id, "r");
  while (!feof ($file)) {
    $line = fgets ($file, 4096);

    // Parse header info out
    if ($started == "0") {
      if (substr($line, 0, 5) == '<body') { $started = "1"; }
      else { continue; }
    }

    // Parse body content until document content block is detected
    if ($started == "1") {
      if (strstr($line, '<div id="doc-contents">')) { $started = "2"; }
      else { continue; }
    }

    // Output document content
    if ($started == "2") {
      // Stop processing, end of content reached
      if (strstr($line, '<div id="google-view-footer">')) { break; }

      // Normalize image links to keep link back to google docs
      $line = str_replace('src="File?id', 'src="http://docs.google.com/File?id', $line);

      // Normalize links to other articles
      $line = str_replace('href="View?docid=', 'href="/mydocview.php?id=', $line);
      $line = str_replace('href="View?id=', 'href="/mydocview.php?id=', $line);
      $line = str_replace('href="View?docID=', 'href="/mydocview.php?id=', $line);
      $line = str_replace('href="View?', 'href="/mydocview.php?', $line);

      // Output result
      echo($line);
    }
  }
  fclose($file);
}

Sample page:

<html>
<head></head>
<body>
<? // Include code above here
?>
</body>
</html>

Expiration of CrystalReport Viewer pages with long running queries

Wow! It worked…

I continue my journey with Crystal Reports Viewer (CRV) inside ASP.Net pages.
Topic of this post is to discuss problems and solutions related to long running queries in CRV.

Before continue I would like to thank Daniel Paulsen from SAP team for his help resolving the issue discussed below.

What are we talking about here?

As it usually happens at some point there is to much data/not optimal query/broken indexes/etc and it is takes significant time to return a result for CR report. As a result ASP.Net page with CRV start to throw errors, acts erratically, and overall strange.

Since we know that it is ASP.net and CRV uses page state and session information then we have usual suspects - session timeout and execution timeout.

Easy? Not so fast… Lets time our query – if it is more then 10 but less then 20 minutes then reason is not an ASP.Net timeout, but CR Engine timeouts.

Crystal Reports Engine Timeouts

Aside from timeouts imposed by .net infrastructure, there are two others which are introduced by Crystal Report itself.

Symptoms:

  • Error similar to ‘Request timed out because there has been no reply from the server in N ms’
  • First Page of the report is displayed but attempt to go to the next page gives JS error related to invalid object ID
  • If report require parameter entry, they are requested again

Cause:

Crystal Reports by default has a timeout of 10 minutes (600,000 ms) before deciding that no data is returned by the query.
Depend on how code behind is implemented for the report page, timeout error may cause different problems and be hidden.

Solution:

Per Daniel’s suggestion I have changed the following settings to a bigger number and it did solve the problem for me

HKEY_LOCAL_MACHINE\SOFTWARE\Business Objects\Suite 12.0\Report Application Server\Client SDK\CorbaAdapter\WaitReplyTimeout = 600000

and

HKEY_LOCAL_MACHINE\SOFTWARE\Business Objects\Suite 12.0\Report Application Server\InprocServer\EnterpriseRequestTimeout = 600000

Final Note:

There are other settings which are allowed to be set for the CR engine as described in Developer’s Guide for CR 2008 under “Configuring your Web.Config file“. It worth to know about some of them.

Is going Linux means replacing I with We?

There we go again… Marketing wars… Is being Linux means replacing I with We?

Accordingly to a new addition to the Mac-v-PC adv. war – Linux – “WE are Linux” – yes.

Personalization in the look at the computers promoted for last few years by Apple, Microsoft, and then followed by Dell and others with “personalize your computer” campaigns now suggested to be replaced with big “communitification“  a-la Linux.

What is a freedom? Ability to be you through the lens of the Big Brothers or ability to be you as part of the Open (Source) World of WE?

Is it a freedom when someone tells you that “you are free to be me”? Does Linux community need to go into war with others, even if it is just advertisements, to prove itself?

I did not like it when Apple said “you are the sad PC and I am the coolest Mac”…

   There you go…
 
Oh, a wrong one, but funny…  

Microsoft had managed not to mention Apple…

then   or now
 

What now? Now we have a new addition – a Linux’s freedom – The big “O”

Did it worth it? What is in it for Linux?

Honda Insight 2010 – test drive

I have wrote about Honda Insight 2010 coming this year on two occasions here: (1), (2).

And I have expressed some of my concerns already, but now I have actually had a chance to try it last weekend… And there are my thoughts and ramblings.

To say I do like my Honda (Accord) and I was looking to replace my Nissan (Altima) with a new car.

With prices on gas, on cars, new models and personal preferences, a new Honda Insight was my target.

I have tried this EX model and I am afraid that I would have to look elsewhere or enjoy my old car a little longer and there is why…

  • As I said before, 40/43mpg (48/45 mpg for Prius) is not an impressive statement from Honda for the comeback of the Insight. Not at all. Yes, driving in ECO mode and trying to stay in the “green” zone may help improve the mileage, but… There are some reports of 60+ on the highway, but I want to see it first and test-drive is probably not a good test for it and I do not want to turn everything off and drive at cruising speed just to get good mileage as reported here.
  • Car feels very fragile when it comes to driving and acceleration. I am somewhat aggressive driver and it was very hard for me to be “green” and accelerate at the same time. There goes mileage…
  • To be fair, on the cruise control, car stayed steady in the “green” zone.
  • In contrast to some reviews, it was fairly quiet inside a car in all driving conditions and engine noise does not stand out like for ex. in Ford cars I have driven in the past.
  • And engine kick-in was not affected much by the AC running at 20% of airflow power.
  • No mpg estimation while driving. I read somewhere that it is optional and only available in some models, but I think it should be standard to “prove the point”.
  • Small… very. Yes, after Accord and Altima, my expectations are a little bit high, but having 6′ one hits the celling sitting in the back and has claustrophobic feeling sitting in front. Plus foot space was on the verge of rejection/inability to fit.
    In addition it is not as wide as Accord and a rear view was a little bit “compressed”. Otherwise, with bigger side windows, it gives better view to the passing cars.
    Just to compare actual numbers, there is a table showing side-by-side Interior dimensions for Insight, Prius and Accord.
  • I did not like light gray interior plastic though, kind of cheap, but it is personal feeling off course.
  • I have driven in-city and on highway, and aside from the need to stay “green” car did provide enough power to stay in the crowd and not behind most of the time (yes, acceleration may be a problem :) )
  • Price probably could be cheaper all consider, but 20K is few thousands cheaper then Prius. Question remains if it covers the difference between two.

Bottom line: if you are tall person, this car may not be for you. Add to this unimpressive mileage and some “cheap” feeling of EX model and expectations are ruined. I have had higher expectations, and may be I shouldn’t. Will see if anything would change with next year model. I guess it is time to visit Toyota or wait for Chevy Volt.

Valid XHTML 1.0 Transitional  Valid CSS!