Friday, July 27, 2007

above the fold (above the scroll, above the crease)

“Above the fold” is a graphic design concept that refers to the location of an important news story or a visually appealing photograph on the upper half of the front page of a newspaper. Most papers are delivered and displayed to customers folded up, meaning that only the top half of the front page is visible. Thus, an item that is “above the fold” may be one that the editors feel will entice people to buy the paper. Alternatively, it reflects a decision, on the part of the editors, that the article is one of the day’s most important.

The term can be used more generally to refer to anything that is prominently displayed.

Above the scroll, a concept in web design referring to location of an item near the top of a web page, which can thus be viewed in a browser without scrolling. Some web marketers have called this “above the crease” referring to way in which newspapers of yesteryear were folded and creased.

tag soup

Tag soup is HTML code written without regard for the rules of HTML structure and semantics (HTML is the markup language which composes Web pages). Generally, tag soup is created when the author is using HTML for a presentational document rather than a semantic document. Because web browsers have always treated HTML errors leniently, tag soup is also used by browser implementers to refer to all HTML. HTML must be treated by web browsers as tag soup in comparison to XML where errors need not, and should not, be corrected according to the specification.

web bug (a.k.a. tracking image, clear gif, 1-by-1 gif, invisible gif)

What exactly is a Web Bug?

A Web Bug is a graphics on a Web page or in an Email message that is designed to monitor who is reading the Web page or Email message. Web Bugs are often invisible because they are typically only 1-by-1 pixel in size. They are represented as HTML IMG tags.

What information is sent to a server when a Web Bug is viewed?

  • The IP address of the computer that fetched the Web Bug
  • The URL of the page that the Web Bug is located on
  • The URL of the Web Bug image
  • The time the Web Bug was viewed
  • The type of browser that fetched the Web Bug image
  • A previously set cookie value

What kinds of uses does a Web Bug have in an Email message?

  • A Web Bug can be used to find out if a particular Email message has been read by someone and if so, when the message was read.
  • A Web Bug can provide the IP address of the recipient if the recipient is attempt to remain anonymous.
  • Within an organization, A Web Bug can give an idea how often a message is being forwarded and read.

Firefoxban a noscript extension az 1.1.6.11-es verziotol letilthatova teszi (about:config > noscript.blockNSWB)

Thursday, July 26, 2007

Tenni Theurer: Maximizing Parallel Downloads in the Carpool Lane

Itt van az egesz, de lenyeg, hogy a HTTP/1.1 specifikacioban leirt ajanlas szerint az IE es a Firefox is max 2 dolgot tolt le parhuzamosan ugyanarrol a hostrol (IP cimet nem nez). Ezt meg lehet valtoztani kliens oldalon.

Az IE-nel a registy manipulalasaval:

  1. Start Registry Editor (Regedt32.exe).
  2. Locate the following key in the registry:
    HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings
  3. On the Edit menu, point to New click DWORD Value, and then add the following registry values:
    Value name: MaxConnectionsPer1_0Server
    Value data: 10
    Base: DecimalValue Name: MaxConnectionsPerServer
    Value data: 10
    Base: Decimal
  4. Quit Registry Editor.

Firefoxban pedig az about:config oldalon a
network.http.max-persistent-connections-per-server atallitasaval.

Kimertek, hogy mennyit huz a sebessegen, ha tobb hostname aliast hasznalnak amivel arra szorithatjak a browsert, hogy egyszerre tobb elemet toltson le, de az jott ki, hogy 2 aliasnal tobbet nem erdemes hasznalni, mert csak meglassabb lehet az egesz, de gyorsitani biztos nem fog.

Ryan Bran merese szerint viszont siman megeri 3 kulonbozo subdomaint hasznalni.

Wednesday, July 25, 2007

Reload IE-ben a cahce kiiktatasaval.

Ha ugy akarunk ujratolteni egy oldalt IE-ben, hogy ne hasznalja a cache-t, akkor nyomni kell kozben a controlt es a shiftet.

Thirteen Simple Rules for Speeding Up Your Web Site by Yahoo! Developer Network

Itt van az egesz, de idemasolom a tartalomjegyzeket:

1. Make Fewer HTTP Requests
2. Use a Content Delivery Network
3. Add an Expires Header
4. Gzip Components
5. Put CSS at the Top
6. Move Scripts to the Bottom
7. Avoid CSS Expressions
8. Make JavaScript and CSS External
9. Reduce DNS Lookups
10. Minify JavaScript
11. Avoid Redirects
12. Remove Duplicate Scripts
13. Configure ETags

