I've just updated my recent GzOutput.class.php (more recent than last file published on Ajaxian :D) and tested successful on many browsers.
The difference from other cache-manager files, functions or classes is that GzOutput is totally indipendent from folders or page type, You could use them to increase JSON responses (using text/plain as Content-Type) as well as XML, (X)HTML, CSS or every kind of document You need.
You could combine this class with a JavaScript compressor (to improve download speed) and you don't need to care about output changes because ETag is based on sha1 and not on every mktime of each file (it means better server performances).
The only think that You need to remember is that You don't need to write everything before to use this class (empty spaces, some char or pages can't be write before its usage).
Four public methods are really simple to use:
create, sending an output string and a Content-Type type to use cache if it's available (if not, forces next download to use cache)
createNew, sending an output and a Content-Type to force everytime the download (it's a must for Ajax interactions with XML, JSON or serialized strings)
createFromList, sending an array of files and a Content-Type to create a single generic output file including each file content and using create properties for output
createNewFromList, sending an array of files and a Content-Type to create a single generic output file including each file content and using createNew properties for output
That's all, do You like it ? :-)
behind the design
My JavaScript book is out!
Don't miss the opportunity to upgrade your beginner or average dev skills.
Friday, December 22, 2006
Wednesday, December 20, 2006
PHP API Manager for Notepad++
I've used fantastic Komodo IDE to develop for a lot of time my Python/PHP web/desktop applications but now that my portable PC "has been regenerated" from SONY I'm spendig a lot of time to re-install everything I need.
My first favourite editor was ConTEXT, a fantastic, fast and powerful editor for every kind of program language but "my last love" has been Komodo that I've won on phpclasses.org.
Difference is amazing but there's just a problem .... Komodo is too much powerful and wants a lot of resources (I've not an extremely powerful VAIO) then I've choosed to install ConTEXT one more time but I've found, inside a forum, another famous editor as Notepad++ is and I don't know why I didn't try them before.
It's exactly what I need, a fast, simple, scite based, auto-completition enabled editor, then it's fantastic because I can write PHP as JavaScript, C and many other languages too !!!
Auto-completition is just what ConTEXT doesn't have but hey, it's a must to remember perfectly each kind of function or method because You can use them with CTRL and SPACE where You want then php.api file, as javascript.api files are a perfect solution to develop quickly without an api search engine under your nose ;-)
That's why I've created two really stupid PHP files to manage PHP API, one to create a personal installation dedicated api and one to update and mantain an api with old, unused or deprecated method too.
This is the readme file:
And this is the link of downloadable zip file with these two php scripts (on title too).
Have fun with Notepad++ :-)
My first favourite editor was ConTEXT, a fantastic, fast and powerful editor for every kind of program language but "my last love" has been Komodo that I've won on phpclasses.org.
Difference is amazing but there's just a problem .... Komodo is too much powerful and wants a lot of resources (I've not an extremely powerful VAIO) then I've choosed to install ConTEXT one more time but I've found, inside a forum, another famous editor as Notepad++ is and I don't know why I didn't try them before.
It's exactly what I need, a fast, simple, scite based, auto-completition enabled editor, then it's fantastic because I can write PHP as JavaScript, C and many other languages too !!!
Auto-completition is just what ConTEXT doesn't have but hey, it's a must to remember perfectly each kind of function or method because You can use them with CTRL and SPACE where You want then php.api file, as javascript.api files are a perfect solution to develop quickly without an api search engine under your nose ;-)
That's why I've created two really stupid PHP files to manage PHP API, one to create a personal installation dedicated api and one to update and mantain an api with old, unused or deprecated method too.
This is the readme file:
PHP API Manager - Andrea Giammarchi [http://webreflection.blogspot.com/]
These two simple phpfiles overwrite or create php.api file for Notepad++ program [http://notepad-plus.sourceforge.net/]
Usage:
- notepad.dedicated.api.php
call this file to create your personal PHP configuration api.
This script create php.api file for Notepad++ program overwriting, if present, precedent php.api file version.
Use this application if You don't need other not loaded/present extensions of your php installation.
- notepad.update.api.php
call this file to update your personal PHP configuration api or original Notepad++ default php.api file.
This script create php.api file for Notepad++ program overwriting, if present, precedent php.api file version.
Use this application if You want every other php functions too that shouldn't be present on your php installation.
Please remember to copy old php.api file inside this folder before to launch this application.
And this is the link of downloadable zip file with these two php scripts (on title too).
Have fun with Notepad++ :-)
Firefox Multiple Vulnerabilities ? Update in few hours !
The Highly critical Secunia Advisory of 2006-12-19 is not a problem, FireFox 2.0.0.1 has been released in few hours !!!
You don't need to download this new version if you have auto update feature enabled because your FireFox will update by itself in a "couple of seconds".
I wonder when Microsoft Internet Explorer released an multiple patches update the day after after and then I wonder why You've not yet installed FireFox on your Windows, Mac or Linux computer!
This is quite a record for a browser and this is the complete FireFox 2 veulnerability report ... just 2 vulnerabilities and just one of them unpatched and it's a less critical problem.
This is "your" Internet Explorer 6 vulnerability report and this is the last version 7 of, again, Internet Explorer Browser vulnerability report with 3 bugs, one of them moderately critical and any of them patched.
So c'mon guys, what are You waiting for ? GetFirefox ;-)
You don't need to download this new version if you have auto update feature enabled because your FireFox will update by itself in a "couple of seconds".
I wonder when Microsoft Internet Explorer released an multiple patches update the day after after and then I wonder why You've not yet installed FireFox on your Windows, Mac or Linux computer!
This is quite a record for a browser and this is the complete FireFox 2 veulnerability report ... just 2 vulnerabilities and just one of them unpatched and it's a less critical problem.
This is "your" Internet Explorer 6 vulnerability report and this is the last version 7 of, again, Internet Explorer Browser vulnerability report with 3 bugs, one of them moderately critical and any of them patched.
So c'mon guys, what are You waiting for ? GetFirefox ;-)
Tuesday, December 19, 2006
IWA Italy didn't choose me !!!
The Web Skills Working Group selection is closed and the group is complete.
A lot of University members, a lot of Information Architect and a lot of IWA members ... but "any every day applications" certified or skilled developer, just people that write books, blog posts, do training courses every day and probably part of the same trainings that make italian ICT as is right now (unlikely often generally "ridi.culo.us" ...) ... well, I can't read about any skilled server and client (both!) developer in the Web 2.0 era (or probably I don't know Him/Her) ... but this group should tell us how should be a Web developer and what kind of certification He should have to be a real Web developer ... sure, one or more IWA certifications !
At this point, my first opinion is that V.U.E. certifications aren't a good start point (I've 2 official server and client certifications,PHP Engeener and AS2.0 - ECMAScript 3/4 Developer) and that my W3C/PHP/JavaScript/ActionScript skill and experience (about 8 years) isn't enought to be part of choosed professionists group ... I'm quite disappointed about that but I really ... really hope that next 3 months will be a revolution for italian Information and Communications Technology !
Well, Good Luck Web Skills Working Group, I hope you'll do an excellent work and I hope you'll find the right way to create real good Web developers and not just "fake Web Doctors" !!!
I'm waiting for your progresses, please respect our expectations, we believe in you ! :-)
[update]
this is just my opinion wrote in an italian forum
A lot of University members, a lot of Information Architect and a lot of IWA members ... but "any every day applications" certified or skilled developer, just people that write books, blog posts, do training courses every day and probably part of the same trainings that make italian ICT as is right now (unlikely often generally "ridi.culo.us" ...) ... well, I can't read about any skilled server and client (both!) developer in the Web 2.0 era (or probably I don't know Him/Her) ... but this group should tell us how should be a Web developer and what kind of certification He should have to be a real Web developer ... sure, one or more IWA certifications !
At this point, my first opinion is that V.U.E. certifications aren't a good start point (I've 2 official server and client certifications,PHP Engeener and AS2.0 - ECMAScript 3/4 Developer) and that my W3C/PHP/JavaScript/ActionScript skill and experience (about 8 years) isn't enought to be part of choosed professionists group ... I'm quite disappointed about that but I really ... really hope that next 3 months will be a revolution for italian Information and Communications Technology !
Well, Good Luck Web Skills Working Group, I hope you'll do an excellent work and I hope you'll find the right way to create real good Web developers and not just "fake Web Doctors" !!!
I'm waiting for your progresses, please respect our expectations, we believe in you ! :-)
[update]
this is just my opinion wrote in an italian forum
Sunday, December 17, 2006
Reset The Element CSS
Few days ago ajaxian posted a YUI solution to reset CSS in a page.
This is a really interesting way to solve inherit CSS problems when You need to create a personal widget or when a library would do it.
Dean Edwards did a WHATWG proposal for a <reset> element because
He's quite right for many reasons and that's mine proposal, a reset css that just use simply a class name.
The element with reset class name and every "resetted" elements seems to work fine and You could see an example using this page changing the href of the style element and changing, for example, the body element in this way
This is just an example because You could use reset with every element to obtain the same result for each nested table, form and elements.
This isn't probably the best solution but should be one solution and You could use multiple class name to define Your style too
There's only some adjustment to do with headers and probably something else that You could set using a dedicated css
It's just an example but it should work with every CSS based browser.
What do You think about this solution ?
This is a really interesting way to solve inherit CSS problems when You need to create a personal widget or when a library would do it.
Dean Edwards did a WHATWG proposal for a <reset> element because
He *really* wants to turn off CSS inheritance.
He's quite right for many reasons and that's mine proposal, a reset css that just use simply a class name.
.reset,.reset div,.reset dl,.reset dt,.reset dd,.reset ul,.reset ol,.reset li,.reset h1,.reset h2,.reset h3,.reset h4,.reset h5,.reset h6,.reset pre,.reset form,.reset fieldset,.reset input,.reset textarea,.reset p,.reset blockquote,.reset th,.reset td
{margin:0;padding:0;}
.reset table
{border-collapse:collapse;border-spacing:0;}
.reset fieldset,.reset img
{border:0;}
.reset address,.reset caption,.reset cite,.reset code,.reset dfn,.reset em,.reset strong,.reset th,.reset var
{font-style:normal;font-weight:normal;}
.reset ol,.reset ul
{list-style:none;}
.reset caption,.reset th
{text-align:left;}
.reset h1,.reset h2,.reset h3,.reset h4,.reset h5,.reset h6
{font-size:100%;font-weight:normal;}
.reset q:before,.reset q:after
{content:'';}
.reset abbr,.reset acronym
{border:0;}
The element with reset class name and every "resetted" elements seems to work fine and You could see an example using this page changing the href of the style element and changing, for example, the body element in this way
...
<link rel="stylesheet" type="text/css" href="reset.css">
</head>
<body class="reset">
...
This is just an example because You could use reset with every element to obtain the same result for each nested table, form and elements.
This isn't probably the best solution but should be one solution and You could use multiple class name to define Your style too
...
<element class="reset mywidgetstyle">
...
There's only some adjustment to do with headers and probably something else that You could set using a dedicated css
.reset h1 {
font-weigth: bold;
font-size: 1.2em;
}
It's just an example but it should work with every CSS based browser.
What do You think about this solution ?
Saturday, December 16, 2006
A stupid Ajax cache problem solution
One of the common problem using Ajax (Flash too) interactions is the cache.
There are a lot of valid PHP, Python, JSP and .NET solutions but browser compatibility is often a question mark.
You could implement easyly and directly a client solution and this is just another proposal.
exactly 123 bytes to solve cache problems and this is the func description:
You could test directly in a loop, a benchmark that many other sites didn't test ...
A script that use Ajax requestes inside a loop is not a good script (I suppose) but this kind of demostration can show You that generated no-cache collisions probability are quite impossible.
A usage example should be this one:
Finally these are some F.A.Q.
Why there is a key and a value and not just a random value to perfom without caching problems ?
- because some server-side code should loop over GET or POST keys and in this way it should know that noCache is a not useful parameter to parse or to check. In other cases a server-side code should consider generated radom value as a key.
Why there is a getTime plus a random value and not just the first one ?
- because some client application should call more than a single request at the same time
Why there is a full stop between getDate and random value ?
- because if client date is modified there are less possibilities that generated value was just used (paranoia style)
I think these F.A.Q. are enought and I hope You'll find this simple function useful :-)
P.S. with ActionScript just change the regExp replacing with
There are a lot of valid PHP, Python, JSP and .NET solutions but browser compatibility is often a question mark.
You could implement easyly and directly a client solution and this is just another proposal.
function noCache(uri){return uri.concat(/\?/.test(uri)?"&":"?","noCache=",(new Date).getTime(),".",Math.random()*1234567)};
exactly 123 bytes to solve cache problems and this is the func description:
function noCache(
uri
// uri string to open
){
return uri.concat(
// concat String prototype,
// the fastest way to produce
// a complete string using multiple values
/\?/.test(uri) ?
// if uri has a query string
"&"
// add last value using & separator char
:
// else
"?",
// add a query string to this url
"noCache=",
// this should be a "cool name" for generated key
(new Date).getTime(),
// the noCache value will be milliseconds
// from 1970/01/01
".",
// plus a dot ...
Math.random()*1234567
// ... and a random value using
// a "big" integer as generator
);
// then this is a return example using uri: http://host.com/mypage.html
// http://host.com/mypage.html?noCache=1166301156233.332083.6663326991
// while this is an example using uri: http://host.com/mypage.html?v0=1&v2=a
// http://host.com/mypage.html?v0=1&v2=a&noCache=1166301168420.631416.7190624559
};
You could test directly in a loop, a benchmark that many other sites didn't test ...
for(var
i = 0, // many loops
max = 10000, // max i value
uri = document.location.href, // this href
obj = {}; // a generic object
i < max; // while i is less than max
i++ // increment the i value
) {
if(!obj[noCache(uri)]) // if obj has not a nocache(uri) key
obj[noCache(uri)] = true; // set them as true
else { // else if obj has just the returned nocache(uri) key
i = max;
alert("noCache doesn't work"); // this method is not so cool
}
};
A script that use Ajax requestes inside a loop is not a good script (I suppose) but this kind of demostration can show You that generated no-cache collisions probability are quite impossible.
A usage example should be this one:
XHR.open("get", noCache(myUri), true);
// or ...
XHR.open("post", noCache(myUri2), true);
Finally these are some F.A.Q.
Why there is a key and a value and not just a random value to perfom without caching problems ?
- because some server-side code should loop over GET or POST keys and in this way it should know that noCache is a not useful parameter to parse or to check. In other cases a server-side code should consider generated radom value as a key.
Why there is a getTime plus a random value and not just the first one ?
- because some client application should call more than a single request at the same time
Why there is a full stop between getDate and random value ?
- because if client date is modified there are less possibilities that generated value was just used (paranoia style)
I think these F.A.Q. are enought and I hope You'll find this simple function useful :-)
P.S. with ActionScript just change the regExp replacing with
uri.indexOf("?") >= 0
Thursday, December 07, 2006
The byte family is now complete, welcome bytedom
another "$" dollar function ? elements prototypes ? no, just a simple library with its namespace that doesn't modify anything else !
This is my last creation to complete my lightweight low-level framework that should be everything You need for your Web 2.0 sites or to develop more complex libraries too.
I've found EJ idea great but I always look for my own solutions.
I've thought about bytedom since I've created btefx but btesonwas more important than simply dom management (P.S. new byteson version 2.0b is available) but now I've completed what I need to develop my projects.
This is the bytedom method list:
These useful methods (at least in my humil opinion) let you get, modify, filter or manage dom elements in a simple, funnny (?) and JS friendly way.
This is just one of examples present in this page while this is a new anti pixel logo for people that use every byte library:
that with every member is less than 10 Kbytes for packer version, less than 15 Kbytes for clean crunched version and finally less than 7 for memtronic version.
Please sorry for incomplete bytedom site, I'll update API section as soon as I can.
Now, You could read about every method and parameters directly inside Open Source file version.
I hope you'll like new bytedom library and please tell me if something doesn't work correclty or some browser is not compatible (successful tested with IE5+, FF1+, Opera8+, Safri2+, KDE3.4+).
This is my last creation to complete my lightweight low-level framework that should be everything You need for your Web 2.0 sites or to develop more complex libraries too.
I've found EJ idea great but I always look for my own solutions.
I've thought about bytedom since I've created btefx but btesonwas more important than simply dom management (P.S. new byteson version 2.0b is available) but now I've completed what I need to develop my projects.
This is the bytedom method list:
- addClassName, to add if not present a class name to an element
- addEvent, to add a standard name event such click, load, mouseover and every other, DOMContentLoaded too
- clear, to remove empty textnode from an entire document (FireFox, for example, reads newlines as textnodes)
- create, to create one or more elements (input, div, span .. and every other)
- every, a method like Array.every official JS 1.5 method, usable with a list of elements and arrays too
- filter, same style of every, to get only what You need with your dedicated filter function
- forEach, as every and filter, to do something with a list of nodes / elements or arrays too
- get, something like dollar function, to get one or more elements with specified ids, lists of nodes of specified types or a list of elements with specified classNames
- getStyle, to know a property of a specified element style
- pop, to get and remove an element from a parent node
- preventDefault, to prevent events defaults
- push, to get and add an element at the end of a parent node (something like appendChild)
- remove, to get and remove an element from a parent node
- removeClassName, to remove a className, if present, from an node / element
- removeEvent, to remove a standard name event such click, load, mouseover and every other, DOMContentLoaded too
- replace, to get and replace a new node from a parent
- reverse, to reverse the order of every child found inside a parent node
- shift, to get and remove the first element of a parent node
- some, as every, filter and forEach
- text, to get and create one or more text nodes
- toggle, to hide an element storing its old visibility and display style values ... and to assign them if element is toggled again
- unshift, to add one or more element at the top of a parent node
These useful methods (at least in my humil opinion) let you get, modify, filter or manage dom elements in a simple, funnny (?) and JS friendly way.
This is just one of examples present in this page while this is a new anti pixel logo for people that use every byte library:
that with every member is less than 10 Kbytes for packer version, less than 15 Kbytes for clean crunched version and finally less than 7 for memtronic version.
Please sorry for incomplete bytedom site, I'll update API section as soon as I can.
Now, You could read about every method and parameters directly inside Open Source file version.
I hope you'll like new bytedom library and please tell me if something doesn't work correclty or some browser is not compatible (successful tested with IE5+, FF1+, Opera8+, Safri2+, KDE3.4+).