{khapre.org}
Nothing More : Nothing Less : Just Perfect : Online Since 1997
Thursday, August 24, 2006

Python on the .NET Framework

One of the least talked language on web is IronPython when it became available in Microsoft CLR.
Dynamic runtime languages were previously thought to run very poorly on the .NET Framework, but IronPython dismisses that idea. Microsoft is backing IronPython because it exemplifies just how well the .NET Framework can handle dynamic runtime languages. Supposedly, IronPython runs as fast as the C-based implementation of Python-2.4, if not faster. The company claims that IronPython can run 1.8x faster than Python-2.4 right now. Besides being speedy, it also allows developers to access all of the standard C Python libraries, not to mention and create their own subclasses deriving from the .NET framework.
IronPython is the codename for a new implementation of the Python programming language on the .NET Framework. It is fast - up to 1.8x faster than Python-2.4 on the standard pystone benchmark. It supports an interactive interpreter with fully dynamic compilation as well as static compilation to produce pre-compiled executables. It's well integrated with the rest of the Framework and makes all of the .NET libraries easily available to Python programmers. In this episode Jim Hugunin introduces IronPython with demos showing interactive exploration and GUI building from a command prompt as well as simple embedding as a scripting language in an existing Windows Presentation Foundation application. Via Overview at Microsft's Download website
Still, when I read this old news, I was surprised to see Microsoft's backing on Python where they will not be investing that much of money to see a dynamic language work. Anyways, as part of research found a very interesting comparision of Ruby, Java and C++ with Python by dmh2000. This comparision is just awesome.
conclusion
Java is more productive than C/C++. Use C/C++ only when speed or bare metal access is called for. Python/Ruby is more productive than Java and more pleasant to code in. There is a big question on static vs. dynamic typing. I contend that static typing has to be better for the purposes of program correctness, but the required cruft reduces productivity. If actual practice in large systems shows that in fact runtime typing errors don't occur often and are worth the productivity tradeoff, then I will bow to dynamic typing. I can't come up with a definitive answer to Python vs. Ruby. They seem very equivalent. Would choose based on practicality in a given situation. My general feeling was that Python annoyed me in ways that Ruby didn't, but I think those annoyances would disappear if I was using Python all the time.

Labels:


VishaL KHAPRE@8:39 AM < (0) @ Add

. . ° º o O o º ° . .
Wednesday, August 23, 2006

log_reuse_wait_desc column in sys.databases

Having these words in your SQL Server error in SQL Server 2005 seems a little unbearable.
The transaction log for database '%.*ls' is full. To find out why space in the log cannot be reused, see the log_reuse_wait_desc column in sys.databases
SQL Server 2005 Database Properties Window There are various reason to get the error. Transaction log expansion may occur because of the following reasons or scenarios: The linked MS Technet article does not help but confuses you.
• Uncommitted Transactions
• Extremely Large Transactions
• Operations: DBCC DBREINDEX and CREATE INDEX
• While Restoring from Transaction Log Backups
• Client Applications Do Not Process All Results
• Queries Time Out Before a Transaction Log Completes the Expansion and You Receive False 'Log Full' Error Messages
• Unreplicated Transactions
Check this FORUM POST out, excellent suggestion, set transaction recovery mode to "Simple". Try that once through database properties panel, it does not work for first time. few times it definitley works. Try changing the "Auto Shrink" and "Auto Close" properties to "True"

VishaL KHAPRE@9:29 PM < (3) @ Add
Wednesday, November 22, 2006 2:57:00 PM
Anonymous Anonymous says....

read the follow up to the forum post - setting recovery mode to simple should only be done if you understand the difference between the "simple" and "full".

Monday, February 18, 2008 5:18:00 AM
Anonymous Preet Singh DBA says....

The same applies to "Auto Shrink" and "Auto Close". i.e. only change if you understanding the implications. Setting "Auto Close" on free's up resources when the DB's are not being used but the SQL Logs will repeatedly show "Starting up Database..."
These options have performance implications.

Monday, February 18, 2008 5:20:00 AM
Anonymous Preet Singh DBA says....

The same applies to "Auto Shrink" and "Auto Close". i.e. only change if you understanding the implications. Setting "Auto Close" on free's up resources when the DB's are not being used but the SQL Logs will repeatedly show "Starting up Database..."
These options have performance implications.


