29 Aralık 2008 Pazartesi

Some YUI notes

YAHOO.util.Event.onDOMReady(init); on window.domready, before window.load (i.e. domready if fired before images are loaded)

YAHOO.util.Event.on("panelbutton", "click", init);

YAHOO.util.Event.addListener("show", "click",
    YAHOO.example.container.dialog1.show,
    YAHOO.example.container.dialog1, true);



Dialog boxes, Panels, lightboxes, tooltips, hint boxes are in Container.
  • A hint box in YUI is Tooltip. They can created in two ways.
    • One Tooltip object for per context, or
    • One Tooltip object for many context. See the YUI example entitled "One Tooltip, Many Context Elements"
  • A lightbox in YUI is Panel.
    • Panel is an implementation of Overlay that behaves like an OS window, with a draggable header and an optional close icon at the top right.
    • Dialog is an implementation of Panel that can be used to submit form data.

      Built-in functionality for buttons with event handlers is included. If the optional YUI Button dependancy is included on the page, the buttons created will be instances of YAHOO.widget.Button, otherwise regular HTML buttons will be created.

      Forms can be processed in 3 ways -- via an asynchronous Connection utility call, a simple form POST or GET, or manually. The YUI Connection utility should be included if you're using the default "async" postmethod, but is not required if you're using any of the other postmethod values.
    • SimpleDialog is a simple implementation of Dialog that can be used to submit a single value. Forms can be processed in 3 ways -- via an asynchronous Connection utility call, a simple form POST or GET, or manually

window.domready or YUI's onDOMReady()

http://developer.yahoo.com/yui/event/#ondomready
DOM readiness is achieved before images have finished loading, however, so onDOMReady is often an excellent alternative to using the window object's load event.

YUI Dependency Configurator

http://developer.yahoo.com/yui/articles/hosting/

Nifty Corners Cube with Javascript+CSS

Good library for nifty corners with Javascript+CSS
http://www.html.it/articoli/niftycube/index.html

28 Aralık 2008 Pazar

Conditional Compilation of JavaScript in IE

Conditional Compilation of JavaScript in IE

javascript / escape(), encodeURI(), encodeURIComponent()

xkr.us / javascript / escape(), encodeURI(), encodeURIComponent()

My note: Use encodeURIComponent() if is supported. Otherwise use escape instead of "not doing anything".

I recommend that you add such a utility function in your utility .js file:
function urlEncode(string) {
  if (window.encodeURIComponent) {
    return encodeURIComponent(string);
  }
  // if encodeURIComponent is not supported, use escape
  return escape(string);
}

Require vs Include in PHP

When PHP cannot find the file
  • if you include you will see an error then will continue to run.
  • if you require you will see an error then will die!!!.

PHP Cheat Sheet

  • Use ini_get() function to get php.ini settings.
     if (function_exists('ini_get')) {
      echo 'register_globals : ';
      echo (((int)ini_get('register_globals') == 0) ? 'Off' : 'On'); 
     }
    

Web Templates - TemplateMonster

Free or priced Web Templates: http://www.templatemonster.com

The Robots META Tag Values

Good quick reference for the HTML Robots META Tag Values
http://www.searchtools.com/robots/robots-meta.html

26 Aralık 2008 Cuma

My Cheat List for SLIME/Emacs

My Cheat List for SLIME/Emacs

General
C-g Quit/Cancel command
C-j Open and insert new line.
It is sometimes useful in REPL buffer.
C-x o Other visible pane/window/frame
C-c C-z Show REPL buffer
C-x k Close current buffer (file)
C-x C-q Toggle current buffer as read-only
C-x C-c Exit Emacs
M-x slime Restart SLIME
, Enter a command manually. (e.g. quit)
Press Tab after "," to see the available commands)
File and Buffer Operations
C-x C-f Open file / New file (if not exist)
C-x C-s Save file
C-x C-w Save buffer as...
C-x C-b Buffer list
C-x b Buffer switch to
Editing
C-_ Undo
C-e End of line
C-s Search (C-s for next, C-r for prev)
M-% Replace (C-s for next, C-r for prev)
C-spc Beginning mark to Copy or Paste
M-w End mark to Copy
- use (C-spc / M-w / goto new place / C-y) to copy-paste
C-w End mark to Cut
- use (C-spc / M-w / goto new place / C-y) to cut-paste
- use (C-spc / M-w / C-y / goto new place / C-y) to copy-paste)
C-y Paste (yank)
Completion / Documentation
C-c C-q Close parens
Tab Complete symbol in REPL
C-c Tab Sole Complete symbol (m-v-b completed to multiple-value-bind)
M-c Tab Sole complete symbol (m-v-b completed to multiple-value-bind)
C-c M-i Fuzzy complete symbol (m-v-b completed to multiple-value-bind)
C-c C-s Insert arg list / complete form
C-c C-d Describe symbol
C-c C-a Apropos
M-. Go to the definition of the symbol at point.
Evaluation / Debugging
C-x C-e Evaluate last expr
C-c C-r Evaluate the region
C-c RET macroexpand-1 the trailing form
C-c C-m macroexpand-1 the trailing form
C-c C-k Compile/Load file
C-c M-k Compile file
C-c C-m macroexpand-1 the trailing form
C-c I Inspect
C-c M-d Disassemble symbol
Help
C-h b Describe bindings/shortcuts now in effect
C-h k Describe the binding/shortcut specified immediately after
C-h w What key combination invokes given command
(reverse of C-h k).

