This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Put this filter early in your filter chain so it can initialize and clean up | |
// the cache | |
object CacheFilter extends Filter { | |
def apply(next: RequestHeader => Future[Result])(request: RequestHeader): Future[Result] = { | |
def init = RestClient.initCacheForRequest(request) | |
def cleanup = RestClient.cleanupCacheForRequest(request) | |
// You have to be very careful with error handling to garauntee the cache gets cleaned | |
// up, or you'll have a memory leak. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
At this very moment, somewhere in the world, two programmers are sitting in a garage and creating our future, one line of code at a time. We are in the era of the high tech startup. | |
This book is the "Hello, World" tutorial for building products, technology, and teams in a startup environment. It's based on the experiences of the author, Yevgeniy Brikman, as well as interviews with programmers from some of the most successful startups of the last decade, including Google, Facebook, LinkedIn, Twitter, GitHub, Stripe, Instagram, AdMob, Pinterest, and many others. | |
If you're at all interested in startups—whether you're a programmer at the beginning of your career, a seasoned developer bored with the politics of large companies, a manager trying to figure out how to motivate your engineers, or just someone trying to figure out what this startup thing is all about—this book is for you. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hello there! I'm Yevgeniy (Jim) Brikman. I'm a programmer, writer, speaker, and traveler. You can find me on Twitter (@brikis98), LinkedIn (linkedin.com/in/jbrikman), Blogger (http://brikis98.blogspot.com), and my Homepage (ybrikman.com). | |
I got my BS and Masters in Computer Science at Cornell Unitversity, started my career at several big companies (Cisco Systems, Thomson Financial), and then made the jump into the startup world (LinkedIn, TripAdvisor). Along the way, I got the chance to work on enterprise products, hiring tools, scalable infrastructure, company culture, engineering branding, travel apps, VoIP software, innovation programs, and much more. | |
I wish I had a book like "Hello, Startup" back when I was in college. By the time I graduated, I had a BS, a Masters, a bunch of internship experiences—and absolutely no idea what I was doing. What technologies should I learn and use? Why should I spend time writing automated tests? How do I build a user interface that doesn't look terrible? How do I get pe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Once you go from storing data on a single server to multiple servers, | |
you are dealing with a _distributed system_. All distributed | |
systems are subject to the CAP theorem, which states the following: | |
[quote, '[<<cap-theorem-2014,CAP Theorem 2014>>]'] | |
____ | |
It is impossible for a distributed computer system to simultaneously | |
provide all three of the following guarantees: | |
. Consistency (all nodes see the same data at the same time) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[quote, '[<<collins-porras-2004,Collins Porras 2004>>]', 'Jim Collins and Jerry I. Porras, _Built to Last_'] | |
____ | |
If you woke up tomorrow morning with enough money in the bank that you would | |
never need to work again, how could we frame the purpose of this organization | |
such that you would want to continue working anyway? What deeper sense of | |
purpose would motivate you to continue to dedicate your precious creative | |
energies to this company's efforts? | |
____ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
main() | |
{ | |
printf("Hello, Startup"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Dear maintainer: | |
// | |
// Once you are done trying to 'optimize' this routine, | |
// and have realized what a terrible mistake that was, | |
// please increment the following counter as a warning | |
// to the next guy: | |
// | |
// total_hours_wasted_here = 42 | |
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Returns the number of key-value mappings in this map. | |
* | |
* @return the number of key-value mappings in this map | |
*/ | |
public int size() { | |
return size; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def asyncResult = { | |
//#async-result | |
import play.api.libs.concurrent.Execution.Implicits.defaultContext | |
def index = Action.async { | |
val futureInt = scala.concurrent.Future { intensiveComputation() } | |
futureInt.map(i => Ok("Got result: " + i)) | |
} | |
//#async-result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Returning futures | |
While we were using the `Action.apply` builder method to build | |
actions until now, to send an asynchronous result we need to | |
use the `Action.async` builder method: | |
@[async-result](code/ScalaAsync.scala) |