. . ° º o O o º ° . .
Tuesday, August 22, 2006

Create a Thumbnail Image of web page

How do I create cached image of a webpage. I just wanted to create a thumbnail of a webpage based on URL. There is no way, you would find the right stuff to do so. I found Alan Dean's page on Generate an image of a web page. He has explained the technique very well. Described his search for such code. He wrote on his own. There are a very few people got it working. So here is the code, took me a lot of time to get it working. Read through the sample I added here very carefully before you copy the code as is. I tried my best to write all comments to make it easy readable.
Tried it in all possible ways to make it successful the way I wanted. This code works awesome but I wanted to use System.drawing very well to make it work. There is no way I could find to do this without using Win32 Api. Apart from that, I need to add the axWebBrowser control and it needs to be visible on form in order to find the image of the web page. Then how do I do it on the fly on my website. There must be a way to create a thumbnail from webpage with out adding ActiveX controls....
Good Luck!! Let me know if this works for you.

'*************************************************************************
'This is main form Class where you will add the basic functions.
'*************************************************************************


Imports
SHDocVw ' Import the shdocvw.dll from Widnows\System32 folder.

Imports mshtml  ' Import the mshtml.dll from Widnows\System32 folder.

Imports System.Runtime.InteropServices ' Need this as we added above two as Interop


Imports
System.Windows.Forms


Public
Class Form1


   
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


        'Add the axWebBrowser control from SHDocVw library to your form name it as axWebBrowser
        'Add the Event Handler as DocumentComplete, because we need to capture screen image when document is completely loaded.
        AddHandler axWebBrowser.DocumentComplete, AddressOf Me.OnDocumentComplete

        End Sub

      Private Sub OnDocumentComplete(ByVal sender As Object, ByVal e As AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent)

 
       
Dim document As IHTMLDocument2 = CType(Me.axWebBrowser.Document, IHTMLDocument2)

        If Not (document Is Nothing) Then

            Dim element As IHTMLElement = CType(document.body, IHTMLElement)

            If Not (element Is Nothing) Then

                Dim render As IHTMLElementRender = CType(element, IHTMLElementRender)

                If Not (render Is Nothing) Then

                    ' Using

                    Dim graphics As Graphics = Me.pictureBox.CreateGraphics

                    Try

                        Dim hdcDestination As IntPtr = graphics.GetHdc

                        render.DrawToDC(hdcDestination)

                        Dim hdcMemory As IntPtr = gdi32.CreateCompatibleDC(hdcDestination)

                        Dim bitmap As IntPtr = gdi32.CreateCompatibleBitmap(hdcDestination, Me.axWebBrowser.ClientRectangle.Width, Me.axWebBrowser.ClientRectangle.Height)

                        If Not (bitmap = IntPtr.Zero) Then

                            Dim hOld As IntPtr = CType(gdi32.SelectObject(hdcMemory, bitmap), IntPtr)

                            gdi32.BitBlt(hdcMemory, 0, 0, Me.axWebBrowser.ClientRectangle.Width, Me.axWebBrowser.ClientRectangle.Height, hdcDestination, 0, 0, CType(gdi32.TernaryRasterOperations.SRCCOPY, Integer))

                            gdi32.SelectObject(hdcMemory, hOld)

                            gdi32.DeleteDC(hdcMemory)

                            graphics.ReleaseHdc(hdcDestination)

                            'Add a PictureBox control to your form, named pictureBox. This way you can 
                            'see the image immediately after it is generated. You can save to FS using Bitmap.Save method.

                            Me.pictureBox.Image = Image.FromHbitmap(bitmap)


                       
End If


                   
Finally

                        'You must dispose Graphics Object for better use.

                        CType(graphics, IDisposable).Dispose()

                    End Try

                End If

            End If

        End If

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        ' Add a button to you form named Button1. 
        ' This way we can control when we want to start Browsing.
        ' Select the URI to be browsed here.

        Me.axWebBrowser.Navigate(New Uri("http://www.khapre.org"))

 

    End Sub

End Class

'*************************************************************************
'This class for dummy for calling GDI Functions from Win32 Api.
'So that you can encapsulate whole GDI work outside. 
'*************************************************************************