24 Aralık 2008 Çarşamba

Long global vars such as $HTTP_SERVER_VARS, $HTTP_SERVER_VARS in PHP

In some environments $HTTP_SERVER_VARS, like the other long global vars, is null, undefined and does not working.

Since PHP 5.0, it is recommended that one should use $_SERVER instead of $HTTP_SERVER_VARS.

As of PHP 5.0.0, the long PHP predefined variable arrays may be disabled with the register_long_arrays directive.

Similarly,

  • use $_GET instead of $HTTP_GET_VARS
  • use $_POST instead of $HTTP_POST_VARS
  • use $_ENV instead of $HTTP_ENV_VARS
  • use $_COOKIE instead of $HTTP_COOKIE_VARS
  • use $_FILES instead of $HTTP_POST_FILES
  • use $_SESSION instead of $HTTP_SESSION_VARS

For detailed info, look at here: http://www.php.net/manual/nl/reserved.variables.php

22 Aralık 2008 Pazartesi

Cross browser HTML DOM browsing example

A simple cross browser script for the case in my other entry.

<head>
    <title>Deneme</title>
</head>

<body>
  Click the Test button<br />
  <button onclick="return test();">Test</button>

<script>
function test(){
  var headNode = document.getElementsByTagName("head")[0];
  var _IE_ = (document.all && document.getElementById);
  if (_IE_){
    var titleNode1 = headNode.firstChild;
    var titleNode2 = headNode.childNodes[0];
    alert("titleNode1 text : " + titleNode1.text);  
    alert("titleNode2 text : " + titleNode2.text);  
  }
  else{
    var titleNode1 = headNode.firstChild.nextSibling;
    var titleNode2 = headNode.childNodes[1];
    alert("titleNode1 text : " + titleNode1.firstChild.nodeValue);  
    alert("titleNode2 text : " + titleNode2.firstChild.nodeValue);  
  }

  // cross browser version
  var titleNode3 = headNode.getElementsByTagName("title")[0];
  var nodeText3 = (titleNode3.text != undefined) ? titleNode3.text : titleNode3.firstChild.nodeValue;
  alert("titleNode3 text : " + nodeText3);
  return false; 
} 
</script>

</body>

HTML DOM tree in Mozilla

This text is valid for only Firefox !!! Internet Explorer behaves differently. This explains why using cross browser DOM library is necessary. I have demonstrated the cross browser script for this example here.

