Rent has gone up significantly in the past year or two. Especially in the city (SF). If you're trying to keep expenses down, find as cheap as possible (while livable) studio or room up with roommates. Otherwise rent can be quite expensive if you never lived in this area. The best way you can see how much rent costs for the conditions of the places is to just browse through craigslist for a feel (it'll be better than any numbers I throw out here).
San Francisco: http://sfbay.craigslist.org/sfc/apa/
Peninsula which includes Silicon Valley: http://sfbay.craigslist.org/pen/apa/
Best places to live are San Francisco or Palo Alto. If you can't afford either, live in nearby cities. Mountain View is a great alternative to Palo Alto that is more affordable.
Having said that, if you're willing to commute via public transit or by car, it matters less. Just be aware rush hour can be brutal between SF and the Valley.
There are a TON of events both in the valley and in SF. For language specific events/meetups, most of the better ones are in the city i.e. python meetup, php meetup, etc... For hacker mixers and various other speaking events, those are more in the valley. There are usually some sort of event happening at Microsoft and Google as well that you can look out for including GTUG at Google.
The best way I find events outside of people sending me links or what not is to join meetup groups via meetup.com, join the StartupDigest email list, join Plancast and follow people/friends, and browse Eventbrite.
Once you're here, you'll be plugged into more private events and stuff as well, that aren't found in the above.
Hope that helps.