środa, 3 września 2014

CPU access in NOT like File Access

Yesterday on a meeting, someone mentioned, that CPU is like File access, that if we have ex: 4 threads system. Having 2 processes accessing the all 4 threads would be on first-come-first-serve basis.
That first process will utilize almost 100% CPU power (will be resource hog). Resulting huge overhead.

That is not the case.

Modern CPU's are very efficient in switching between threads.
The CPU time (computation time) of both processes would be divided almost equally.
The computation time of each processes would be ca. twice slower. Than running them separetly.
The total computation time of both processes would be (almost) equal to time of running them sequentially.

So CPU access in nothing like File Access

BTW: Modern kernels also can give multiple file descriptors so even File access would not be on first come-first-serve-basis

It all would be ok, I mean, all people can have false assumptions, but the person stating such bologna is Head of IT Unit :(...

Further reading:

środa, 16 lipca 2014

brack.ch never again

brack.ch never again... they just sold me used phone as a new one. I start the phone.. and what do I see? A naked picture of previous owner :D ... together with his Hotmail account, and a friends list... :( What is more disturbing that the shop representative did not care at all. Apparently I'm supposed to send the phone on my cost to some 3rd party shop, and they will allow me to buy other things on theirs website up to phone cost.

czwartek, 28 marca 2013

Choosing Framework for your business

Wich framework would be best to build company on? This graphs may help deciding. We can see that due to extensive commercial support 'Play'(blue) is really quickly closing gap to 'Spring Java'(yellow). 'Ruby on Rails'(purple) stays 'the coolest' framework, and 'Zend Framework' basically kills 'Symfony Framework'(green) play frameworkzend frameworkspring framework200520072009201120...2020404060608080100100

wtorek, 12 lutego 2013

Recracforing To Command Pattern

//usage of command pattern to refractor big or overloaded methods
//Gigantic classes with hard to change methods
class Wrong_Customer {
    var  $_age;
    var $_bill;
    var $_man;
    function __construct($age, $bill, $man) {
        $this->_man= $man;
    //addind discount will require modyfy other classes
    //new calculation devices requre to chenge methods
    function returnFinalBill() {
        if($this->_age >60) { $discountPercent +=0.10;}
        if(!$this->_man) { $discountPercent +=0.20;}
        $bill = $this->_bill*(1-$discountPercent);   //100%=1
        return ("Wrong Customer Bill Amount: $".$bill."
"); } } interface BillPlayer { //based on sex how to calculate bill public function calculateBill($amountDue); } interface Command { //methods that change function executeCalculateBill($amountDue); } class WomanOver60 implements BillPlayer { public function calculateBill($amountDue) { return "Bill Amount for Woman over 60: $".($amountDue*(1-0.30))."
"; } } class ManOver60 implements BillPLayer { public function calculateBill($amountDue) { return "Bill Amount for Man over 60: $".($amountDue*(1-0.10))."
"; } } class ManUnder60 implements BillPLayer { public function calculateBill($amountDue) { return "Bill Amount for Man under 60: $".($amountDue)."
"; //no discount } } class Waiter implements Command { //Comander var $_billPayer; function __construct(BillPlayer $billPayer) { $this->_billPayer=$billPayer; } function executeCalculateBill($amountDue) { return $this->_billPayer->calculateBill($amountDue); } } class CashRegister { //invoker from command pattern, execute diferent methods based onobject type passed //return final bill //_Waiter diferent weiters, !adds flexibility! //stores Command's var $_command; function __construct(Command $command) { $this->_command=$command; //all things that implements command //like waiters } function returnFinalBill($amountDue) { return $this->_command->executeCalculateBill($amountDue); } } // more flexebility - only one thing to change for adding bill Payers class CustomerTypePicker { //if u want NEW bill payer tpe goes here!!! static function getManOver60(){ return new ManOver60(); } static function getManUnder60(){ return new ManUnder60(); } static function getWomanOver60(){ return new WomanOver60(); } } //adding customer group for easier to menage diferent customers class CustomerGroup { private $_customers=array(); function __construct($customers=array()) { $this->_customers = $customers; } function getCustomer($index) { return $this->_customers[$index]; } function addCustomer(BillPlayer $customer) { return $this->_customers[]=$customer; }//TODO deleteCustomer } class Main { function __construct() { $wC = new Wrong_Customer(70, 100, false); //woman Over 60 echo $wC->returnFinalBill(); } function testCommandOnWomenOver60() { $picker = new CustomerTypePicker(); $sally = $picker::getWomanOver60(); $waiter = new Waiter($sally); //sallysWaiter $bill = new CashRegister($waiter); echo $bill->returnFinalBill(100); } function testCommandOnManOver60() { //NOW better groups customers to array $picker = new CustomerTypePicker(); $bob = $picker::getManOver60(); $waiter = new Waiter($bob); //sallysWaiter $bill = new CashRegister($waiter); echo $bill->returnFinalBill(100); } function testCustomerGroup() { $picker = new CustomerTypePicker(); $customerGroup = new CustomerGroup(); $sally = $picker::getWomanOver60(); $customerGroup->addCustomer($sally); echo $customerGroup->getCustomer(0)->calculateBill(100); } } $run = new Main(); $run->testCommandOnWomenOver60(); $run->testCommandOnManOver60(); $run->testCustomerGroup();
Java implementation here: http://www.newthinktank.com/2013/02/code-refactoring-13/

poniedziałek, 7 stycznia 2013

Advertisement hell

środa, 11 stycznia 2012

Pesky FACEBOOK adds

How to remove advertisement from facebook?
*install AdblockPuls from page http://adblockplus.org/en/

*add filter "###pagelet_ego_pane_w"
*add filter "#div(ego_section)"

or even better:
*add filter ###pagelet_ego_pane
*add filter ###pagelet_ego_pane_w
*add filter #div(ego_unit_container)

*done. Annoying ads are now blocked!

Why we do that? There may be many reasons ex. low bandwidth connection.
If u want i may also present filters for ads for most important sites.

Edited 12.01.2012: for new Facebook ads

czwartek, 15 kwietnia 2010

Virtualne maszyny Linux przez przegladarkę

1.W pracy/biurze często strony typu youtube sa filtrowane.
Co zrobic?
2.Często mamy jakąś aplikację i chcemy ja przetestować - czemu nie na zdalnym wirtualnym serwerze.

Odpowiedzią jest wirtualny komputer dzialający przez okno przeglądarki: