Microsoft browser comparison
by luka8088 on Jun.22, 2009, under Talk, Web
Recently, my friend showed me a link about Microsoft comparing browsers (it is first on Google under “microsoft browser comparison” – I don’t want to put it here because I don’t want to increase that’s link search rating :])
It is, as you can see, a review and comparison of Internet Explorer 8, Firefox 3 nad Chrome 2, and charts says that Internet Explorer 8 is the best browser there is. I can understand Microsoft propaganda, but anyone that has even little experience with those browsers knows that most of it is a lie or half-truth, the truth is, Internet Explorer 8 is much, much better then Internet Explorer 7, but still needs much developement, try it yourself and see…
My propaganda is to to spread web browsers that fully support web standards so that web developers don’t have to make hacks for every browser, and Internet Explorer is not only far from that, but in many cases, it is the only browser that still needs special hacks to make page display properly …
I anyone don’t know what to use, then use browsers that follow web standars and give support for web developers that would like to use great new web freatures, but they can’t because of browser’s lack of support…
A good place to go is: http://abetterbrowser.org/
mod_rewrite
by luka8088 on Jun.16, 2009, under Web
Hi, after setting this nice theme, i started organizing the rest on my new site, even before setting up wordpress, i decided to point luka8088.com to one folder (~/public_html), www.luka8088.com to that same folder, and everything else to it’s sub folder, in other words, blog.luka8088.com is located in www.luka8088.com/blog/ (~/public_html/blog), and so on… I wanted to make it all automatically using mod_rewrite:
mod_rewrite is apache module that allows complex url rewriting using regular expressions.
So what I did, since mod_rewrite was already enabled on server, I edited .htaccess file located in ~/public_html and tryed to add some rewrite rules but got many problems, and since I am familiar with regexp, I thought how hard then must be for those people that are not, so I wanted to share some tips:
Rewrite rules can be anywhere in configuration, but I will only speak about them in .htaccess context, basically, it is enough to add:
RewriteEngine On
RewriteRule rewrite-from rewrite-to
Note: If .htaccess does not exists, just create it
Example:
RewriteEngine On
RewriteRule ^index\.html$ index.php
This means: if ^index\.html$ is matched to url, it will be replaced with index.php but, not the whole url, if we, for example, open: http://www.example.com/folder/test/index.html,
if .htaccess is located in http://www.example.com/folder/test/
then it will compare regexp with index.html,
if .htaccess is in http://www.example.com/folder/
(test/ doesn’t exists or there is no .htaccess with rewrite rules inside)
then it will compare regexp with test/index.html
and if in http://www.example.com/
then it will compare regexp with folder/test/index.html
And i want to rewrite http://test.example.com/ into http://example.com/test/, so obviously this was not enough… but… I found some other nice directive called RewriteCond :], again… example:
RewriteCond %{HTTP_HOST}abcd%{REQUEST_URI}1234 abcd(.*)$
RewriteCond compares some text (which can contain variables) with regex, and if true, RewriteRule that follows is evaluated, as you can see in example above…
So, I tried:
RewriteEngine On
RewriteCond %{HTTP_HOST}%{REQUEST_URI} ^([^\.]*)[^\/]*(.*)$
RewriteRule .* /%1%2
… now when we try to open: http://abc.example.com/test/ RewriteCond will compare abc.example.com/test/ with given regexp, ([^\.]*) is everything before first dot, that is abc, [^\/]* is everything before first slash, and (.*) is everything else, that is /test/, and we can backreference that parts from RewriteRule using %1 (%1 is backreference from last RewriteCond and $1 is backreference from the same RewriteRule)…
… RewriteRule matches test/ and rewrites it to /abc/test/, so, the new url is: http://abc.example.com/abc/test/ and then new request is issued, and all this rewriting is done again !!!
Basically, what I want to say is, .* in RewriteRule is infinite loop in most cases ! because abc/test/ is next time rewritten to abc/abc/test/ and so on … I wanted to point this out because i had a lot of problems with that.
The solution is to make sure that RewriteRule will rewrite to something that will not match it’s pattern !
Other thing is, I don’t know how to rewriting a domain without browser seeing it, even on the same server, so, pointing all subdomains ( *.luka8088.com ) to the location ( ~/public_html/ ) does the trick, because now, rewriting from http://abc.example.com/test/ to http://www.example.com/abc/test/ is the same as http://abc.example.com/abc/test/ (no domain rewriting is needed)…
For infinite recursion, the best thing I came up with is:
RewriteEngine On
RewriteCond %{HTTP_HOST}%{REQUEST_URI} ^([^\.]*)[^\/]*(.*)$
RewriteRule (^[^\~]|^$) /~%1%2
This means, rewrite only if folder doesn’t start with ~, and rewrite it so it does start with ~, this way, subfolders have to start with ~, for example:
http://abc.example.com/test/ is rewritten to:
http://abc.example.com/~abc/test ( ~/public_html/~abc/test )
There is one restriction about this, and that is, you can’t use ~ as first character of root folder in subdomains, because redirect rule would be skipped…
Related links:
http://www.regular-expressions.info/
http://www.regextester.com/
http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html
http://httpd.apache.org/docs/2.0/misc/rewriteguide.html
Comments, suggestions and questions are always welcome
contentEditable
by luka8088 on Jun.15, 2009, under Jokes, Web
Few weeks ago, while talking with my friend, he again said he wanted to make web based code editor, you know, like notepad2 or notepad++, but web based… So I decided to try to write something…. While reading online docs and other people posts, I found an interesting thing, setting attribute contentEditable=”true” on any html element, makes it’s content editable by user, and it even works in Internet Explorer !!
The funny part is, you can put it on body, and then, entire page is editable by user ![]()
You can try to edit my blog: here (just refresh to get everything back as it was)
You can try this Edit Mode switcher by putting it in your bookmarks, add a new Bookmark (or Favorite) and put below code as a href, then on any page you can use that Bookmark to switch to Edit Mode, then change any part of the page that you want, and then turn Edit Mode back off
javascript:document.body.contentEditable=document.body.contentEditable.length==4?false:true;void(0);
A new blog …
by luka8088 on Jun.11, 2009, under Talk
Hi, I am Luka and I finally opened this blog because I have a lot of stuff to share, but first, I need to put some other theme :] … as always, questions are welcome…