Yii::app()->controller->action->id //current action name Yii::app()->controller->id //current model name Yii::app()->controller->pagetitle //page title
casualprogrammer
poniedziałek, 12 grudnia 2011
[Leraning Yii] How to get current page title, current action, and current model ?
środa, 7 grudnia 2011
[Learning Yii] Find by ID - One to rule them all
Yii is fun. If you understand it. I try to understand it everyday, so I will write about it from time to time.
How to get only 1 result from any table in your project using ID?
NameOfTable::model()->search criteria->columne nameex:
TestPack::model()->findByPk(1)->name //means: in table TestPack find row with id 1 and show it's nameFun starts, when you need to do more complex requests - then you can chain requests:
TestPack::model()->findByPk(Test::model()->findByPk($_GET['id'])->test_pack_id)->name
piątek, 2 grudnia 2011
How to change MAC address under Linux Debian Squeeze
Changing MAC address should be easy, and it almost is. There are plenty of methods. I like this one - it will work for simple LAN configuration with DHCP, for one session. There is also simple modification to make it permanent. If it will work for WLAN - I have no idea.
In Debian there is something called Networking Manager. Networking Manager, automagically manages your network. So if you want to change MAC addres for card, you must first disable Networking Manager for this card . To do so:
- Open /etc/network/interfaces<
- Uncomment
iface eth0 inet dhcp
- Add line
auto eth0
- Save
Be sure that Networking Manager doesn't remember about your card and reboot or do:
$ /etc/init.d/network-manager stop $ /etc/init.d/network-manager start
Now you are ready to change MAC address:
$ ifdown eth0 $ ifconfig eth0 hw ether 01:02:03:04:05:06 $ ifup eth0
If you want to revert to your original MAC address you have to repeat commands, giving your real MAC or reboot computer. I didn't find any method for restoring MAC to original state, without wiritng it again. If you know one, let me know.
Make it permanent
If you want to change MAC for longer than just one session in /etc/network/interfaces add another line, to stated above, under last line:
hwaddress ether 01:02:03:04:05:06
Macchanger
There is also program called macchanger, which does the same, but in one line. It's OK, but it still doesn't have option to restore real MAC address.
wtorek, 22 listopada 2011
HTML5 local storage in browser vs cookie
localStorage.setItem("name_of_item", your_data)To read from local storage:
your_data = localStorage.getItem("name_of_item")If you want to keep some data only for current session, use:
sessionStorageinstead of
localStorageBtw. everything you put into storage, will become string. If it doesn't want to fit - make it string.
Good tutorial about PHP objects, classes etc.
poniedziałek, 31 października 2011
How to convert to 8-bit 256 palleted png using php imagick
$thumb->setImageType (4); //sets to 256 colors
$thumb->setImageFormat('png');
$thumb->setImageDepth('8'); // :)
$thumb->setImageCompressionQuality(90); //u can try also 95
$thumb->writeImage('temp.png');