'Development' Category

  • Make all markers visible

    January 3, 2010

    This code allows you to set map’s bounds so that all markers are visible: function makeRouteVisible(markers) { var bounds = new GLatLngBounds; for (var i = 0; i < markers.length; i++) { bounds.extend(markers[i].getLatLng()); } map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds)); }

  • Parse JSON in JavaScript: eval gotcha

    November 24, 2009

    Recently I met the following obscure behaviour while working with AJAX queries that return JSON Data. In onLoadOk I had the following code: function onLoadOk(o) { try { data = eval(o.responseText); … } catch(e) { … } } However, in test harness if the response was underfined I did not reach the catch block, data […]

  • JavaScript: sort an array

    October 13, 2009

    For some reason I needed to sort an array of objects by their ‘url’ property. Array’s sort method accepts a sort function and initially my code looked like: function sortFunc(a, b) { return a.url &gt; b.url; } list.sort(sortFunc); I was developing with FF and this code worked fine. However, other browsers refused to sort the […]

  • JavaScript frameworks

    September 15, 2009

    For testing JavaScript we use YUITest (http://developer.yahoo.com/yui/yuitest/) – it has all necessary assertions, is able to run asynchronous tests, simulate user clicks and keypresses and moreover it has the ability to build test suites and send their results in xml. I should say that guys from Yahoo are great – not every framework has so […]

  • Test that alert was called in JavaScript

    September 15, 2009

    We started to write tests for JavaScripts in our web UI to ‘freeze’ it and not to be worried when making changes… So, we have a function that checks some form’s data and displays a message if something is wrong. Messages are displayed via alert function and I needed to test that alerts are showed. […]

  • urllib and cookies

    September 10, 2009

    urllib doesn’t have cookie support and it’s difficult to test a django application that uses sessions as session id is stored in the cookies. However, urllib2 is able to handle cookies: import urllib2, cookielib jar = cookielib.CookieJar() handler = urllib2.HTTPCookieProcessor(jar) opener = urllib2.build_opener(handler) urllib2.install_opener(opener) data = urllib2.urlopen(someurl).read() Source: http://coding.derkeiler.com/Archive/Python/comp.lang.python/2006-04/msg04229.html

  • Django + new thread v.2

    September 4, 2009

    Here I wrote about creating a new thread in django-application, where I had some difficulties with created thread as it was killed by Apache after some time. So I had to create a new task by opening another link via urllib. I was OK with that until I had to work with session. As session […]

  • Maximum of GET request line

    September 4, 2009

    Apache has a setting which configures the maximum length of HTTP request: http://httpd.apache.org/docs/2.2/mod/core.html#limitrequestline Description: Limit the size of the HTTP request line that will be accepted from the client Syntax: LimitRequestLine <var style=”font-style: italic;”>bytes</var> Default: LimitRequestLine 8190 Context: server config Status: Core Module: core However for IE it’s not true: I found out that if request length is over […]

  • Empty POST data, IE 6

    September 3, 2009

    IE6 (may be IE7) has an interesting feature(bug). While sending data via POST I get an empty POST dictionary at the server side – all data is lost somehow. I don’t know why, but IE6 doesn’t send data from an url with NTLM authenctication to a non-authenticated. Suprisingly, but IE8 does’t have this behaviour. So I had […]

  • Javascript: encodeURIComponent, escape, urlencode

    June 19, 2009

    We had a problem with international symbols which were transfered via GET. The request string we form in JavaScript. I don’t know why but IE has some problems with international symbols – just try to open the following url in IE http://www.google.ru/search?q=Français – be sure to copy this url exactly one by one and the symbol […]

Powered by Wordpress and MySQL. Theme by Shlomi Noach, openark.org