Aug 262010
 
for i in range(0, len(sys.path)):    
    if sys.path[i].find("~") > -1:        
        sys.path[i] = path.expanduser(sys.path[i])
        break
else:    
    sys.path.insert(1,path.expanduser("~/lib/python"))

More duct tape code to allow me to rely on ~/lib/python to store common code (ex. apache log parsing & analysis ) when PYTHONPATH might not be set or
set incorrectly.

Basically if ~ is found in sys.path, the break statement skips the else. Alternatively, if not found then else is executed.
Python compound statements: For loops

 

Been playing with a tool released by Facebook called xhprof, http://mirror.facebook.net/facebook/xhprof/doc.html , which is a
very nice tool for figuring out what exactly is going on in your PHP code.

Meanwhile I used Doxygen a lot, its great for finding out how spread out calls are to individual libraries, has great call graphs, and if setup correctly can draw out the entire hierarchy of even the most complicated of projects.

What I’d like to do is create something that uses xhprof with documentation logic similar to doxygen, to make dynamically generated documentation that not only shows you how a class is defined, but how it’s defined, what depends on it, and what does it depend on.

UI:
I was thinking of something that was intelligent in the ways of MVC frameworks, recording a list of all urls called into a framework and then displaying them as a list broken down by URL components.

A simple example might be a MVC project with one controller called user
User has a standard CRUDE outline so the url’s might be
/user/create
/user/list
/user/edit
/user/save
/user/delete

So the first screen would be:

Entry points:
User – 5 sub points

The sub points part would be a anchor leading to a digest page listing # of recorded profiles to /user/ then maybe a digest of slowest call with the subcompontent ( say save ) to fastest ( delete ), highest / lowest memory consumption, a link to files common to this URI, and then links to progress further down the URL chain.

Clicking on list would lead to /usr/list – again showing the above, but now specific to this URL. At this point there shouldn’t be anymore child components in the URL ( GET arguments are automatically stripped OFF ) so an additional feature would be to click a link to show a visual graph similar to what stock xhprof UI provides.

The fun part would be when you clicked on one of the listed files. Immediately this would bring up a page similar to a doxygen product, but it would have some additional information:
# of dependant URLS that executed this file
# of classes, functions, and methods used in this file by this url path ( /user/list )
fastest and slowest execution speeds plus memory consumption percentage for /user/list.

Clicking on a class, method, or function would cause it to again drill down and show stats JUST for the specified scope.

Considering its taken me 3 months to get PyProxy to stable useful Alpha, this project is probably going to take me a year or more… but it should be fun.

Aug 192010
 

So PyProxy is a mostly operational death star able to successfully sit between any website and the browser, one of the latest additions I made was the following inject for html payloads:

<script>
    (function(){
        var original = document.write;
        document.write = function(arg1){
                        console.group("document.write");
                        console.log("doc.write: " + arg1);
                        console.groupEnd();
                        original.apply(document, arguments);
        };
    }());

    (function(){
       var truImage = Image;
       window.Image = function(width, height){
        try{

            this.root = new truImage(width, height);
            this.__defineSetter__("src", function(val){
                console.log("New Image @ " + val)
                this.root.src = val;

                });
        }catch(Err){
            console.log("New Image Err");
        }
       }
    }())
</script>

It’s abomination code yes, but it is also extremely useful for further illuminating what exactly is going on in the time prior to document.onLoad plus exposes image beacons generated using Javascript Image objects… something that normally doesn’t show up any where in the DOM, hence I don’t believe FireBug or Chrome inspector panels can report it.

Normally to get something like this into a website would require adding it into development, which then opens the risk of it slipping into production.

The functional beta of PyProxy should be released this weekend if I don’t go on a bender.

Pardon my widgets

 Uncategorized  Comments Off
Aug 132010
 

Rendering delays are likely.

© 2012 Refactored scope Suffusion theme by Sayontan Sinha