Public Class gdi32

    ' I copied all the signatures in this class from http://www.pinvoke.net 

 

    Public Declare Function DeleteDC Lib "gdi32.dll" (ByVal hdc As IntPtr) As Boolean

    Public Declare Function SelectObject Lib "gdi32.dll" (ByVal hdc As IntPtr, ByVal hgdiobj As IntPtr) As IntPtr

    Public Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hDC As IntPtr) As IntPtr

    Public Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hDC As IntPtr, ByVal nWidth As Integer, ByVal nHeight As Integer) As IntPtr

    Public Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As IntPtr, ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal hSrcDC As IntPtr, ByVal xSrc As Integer, ByVal ySrc As Integer, ByVal dwRop As Integer) As Integer

    Enum TernaryRasterOperations As Integer

 

        SRCCOPY = 13369376      'dest = source

        SRCPAINT = 15597702     'dest = source OR dest

        SRCAND = 8913094        'dest = source AND dest

        SRCINVERT = 6684742     'dest = source XOR dest

        SRCERASE = 4457256      'dest = source AND (NOT dest )

        NOTSRCCOPY = 3342344    'dest = (NOT source)

        NOTSRCERASE = 1114278   'dest = (NOT src) AND (NOT dest)

        MERGECOPY = 12583114    'dest = (source AND pattern)

        MERGEPAINT = 12255782   'dest = (NOT source) OR dest

        PATCOPY = 15728673      'dest = pattern

        PATPAINT = 16452105     'dest = DPSnoo

        PATINVERT = 5898313     'dest = pattern XOR dest

        DSTINVERT = 5570569     'dest = (NOT dest)

        BLACKNESS = 66          'dest = BLACK

        WHITENESS = 16711778    'dest = WHITE

    End Enum

End Class


'Check out Alan Dean's explaination, because I don;t get it. He is smarter than me, so I just believed that it works.
<Guid("3050f669-98b5-11cf-bb82-00aa00bdce0b"), System.Runtime.InteropServices.InterfaceTypeAttribute(System.Runtime.InteropServices.ComInterfaceType.InterfaceIsIUnknown), System.Runtime.InteropServices.ComVisible(True), System.Runtime.InteropServices.ComImport()> _

Interface IHTMLElementRender

    Sub DrawToDC(<System.Runtime.InteropServices.In()> ByVal hDC As IntPtr)

    Sub SetDocumentPrinter(<System.Runtime.InteropServices.In(), System.Runtime.InteropServices.MarshalAs(UnmanagedType.BStr)> ByVal bstrPrinterName As String, <System.Runtime.InteropServices.In()> ByVal hDC As IntPtr)

End Interface

 

 

 

Labels:


VishaL KHAPRE@10:51 AM < (1) @ Add
Wednesday, May 16, 2007 3:09:00 PM
Anonymous Alan Dean says....

I have been moving my old entries across from dotnetjunkies to my new domain.

As part of that process, I have been reworking some of the content, where it was worth keeping. The "[How To] Generate an image of a web page" has been extensively rewritten and I have also made a Visual Studio 2005 solution available for download as well.

See http://thoughtpad.net/alan-dean/web-page-image-thumbnail.html

Thanks for the credit given :-)


. . ° º o O o º ° . .
Monday, August 07, 2006

Marathi Blog Viewer

Always thought about my own website scrapign continuously on readable content. So wrote something simple to get blog contents from all who write good. You can read it here or view it on writers website. Everything is using ATOM and RSS Content Feeds.
Still code is in BETA mode. Check this out Marathi Blog Viewer
The development speed is very slow. So it might be a month before it can be completed.

VishaL KHAPRE@11:59 AM < (2) @ Add
Tuesday, August 15, 2006 1:30:00 PM
Blogger sandeep kadam says....

hi this is sandeep kadam

Wednesday, October 31, 2007 6:19:00 PM
Anonymous Anonymous says....

विशाल, कृपया माझा नवीन मराठी ब्लॉग तुमच्या लिस्टिंगमध्ये सामाविष्ट करावा!

http://circuitesh.blogspot.com

regards,
Rajesh.


. . ° º o O o º ° . .
Saturday, August 05, 2006

Shri Satyanarayan Pooja Katha and Photograph

Every year, in the month of Shravan as per India calendar, me and my wife decided to arrange Satyanarayan Pooja. Last year was the most pleasure, this year we are doing with same spirit and devotion on August 12, 2006.
I had been searching for Katha in Marathi, expectation was atleast told and made as I heard since my childhood.

