Alagu's Personal Weblog
 

Pattern troubles

Not every code is written right. Sometimes it turns out good if you are experienced. First timers learn and refine.

Patterns
Courtesy: walkadog

When you get better, you find patterns. You see them happening again and again, and you make a pattern out of it. Your new pattern is extremely awesome, it is capable of even encapsulating the whole world. Then it gets simple, not. You have to map your old house inside the world, and there isn’t one house. Everything can be corrected, but it takes time and patience which I lack.

If only I could regex everyone back to where they belong to or rather design better patterns.

PS: I thought I forgot my password for my blog. After a few attempts, I got it right

Comments off

Thanks for no plastic

Whenever I say “No need for plastic bag” or “No need for straw” they shopkeepers say “Thanks!”. I likes.

Comments

1 Y!ear

I complete one year at work today! Let me jot it in teemus’s style

learnt a lot . met rasmus. great friends as teammates. shout. cubicle cricket. foosball. cycling 2 office. football. php. pecl. pool. trekking. inox movies. snacks (order). jump. hide & seek. brigade road shopping during office hours. mash. night outs. brindavan hotel. DC vs RCB IPL T20 with team. yblr. emiblr. hackdays. ubuntu. vim. self-cooking. ycore movies, t20. openhackday. unsolicited deal proposal fossconf. #linux-india. vegpuff. missed foss.in. barcamp. bcb. brtff . ymi. tintin. twitter. mokkai. june25.

I am lucky :)

Comments (4)

Know your Opcodes

Gopal says,

PHP programmers don’t really understand PHP.

They know how to use PHP - but they hardly know how it works,
mainly because it Just Works most of the time.

Very true. A level of abstraction is important for the programmer to concentrate on the logic, than handling cases for memory leaks and socket connections. With that said, it is equally important to know what is being done to the code to give the output.

PHP Code is compiled to Opcodes (like instruction codes) and instruction stack is processed. To see your opcodes, you need pecl/vld. Download it, compile it. For compiling, you might need the php-dev package. In ubuntu, php5-dev is the package name. To install :
$ phpize; ./configure; make; sudo make install
It puts the ‘vld.so’ shared object in your php-lib folder. Check whether vld is installed:
$ php -d extension=vld.so -m
Above command should list all the loaded modules, alongwith vld. Now, try it out :

$ cat test.php
<?
define('MY_BLA',42);
echo MY_BLA;
?>
$ php -d extension=vld.so -d vld.active=1  test.php
Branch analysis from position: 0
Return found
filename:       /tmp/test.php
function name:  (null)
number of ops:  7
compiled vars:  none
line     #  op                           fetch          ext  return  operands
——————————————————————————-
   2     0  SEND_VAL                                                 ‘MY_BLA’
         1  SEND_VAL                                                 42
         2  DO_FCALL                                      2          ‘define’
   3     3  FETCH_CONSTANT                                   ~1      ‘MY_BLA’
         4  ECHO                                                     ~1
   5     5  RETURN                                                   1
         6* ZEND_HANDLE_EXCEPTION

That gives a lot of opcodes! (Remember 8085?) All these opcodes are C macros .

For now, have a look at opcodes for your code and see how you can optimize your it until I come back with the next.

Comments (1)

Spoil your kids, please

Your children are not your children.
They are the sons and daughters of life’s longing for itself;
They come through you but not from you.
You may give them your love but not your thoughts,
For, they have their own thoughts.
You may house their bodies but not their souls,
For their souls lie in the house of tomorrow,
Which you cannot visit,
Not even in your dreams!

If you reached here after reading the quote, I appreciate your patience :)

I read the above lines in Hindu’s Open page. For a moment, it stuck like a lightning. Kahlil Gibran has given straight forward opinion for the parents and students who are victims of the current educational system (Including me).

Taare Zameen Par expressed how parents attribute everything with success. Things are forced upon them or rather they are made to think that what their parents think is the best choice, forcing the kid do what the parent failed to do as a kid, forcing them to walk exactly on their footpath and a lot more.

Being first in rat race may be appreciated by other rats, but what matters is how the person relates the success .

Being able to do is different from wanting to do. Do what you want to do, and show middle finger for the rest.

Comments (9)

« Previous entries
I work at Yahoo! - the opinions expressed here are my own, and neither Yahoo! nor any other party necessarily agrees with them.