Years of work. I networked my ass off for years. Hackathons, developer meetups, etc.
I probably would have had trouble finding projects if I decided to do contracting when I moved to the Bay Area right away.
For my first few projects, my rate was really low. It was meant to help friends out and get to work on high-profile projects. Some of the companies I have worked for ended up doing YC or raising seed/VC money.
I never had to do cold-emails.
I live in the Bay Area though where there are a lot of companies looking for somebody to build their Android app.
What's great with the network though is that I never had to negotiate rates since there's already some trust established.
Those who found me through LinkedIn though seem to negotiate a lot with rates which can be a pain.