<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Andrew Conner on Medium]]></title>
        <description><![CDATA[Stories by Andrew Conner on Medium]]></description>
        <link>https://medium.com/@andrewconner?source=rss-c423382a3121------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*MlPxs1W3lJIiz6A03hR9Qw.jpeg</url>
            <title>Stories by Andrew Conner on Medium</title>
            <link>https://medium.com/@andrewconner?source=rss-c423382a3121------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 05:37:27 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@andrewconner/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Route binding custom classes in Play! Framework]]></title>
            <link>https://medium.com/kifi-engineering/route-binding-custom-classes-in-play-framework-c6921cfe83c2?source=rss-c423382a3121------2</link>
            <guid isPermaLink="false">https://medium.com/p/c6921cfe83c2</guid>
            <category><![CDATA[play-framework]]></category>
            <category><![CDATA[scala]]></category>
            <dc:creator><![CDATA[Andrew Conner]]></dc:creator>
            <pubDate>Fri, 13 May 2016 00:44:36 GMT</pubDate>
            <atom:updated>2016-05-13T00:44:36.143Z</atom:updated>
            <content:encoded><![CDATA[<p>One of <a href="https://playframework.com/">Play!</a>’s primary features is <a href="https://www.playframework.com/documentation/2.5.x/ScalaRouting">typed routing</a>, which enables you to use strong types from your controllers. <a href="https://www.playframework.com/documentation/2.5.x/ScalaRequestBinders">Buried in Play’s documentation</a> (to the best of my knowledge, not linked anywhere) is an example of how to use your own types in routes using <em>QueryStringBindable</em> and <em>PathBindable</em>. At <a href="https://www.kifi.com/">Kifi</a>, we’ve found immense value in typing nearly all paths and query parameters. For example, instead of using a <em>Long</em> for a User id, we use<em> Id[User]</em>. This helps us document our endpoints more safely, and makes using types in the controllers much easier.</p><p>Implementing this is simple enough:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a5af396a6f22e16302d32b9d6945bb19/href">https://medium.com/media/a5af396a6f22e16302d32b9d6945bb19/href</a></iframe><p>If you provide your own PathBindable or QueryStringBindable, make sure Play! knows to import them in your routes file by using the <a href="http://stackoverflow.com/questions/33900153/play-2-4-value-routesimport-is-not-a-member-of-object-play-play-autoimport-playk"><em>routesImport</em> SBT settings key</a>.</p><p>You can take this approach a bit further and accept binding to/from entire case classes. Let’s say you have a value class holding filtering and sorting information:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/67f196c520d63e7f921e1d83bbbcab20/href">https://medium.com/media/67f196c520d63e7f921e1d83bbbcab20/href</a></iframe><p>If you plan on using this case class in many routes (for all endpoints that support this kind of pagination, filtering, etc), it’s may be useful to define a QueryStringBindable so that your routes file can be as simple as:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4d6d918f83df0ee485871e36cf67f625/href">https://medium.com/media/4d6d918f83df0ee485871e36cf67f625/href</a></iframe><p>Here’s a direct implementation:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/507bb47815afbf138cf40c9cfd99465b/href">https://medium.com/media/507bb47815afbf138cf40c9cfd99465b/href</a></iframe><p>You’ll notice two helper methods <em>bnd</em> and <em>ubnd</em> that help a bit with boilerplate and type inference. Since all parameters are optional (or we can fill in a default), we’ll always match (by always returning <em>Some</em>). However, if any sub-keys are provided, they must bind correctly — so if an invalid <em>DateTime</em> is provided, the client will know.</p><p>Routing will simply use the key specified in your routes file, followed by <em>.subkey</em>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b8ad0d0547ba4811c66600e05413a152/href">https://medium.com/media/b8ad0d0547ba4811c66600e05413a152/href</a></iframe><p>Ideas for future work: If you use this pattern frequently, you may want to use <a href="https://github.com/playframework/playframework/blob/master/framework/src/play-functional/src/main/scala/play/api/libs/functional/Products.scala">Play’s functional combinators</a> to create something similar to their <a href="https://www.playframework.com/documentation/2.5.x/ScalaJsonCombinators">JSON combinator parsing</a>. Or, use a macro, like Kifi’s <a href="https://github.com/kifi/json-annotation">json macro</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c6921cfe83c2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kifi-engineering/route-binding-custom-classes-in-play-framework-c6921cfe83c2">Route binding custom classes in Play! Framework</a> was originally published in <a href="https://medium.com/kifi-engineering">Keep It Up</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Run Play dev mode from the console]]></title>
            <link>https://medium.com/kifi-engineering/run-play-dev-mode-from-the-console-5575a557b63f?source=rss-c423382a3121------2</link>
            <guid isPermaLink="false">https://medium.com/p/5575a557b63f</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[play-framework]]></category>
            <dc:creator><![CDATA[Andrew Conner]]></dc:creator>
            <pubDate>Tue, 12 May 2015 12:48:57 GMT</pubDate>
            <atom:updated>2016-05-06T21:24:01.895Z</atom:updated>
            <content:encoded><![CDATA[<p>Scala’s REPL is incredibly useful during development. For Play apps, especially in version 2.3 and before, much of the API requires a running application (such as WS, database access, etc). They provide a StaticApplication, but this runs in production mode. This could be an issue for configuration reasons (if there is differences in behavior, configuration, or logic between development and production).</p><p>If you try to use WS without a running application, you’ll first see: You do not have an implicit Application in scope. If you want to bring the current running Application into context, just add import play.api.Play.current. Then if you import Play.current, java.lang.RuntimeException: There is no started application.</p><p>A simple solution is to create your own ApplicationProvider that runs in dev mode.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e53ef90115ea569a0b59f04fea206ef2/href">https://medium.com/media/e53ef90115ea569a0b59f04fea206ef2/href</a></iframe><p>Simple enough. In fact, it’s useful to have this available always. You can put code in a SBT setting called initialCommands to be run whenever the console is started. It’s also useful to import commonly used APIs:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9dd0bcf8d8c2b149a70c066573705f43/href">https://medium.com/media/9dd0bcf8d8c2b149a70c066573705f43/href</a></iframe><p>Then, starting a dev mode application is as easy as typing app in the console.</p><p><em>We wrote this post while working on Kifi — Connecting people with knowledge. </em><a href="http://kifi.com/"><em>Learn more.</em></a></p><p><em>Originally published at </em><a href="http://eng.kifi.com/run-play-dev-mode-console/"><em>eng.kifi.com</em></a><em> on May 12, 2015.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5575a557b63f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kifi-engineering/run-play-dev-mode-from-the-console-5575a557b63f">Run Play dev mode from the console</a> was originally published in <a href="https://medium.com/kifi-engineering">Keep It Up</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dynamic sizing content in Keep cards]]></title>
            <link>https://medium.com/kifi-engineering/dynamic-sizing-content-in-keep-cards-935dd7ba7296?source=rss-c423382a3121------2</link>
            <guid isPermaLink="false">https://medium.com/p/935dd7ba7296</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Andrew Conner]]></dc:creator>
            <pubDate>Wed, 23 Jul 2014 10:39:59 GMT</pubDate>
            <atom:updated>2016-05-06T21:17:52.284Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="http://blog.kifi.com/making-kifi-vision-visual/">For our latest design</a> of <a href="https://www.kifi.com/">Kifi.com</a>, we’ve moved to a graphical, content-centric view for keeps. Each keep appears as a card that contains the title, description, primary image, and metadata about the keep itself. We wanted to design an experience where the user could quickly digest the content of the keep, so wanted to optimize the card presentation as much as possible.</p><p>Occasionally, we have either no description or a very short one — but we do have a large image. For cases like this, we display the image full sized:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*07iK8U0h5mZenTB9.png" /></figure><p>Other times, we have no good image, but do have a textual description. This time, the description is full sized:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*aooDp4tKyhQmORmh.png" /></figure><p>For times when we have both a description and image, we wanted an experience that would balance the image and description as best as possible, to create a newspaper / magazine style layout. This gets a bit tricky: the description and image can be any* size (strictly speaking, descriptions are between 20 and ~500 words, and images are larger than 50×50).</p><p>Since clients may have different window sizes, we needed to dynamically size the images and text. There’s a few ways to approach this. Initially, I attempted to size the content to minimize the total height of the card. Unfortunately, this gave a large bias towards smaller images, and most of my keeps cards looked the same.</p><p>Here’s are a few layout options for the same keep:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ge5b6hr2pF7zn7pD.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9E6OtEEAwkdCtkPg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Ka66w4Y4gMRu7vbh.png" /></figure><p>We agreed that even though the third design minimized the keep height, the second design looked the best. Remember that this is completely dependent on: a) the keep card size (i.e., my window size), the description length, and the image size. A rough 50/50 split between text and image doesn’t always work. Consider these keeps:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/0*Ik4Zkah9VRDoq0yH.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/0*10jh1M61XhC2OxT0.png" /></figure><p>The visually optimal sizes, based on manual experimentation, seemed to use smaller images for these specific keeps. In fact, the “optimal” sizing seemed to vary quite a bit — we liked a 50/50 split when possible, but often 60/40, 70/30, or 80/20 was better. And on edge cases, 90/10 was sometimes best.</p><p>We decided that what we most wanted was to minimize wasted white space between the bottom of the image and the text.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*X8DJrQ_JNl5EU9ad.png" /></figure><p>Unfortunately, this is difficult to calculate directly. We know the keep card width, the description string, and the image dimensions, but it’s not simple to calculate the delta between the image height and the rendered text height (wasted space) since we don’t know how the text will be drawn. Using character and word counts for an approximation yielded very inconsistent results.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1e7fb429df95fbf0090ec21fa591d258/href">https://medium.com/media/1e7fb429df95fbf0090ec21fa591d258/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/0*2QbCYsCwMxpEL8vC.png" /></figure><p>By rendering a keep card off screen hidden from the user, we can directly measure these. We can avoid a full reflow by absolutely positioning the card, so just pay the cost of the browser rendering the card, and us measuring the delta. My initial approach was to set the image width, then binary search for the minimum delta: take two samples, determine the better delta, try again with a better image width guesses. Unfortunately, the delta doesn’t follow a smooth curve.</p><p>This shouldn’t be too surprising: words wrap, causing jumps in the delta. Thus, simply binary searching can’t be trusted to find the actual minimum. Furthermore, in other examples, there were two primary local minimum (two different image widths that yielded local minimums).</p><p>Instead of complicating the binary search, we simplified it: we’d take a sample every 40px, and choose the best. This most often yielded very close to the optimal image width, with far fewer samples.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cdafe830c6cd99f49ed633dad4d45c26/href">https://medium.com/media/cdafe830c6cd99f49ed633dad4d45c26/href</a></iframe><p>We then sized the card accordingly, taking care to size the text height so that we don’t cut a line in two horizontally. This yielded quite nice results, and was fast enough. After playing with this with tens of keeps, we found several examples where the image size did not change the delta significantly: for a large range of image sizes, the delta was roughly the same. This would give slightly arbitrary minimums, so we added a scoring mechanism so we could give a bias for sizes that yielded roughly a 50/50 split.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/df7382eaa9efd63bdecb007e9649c352/href">https://medium.com/media/df7382eaa9efd63bdecb007e9649c352/href</a></iframe><p>We can also tweak the score for image sizes that are larger than their originals, since it looks bad:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6d158d220b0dc44746db8e2724953716/href">https://medium.com/media/6d158d220b0dc44746db8e2724953716/href</a></iframe><p>This delta minimization + scoring mechanism gave us a very pleasant range of keep card variations, with some small images, some large, and several in between.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*FDCg_Un2_9pQHZYC.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kZ2zugPVgA3bXTR4.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pOhItAxj_r51qonq.png" /></figure><p><em>We wrote this post while working on Kifi — tools that help people outsmart information overload together. </em><a href="http://kifi.com/"><em>Learn more.</em></a></p><p><em>Originally published at </em><a href="http://eng.kifi.com/dynamic-sizing-content-keep-cards/"><em>eng.kifi.com</em></a><em> on July 23, 2014.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=935dd7ba7296" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kifi-engineering/dynamic-sizing-content-in-keep-cards-935dd7ba7296">Dynamic sizing content in Keep cards</a> was originally published in <a href="https://medium.com/kifi-engineering">Keep It Up</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Typesafe case study on Kifi]]></title>
            <link>https://medium.com/kifi-engineering/typesafe-case-study-on-kifi-e703178150ab?source=rss-c423382a3121------2</link>
            <guid isPermaLink="false">https://medium.com/p/e703178150ab</guid>
            <category><![CDATA[scala]]></category>
            <dc:creator><![CDATA[Andrew Conner]]></dc:creator>
            <pubDate>Wed, 16 Jul 2014 09:07:06 GMT</pubDate>
            <atom:updated>2016-05-06T21:17:08.177Z</atom:updated>
            <content:encoded><![CDATA[<p>We were happy to participate in a case study that <a href="https://typesafe.com/blog/case-study-kifi-powered-by-typesafe">Typesafe wrote on Kifi</a>. Specifically, they were interested in how we used the <a href="https://typesafe.com/platform">Typesafe Platform</a> to build the reactive and scalable platform that powers Kifi.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SPKB9cuzrlkYSj7_.png" /></figure><blockquote><em>The service’s unique approach to search is based on users easily tagging and keeping anything found online — articles, videos, pictures, email — allowing these saved items to be easily found on top of favorite search engine results from that point forward. It’s like a higher powered bookmarking system that includes the best elements of search and social.</em></blockquote><p><a href="http://downloads.typesafe.com/website/casestudies/Kifi-Case-Study.pdf?_ga=1.101520513.1036112353.1371684768">Read it here</a>. Big thanks to <a href="https://twitter.com/lwmasterson">Laura Masterson</a> and <a href="https://twitter.com/AlexSalkever">Alex Salkever</a> for doing this.</p><p><em>We wrote this post while working on Kifi — tools that help people outsmart information overload together. </em><a href="http://kifi.com/"><em>Learn more.</em></a></p><p><em>Originally published at </em><a href="http://eng.kifi.com/typesafe-case-study-kifi/"><em>eng.kifi.com</em></a><em> on July 16, 2014.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e703178150ab" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kifi-engineering/typesafe-case-study-on-kifi-e703178150ab">Typesafe case study on Kifi</a> was originally published in <a href="https://medium.com/kifi-engineering">Keep It Up</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Clean and re-usable Slick modules]]></title>
            <link>https://medium.com/kifi-engineering/clean-and-re-usable-slick-modules-dd3cdc315db4?source=rss-c423382a3121------2</link>
            <guid isPermaLink="false">https://medium.com/p/dd3cdc315db4</guid>
            <category><![CDATA[scala]]></category>
            <category><![CDATA[slick]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Andrew Conner]]></dc:creator>
            <pubDate>Thu, 27 Feb 2014 08:06:13 GMT</pubDate>
            <atom:updated>2016-05-06T21:12:39.822Z</atom:updated>
            <content:encoded><![CDATA[<p>This is the second post in a three part series about our database access layer and patterns we’ve adopted. If you missed the first, <a href="http://eng.42go.com/database-patterns-in-scala/">read about some of the patterns we use when working with our databases</a>.</p><p>We’ve talked previously about how we’ve abstracted away our database backend and query/access libraries. Unfortunately, the recent <a href="http://slick.typesafe.com/">Slick 2.0</a> upgrade meant our previous abstraction and every Repo (63 at last count) needed to be upgraded. So, we had a fix-it morning and had Slick 2.0 in production by lunch. Huzzah!</p><p>This post gets into more implementation details about our database access patterns. Some of this overlaps <a href="http://eng.42go.com/using-scala-slick-at-fortytwo/">Eishay’s talk about how we used Slick 1.0</a>, and updates the code he shared to Slick 2.0.</p><p>Our code that accesses the database happens in a <a href="http://eng.42go.com/tag/guice/">Guice injected</a> class called a Repo. Our product, <a href="https://www.kifi.com/">Kifi</a>, handles very large imports of links that people want to become keeps. In order to protect our users’ data, we persist the raw links as fast as possible in a batch insert, before we normalize the URL (so <a href="https://www.kifi.com/">https://www.kifi.com</a> is the same as <a href="https://www.kifi.com/">http://kifi.com/</a>), de-duplicate, run our scraper service, etc. Here’s part of the RawKeepRepo implementation:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cf6e6d1fe364fc0e00d69a3122038099/href">https://medium.com/media/cf6e6d1fe364fc0e00d69a3122038099/href</a></iframe><p>RawKeepRepo comes automatically with a few helpful methods: save(m: RawKeep), get(id: Id[RawKeep]), etc. How does that work? All of our repos extend DbRepo[T], which defines some basic functionality of repos.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/19a6c19584b3464a9b5dd0ad3cad8264/href">https://medium.com/media/19a6c19584b3464a9b5dd0ad3cad8264/href</a></iframe><p>That’s a lot to take in, so we’ll break it down. In RawKeepRepo, we inject a DataBaseComponent which wraps the database driver and dialect. We then implement a RawKeepTable that extends RepoTable, which provides definitions of columns not automatically provided (such as userId, url, etc), as well as the * binder that Slick needs. We also define a def table that takes a tag (which Slick provides) and returns an instance of the table.</p><p>You may notice that all public methods in the DbRepo take an implicit RSession. This is actually a trait, extended by RWSession and ROSession. We define sessions as read-only or read-write outside of the Repo level, so we can be transactional when necessary and combine several queries in one connection.</p><p>What does this give us? An instance of RawKeepInfoImpl has common columns like id, createdAt, updatedAt, and state defined automatically, so we’re able to keep our classes small. Additionally, it has convenience getters and setters implemented already, such as rawKeepRepo.get(someRawKeepId). Using the repo is quite easy:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5c944b39ace133dcdf3dba44762c1949/href">https://medium.com/media/5c944b39ace133dcdf3dba44762c1949/href</a></iframe><p>Next time, we’ll combine all of this together in a sample project you can play around with.</p><p><em>We wrote this post while working on Kifi — tools that help people outsmart information overload together. </em><a href="http://kifi.com/"><em>Learn more.</em></a></p><p><em>Originally published at </em><a href="http://eng.kifi.com/clean-and-re-usable-slick-modules/"><em>eng.kifi.com</em></a><em> on February 27, 2014.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dd3cdc315db4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kifi-engineering/clean-and-re-usable-slick-modules-dd3cdc315db4">Clean and re-usable Slick modules</a> was originally published in <a href="https://medium.com/kifi-engineering">Keep It Up</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Emojis in Play! test logs]]></title>
            <link>https://medium.com/kifi-engineering/emojis-in-play-test-logs-bf6d58a60fc5?source=rss-c423382a3121------2</link>
            <guid isPermaLink="false">https://medium.com/p/bf6d58a60fc5</guid>
            <category><![CDATA[play-framework]]></category>
            <dc:creator><![CDATA[Andrew Conner]]></dc:creator>
            <pubDate>Thu, 13 Feb 2014 09:55:26 GMT</pubDate>
            <atom:updated>2016-05-06T21:10:59.169Z</atom:updated>
            <content:encoded><![CDATA[<p>Several months ago, <a href="https://github.com/playframework/playframework/pull/1642">Play! secretly added emoji support</a> in the test logs. To add this revolutionary feature to your project, throw play.Project.emojiLogs in your project’s settings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/0*IaypPueUt6xbJkH6.png" /></figure><p><a href="https://twitter.com/jroper">James Roper</a> cautions that the feature is unsupported and may be removed, so you may rather to include it directly in your Build.scala:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/eeb5bab9ff45b10d971db74528f73af3/href">https://medium.com/media/eeb5bab9ff45b10d971db74528f73af3/href</a></iframe><p><em>We wrote this post while working on Kifi — Connecting people with knowledge. </em><a href="http://kifi.com/"><em>Learn more.</em></a></p><p><em>Originally published at </em><a href="http://eng.kifi.com/emojis-in-play-test-logs/"><em>eng.kifi.com</em></a><em> on February 13, 2014.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bf6d58a60fc5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kifi-engineering/emojis-in-play-test-logs-bf6d58a60fc5">Emojis in Play! test logs</a> was originally published in <a href="https://medium.com/kifi-engineering">Keep It Up</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Database patterns in Scala]]></title>
            <link>https://medium.com/kifi-engineering/database-patterns-in-scala-3899f245a0be?source=rss-c423382a3121------2</link>
            <guid isPermaLink="false">https://medium.com/p/3899f245a0be</guid>
            <category><![CDATA[scala]]></category>
            <category><![CDATA[slick]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Andrew Conner]]></dc:creator>
            <pubDate>Tue, 11 Feb 2014 08:00:23 GMT</pubDate>
            <atom:updated>2016-05-06T21:03:12.046Z</atom:updated>
            <content:encoded><![CDATA[<p>This is the first in a three part series about our database access layer and patterns we’ve adopted (part 2: <a href="http://eng.42go.com/clean-and-re-usable-slick-modules/">Clean and re-usable Slick modules</a>). We use <a href="http://slick.typesafe.com/">Slick</a> to type-check and build our queries, but many of these ideas may help with other libraries.</p><p>There’s a decent amount of material out about Slick basics (how to query), but not much about building a larger, multi-module app using it. This post is a soft introduction into some of the lessons we’ve learned and patterns that keep us sane.</p><ul><li>Type what’s important. In Scala, typing is easy (and with value classes, cheap). So, type your values. Id[User] is much better than Long. The compiler will make sure you don’t mix your IDs, and it’s always clear what you’re working with.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bbdbc20b904b8eb8b56e7d3996b09c55/href">https://medium.com/media/bbdbc20b904b8eb8b56e7d3996b09c55/href</a></iframe><ul><li>Determine common patterns between your tables, and only write it once. All of our tables have id, createdAt, and updatedAt columns, so we implement them on the RepoTable (which extends Slick’s Table) level. Additionally, some of our tables have an externalId column, so it’s an optional mix-in.</li><li>Log your query statements, watch out for inefficient generated SQL. The easiest way to do this is to wrap java.sql.Connection with logging around prepareStatement, prepareCall, nativeSQL, and createStatement.</li><li>Sometimes, hand writing SQL is the best option. <a href="http://slick.typesafe.com/doc/2.0.0/sql.html">Slick makes it easier</a> than writing your own prepared statements.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/878b344d1b33e40e142289227100d855/href">https://medium.com/media/878b344d1b33e40e142289227100d855/href</a></iframe><ul><li><a href="http://slick.typesafe.com/doc/2.0.0/queries.html#compiled-queries">Precompile your hot queries</a>. Slick lets you compile queries ahead of time, and provide parameters as needed. It’s more verbose, and isn’t nearly as flexible, but in our benchmarks, you can sometimes save ~1ms per query.</li><li>Use a caching layer for complex queries. Of course, <a href="http://martinfowler.com/bliki/TwoHardThings.html">cache invalidation can get complex</a>, so be careful. <a href="http://www.42go.com/team.html#yasuhiro">Yasuhiro Matsuda</a> wrote a wonderful transactional caching layer that sits on top of in-memory and memcached caches. A little birdie told me he’ll write about it soon, so stay tuned.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a640a269a07f09a6f1c8a7f7b2ca4aa0/href">https://medium.com/media/a640a269a07f09a6f1c8a7f7b2ca4aa0/href</a></iframe><p><em>We wrote this post while working on Kifi — Connecting people with knowledge. </em><a href="http://kifi.com/"><em>Learn more.</em></a></p><p><em>Originally published at </em><a href="http://eng.kifi.com/database-patterns-in-scala/"><em>eng.kifi.com</em></a><em> on February 11, 2014.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3899f245a0be" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kifi-engineering/database-patterns-in-scala-3899f245a0be">Database patterns in Scala</a> was originally published in <a href="https://medium.com/kifi-engineering">Keep It Up</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Future goodies and helpers: SafeFuture, TimeoutFuture, CancelableFuture]]></title>
            <link>https://medium.com/kifi-engineering/future-goodies-and-helpers-safefuture-timeoutfuture-cancelablefuture-4bccb370a21b?source=rss-c423382a3121------2</link>
            <guid isPermaLink="false">https://medium.com/p/4bccb370a21b</guid>
            <category><![CDATA[akka]]></category>
            <category><![CDATA[asynchronous]]></category>
            <category><![CDATA[scala]]></category>
            <dc:creator><![CDATA[Andrew Conner]]></dc:creator>
            <pubDate>Wed, 28 Aug 2013 06:06:31 GMT</pubDate>
            <atom:updated>2016-05-06T20:59:36.289Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/320/0*I234YRo4LR5DuD6s.jpg" /></figure><p>Related to our <a href="http://eng.42go.com/handling-akka-actor-exceptions-with-prerestart/">previous post about catching top-level Actor exceptions</a>, we also have a few utility classes for working with Futures. These do things such as offer baked-in exception logging, establish SLA-timeouts on futures, and give the ability to interrupt a running code block that is in a future.</p><p><a href="https://gist.github.com/andrewconner/6362491">Check out all of the code together on</a></p><p><a href="https://gist.github.com/andrewconner/6362491">Github.</a></p><h3>SafeFuture</h3><p>SafeFuture is a Future that simply binds an onFailure to any future passed in to deal with hard failures. Future failures can and should be handled, but for fire-and-forget and map-chaining, it’s often easy to not handle failures explicitly. The result is a exception that goes nowhere — including failure to your go to your logs. Mysterious failure is not good, so SafeFuture lets you design an application level failure monitoring strategy. This won’t save your result, but at least you’ll be aware it failed.</p><p>As an added bonus, there’s a second apply in SafeFuture that lets you name the future for logging purposes.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7ddfcce4d34fa8ba632397e508e1eca1/href">https://medium.com/media/7ddfcce4d34fa8ba632397e508e1eca1/href</a></iframe><h3>TimeoutFuture</h3><p>TimeoutFuture lets you establish a SLA timeout for a Future. Simply, if that time passes and the future has not resolved, it resolves as a failure with a TimeoutException. Typically, this should be explicitly handled by your application — supplying a default value, returning an error, etc.</p><p>For efficiency, we use netty’s HashWheelTimer. This does not give explicit guarantees about exactly when it runs, and instead provides a best-effort timer. So: It’s much lighter than a scheduler, but less accurate.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5c180110e16b05b09bacf5dc263ac9ee/href">https://medium.com/media/5c180110e16b05b09bacf5dc263ac9ee/href</a></iframe><h3>CancelableFuture</h3><p>CancelableFuture creates a future that can be cancelled, from a blocking code block. This is not usually for SLA timeout guarantees like above. Rather, it’s for when you have a complex long-running blocking bit of code that you want to be able to kill. So, this returns a method that, once called, will harshly interrupt the thread and stop the code. It’s nasty, be careful with it. Example non-deterministic usage:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3e2b99dbfb9faca2420686beb595ae78/href">https://medium.com/media/3e2b99dbfb9faca2420686beb595ae78/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c8a78263284f0d6b1a98c098d552d4be/href">https://medium.com/media/c8a78263284f0d6b1a98c098d552d4be/href</a></iframe><p><a href="https://gist.github.com/andrewconner/6362491">All of this code together (with necessary imports) is on Github.</a> Have any other useful utility classes for working with Akka and Futures? Let us know!</p><p><em>We wrote this post while working on Kifi — tools that help people outsmart information overload together. </em><a href="http://kifi.com/"><em>Learn more.</em></a></p><p><em>Originally published at </em><a href="http://eng.kifi.com/future-safefuture-timeout-cancelable/"><em>eng.kifi.com</em></a><em> on August 28, 2013.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4bccb370a21b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kifi-engineering/future-goodies-and-helpers-safefuture-timeoutfuture-cancelablefuture-4bccb370a21b">Future goodies and helpers: SafeFuture, TimeoutFuture, CancelableFuture</a> was originally published in <a href="https://medium.com/kifi-engineering">Keep It Up</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dealing with top-level Actor exceptions]]></title>
            <link>https://medium.com/kifi-engineering/dealing-with-top-level-actor-exceptions-c53a247115ea?source=rss-c423382a3121------2</link>
            <guid isPermaLink="false">https://medium.com/p/c53a247115ea</guid>
            <category><![CDATA[akka]]></category>
            <category><![CDATA[scala]]></category>
            <dc:creator><![CDATA[Andrew Conner]]></dc:creator>
            <pubDate>Fri, 23 Aug 2013 18:22:24 GMT</pubDate>
            <atom:updated>2016-05-06T20:58:52.799Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="http://doc.akka.io/docs/akka/snapshot/scala/actors.html">Akka actors</a> are great for reactively and asynchronously handling work loads. Typically, for larger actor systems, it’s best to use a <a href="http://doc.akka.io/docs/akka/snapshot/general/supervision.html">Supervisor</a> to handle unexpected failure. However, for top-level actors, it’s nice to be able to intercept and handle exceptions for alerting purposes. For this specific purpose, we created an actor trait called AlertingActor, which very simply defines a preRestart that gets called with the Throwable when an unhandled exception occurs in an actor.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f351b8202d6dcf186905219f018afd3b/href">https://medium.com/media/f351b8202d6dcf186905219f018afd3b/href</a></iframe><p><em>We wrote this post while working on Kifi — Connecting people with knowledge. </em><a href="http://kifi.com/"><em>Learn more.</em></a></p><p><em>Originally published at </em><a href="http://eng.kifi.com/handling-akka-actor-exceptions-with-prerestart/"><em>eng.kifi.com</em></a><em> on August 23, 2013.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c53a247115ea" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kifi-engineering/dealing-with-top-level-actor-exceptions-c53a247115ea">Dealing with top-level Actor exceptions</a> was originally published in <a href="https://medium.com/kifi-engineering">Keep It Up</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Websockets with Play! talk]]></title>
            <link>https://medium.com/kifi-engineering/using-websockets-with-play-talk-c05bdc486e26?source=rss-c423382a3121------2</link>
            <guid isPermaLink="false">https://medium.com/p/c05bdc486e26</guid>
            <category><![CDATA[play-framework]]></category>
            <category><![CDATA[websocket]]></category>
            <category><![CDATA[scala]]></category>
            <dc:creator><![CDATA[Andrew Conner]]></dc:creator>
            <pubDate>Fri, 26 Jul 2013 03:38:31 GMT</pubDate>
            <atom:updated>2016-05-06T20:51:48.876Z</atom:updated>
            <content:encoded><![CDATA[<p>We use websockets for our clients because we care deeply about a fast, responsive user experience. At the <a href="http://www.meetup.com/PlayFramework/">Play! Framework meetup</a> (based near us in Mountain View, CA), we presented an introduction to using Websockets with Play!. We cover some relevant background into alternatives, benchmarks, and how Websockets work within Play!. If you were not able to come, here is the presentation (<a href="http://ustream.tv/recorded/36372789"><strong>a video of the talk is here</strong></a>):</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.slideshare.net%2Fslideshow%2Fembed_code%2Fkey%2F3llEtS5JvnsfN7&amp;url=http%3A%2F%2Fwww.slideshare.net%2FAndrewConner%2Fusing-websockets-with-play&amp;image=http%3A%2F%2Fcdn.slidesharecdn.com%2Fss_thumbnails%2Fwebsockets-130725154256-phpapp02-thumbnail-4.jpg%3Fcb%3D1374774749&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=slideshare" width="600" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/83514597e4b5602b639d108e0e7e5876/href">https://medium.com/media/83514597e4b5602b639d108e0e7e5876/href</a></iframe><p>Additionally, here’s some relevant resources that may help:</p><ul><li><a href="http://www.playframework.com/documentation/2.1.1/ScalaWebSockets">Play! Websocket overview</a></li><li><a href="http://www.playframework.com/documentation/2.1.1/Iteratees">Play! Iteratee overview</a></li><li><a href="http://eng.42go.com/secure-websockets-vs-https-benchmark/">Our echo Websocket benchmarks (WSS vs HTTPS)</a></li><li><a href="http://mandubian.com/2012/08/27/understanding-play2-iteratees-for-normal-humans/">Excellent guide to understanding Iteratees / Enumerators (and more!)</a></li><li>In lieu of complete documentation, Play! source for <a href="https://github.com/playframework/playframework/blob/master/framework/src/iteratees/src/main/scala/play/api/libs/iteratee/Iteratee.scala">Iteratee.scala</a> and <a href="https://github.com/playframework/playframework/blob/master/framework/src/iteratees/src/main/scala/play/api/libs/iteratee/Concurrent.scala">Concurrent.scala</a></li><li><a href="https://github.com/playframework/playframework/tree/master/samples/java/websocket-chat">Play! Websocket chat example</a></li></ul><p><a href="http://www.slideshare.net/brikis98/the-play-framework-at-linkedin">Jim’s Intro to Play slides are located here</a>.</p><p><em>We wrote this post while working on Kifi — Connecting people with knowledge. </em><a href="http://kifi.com/"><em>Learn more.</em></a></p><p><em>Originally published at </em><a href="http://eng.kifi.com/using-websockets-with-play-talk/"><em>eng.kifi.com</em></a><em> on July 26, 2013.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c05bdc486e26" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kifi-engineering/using-websockets-with-play-talk-c05bdc486e26">Using Websockets with Play! talk</a> was originally published in <a href="https://medium.com/kifi-engineering">Keep It Up</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>