Showing posts with label scripts. Show all posts
Showing posts with label scripts. Show all posts

Monday, December 7, 2009

Internet Explorer Strikes Again

Just found out my Radar Chart Google Spreadsheet Gadget did not work on all popular browsers.  Guess which one?!

The error message was:
window.G_vmlCanvasManager is null or not an Object
I swear I had verified it working on Internet Explorer before.
I swear I had not made any change since.
and I swear...
and I swear...

Apparently, there was a problem loading excanvas.js (a javascript to enable HTML5 canvas for Internet Explorer).  As a result, window.G_vmlCanvasManager did not exist.

My original code was:
<content type="html"><![CDATA[
<!--[if IE]><script type="text/javascript" src="http://hosting.gmodules.com/ig/gadgets/file/115560173853763482292/excanvas.js"></script><![endif]-->
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
As it turns out, there needs to be something between <![CDATA[ and the conditional comment <!--[if IE]>... even if it is just a <p> or another <script> line.

So I changed the code to:
<Content type="html"><![CDATA[
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
<!--[if IE]><script type="text/javascript" src="http://hosting.gmodules.com/ig/gadgets/file/115560173853763482292/excanvas.js"></script><![endif]-->
The gadget is working once again.
 

Friday, March 13, 2009

Using rsync on Windows

I posted an article on an issue of SQL Memory Paged Out During Large File Copy last month, which documented my effort in finding a way to solve the issue. Yes, rsync (from Cygwin) is still our final choice.

Today I'm going to post some tips on using rsync on Windows.

To install rsync, run the Cygwin setup.exe installer and install rsync package. After that, I would recommend adding Cygwin's bin folder into your environment path. This way, you can call rsync directly from the command line.
  • Right click on My Computer. Choose Properties.
  • Click on Advanced tab.
  • Click on Environment Variables button. (The Environment Variables window will be opened)
  • Under System variables, highlight Path. Click Edit.
  • At the end of the Variable value, append ;c:\cygwin\bin (or wherever your installation path is. Don't forget the semi-colon in front).
  • Click OK | OK | OK to finish.
Now you can use rsync to copy file in the command window, like the followings:
rsync.exe \\fromserver\share\filename d:\backupfolder\filename
But there is another issue. The destination file (copied via rsync) is owned by the user account running rsync. One may prefer to have the file permissions inherited from the parent folder instead. To fix that, I use the setacl utility from SourceForge.

The following commands first change the file ownership to local Administrators group of the backup server, clear the discretionary and security access control lists (DACL, SACL) of the file, and finally set the ACLs to be inherited from the parent folder.
setacl.exe -on filename -ot file -actn setowner -ownr "n:backupserver\Administrators;s:n"
setacl.exe -on filename -ot file -actn clear -clr dacl,sacl
setacl.exe -on filename -ot file -actn setprot -op "dacl:np;sacl:np"
Put them all into a batch file, and you have a simple script to perform nightly backup using rsync.

Monday, October 13, 2008

Wrapper for Microsoft SQL Injection Source Code Analyzer Tool

Microsoft has released a SQL Injection Source Code Analyzer for ASP code. Refer to KB 954476 for more information about the tool. However the analyzer can only check one ASP page at a time. It does not automatically recursive scan all ASP files in a folder. Therefore I wrote a simple wrapper around it. Here is the source code:
@echo off
setlocal
set source=\\servername\applicationname
set include=%source%\include
set logfile=check_applicationname.log
IF EXIST %logfile% DEL %logfile%
FOR /F "usebackq tokens=1 delims=?" %%i IN (`dir /S /B %source%\*.asp`) DO (
msscasi_asp.exe /NoLogo /GlobalAsaPath=%source% /input="%%i" /IncludePaths=%include% >> %logfile%
)
endlocal

Wednesday, October 8, 2008

F5 iRule Competiton Honorable Mention Finalist

I attended the Load Balancer iRule (scripting) competition organized by F5 Networks. I didn't win the first prize. In fact, they never even contacted me afterwards.

I just found this out today that I was on their Honorable Mention Finalist.

Tuesday, April 12, 2005

Convert Today's Date to YYYYMMDD In Batch File

Here is a simple script to convert today's date into yyyy-mm-dd format in batch file:
FOR /F "usebackq tokens=1,2,3,4 delims=/ " %%i IN (`date /t`) DO (
set yyyymmdd=%%l%%j%%k
)