Wednesday, January 25, 2012

Algorithm which runs in brain of every girls !

while(girl is unmarried)

 best_friend=friends.pop()
 
 if best_friend is better than boyfriend //better contains (richer,taller,handsome,owns better vehicle,caring etc)
  temp =boyfriend
  boyfriend = best_friend
  free(temp)
 end
 
 for(i=0;i< depends on mood of girl ; i++)
  friend =select(one candidate friend from corpus of eligible males)
  friends.push(friend)
 end
 
end

Dedicated to XX chromosomes !!

Monday, June 27, 2011

Net::SMTPAuthenticationError (504 Authentication mechanism not supported.)

Reason:
Reason for this error is that your server is not supporting the authentication type which your are choosing.
e.g. :authentication => :plain is not supported.

Solution 1:
  • Try changing :authentication => :plain --------> :authentication => :login
Solution 2:
  1. Goto: Settings ->Protocols -> SMTP
  2. Go to tab "RFC Compliance"
  3. Check "Allow plain text authentication" (You can check one or more options according to your requirements)
  4. Now try sending an e-mail
Cheers

Keywords: Actionmailer, ruby,rails, smtp, 504, plain, login, email, hmail,

Thunderbird: Configuration could not be verified - is the username or password wrong

Solution:
  1. Goto "%APPDATA%\Thunderbird" (without quotes)
  2. Delete everything in this folder(Better you cut and paste everything to some other location)
  3. Start Thunderbird
  4. Create a new account
  5. Now it will work

Cheers

Keywords: thunderbird, email, smtp, hmail, server,email-client



Thursday, December 23, 2010

Intel Interview Questions

Here are the Questions which I was asked By Intel.

  1. Reverse a singly linked list in order O(n).
  2. Write a code to check if a given string is palindrome.
  3. Buy 100 lappies (anything) in Rs. 100, given lappyA price is Rs 5 per lappyA , lappyB price is Rs 1 per lappyB, lappyC price is 5 paise per lappyB. Find out quantities of each of lappyA, lappyB, lappyC.
  4. There is a 100 steps stair. One can either take one step at a time or 2 steps at a time. Find out the number of ways of reaching to the top. [Hint: take one step stair, then 2 steps, 3,steps, n try to find out pattern or formula.]
  5. Find trailing number of zeros in factorial of 1947 (1947!).
  6. Read a file and if you find L1 and L2 as consecutive lines then print previous 100 lines including L1 and L2.
  7. What do you understand by OOP (object oriented principles) i)implement oop in c
  8. Super structure: implement a super structure which can behave like both stack and queue using liked list. Try to make enqueue,dequeue,push,pop in O(1)
  9. Shuffle an array of length n in one traversal.
  10. How you can generate a pseudo random number mathematically [i couldn't ans this]
  11. Difference b/w process and thread
  12. fork().
  13. What do you understand by "Singleton class". Implement it.
  14. Design a Library database.[Don't take design question lightly]
  15. Questions related to job scheduling and threading.
  16. Question related to Mutex. I don't remember exact question but if you have a little knowledge of Mutex you will be able to solve it.

Note: I was supposed to find out the logic first then I was asked to code that logic in language of my choice. So just Knowing logic is not enough one must practice a little to code on paper before going to any such interviews.

These questions has been asked in several rounds of interview which I went through before getting into INTEL :)

Answers to most of the questions are available on internet.

But still anyone wants to know the solution of any of question he/she can contact me directly.


Friday, August 27, 2010

Vi commands .... which make life easy !!

Here I will put some really handy vi short-cuts. I am putting only those vi commands which a newbie can remember quickly and start using vi from now-onwards.

Note: Do not forget to press "Esc" first and the start following commands.

1) [n]dd :: Pressing 'dd' will cut the current line. If you press say '2dd' it will cut two lines.

2) [n]yy :: Pressing 'yy' will copy the current line. If you press say '2yy' it will copy two lines.

3) p :: Pressing 'p' (small p) will paste the copied/cut line(s) starting from the next line with respect to cursor.

4) [n]<< :: Pressing '<<' will shift current line by one tab. If you press say '2<<' it will shift the two lines counting from the current line(inclusive).

5) [n]>> :: Same as '4' but it will shift right.

6) /guru :: Pressing '/' then typing the text to search will search the text you have typed. But this search is case sensitive.

7) :set ignorecase :: To make you search case insensitive. Now onward you all searches will be case insensitive.

8) :set noignorecase :: To reset the '7' to case sensitive.

9) uu :: Pressing 'uu' will undo you last change. But if you keep pressing 'uu' several times it will keep redoing in reverse order of changes you have made.

10) Ctrl + r :: Pressing 'Ctrl+r' will do redo work for you.

11) ZZ :: Pressing 'ZZ' is same as ':wq'

12) D :: Pressing 'D' will delete current line starting from the cursor position to end of line. All text behind the cursor will remain as it is.

13) R :: Pressing 'R' will take you into replace mode. Meaning if you type over some text it will replace that text with letters you have typed.


Keywords:: vi cheats, vim cheats, vi commands, vi commands cheat sheet

Wednesday, August 11, 2010

Setting Virtual Host on Linux (Ubunut 10.04 -Lucid Lynx)

Here I am going to describe very briefly how to set up virtual host on apache2 on Ubuntu 10.04
Step 1: Create a your own folder lets call it 'myproject'. Create a simple html file inside this folder

Step 2: Go inside 'myproject' and create a file 'index.html' and put following code in this file

‹ html ›
‹ body ›
It works !!
‹/body ›
‹/htm ›

commands:
> mkdir myproject
> cp -r myproject /usr/share/doc/
>sudo ln -s /usr/share/doc/myproject /var/ww/myproject

Now at this point of time you have created a test to check if your virtual host setting is working fine or not

Step 3: creating virtual host
>sudo vi /etc/apache2/sites-enabled/000-default
Now add following lines in this file
--------------------------------------------------
VirtualHost *:80
ServerAdmin xyz@gmail.com
DocumentRoot "/var/www/myproject/"
ServerName myproject
‹/VirtualHost
--------------------------------------------------
Step 3: >sudo /etc/init.d/apache2 restart
Step 4: >sudo vi /etc/hosts
and add following lines in this file
-------------------------------------------
127.0.0.1 myproject
yourIP myproject
--------------------------------------------
Step 5: Set no proxy for 'myproject'

Step 6: Open http://myproject

If any php script present is myproject folder is not working add following line in virtual host setting file

LoadModule php5_module /usr/lib/apache2/modules/libphp5.so

So your final Virtual host setting will look like as follows
--------------------------------------------------
VirtualHost *:80
ServerAdmin xyz@gmail.com
DocumentRoot "/var/www/myproject/"
ServerName myproject
LoadModule php5_module /usr/lib/apache2/modules/libphp5.so
‹ /VirtualHost

--------------------------------------------------

For any doubt feel free to ask !!