Sounds like something that Carol Dweck's ideas (
http://www.aaronsw.com/weblog/dweck) could help with for you, when she talks about fixed mindset versus growth mindset. Right now, it seems like you are looking for present-tense validation from the external -- "I used to be intelligent... but now I'm dumb and worthless. [drawing evidence from criticism of pull requests and a failed interview, which are normal and perfectly natural challenges for someone starting out in their career]" Whereas a more effective way to try to frame your conceptions of yourself and human beings in general may be to take a future-tense inclusive view, where your current challenges are considered as opportunities for your future self to become more skilled and intelligent.
It's natural for intelligent, scientifically-minded individuals to tend towards a fixed mindset, where you create hypotheses about yourself, collect evidence based on your performance on objective measurements, and draw durable conclusions from that evidence. But while this may work for physical laws in physics or chemistry, human beings change and grow in response to stimuli -- so in fact that most intelligent version of yourself possible is the one that overcomes all your current challenges, instead of becoming discouraged by your current inability to overcome those challenges in the past.
There is no need to base your own consideration of your own worth as a human being from your ability to solve interview puzzles or submit code requests. Simply take a vow to yourself to forgive yourself for even your most painful failures. Do not view them as evidence against yourself, proving your adequacy or inadequacy -- instead try to come to view your failures and challenges as stepping stones towards a more skilled future version of yourself. And try to understand that when someone criticizes you, it is because they want to help you improve. That was and still is a difficult one for me.
About your social status -- people tend to take unconscious cues in how they think of someone from how that person views themselves. The goal is not to edit your actions until you have convinced them to like you. (See Bill Murray's character from Groundhog Day.) Instead, once you come to like yourself by finding ways you can be of service to others, and view yourself as part of a greater whole -- in the social scale of as a member of your community, as well as the time scale of past, present, and future you -- the friends and social invitations will come. (Dale Carnegie's book helps too.) To borrow an idea from calculus, try to care more about your dx than your x, and approaching the limit of the best self you can be.
:) I'm sure there will be a lot of other helpful advice given in this thread. If this particular line of thinking appeals to you like it did to me when I went through something similar to what you are going through, feel free to let me know as I have infinitely more links on this from that time in my life.