"in" Operator in Javascript Date: March 23, 2008 Tags: javascript Comments(0)
Javascript 1.5 contains the in operator that checks only property names.I can't figure out why Javascript returns the exact opposite of that other programming languages return on this operator. Here is an example:
>>> var hello = ["bonjour","hola","saluton","selam"];
>>> "bonjour" in hello
false
>>> 1 in hello
true
Actually, we don't need to the in operator to check values of Array, we can use indexOf property to this action easily;
>>> var hello = ["bonjour","hola","saluton","selam"];
>>> hello.indexOf("bonjour")>-1;
true
>>> hello.indexOf("Hallo")>-1;
false
This operator available to checking object properties too but there are many way to check object properties already;
>>> var hello = { "french":"bonjour", "esperanto":"saluton", "turkish":"selam" };
>>> "turkish" in hello
true
>>> "german" in hello
false
>>> Boolean(hello["turkish"]);
true
>>> Boolean(hello["german"]);
false
The question is, how are object values checked?
gmÇeviri Date: March 22, 2008 Tags: greasemonkey , javascript , misc Comments(4)
gmÇeviri, web sayfalarını gezerken fare imleciyle seçilen ingilizce metinleri türkçeye çevirmek için geliştirdiğim greasemonkey betiğidir.Daha fazla bilgi için yazının devamını okuyun. Continue Readingpi.comet's python module is available Date: March 21, 2008 Tags: cherrypy , comet , django , javascript , pi , python Comments(2)
I coded a python module to get cross browser output and a CherryPy example is available too.You can get these files in downloads list.You can use this module with any python web framework but there are some problems.Firstly, Django doesn't support multi-threading.And there is no shared hosting for CherryPy ( Webfaction runs CherryPy with CGI, sys.stdout.flush function doesn't work on that application ) I hope we have got more comet friendly web frameworks in the future.
VIM Ipuclari Date: March 17, 2008 Tags: linux Comments(2)
VIM ogrenmek istiyeyenler icin belgeler.org'da ogretici bir yazi var. Bu yazinin icermedigi ama ihtiyac duyacaginiz vim komutlari:
syntax enable: syntax'i renklendirmeyi saglar.set number: satir numaralarini acar.
set nowrap: wrap ozelligini kapatir, uzun kod satirlarini pencereye sigdirmaya calismaz.
set ai: auto indent.Yeni satira gecildiginde eski satirdaki hizadan baslar.
Her actiginizda otomatik calismasini istediginiz komutlari /home/$kullanici/.vimrc dosyasina yazin.
split dosya adi: pencereyi bolmek icin kullanilir, dikey olarak bolmek istenirse komutun onune vertical yazilir.
tabnew dosya adi: yeni tab acmak icin kullanilir. tab'lar arasinda hareket etmek icin, tabp (geri) ve tabn (ileri) komutlarini kullanin.
Genellikle ihtiyac duygudugum komutlar bunlar.Dilerseniz vi kilavuzunda da belirtildigi gibi, :help komutuyla yeni seyler kesfedebilirsiniz.Ayrica vim.org adresinde bir manual de bulunuyor.
linux terminalinde komut tanimlamak Date: March 17, 2008 Tags: linux Comments(0)
Linux kabugunun en sevdigim ozelligi, `alias` ile yeni komutlar olusturabilmek.Bu sayede pek cok isi tek komutla yapabilirsiniz, ornegin?Sistemi her yeniden yukleyisinizde `apt-get` programiyla ihtiyaciniz olan yazilimlari tek tek kurmak yerine, tek komutla bu isi halledebiliriz.Adimlari izleyin:
- herhangi bir editorle /home/$kullanici/.bash_aliases dosyasini acin.
- Ve istediginiz komutlari alias ile bu dosyada tanimlayin:
alias installMyPrograms="apt-get install rar unrar unzip cabextract" - dosyayi save edin ve yeni bir shell oturumu acin, artik komutunuzu kullanabilirsiniz.
komutlari dosyaya yazmamizin sebebi, kalici olmalarini saglamak.eger kalici olmasina gerek olmayan bir komut tanimlamak isterseniz, dogrudan komut satirinda da alias kullanilabiliyor.
Eger konsol yazdiginiz komutlari dikkate almiyorsa, alias dosyanizi include etmiyor olabilir.Bu problemi cozmek icin /home/$kullanici/.bashrc dosyasini editorunuzle acin ve su satirlarin onundeki comment'leri kaldirin:
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
Tekrar yeni bir shell oturumu acarak deneyin, artik calistigini goreceksiniz..
Creating Comet Applications In 3 Minutes Date: March 16, 2008 Tags: comet , javascript , pi Comments(10)
First version of my pi library has been released.This version contains a comet class and you can make comet requests in your applications by using it.Tutorial: Getting unix time from server(Sample File, Source)
Firstly, create an html file and import pi.js:
<script type="text/javascript" src="pi.js"></script>
Then, send a request to push.php to get unix time from server:
var request = new pi.comet();
request.environment.setUrl("push.php");
request.event.push = function(RESPONSE){
document.title = "UNIX TIME AT SERVER: "+RESPONSE;
};
request.send();
Finally, create an infinite loop at push.php, import pi.pushData function to this file and print the data which will be updated each time;
require_once "pi.pushData.php";
$type = $_GET["cometType"];
$name = $_GET["cometName"];
while(true){
pushData(time(),$type,$name);
ob_flush();
flush();
sleep(1);
}
That's all! You can get more information at pi.comet's wiki page.
İleri Seviye Javascript Date: March 16, 2008 Tags: javascript Comments(3)
Birkaç ay uğraşarak az bilinen teknikleri içeren 14 sayfalık bir döküman yazdım.İçerik İndeksi:- Fonksiyonlar
- Diziler
- Objeler
- İleri Seviye OOP
PyWeblog: Simple&Useful Weblog Application Date: March 13, 2008 Tags: django , python Comments(0)
PyWeblog is a Django based open source blog application has written by me.Features:
- Template support (Django contains an advanced template language)
- Django administration interface
- Tagging
- Commenting
- Picture Uploading
Releases:
Installing
- Download latest version and extract anywhere.
- Create a MySQL database to use for this application
- Open settings.py to editing and set DATABASE_NAME,DATABASE_USER AND DATABASE_PASSWORD variables
- Open terminal in where you extracted the files, and type:
>>> python manage.py validate - If manage.py counted zero errors, type this:
>>> python.manage.py syncdb - That's all :)