Everywhere I could see Maharashtrians posting requests to send one or where do you get it. It is really difficult in US to have that fantacy unless there is somebody who is scanning and emailing that. This year decided to spread the pleasure by providing a copy to all. Check this page for Satyanarayan Pooja. Completely in Marathi.
There is also a photograph for your use.
Let me know what you think, post a comment here if you need anything else. Allow me sometime before I can make it available, but your comments are more valuable.

VishaL KHAPRE@8:55 PM < (11) @ Add
Saturday, August 19, 2006 6:53:00 AM
Anonymous Aarya says....

Thanks for the satyanarayan Katha.we are staying in dubai and i needed something like this for doing Puja at home.and this was really useful.
punha ekda thank u.

Saturday, August 19, 2006 9:19:00 PM
Blogger VishaL KHAPRE says....

Pooja Photographs are posted online on our very own Album website.

Shri Satyanarayan Pooja - Islanders - 2006

Wednesday, August 30, 2006 5:41:00 PM
Anonymous Anonymous says....

Vishalji,
Shree SatyaNarayan pooja aani Katha internet svaruupat blogmadhye antarbhut karuun paradeshee raahanaarya marathi baandhavaanaa aapan khupch molaachi madat keli aahe. Etarahi Poojapath aapan Blogmadhye antarbhut karanaar aahat kaa ? tashi apeksha karato.
Suyash chintito,
Dr. Gurudas Banavalikar.

Monday, January 22, 2007 7:24:00 AM
Anonymous Anonymous says....

Date : 15 Dec 2006
Dear Vishal,
I am writing this mail just to thank you for helping me through your web site.
Actually I was searching, searching and searching for satyanarayana pooja but couldn't find proper procedure
and katha on Internet, mostly they were all south Indian pooja procedures, got frustrated and found your site.
Cant tell you how u liteup my face by uploding satyanarayan katha and specialy photo on web.

Ooooooooops forgot to introduce myself. my name is
Mrs Sonali Metkar , I live in UK . We just purchased a new house so doing pooja in our new house.
And its easily possible for us because of you.

Thanks a lot.

Regards
Sonali.

Monday, January 22, 2007 7:26:00 AM
Anonymous Anonymous says....

Date : 20 Jan 2007

Hi Mr.Vishal

I was searching for satyanarayana pooja & katha in Marathi on google, until now i could find only english versions & used that to perform the same. I was planning to perform satyanarayana pooja in my house & today while searching on google i found the marathi version you have stored. It is really helpful, thanks. I am Amit Khire & am from pune now here in Lexington,Ky since last 2 yrs. It was nice to get the marathi version of the pooja, i am really happy. Thanks once again.

Regards
Amit Khire

Sunday, February 04, 2007 2:24:00 PM
Anonymous Anonymous says....

Hey brother, thanx for the Satyanarayan Katha and finally i found it today.

Regards,
Prashant Aware
kumar754@gmail.com
San Antonio, TX, USA

Thursday, January 31, 2008 4:51:00 PM
Anonymous Anonymous says....

Go to www.Bhaktisangeet.com for Satyanarayan katha

Thursday, January 31, 2008 4:52:00 PM
Anonymous Anonymous says....

Go to Bhaktisangeet.com for Satyanarayan katha in Audio & text

Friday, March 07, 2008 10:58:00 AM
Anonymous Anonymous says....

I am very pleased with your website. I think you have done a very beautiful favour to us by loading the Puja and the photographs. This has helped me to mainatin our culture and faith in Pooja and at a Time when I was really longing for it.
Thank you very much.

Shekhar-UK.

Wednesday, August 06, 2008 6:08:00 AM
Blogger prajkta says....

hi Vishal,

I think the page for satyanrayan puja is down for maintenance. can you please send me a copy of the puja.. aamhi ya shanviari ( 9th aug) la puja karanr aahot and was banking on your site t take printout as I had seen it earlier. Can you please send it ot me, I will be grateful.

Thanks in advance

Prajkta Malvankar-Kulkarni

Thursday, October 02, 2008 2:59:00 PM
Anonymous Anonymous says....

Cud u please send the list of the things needed for satyanarayan pooja ...thank u


. . ° º o O o º ° . .