PHPUnit to display function name as it tests

Just a quick tip.

Hope someone will find it beneficial.

 

The logging bit is what I am talking about. It will read the test function name and display.

 

If pass it will show [x] Add action can be accessed for the function public function testAddActionCanBeAccessed(){ … }
Else F [ ]

 

vim – My favorite minimalistic .vimrc configuration

 

Change Django DeleteView behaviour

I am sure CBGV(Class Based Generic View) is a bless and there is a lot to learn and find and learn and find and dig and learn.

Anyway, I was looking for an easy hack to override the DeleteView. Actually I didn’t want to delete the object as it does, instead I wanted to set a flag as deleted for the object.

Django DeleteView calls its function delete(), which is basically this,

So, all you have to do is override delete function and your logic.

Here is an example, I have an appointment model,

When I delete an appointment, it should update the status to ‘deleted’ instead of deleting it.

 

Some useful git aliases

Add the following snippets to your .bash_aliases and make sure .bash_aliases is uncommented in your .bashrc.

 

undefined method `vbguest’ in ubuntu

I am trying for last half an hour to create a basic vagrant box. But I am continuously rejected by saying

undefined method `vbguest’ 

Let me give you a few background of my setup. I was using Ubuntu  12.04 but was tired of their mac looking features. So I installed xfce Desktop. (May be I should have done a clean install of Xubuntu)

Now here I have my box file, I have virtualbox from apt-get. I installed vagrant from apt-get but Lo,