Monday, July 23, 2007

palindromic pangram

A palindrome is a word, phrase, number or other sequence of units that has the property of reading the same in either direction.

A pangram or holoalphabetic sentence, is a sentence which uses every letter of the alphabet at least once.

A palindromic pangram is a multi-word palindrome that includes all 26 letters of the alphabet.

Tuesday, July 17, 2007

Fritz Onion: Beware trailing comma in JavaScript prototypes

Itt van, de rovid ugyhogy be is masolom:

When defining a number of functions in a prototype in JavaScript, do not include a trailing comma after the last

MyType.prototype = {
foo : function() {
// ...
},

bar : function() {
//...
}, //<- fails in IE!
}

function:What was especially tricky about tracking this problem down was that FireFox works with or without the trailing comma, so it only fails in IE!

Aza Raskin: Never Use a Warning When you Mean Undo

Itt van az egesz, de lenyeg, hogy webalkalmazasokban mondjuk ha torlunk valamit akkor jo lenne a warning helyett (amit sokszor automatiksuan leokezunk, majd a fejunkhoz kapunk) egy undo megoldas. Peldanak a Gmail leveltorleset hozza fel, ami nem figyelmeztet, de rogton utana egy mozdulattal vissza tudjuk vonni, ha tevedesbol tettuk.

Row Swan: Conflicting Absolute Positions

Ez a problema:

“On two separate occasions this month, I’ve been required to produce a layout in which a fixed-width scrolling side “pane” and flexible scrolling main “pane” must resize to fill all available space in a browser window.”

Vegigjarja a dolgot es vegul Div-ekkel es CSS-sel oldja meg. Persze most is az IE bonyolitja a megoldast.

Monday, July 16, 2007

Peter-Paul Koch: The this keyword (in javascript)

Itt van az egesz, de a lenyeg:

What does this refer to in the function doSomething()?

function doSomething() {
this.style.color = '#cc0000';
}

If you want to use this for accessing the HTML element that is handling the event, you must make sure that the this keyword is actually written into the onclick property. Only in that case does it refer to the HTML element the event handler is registered to. So if you do

element.onclick = doSomething;
alert(element.onclick)

you get

function doSomething()
{
this.style.color = '#cc0000';
}

As you can see, the this keyword is present in the onclick method. Therefore it refers to the HTML element.

But if you do

alert(element.onclick)
you get

function onclick()
{
doSomething()
}

Examples - copying

this is written into the onclick method in the following cases:
element.onclick = doSomething
element.addEventListener('click',doSomething,false)
element.onclick = function () {this.style.color = '#cc0000';}

Examples - referring

In the following cases this refers to the window:

element.onclick = function () {doSomething()}
element.attachEvent('onclick',doSomething)

Sunday, July 15, 2007

Ackermann fuggveny

A:N x N -> N

A(m,n) =

  • n+1, ha m=0
  • A(m-1,1), ha n=0
  • A(m-1, A(m, n-1)), ha m>0, n>0
    Ahogy a wikipediaban irtak:
    A(4, 2) nagyobb, mint az Univerzum részecskéinek száma a 200. hatványon. A(5, 2) tízes számrendszerben írva nem férne el a fizikai Univerzumban…Ha megtehetnénk, hogy a mostani Univerzum minden részecskéjét egy csettintéssel egy univerzummá tágítsuk, utána ugyanezt a megjelent univerzumok részecskéivel, és ezt sokszor megtennénk, meghalnánk végelgyengülésben mielőtt a részecskék száma elérné a A(4, 3)-t.”

Tuesday, July 10, 2007

Miert ne hasznaljunk with-et javascriptben

Crockford nem ajanlja, mert peldaul a


with (o) {
foo = null;
}

jelentheti azt is, hogy az o.foo lesz null meg azt is, hogy a globalis foo valtozo lesz null vagy akar mindketto.

throw a javascriptben

A sima throw new Error(reason); mellett lehet object literalt is hasznalni.

Pelda a Crockford videobol:


throw {
name: exceptionName,
message: reason
}

for..in buktato javascriptben

Vegig lehet menni egy object minden member-en igy:


for (var name in object) {...}

de ilyenkor vegigmegyunk azoknak az object-eknek is minden elemen amibol a mi objectunk szarmaztatva volt. Ezert Crocford szerint jobb igy megszokni meg ha csunya is:


