PHP method chaining

Posted in Crosspost on July 31st, 2010 by Haris Nezirić – Be the first to comment

Method chaining is a really nice technique that adds class methods one on top the other. It’s commonly used in jQuery and some PHP framework modules.

The whole “magic” behind object chaining is made with a single line – “return $this” which is added in each method you wish chain.

So, in order to get this behavior in PHP:

[php]
$human = new Human;
$human->setName(‘Haris’)
->setAge(30)
->setSex(‘male’)
->display();
[/php]

you have to define class(es) like this:

[php]
class Human {

protected $_name;
protected $_age;
protected $_sex;

public function setName($name) {
$this->_name = $name;
return $this;
}

public function setAge($age) {
$this->_age = $age;
return $this;
}

public function setSex($sex) {
$this->_sex = $sex;
return $this;
}

public function display() {
printf(‘Hi, I\’m %s. I\’m %d years old, and I\’m %s!’,
$this->_name,
$this->_age,
$this->_sex
);
}

}

class Man extends Human {
protected $_sex = ‘male’;
}

class Woman extends Human {
protected $_sex = ‘female’;
}

[/php]

Now compare the methods called with method chaining and the old fashioned way

[php]
$woman = new Woman;
$woman->setName(‘Jane’)
->setAge(27)
->display();

$woman = new Woman;
$woman->setName(‘Jane’);
$woman->setAge(27);
$woman->display();

// Hi, I’m Jane. I’m 27 years old, and I’m female!
[/php]

Kompajliranje kernela na Debian-u

Posted in Howto, Linux on June 26th, 2010 by Amar Ćosić – Be the first to comment

Iako Debian, Ubuntu i slicne ‘binarne’ distribucije i nisu bas cest poligon za kompajliranje kernela, ponekad zaista imamo potrebu i za tim. Konkretno ja sam imao potrebu za ovim vec od kad se 2.6.29 poceo pojavljivati po raznim distribucijama. Iako mi kompajliranje kernela nije strano, do sad sam bio previse lijen da to isto uradim i na Debian-u. Ovaj put sam odlucio da to uradim. read more »

Stallman u Sarajevu

Posted in Događaji, Obavještenja on May 13th, 2010 by Haris Nezirić – Be the first to comment

Update: ipak se radi o 2 predavanja. 19-tog i 20-tog

Sarajevo, Bosnia and Herzegovina – IBU conference hall, main building, third floor, Francuske revolucije bb

What
  • RMS Speech
When May 19, 2010
from 11:00 AM to 01:30 PM
Where Sarajevo, Bosnia and Herzegovina
Contact Name events@ibu.edu.ba
Add event to calendar vCal
iCal

Copyright developed in the age of the printing press, and was designed to fit with the system of centralized copying imposed by the printing press. But the copyright system does not fit well with computer networks, and only draconian punishments can enforce it.

The global corporations that profit from copyright are lobbying for draconian punishments, and to increase their copyright powers, while suppressing public access to technology. But if we seriously hope to serve the only legitimate purpose of copyright–to promote progress, for the benefit of the public–then we must make changes in the other direction.

Sarajevo, Bosnia and Herzegovina – IBU conference hall, main building, third floor, Francuske revolucije bb

What
RMS Speech
When May 20, 2010
from 02:00 PM to 04:30 PM
Where Sarajevo, Bosnia and Herzegovina
Contact Name events@ibu.edu.ba
Add event to calendar vCal
iCal

Izvor: http://www.fsf.org/events/aggregator

DebConf11 ipak u Banja Luci

Posted in Linux vijesti on February 28th, 2010 by Amar Ćosić – Be the first to comment

Da, dobro ste pročitali. Najveća Linux konferencija i jedna od najvećih IT konferencija u svijetu će se 2011. desiti u Bosni i Hercegovini. U konkurenciji sa još dva grada Minhen (Njemačka) i Quito ( Ekvador) , Banja Luka je odnjela pobjedu. Zahvaljujući prije svega odličnoj pripremi i organizaciji koju je na sebe preuzeo kolega Adnan ali i vladi RS-a koja će pružiti punu finansijsku kao i pomoć u infrastrukturi, ostala dva grada nisu imala šanse : ). Banja Luka i Bosna i Hercegovina zaista imaju čast da su organizatori nečeg ovako velikog, a ukoliko još niste svjesni značaja jednog DebConf-a , dovoljno je pogledati listu gostiju za npr. DebConf8 koji se desio u Argentini. Zašto ne očekivati neke velike Linux i IT face i u Banja Luci ? : )

DebConf11 Bosnia
DebConf

DebConf11 možda u Banjaluci?

Posted in debconf on February 22nd, 2010 by Haris Nezirić – Be the first to comment

Upravo sam dobio vest da ćemo izgleda biti u mogućnosti posete jednom ozbiljnom FLOSS događaju  u komšiluku, u Banjaluci – Debian Conference, DebConf11 ima velike šanse da se organizuje u Banjaluci.

Zainteresovani mogu da saznaju više na serveru  irc.debian.org  soba #debconf11-bosnia kao i na  http://wiki.debconf.org/wiki/DebConf11/BanjaLuka ili na www.debconf.org i http://velimir.foolcontrol.org/dc11/debconf11_invite.pdf

LUGZDK logo

Posted in Obavještenja on February 21st, 2010 by Haris Nezirić – 4 Comments

LUGZDK udruženje je u potrazi za svojim novim identitetom / logom.

Ovim putem, pozivaju se svi zainteresovani da dostave idejni prijedlog na email “info at lugzdk.org”.

Logo u svom nazivu treba da sadrži slova “LUGZDK”.

Svi prijedlozi će biti objavljeni online na našoj strani a pobjednika će birati članovi udruženja glasanjem.

Pobjednik će biti objavljen na sastanku 10. Aprila 2010. godine.

Dobrodošli

Posted in Obavještenja on February 16th, 2010 by Haris Nezirić – Be the first to comment

Dobrodošli na strane LUGZDK-a (Linux udruženja građana Ze-do kantona).

Na ovim stranama možete pratiti šta naši članovi pišu o Linuxu.

Ukoliko želite saznati više o Open Source pokretu, Linuxu, našem udruženju ili želite da budete dio LUGZDK zajednice, slobodno nam se obratite.