at 9:21 PM

Get site ranking with python and beautifulsoup

To get information about site, we can use alexa.com but sometimes we just need some pieces of information like ranking of site global or local country.
In this case i just need that information, when i looking on alexa i found so many information about the target site.
I have some knowledge about python and beautifulsoup library and i try to grep that information with them.

First time i analyzing structure of page of alexa.com, find element of html tag which contains the data.


at 6:00 PM

Newbie using gnuchess

Hari ini tepatnya dini hari tadi, pas ketika lagi bete ngoding akhirnya browsing-browsing ga jelas vi Chromium tapi ternyata internet sangat lambat, karena koneksi IX dari kantor lagi kacau, buat ngebuka satu google.com aja lama banget, tapi yang aneh buka situs Indonesia juga lambat banget, yah.. tingkat keboringan jadi meningkat gara-gara ini

Akhirnya buat ngilangin bosen dari browsing ane main catur, pas nyari di Games ternyata belum ada tuh caturnya,, dengan berat hati (karena koneksi lagi kacau) akhir nginstall via apt-get meski agak lama akhirnya gnuchess sukses dengan gemilang terinstall.

Seperti biasa ketika jalanin aplikasi ane pencet ALT+F2 trus ketik gnuchess  dan dengan penuh semangat kelingking ane menekan Enter and... ga ada muncul apa-apa?? Trus coba lagi dengan metode yang sama, ternyata ga muncul apa-apa juga... Ok its time to googling.. ternyata gnuchess itu cuma engine nya doang, kalaupun ada tampilan ini juga sangat-sangat sederhana sekali.. like this screenshot
at 6:18 AM

php: array_key_exists or isset

I know array_key_exists is a function and isset is a keyword, later, i think array_key_exists and isset in PHP is a same or array_key_exists is shortcut for isset. But when i read  on php manual, there is no document that explains that it is the same or related, so i try to look in php source code, and i got the same answers.
In my mind, array_key_exists is like that :)
boolean array_key_exists (key, arrayName) {
    return isset(arrayName[key]);
}

at 4:31 PM

Default value for return

A few days ago, i try to create a code with PHP, with a function i do a return in function with some values and then i got a mystery about default value for return keyword, to get absolutelly value with this keyword i create a function to test it, like this.

<?php
function defaultValueForReturn(){
   return;
}// now i test it
var_dump (defaultValueForReturn());  ?>

And this is result:


What about with other programming language such as Python, Javascript, etc.
Check this!
at 8:08 PM

Using keyword as method in PHP

As we know, we can't use keyword like if, while in common language programming as function, method or variables, neither does in PHP Programming. Last time, i agree with this condition, but when i learn about Object Oriented Programming i found a way how to make this is possible, i've got a trick how to make keyword as a method or function (as a variable we can do that easily) in PHP Programming.

How to do that?
In PHP Programming there a feature in OOP, as known as with magic method, with this feature we can do a "magic" in PHP. For completed information about it you can click that link.


Keyword as Function.
at 12:00 AM

PHP: Menghitung lama eksekusi sebuah skrip

Untuk apa menghitung lama eksekusi sebuah skrip? Alasan utama adalah performance dari skrip yang dibuat, hal ini bertujuan untuk membandingkan fungsi yang akan digunakan sehingga losstime bisa dikurangi. Dalam pemrograman PHP bisa dilakukan dengan mengambil nilai fungsi microtime(), tentu saja ditambahkan parameter boolean bernilai true agar nilai yang dikembalikan adalah float, karena jika tidak ada parameter yang diberikan maka nilai return dari fungsi ini adalah string.
at 8:12 PM

How to fill constant with array in PHP

Create a constant variable in PHP so easy, we can use keyword define, followed by name of constant and constant value, or we can adding once more argument (boolean true) to identified that is incase-sensitive, like this:

define ('NAME', 'value of constant');
echo NAME; //output value of constant;
echo Name; //output value of constant with somes notice

define ('OK', 'its ok', true);
echo OK; // output its ok.
echo oK; //output its ok, there are no problem here.