IN FIREFOX, first and last chilren of DOM elements (html, head, body, and others) are text nodes. In the example below they are represented as (#text). This is very important!. Suppose that we have
<head>
    <title>Deneme</title>
</head>
To get the Title node, we should write a code like:
    var titleNode1 = headNode.firstChild.nextSibling;
    // or
    var titleNode2 = headNode.childNodes[1];

document
   |----- html (element)
            |
            |----- (#text)
            |
            |----- head (element)
            |        |
            |        |----- (#text)
            |        |
            |        |----- title (element)
            |        |        |
            |        |        |----- (#text)
            |        |
            |        |----- (#text)
            |
            |----- (#text)
            |
            |----- body (element)
            |        |
            |        |----- (#text)
            |        |
            |        |----- p (element)
            |        |        |
            |        |        |----- (#text)
            |        |        |
            |        |        |----- i(element)
            |        |        |        |
            |        |        |        |----- (#text)
            |        |        |
            |        |        |----- (#text)
            |        |
            |        |----- (#text)
            |
            |----- (#text)

Compressing Javascript codes

ESC (ECMAScript Cruncher) can be used to compres/crunch Javascript codes. It can be downloaded from http://www.saltstorm.net/downloads/esc/ESC.zip

typeof and undefined in Javascript

For declared but unassigned variables (not object attributes),
      x==undefined yields true
      typeof x=="undefined" yields true, too.
BUT
For undeclared variables the former throws error,
whereas the latter returns true.

So,

  • If we don' t guarantee that the variable has been declared, it is good to use typeof x=="undefined" to test whether the variable has been declared or not.
  • If we know that the varible has been declared, it is good to use x==undefined to catch our typing errors.

Object attributes could be thought as members of hashmaps like below
      x.name === x["name"]
So, for undeclared x.name, x.name == undefined won' t throw error, it will return true.

Types returned from Javascript' s typeof

6 types can be returned from typeof

  1. "string"
  2. "number"
  3. "boolean"
  4. "function"
  5. "object"
  6. "undefined"

Hints:

  • for date variables, typeof returns "object"
  • for null variables, typeof returns "object", too.

19 Aralık 2008 Cuma

Mizah - VIP sekşını

Biraz da mizah. VIP sekşını nedir? Linkteki skeçe dikkat :) http://www.newsweekturkiye.com/haberler/detay/22813/vip-sekn

15 Aralık 2008 Pazartesi

PHP MySQL Türkçe karakter probleminin çözümü

Asagidaki satirlardan uygun olanini datayi fetch etmeden once, tercihan mysql_select_db' den hemen sonra kullanin.

Eger tablolariniz utf8_turkish_ci ise

mysql_query("SET NAMES 'utf8'");
mysql_query("SET CHARACTER SET utf8");
mysql_query("SET COLLATION_CONNECTION = 'utf8_turkish_ci'");

Eger tablolariniz utf8_general_ci ise

mysql_query("SET NAMES 'utf8'");
mysql_query("SET CHARACTER SET utf8");
mysql_query("SET COLLATION_CONNECTION = 'utf8_general_ci'");

<button> u Enter icin default yapmak

<button>

  • type="submit" attribute u tanimlanirsa button focused olmadigi halde Enter' a basildiginda form submit edilir.
  • name attribute' u tanimlanirsa form icerisinde button icin bir form variable gonderilir. Gonderilen deger ekranda goruntulenen label' dir. Yani burada <button...>Login</button> oldugundan Login degeri gonderiliyor.

    Ama bu pek isimize yaramayacagi icin name attribute' unu kullanmamiza gerek yok. Cunku

Sadece name attribute u kullanirsak

  • butonumuza basilip basilmadigini (baska bir yolla submit edilmis olabilir)
  • ekranimizda birden fazla button varsa hangisine basildigini
anlayamayiz. Bu nedenle hidden field ve JavaScript kullanarak hangi butona basildigini gondermeliyiz. form' da field kalabaligi yaratmamak icin name attribute' unu kullanmamakta fayda var.


<script> function doButtons(btn){ document.testform.clickedBtn.value = btn.value; var elems = document.testform.elements; for(var i=0; i<elems.length; i++) alert('"testform.' + elems[i].name + '" : ' + elems[i].value); document.testform.submit(); return false; } </script> <form name="testform" action="" method="post"> <input type="hidden" name="clickedBtn" /> <table border="0" cellspacing="1" cellpadding="1" > <tr> <td>User Name</td><td>:</td><td><input name="username" type="text" maxlength="20"/></td> </tr> <tr> <td>Password</td><td>:</td><td><input name="pass" type="password" maxlength="20"/></td> </tr> <tr> <td colspan="2"></td> <td align="right"> <button type="submit" onclick="doButtons(this);" >Login</button> </td> </tr> <tr> <td colspan="2"></td> <td align="right"> <button onclick="doButtons(this);">Cancel</button> </td> </tr> </table> </form>

6 Aralık 2008 Cumartesi

5 Aralık 2008 Cuma

Ubuntu üzerine apache2 php5 mysql phpmyadmin kurulumu

http://pihajpi.blogspot.com/2008/11/ubuntu-zerine-apache2-php5-mysql.html

Ubuntu uzerine apache2 php5 mysql phpmyadmin kurulumunu (ayri ayri kurulum) ayrintili ve Turkce olarak anlatiliyor. Yalniz burada anlatilanlardan farkli olarak:

  1. chown... ile baslayan komut dizininin basina sudo koydum. /var/www yi /home/sezgin/public-html olarak degigtirdim. Yani
    sudo chown -R sezgin:sezgin /home/sezgin/public-html
    ile bu folder' a yetki verdim.
  2. /etc/apache2/sites-availabe/default dosyasinda DocumentRoot ' u (/var/www/ idi) /home/sezgin/public-html olarak degistirdim. Yani
    DocumentRoot /home/sezgin/public-html/
    oldu. Ardindan public-html icin de /var/www/ icin tanimlanmis tanimininin benzerini yaptim.

Ubuntu'da LAMP (Linux-Apache-MySQL-PHP) Kurulumu

http://wiki.ubuntu-tr.org/index.php/Ubuntu'da_LAMP_(Linux-Apache-MySQL-PHP)_Kurulumu

Max Text Length for HTML Textarea

http://www.quirksmode.org/dom/maxlength.html Normalde HTML textarea' nin maxlength attribute' u yok ve mevcut attribute' lariyla max character sinirlamasi yapilamiyor. Bu linkte max length sinirlamasi yapabilmek icin guzel bir javascript kodu aciklamali olarak veriliyor.

Internet and Society study from Stanford

http://www.stanford.edu/group/siqss/Press_Release/Preliminary_Report.pdf Internet and Society study from Stanford.

Software Engineering for Internet Applications

http://philip.greenspun.com/seia/ Very good textbook used at MIT Software Engineering for Internet Applications by Eve Andersson, Philip Greenspun, and Andrew Grumet.

Django, a pragmatic Web Framework developed in Python

http://e-bergi.com/2008/Ocak/Django , Python ve Django' nun avantajlarından bahseden güzel bir Türkçe giriş linki.

InformIT - Django for the Impatient: Building a Blog

Wikipedia entry for Django

Dustin Diaz

http://www.dustindiaz.com/top-ten-javascript/

I've seen this link in login.js of PULS (PHP User Login Script). Dustin Diaz is JavaScript guru and had written the book Pro JavaScript Design Patterns.

Bu linki PULS (PHP User Login Script)' ın login.js' inde gördüm. Dustin Diaz JavaScript konusunda bir üstad ve Pro JavaScript Design Patterns adında bir de kitabı var.

Placing scripts in an HTML

Placing scripts in the <head> makes sure that any functions are loaded before the buttons, links or other things that call them are loaded. If you put your scripts at the very end of a page, it is possible that a user already sees part of the page including a button with a JavaScript function call, while the rest of the page hasn't loaded yet. Result: user pushes button and gets JavaScript Error Message Alerts, because the browser can't find the script (yet).

Unless there's a good reason to do otherwise, place your scripts in the <head> .

captcha

Captcha is a type of challenge-response test used in computing to ensure that the response is not generated by a computer. It is done by generating an obfuscated image like .

Wikipedia entry for captcha

http://accessify.com HTML-JavaScript converter

Turkce versiyonu icin tiklayiniz.

http://accessify.com/tools-and-wizards/developer-tools/html-javascript-convertor/

There is an HTML to JavaScript converter. The question "Why might you want to use this tool?" is answered there. I am not not so convinced about the necessity for HTML to JavaScript conversion. But, if considerable amount of your users are displaying yor pages on their PDAs or mobile phones, the conversion will be useful. Or if you want your page can be displayed by "only" javascript-enabled browsers, you can use conversion.

After copying and pasting the code generated by this tool, I recommend that you add

<noscript>You need Javascript to use this page. </noscript>
So, it should be like this
  <script language="JavaScript" type="text/javascript">     <!--     function writeJS(){       var str='';       str+='...';       str+='...';       document.write(str);     }     writeJS();     //-->   </script>
  <noscript>You need Javascript to use this page. </noscript>
CAUTION: When I tried the tool, I have seen that the tool stripped the \'s(backslashes). Be careful about the backslashes in path strings!!!

http://accessify.com HTML-JavaScript cevirici

For English version, please click.

http://accessify.com/tools-and-wizards/developer-tools/html-javascript-convertor/

Burada HTML to JavaScript converter var. Neden faydali oldugunu da anlatiyor ama conversion' a gerek olacagina tam olarak ikna olmadim. Kullanici kitlenizde PDA ve mobil telefon kullanicilari onemli bir yer tutuyorsa ya da sayfanizi sadece JavaScript enabled browser' larda goruntulemek istiyorsaniz conversion kullanilabilir.

Elde edilen script' i aynen copy/paste ettikten sonra hemen altına

<noscript>You need Javascript to use this page. </noscript>
eklemekte fayda var. Yani
  <script language="JavaScript" type="text/javascript">     <!--     function writeJS(){       var str='';       str+='...';       str+='...';       document.write(str);     }     writeJS();     //-->   </script>   <noscript>You need Javascript to use this page. </noscript>
şeklinde olmalı.

DIKKAT: Deneme yaptigimda bu tool \ (backslash) lari yok etti. Path' lerdeki backslash' lara dikkat !!!

PHP de kullanıcı üyelik sistemi hazır script araştırması

For English version, please click.

Google arama metni : php source signup activation code http://www.sourcecodeonline.com/list?q=cooking_academy_activation_code (Buradakiler ücretli) Google arama metni : free php source code user registration http://www.opensourcescripts.com/dir/PHP/User_Management/ Burada P.U.L.S, Mumsai, SMK gibi güzel programlar var: Bunlardan PULS ve PHP Login Script' in demolarina ve kodlarina goz attim. Bu blog' un tumunde oldugu gibi asagidaki yorumlarin da kisa surede ve uzman olmayan birinin ilk izlenimleri oldugunu tekrarlamak istiyorum.
PULS'ta

  • (-) Email ile aktivasyon ozelligi yok.
  • (-) Pwd yanlis girilirse uyari vermiyor. Kodu inceledigimde bu asamada redirection yapildigini gordum. Redirection kaldirilirsa istenilen uyarilar kolaylikla verilebilir.
  • (+) Bu 2 olumsuz izlenim disinda gayet guzel hazirlanmis ve GPL lisansi ile dagitilan bir script.
PHP Login Script' te
  • (-) Captcha' sini yetersiz buldum.
  • (-) Userid olarak email adresi kullaniliyor. Uye olmak isteyenleri kizdirabilir.
  • (+) Mail ile aktivasyon ozelligi var.
Sonuc olarak bu ikisinin melezi guzel bir secenek olabilir.

4 Aralık 2008 Perşembe

Clisp StarterPack and clbuild

The Linux companion of CLisp Windows StarterPack, a very good library package for Common Lisp newbies prepared by Edi Weitz, is clbuild. It can be reached at http://common-lisp.net/project/clbuild/

For Mac OS X, look at Bill Clementson's blog.

Edi Weitz' in Windows ortami icin hazirladigi Starter Pack nin Linux' taki benzeri clbuild in adresi http://common-lisp.net/project/clbuild/

Mac OS X icin ise Bill Clementson' un bloguna bakiniz.

PHP user registration free code search

Türkçe versiyonunu okumak için tıklayınız.

Google search str : php source signup activation code http://www.sourcecodeonline.com/list?q=cooking_academy_activation_code (Those scripts are required to be PAID!!!)

So I' ve changed the Google search string. Google search str : free php source code user registration http://www.opensourcescripts.com/dir/PHP/User_Management/ Here, there are some good PHP scripts like P.U.L.S, Mumsai, SMK, PHP Login Script. Among those, I have run demos and viewed the source code of PULS and PHP Login Script.

I want to repeat that my all comments in my all blog entries are my subjective opinions after a very short review. Also, I am not expert, I am investigating and trying to learn things about which I commented.

PULS

  • (-) Email activation is not supported
  • (-) No warning is displayed when user enters a wrong password. Viewing the source code, I' ve seen that redirection is done when user enters a wrong password. I think that, if the code changed in a way that uses no redirection, the warnings can easily displayed.
  • (+) Except for these 2 negatives, it is very good scripts with good captcha, configuration capability, good inline documentation, etc. It is distributed by GPL license.
PHP Login Script
  • (-) I found that Captcha image is insufficient.
  • (-) For userid, email address is used. It would be annoying for the users during registration and each login.
  • (+) Email activation is supported. It is another good script.
As a conclusion, a hybrid version of both which will be created by the programmer would be a very good user registration system.

SCA Source Code Analysis

Fortify - http://www.fortify.com/

CodePro Anayltix form Instantiations - http://www.instantiations.com/codepro/

http://java-source.net/open-source/code-analyzers FindBugs, PMD, CheckStyle, JLint, DoctorJ, JCSC, Macker, QALab, QJ-Pro, Hammurapi, XRadar, Spoon, Condenser, JarAnalyzer, UCDetector...