Posts

Showing posts with the label C#

re-introduction to JSON.hpack

Let me try again, this time with an official project page and a nearly complete wiki page . JSON.hpack, the Fat-Free Alternative to JSON JSON.hpack is a lossless, cross language, performances focused, data set compressor. It is able to reduce up to 70% number of characters used to represent a generic homogeneous collection. To understand how to use JSON via JavaScript, PHP, or C# (Python coming soon and hopefully other languages as well), please have a look into the wiki page or if you want, try out the demo page ! I am waiting for comments :-)

Levenshtein algorithm revisited: 2.5 times faster

First of all one consideration: JavaScript is SLOW! Chrome, Safari, Opera, FireFox (Internet Explorer obviously is the only one 2 to 8 times slower!) It does not matter which tracemonkey or V8 you are using, JS is far away to be fast as C#, C++, C are! About Levenshtein If you would like to create a project like BJSpell with a reasonable suggestion , the levenshtein algorithm will trill at some point: it calculates the distance between 1 string to another one. It means that from the word "Gofy" to the word "Goofy", this algo will return 1 character to change replace, or add, before Gofy will become Goofy. Why Levenshtein To obtain a suggestion that makes sense, we could use some known algorithm to recognize at least words close to the mistyped one. So far, my suggestion in BJSpell was something truly rude and often useless, but as far as I know there is NO WAY to implement something more clever, using every possible best performances practice. How to speed up the ...

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

Google Code Jam: Mousetrap in 4 languages - GAME OVER

First of all, I would like to thank the Google team for Code Jam opportunity, and its organization: AMAZING! Yesterday I have lost my Round without a single commit. This time I have not excuses, it was simply my fault. I did not understand properly first two problems, or better, expected results, but I was sure the reason was my poor English knowledge, and I wouldn't be silly, asking silly questions (some question was silly enough, so, next time, I'll be less shy than this time). Accordingly, since Code Jam is a challenge, I chose to solve the most difficult problem, the Mousetrap. First of all, because the problem, and the expected result, was so simple to understand, secondly, because it was the best one for points :geek: Problem Analysis Ok, we had 2 hours to analyse the problem, to find the best solution, and to commit results, and this time I did not even download the test, because I would like to be sure that my solution was good enough to solve the problem. Count positio...

packed.it screencast ... (maybe) Yesss!!!

I didn't find a way to create a clean video, probably 450 pixels are not enought to show how does packed.it work? However, I'll try to explain these two screencast. First one - Ext JS Home Page - from 223Kb to 52Kb This video shows a saved version of Ext JS Home Page . This site uses a lot of external CSS, one imported and one in page but not every one is used by JavaScript disabled browsers. Total CSS size is about 93,2Kb while 4 used JavaScript files size is about 130Kb. With packed.it You can create a project using both CSS and JavaScript and the result will be a single file with total size of 52Kb, including both CSS and JavaScript. I didn't add to project Google Analytics unrich.js file but this should be included without problems too saving other 15Kb. As You can see (I hope), the result is even smaller on page, just three tags, using IE5 compatibility one, instead of 8 inside page ... these are few bytes less than original and layout is even more clean than ever. CS...

new packed.it automatic content generator

packed.it service now creates archives with 3 types of automatic content generator: ASP.NET (C#) , PHP (4 or 5) and Python (mod_python and psp or WSGI version). These generators complete packed.it service and are usable with MyMin produced code too if You choose to manage your own projects by yourself. Probably there will be future implementations (Java, Perl, Ruby), however today You can use packed.it to create optimized CSS and JavaScript for more than 80% of hosting solutions. A special thanks to Cristian Carlesso for C# porting, He doesn't like my revision style so much ... but it works perfectly and it's more simple to mantain too (at least for me :D) Have fun with packed.it :-)

MyMin project 1.0.1 available

I've just uploaded last version of MyMin project fixing only JSmin problems with regular expressions when it's not inside a closure, not after '{' or ';' allowing them to parse entire jQuery UI, for example, without problems. This fix has been successfully tested on Python 2.5, PHP 5.2, C# 2 and JavaScript 1.3 You can find MyMin project description in this page while You can optimize CSS and JavaScript in a single file simply using my on-line packed.it service . Have fun with optimizations and please feel free to post a comment if You find some bug using MyMin project, Thank You!

A "little bastard" BUG using JSmin parsers

Update It seems I found a valid fix for "strange" regular expressions. I suppose MyMin will be available tomorrow while packed.it has been just updated with last client version. Have fun with packed.it and please tell me if some source cannot be parsed. -------------------------------------- While I was testing every kind of source and CSS with my last creation, packed.it , I found a bug on JSmin logic, partially recoded inside MyMin project as JavaScript minifier (MyMinCSS and MyMinCompressor seem to work perfectly). This bug seems to be present on every version linked in JSmin page . I found this bug parsing jQuery UI + every CSS with my new service but one JavaScript file has one single, simple problem: function(){return /reg exp with this ' char/;} Bye bye JSmin, regexp will be parsed as string and an error will be raised. The problem is reproducible just with a string that contains only this (so a source that begins and end with these 3 chars): /'/ that's a...

Are You Ready To Pack ?

I'm pleased to announce my last revolutionary project called packed.it ! Just another minifier packer alternative ??? No guys! packed.it goals is to reduce using best practices both CSS and JavaScript sources in a single file . You can write directly on JS area or in CSS one or upload one or more file, choosing which one should be executed before others. Based on MyMin project , a personal revisit of JSmin plus a dedicated compressor and a CSS minifier for C# , JavaScript , PHP or Python languages, packed.it creates a project archive, in zip format, that will contain everything You need to server your files gzipped, deflated or clear for browsers or robots that does not support gz pages. Not only JavaScript ! The innovative packed.it idea is to process both JavaScript and CSS to create a single project file just compiled to be served using gzip, deflate or clear text. In this case your server will not need to do anything, just serve correct file verifying its sha1 summary to ...