Posts

Showing posts from January, 2009

32 bytes, ehr ... 9, ehr ... 7!!! to know if your browser is IE

Update another clever trick from comments, which I will explain later: if(!+"\v1") // true only in IE if("\v"=="v")// true only in IE try{IE=window=!1}catch(e){IE=!0} it works, doesn't it? The reason is simple, if we consider "\v" as a vertical space, browsers interpreter that check in this way: !(+ 1 ) where "not one" is always false, considering that 0 is always casted as false, and every other number is casted as true. Internet Explorer will ignore the vertical space, trying to cast a "v" character into a number, thanks to the sign (plus or minus, it does not matter) // How IE interpreters the code !(+"v") // where isNaN(+"v") === true // and where NaN is implicitly casted as false About conditional comments I read a lot of comments in both Ajaxian and other places ... well, guys, this is a trick as conditional comment is. The day IE will interpret correctly the "\v" character, Opera or so...

png to gif transformation - an excellent free solution via PHP GD2

Why we still need png to gif in our web pages There a couple of valid plugins for different libraries able to manage " silently " png transparency in order to fix those browsers (cough: IE6) that are still used, for god knows which reason, but not able to understand properly the alpha channel. The problem is that these plugins cause overhead in our pages and for each png images, which is nearly a non-sense since these plugins fix old browsers whose performances have never been brilliant! Especially for modern GUIs, where little icons are widely used, these plugins could make the application incredibly slow. If we could choose old good GIF instead of png, 'till the end of those browsers, the problem will not exist and performances will be acceptable. PNG 2 GIF, simple? ... not, really! First of all a couple of search via Google brought me in " free but you have to pay anyway " applications through some open source, simple, but not that nice, program language solu...

IE8 RC1 - Faster SunSpider? It does not matter!

Just a quick post about IE.Next - SunSpider could score a bit better (not compared with other browsers) but the render speed, css direct/text visualization, plus events propagation, is about 2 times slower than beta 2 and 7 Guys ... just 3 words: what the hell!

PAMPA-J calls for tests

More downloads, and as usual more problems caused by different configurations. I would like to leave a single official 1.0 release in Google Code PAMPA-J Project page but I need your tests to do this. Test I would like to perform with your configurations: PAMPA starts (default configuration: Apache, MySQL, PHP, Jaxer) PAMPA works from every folder (Desktop, Documents, others) PAMPA closes processes on stop and/or exit PAMPA works from network as well (old version could be launched from another PC without problems and respecting paths) All above tests passed without problems for me, but I would like to be sure it works properly in other environments. Would you help me? Cheers :-)

PAMPA 1.0 - Jaxer included!

Update - Windows Home Fixed! Version 1.0b contains hot fixes for Window$ Home Edition plus some little change to make PAMPA more robust than before during process managment. If you already downloaded version 1.0 you can download only the Tray executable and rename it as PAMPA.exe Please tell me if you have still problems, hoping this b version will be the final 'till 1.1 ;-) Update Final Version 1.0 now served via Google Code ;-) I am proud to announce the first Release Candidate final 1.0 release of my tiny precious PAMPA , jumped from version 0.7 to 1.0 and rewrote from the scratch considering every suggestion its users gave me during these years (project born in 2006 and completely revisited for version 1.0) What is PAMPA-J PAMPA means P ortable A pache, M ySQL, and P HP A pplication, in this release with Aptana Jaxer included ! (shell I consider PAMPA-J a portable Aptana Cloud ?) What does it mean: Portable PAMPA is the first customizable and portable WAMP environment that...

Quick Tip: C# GZip content

A quick post with a simple trick that let us reduce instantly every Ajax interaction over our C#.NET application: [-] public void GZResponse() { if(-1 Response.AddHeader("Content-Encoding", "gzip"); Response.Filter = new System.IO.Compression.GZipStream( Response.Filter, System.IO.Compression.CompressionMode.Compress ); } } The good part is that precedent code, whenever we were using Response.Write, became automatically compatible. Above code could be used to serve JavaScript or css files too: [+] public void GZResponse(){} [-] protected void Page_Load(object sender, EventArgs e) { GZResponse(); Response.AddHeader("Content-Type", "text/javascript"); Response.WriteFile("jquery.min.js"); } That's it :-) P.S. for file serving I suggest a cache system for pre gzipped files

ellipse and circle for canvas 2d context

These days I am working inside an ExtJS panel to create some sophisticated drawing stuff, and I discovered (too late ...) that there is almost nothing in canvas 2d context to draw circle or ellipse. That's why I have extended Google excanvas library and/or native canvas 2d context prototype to let us create circles and ellipse in the same simple way we can create rectangles. Here the extended proto: (function(){ // Andrea Giammarchi - Mit Style License var extend = { // Circle methods circle:function(aX, aY, aDiameter){ this.ellipse(aX, aY, aDiameter, aDiameter); }, fillCircle:function(aX, aY, aDiameter){ this.beginPath(); this.circle(aX, aY, aDiameter); this.fill(); }, strokeCircle:function(aX, aY, aDiameter){ this.beginPath(); this.circle(aX, aY, aDiameter); this.stroke(); }, // Ellipse methods ellipse:function(aX, aY, aWidth, aHeight){ var hB = (aWidth / 2) * .5522848, ...

Internet Explorer Object watch

Update As Luke suggested, there is a method remove in the watcher that should solver leaks problem while the new version should be supported by most recent Opera, Safari, FireFox, and Internet Explorer. Main updates: the watcher is always another object and not the original one to safely destroy the watcher use its destroy method and then delete it ---------------------------------------------- We all complain about IE and its non-standard attitude, this time I would like to introduce a non standard feature, as Object.prototype.watch is, for Internet Explorer. What is watch and why we need it The watch method allows validation, control, monitoring, over a generic object. This means that we can control properties assignment with one, or more, callbacks. var man = {}; man.watch("name", function(propertyName, oldValue, newValue){ // propertyName: name // oldValue: undefined if it is the first time, the old one otherwise // newValue: new assigned valu...