for (var name in object) {
if (object.hasOwnProeprty(name)) {..}
}

laballed break a javascriptben

Crockford video (00:23) slide 40
  • Statements can have labels.
  • Break statements can refer to those labels.


loop: for (;;) {
...
if (...) {
break loop;
}
...
}

Egymasba agyazott ciklusoknal is mukodik.

Friday, July 06, 2007

Honnan tudjuk, hogy az utolag include-olt javascript mar betoltodott. [2]

Az elozo problemara a codingforums.com-on callback-es megoldast javasolnak a firefoxban az element.addEventListener, IE-ben pedig a onreadystatechange event segitsegevel:


function loadScript(src, callback) {
var node = document.createElement("script");
if (node.addEventListener)
node.addEventListener("load", callback, false);
else
node.onreadystatechange = function() {
if (this.readyState == "complete") callback.call(this);
}
node.src = src;
document.getElementsByTagName("head").item(0).appendChild(node);
node = null;
}


// load 30k script.
// Listener.cleanUp is defined at the bottom of drag.js
callback = function() {
var self = this;
alert("Loaded: " + this.src + "\nListener.cleanUp (nested):" + Listener.cleanUp);
};
loadScript("http://dhtmlkitchen.com/editor/js/drag.js", callback);

[Update]
Ahogy Jan Volter is emliti jobb vigyazni ezzel a readyState propertyvel es onreadystatechange eventtel, mert:
The “this.readyState == ‘complete’” test doesn’t actually entirely work. The readyState theoretically goes through a series of states:

0 uninitialized
1 loading
2 loaded
3 interactive
4 complete

But in fact, states may be skipped. In my experience with IE 7, you get either a loaded event or a completed event, but not both. It may have something to do with whether you are loading from cache or not but there seem to be other factors that influence which events you get. Sometimes I get loading or interactive events too, and sometimes I don’t. It’s possible the test should be “this.readyState == ‘loaded’ || this.readyState == ‘complete’“, but that risks triggering twice.

Honnan tudjuk, hogy az utolag include-olt javascript mar betoltodott.

Viszonylag egyszeru utolag hozzaadni egy js filet az oldalunkhoz (1, 2), de ha rogton ezutan valamit hasznalni szeretnenk belole akkor az nem biztos, hogy menni fog, mert lehet, hogy meg nem toltodott be teljesen.

Stoyan (mar torolt) irasa szerint egy 1998-as MSDN cikkben talalkozott a readyState property-vel es azt hasznalva ez a kodreszlet IE-ben (csak ott!!) mukodik:

The idea is that after a new DOM element (a script tag) is created, you can have access to the readyState property of the element. If it says “complete”, then the new script is included and it’s OK to call functions from it. If you want to “listen” when the script download will be completed, you can attach an listener to the onreadystatechange event, just like with XMLHttpRequests.

Here’s an example:


var js;
function include_js(file) {
var html_doc = document.getElementsByTagName('head').item(0);
js = document.createElement('script');
js.setAttribute('type', 'text/javascript');
js.setAttribute('src', file);
html_doc.appendChild(js);

// alert state change
js.onreadystatechange = function () {
alert(js.readyState);


if (js.readyState == 'complete') {
// safe to call a function
// found in the new script
imready();
}
}
return false;
}

A commentek kozott Aaron Bassett egy masik megoldast javasolt, amihez modositani kell egy kicsit a betoltendo scripten (mar ha ez lehetseges), de szerinte minden browserben mukodik (bar nem probalta):

This untested but I dont see any reason why it wouldnt work, and should work across all browsers.

Right at the end of the external js file set a variable like:

var externalScriptLoaded = true;

Then in your main code you could use:


function checkScriptLoaded() {
if(!externalScriptLoaded) {
setTimout("checkScriptLoaded", 500);
} else {
// script loaded and ready to use
}
}

If you have multiple external files you want to check just make sure each has a unique variable name being set and check them accordingly.

This polling every half-second isnt perfect but it will work.

Your other option would be to create a function/method in your main script which inits the actions to perform when the external script is loaded.
Then as the very last thing in your external script you could just call that function/method

externalScripts.myScriptLoaded();

As this call would be at the end of your file it wont be run until the rest of the file ahead of it has been downloaded.

Once again this method is untested but am 99% sure will work and will be cross browser.