undefined method `vbguest’ 

This is what I did:

I purged vagrant, sudo apt-get purge vagrant

I installed vagrant through ruby gems. sudo gem install vagrant, then sudo gem install vagrant-vbguest.

But now I have two short-cuts for vagrant. In /usr/bin and /usr/local/bin.

The vagrant command is looking in /usr/bin but the working vagrant is in /usr/local/bin.

I went to remove the /usr/bin and create a symlink to /usr/local/bin/vagrant but it removed both.

So I just re-install vagrant from the apt-get and Lo it works fine.

Simple email validation in python

Email validation is lot more complicated than it seems.  A real validation will take this pretty looking regex to implement. 

So here is a very very basic email validation to your rescue,

All it does is checking:

  • must have ‘@’ and ‘.’
  • at least one character before ‘@’ [yes I know about the '_', as I said, its very basic]
  • at least one character after ‘@’
  • at least one character after ‘.’

Interview questions for pyton and php programmers

I have been using this format for my interviews previously and it greatly helped me.
Since I am trying to create a new blog, I was thinking of publishing something that will have some use for programmers. So I am sharing my interview checklists. Hope that will help you all.

  • Tell me about yourself
    • Team player
    • Self motivated
    • Enjoy learning and sharing
    • Pragmatic
    • Social
  • What do you enjoy most in your current job
    • Coding kata   
    • Book club  
    • Technical Presentation
  • What’s the biggest challenge you’ve faced in your work
  • Why do you want to leave your current job
  • What is your present boss like
    • Good forecasting
    • Innovative  
  • Why do you think you are best match for this job
  • What do you know about our company
  • What can you bring to the company
    • Agile
    • TDD
  • How long  do you expect in stay in the company
    • Progress
    • Contribution
  • What are your greatest strengths
  • What is your biggest weakness
  • Where do you see yourself in five years time
    • Keep progressing to senior role
  • Give me an example of a difficult team situation you had to deal with
  • Give me an e xample of a product or concept you found hard to understand
  • Give me an example of something you are very proud of
  • Give me an example of a change or improvement you made to development or testing processes in your organisation
  • Give me an example of a time you performed well in a team
  • Give me an example of a time you showed initiative
  • Give me an example of a time you demonstrated creativity
  • Give me an example of a time when you demonstrated leadership
  • What is the most challenging piece of work you have undertaken and why? What were the challenges and how did you overcome them?
  • Aside from your day to day project work have you made a broader contribution to the technical advancement of your team as a whole?
  • What new technology, either inside or outside of work, do you find most exciting and why?
  • Why are you interested in the role?
  • What aspects of the role interest you the most?
  • What can you offer us?
    • I have great energy going through complicated problems
    • I am a great team player
    • I love playing with new technology and sharing
    • I assure best practice in working

Python Topics:

  1. Python ?
  2. Property, http://adam.gomaa.us/blog/2008/aug/11/the-python-property-builtin/
  3. Data structures http://docs.python.org/tutorial/datastructures.html (list,tuples, set, dict)
  4. File processing http://docs.python.org/library/stdtypes.html#file-objects
  5. Exception handling http://docs.python.org/tutorial/errors.html
  6. Itertools http://docs.python.org/library/itertools.html
  7. Iterators http://www.learningpython.com/2009/02/23/iterators-iterables-and-generators-oh-my/
  8. Generators http://wiki.python.org/moin/Generators
  9. Decorators, http://www.artima.com/weblogs/viewpost.jsp?thread=240845
  10. @classmethod vs @staticmethod http://stackoverflow.com/questions/136097/what-is-the-difference-between-staticmethod-and-classmethod-in-python
  11. List comprehension vs generator expression
  12. Builtin functions (http://docs.python.org/library/functions.html )
  13. Special method
  14. Function as first class object http://en.wikipedia.org/wiki/Function_object#In_Pythonhttp://blog.benchside.com/2010/02/treating-python-functions-as-first-class-objects/
  15. Lambda http://www.secnetix.de/olli/Python/lambda_functions.hawk
  16. Testing
  17. Debugger (pdb)
  18. Multiple inheritence
  19. Multi-threading vs Multi-processing
  20. Re
  21. Setup script, http://docs.python.org/distutils/introduction.html#distutils-simple-example
  22. Glossary http://docs.python.org/glossary


Django Topics:

  1. Django design philosophy, https://docs.djangoproject.com/en/dev/misc/design-philosophies/?from=olddocs
  2. New features
  3. Django ORM (query especially)
  4. admin.py, manage.py
  5. Django settings
  6. URL dispatcher, https://docs.djangoproject.com/en/1.3/topics/http/urls/
  7. Reverse
  8. Reverse url matching
  9. Model manager
  10. Caching, https://docs.djangoproject.com/en/1.3/topics/cache/
  11. Abstract  base class, https://docs.djangoproject.com/en/dev/topics/db/models/#abstract-base-classes
  12. ORM limitation, stored procedure
  13. User profile
  14. Signal, http://www.chrisdpratt.com/2008/02/16/signals-in-django-stuff-thats-not-documented-well
  15. How djagno process a request
  16. Request and response
  17. Fixtures
  18. Generic view, https://docs.djangoproject.com/en/1.3/topics/class-based-views/
  19. Middleware, https://docs.djangoproject.com/en/dev/topics/http/middleware/
  20. MVT
  21. URL patterns/ URL Naming/ URL template tag
  22. Template, model and table inheritance
  23. Internationalization
  24. Forms
  25. Test framework, https://docs.djangoproject.com/en/1.3/topics/testing/


Programming Architecture:

  1. Dependency injection
  2. Separation of Concern 
  3. Single Responsibility Principle  
  4. Design patterns  http://ginstrom.com/scribbles/2007/10/08/design-patterns-python-style/
    1. singletone
    2. factory
    3. decorator
    4. observer
    5. template
    6. State
    7. Iterator

Others from CV:

  1. scrum-ban
  2. rabbitmq
  3. celery
  4. fabric
  5. OOC in java script
  6. load balancer


More Questions:


CSS questions:

  1. http://dev.fyicenter.com/Interview-Questions/CSS/index.html


Javascripts questions:

  1. http://www.techinterviews.com/javascript-interview-questions-and-answers
  2. http://vikasrao.wordpress.com/2010/02/07/common-javascript-interview-questions/
  3. http://www.evotech.net/blog/2007/05/web-developer-interview-questions/
  4. http://dev.fyicenter.com/Interview-Questions/JavaScript/What_is_negative_infinity_.html


Mysql questions:


PHP questions:


Programming Exercise:

  1. prime number
  2. factorial
  3. fibonacci

Unable to connect to node rabbit@

My whole day spent by doing http://tinyurl.com/63mlku8
I have updated my Perl5, updated Erlang. Re-installing Rabbitmq etcetra etcetra.
But at last I found a work around to get my Rabbitmq working yet know idea why it has happened in the first place.

Try locating schema.DAT and remove.
Restart your computer and here you go.

locate scheme.DAT
sudo rm -rf schema.DAT

Hope that helps.

Clean up deleted remote branch in GIT

Suppose you have multiple users working on the repo and a user has deleted some unused branches. The other user might still be able to see the remote branches using git branch -r, which is unexpected.

To clean up deleted remote branch use git remote prune origin, the code will delete all stale tracking branches under origin.

Also some other important command for pruning:
git gc --prune=now, gc works as defragment for git files
git remote rm origin, Remove the remote named . All remote tracking branches and configuration settings for the remote are removed.

Installing mysql for python throws mysql_config not found

I am just re-inventing the wheel here. I had this article on this site but the previous hosting was expired and my database file was corrupted, so I had to do this again. And I also know at least one person will be looking for that information soon, so I am contributing to the community again in some simple steps,

    Download the latest version of MySQLdb
    Locate mysql_config locate mysql_config
    Open site.cfg and update mysql_config path
    Run sudo python setup.py build
    Run sudo python setup.py install

Now if you import MySQLdb in your python CLI it should just work fine. Let me know if you still have some problem. I will try to reshape my reinvented wheel.