<?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[Evil Martians - Medium]]></title>
        <description><![CDATA[The Martian Chronicles - Medium]]></description>
        <link>https://medium.com/evil-martians?source=rss----e2969ed68dd3---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Evil Martians - Medium</title>
            <link>https://medium.com/evil-martians?source=rss----e2969ed68dd3---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 21:59:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/evil-martians" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[We studied 100 dev tool landing pages — here’s what really works in 2025]]></title>
            <link>https://medium.com/evil-martians/we-studied-100-dev-tool-landing-pages-heres-what-really-works-in-2025-567436807e29?source=rss----e2969ed68dd3---4</link>
            <guid isPermaLink="false">https://medium.com/p/567436807e29</guid>
            <category><![CDATA[landing]]></category>
            <category><![CDATA[developer-tools]]></category>
            <category><![CDATA[devtools]]></category>
            <category><![CDATA[open-source]]></category>
            <dc:creator><![CDATA[vicamelnikova]]></dc:creator>
            <pubDate>Wed, 09 Jul 2025 19:20:53 GMT</pubDate>
            <atom:updated>2025-07-09T19:20:53.253Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>We studied 100 dev tool landing pages — here’s what really works in 2025</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TfDrDfFHFbHd64bByP7e7A.png" /></figure><p>So, you’ve built an amazing open source project or developer tool. Now you need a landing page that doesn’t suck! You could spend weeks researching what works, A/B testing layouts, and second-guessing design decisions. Or… you could fight blank page pain by learning from what the best dev tools are doing in 2025. To save you the time, <a href="https://evilmartians.com/martians/anton-lovchikov">Anton Lovchikov</a>, Head of Design at Evil Martians, analyzed <a href="https://playbook.com/s/evilmartians/fC4GeU82d7NRDYimWgosmgpc">100+ dev tool landing</a> pages, from Linear to Vercel to Supabase. Here’s exactly what works, backed by real data from real companies. (And yes, we’ve turned this research into an <a href="https://launchkit.evilmartians.io/">open source template</a> you can use to ship within minutes.)</p><blockquote>Our free open source template is a great starting point. Now, let’s talk go-to-market for your developer tool. Schedule a free call: <a href="https://cal.com/team/evilmartians/exploration">https://cal.com/team/evilmartians/exploration</a></blockquote><p>Here’s the structure that works for early-stage product landing pages based on our research:</p><ul><li>Hero section</li><li>Trust block</li><li>Feature block</li><li>Social proof block</li><li>Supporting blocks</li><li>Final CTA</li></ul><p>In this Medium article, we will examine only the Hero section. To read the full version of this article, go to <a href="https://evilmartians.com/chronicles/we-studied-100-devtool-landing-pages-here-is-what-actually-works-in-2025">https://evilmartians.com/chronicles/we-studied-100-devtool-landing-pages-here-is-what-actually-works-in-2025</a></p><h3>General layout notes</h3><p>Before we dive into the specific sections, let’s note that two rules stood out across nearly every dev tool landing page we studied:</p><ul><li>No salesy BS.</li><li>Clever and simple wins.</li></ul><p>Most pages avoid flashy interactions. They focus on clean design: solid typography, clear layout, and enough breathing room. This makes sense since early-stage teams need to move fast, validate ideas, and get users. The flashy stuff comes later.</p><p>Almost all pages use a centered layout with a max-width container. It’s simple, readable, and quick to build. A few go wide, stretching edge to edge. While this is a bold move that can look premium, it’s also harder to execute. Still, if done right, it’s a good way to stand out.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jjnfg-oyCtMzosoG.png" /></figure><h3>Hero section</h3><p><strong>TL;DR:</strong> Use centered composition with a static or animated product shot and an engaging CTA.</p><p>Most developer tool landing pages in 2025 follow a surprisingly consistent pattern in the hero section.</p><h4>Centered composition</h4><p>In the vast majority of examples we studied, the hero section is centered: a big, bold headline in the middle of the screen, with a supporting graphical element placed right below. This looks stable, feels trustworthy, and it just works.</p><p>Only a handful of sites go for a side-by-side layout, with text on the left and visuals on the right. These feel more like classic SaaS pages, but while they can look great with the right design, they seem to be the exception, not the rule, especially in the dev tools space.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wWwYoOgJj5XbNupm.png" /></figure><h4>Main visual element</h4><p>The graphic part of the hero section varies a lot depending on the product’s maturity and nature:</p><ul><li><strong>Animated product UI</strong><br>This adds movement, shows off more product surface. Great for demos, but takes more effort to prepare.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4qUGVlMSYvX9LEJWK4C3qw.png" /><figcaption><a href="https://www.playbook.com/s/evilmartians/Xa375CDC7V6gshA21m2rZMgd?assetToken=dZ8njtFAXjsd9KgwyykpCF8C">Playbook</a>: Animated product preview (we made screenshots of all landings as of today and put them into a single <a href="https://playbook.com/s/evilmartians/fC4GeU82d7NRDYimWgosmgpc">folder</a>, so your design team can use it for inspiration)</figcaption></figure><ul><li><strong>Static product UI</strong><br>Totally valid but also much faster to implement and still gives users a sense of what the tool looks like.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/864/1*66MQup8qwfa9yHa8gakxYg.jpeg" /><figcaption><a href="https://www.playbook.com/s/evilmartians/X7cdNJt9Ebf9e3VrGuNqp7X9?assetToken=BQWSMBERTepyfwH4jQg42Kx2">Linear</a>: Static product shot</figcaption></figure><ul><li><strong>Switchable multiple product UI</strong><br>This works especially well if your product has multiple use cases or features, and you haven’t narrowed your core messaging yet.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q1JbzR4MfNBKKNOpxhbLew.png" /><figcaption><a href="https://www.playbook.com/s/evilmartians/vXpzrzn8sEoik6wVtFcQ8BqW?assetToken=mNZEGMTtymwm6Sj8WLLp49C6">Mintlify</a>: Multiple switchable product shots</figcaption></figure><ul><li><strong>Live product embed</strong><br>Some small utilitarian products skip screenshots entirely and embed a real, working UI element. It’s a power move if you can pull it off, but only realistic for narrow-scope tools (e.g. image upscaler, background remover, and so on).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Am1AeitciwGekgtvPmYEmQ.jpeg" /><figcaption><a href="https://www.playbook.com/s/evilmartians/P4Jik5NvJ3Pc8zv6AqM8XkGg?assetToken=THLmWkgCc2YR78Hw8htC9aUK">Pixelcut</a>: Live demo in the hero section</figcaption></figure><ul><li><strong>Code snippet</strong><br>Common for tools without much UI like libraries, SDKs, and infra products.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Pyg8gcsQ4qnqkF-fx9tUSw.jpeg" /><figcaption><a href="https://www.playbook.com/s/evilmartians/PRNfLY8dUGMok5VvjFLBQrN9?assetToken=awTQexQDmFi3Zade6jHpFJad">Tailwind</a>: Code snippet as main visual element</figcaption></figure><ul><li><strong>Abstract illustration or no visual at all</strong><br>Useful when the UI doesn’t yet exist, or when the product lives under the hood (e.g. observability, data infra). This is also used by stealth or pre-launch projects testing demand.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lOYTv-WrHD5a8lXAwCXicA.jpeg" /><figcaption><a href="https://www.playbook.com/s/evilmartians/gExqLMwsGbJjv3P2WfezHmM3?assetToken=spU4DP2GG6fXgKyunwb34LX4">Recraft</a>: Textual composition instead of UI preview</figcaption></figure><h4>Eyebrows and Banners</h4><p>In order to create a sense of activity and momentum around the product (something especially important for early-stage startups looking to gain trust quickly) product teams pack extra information into the hero section using small elements, like these:</p><p><strong>Eyebrows</strong> are small text above the title, usually used for highlighting a new release, funding round, or launch event. This is a useful element for setting the context.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4UWRuRjA6u8iKpgu_vI20g.jpeg" /><figcaption><a href="https://www.playbook.com/s/evilmartians/vWSrr7H4NECUGEXDavJLF8Bq?assetToken=EcxnyAyY1Q3JgrsAMi8HoFff">Ion</a>: A promo link featuring an important milestone</figcaption></figure><p><strong>A full-width banner</strong> at the top of the page — used for similar purposes, but often with a longer message.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o_MUgN6Ooz70-2SUDsppzQ.jpeg" /><figcaption><a href="https://www.playbook.com/s/evilmartians/n7RRbmXrtQuft7N7AFQz9rHB?assetToken=yqtaypFCBzhpThmA26acrACJ">PlayAI</a>: banner with new feature announcement</figcaption></figure><h4>Call to Action</h4><p>Leveraging two CTAs in the hero allows you to both convert paid customers and provide immediate value to developers, either through open source or direct access to documentation.</p><ul><li>The primary CTA is styled boldly. Try to avoid generic “Get started” language and use something more specific for your product: “Start building”, “Download now”, and so on.</li><li>If there’s a secondary CTA (e.g. “View docs,” “Join waitlist,” or “GitHub”), it’s always visually distinct — lighter, outlined, or styled differently to avoid competing.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*24o4Gt68KiBHQK_gq9bVpA.jpeg" /><figcaption><a href="https://www.playbook.com/s/evilmartians/dtp1rpJs1uRcdmXk7RomMHjb?assetToken=UYFhNGHVDb6rZUqBBG8cHESA">Cursor</a>: Two CTAs with different styles</figcaption></figure><h3>Trust block</h3><p><strong>TL;DR:</strong> Display logos of a few important customers or show off a few numbers demonstrating user engagement.</p><p>The majority of developer tool startups include a clients section, and most of them place it right after the hero. This is one of the fastest ways to build credibility. If your product is already used by teams with recognizable names — show them off. Remember, open source users are users, too.</p><p>There are two main directions this section takes, depending on the type of product:</p><p>…</p><p>Read full version: <a href="https://evilmartians.com/chronicles/we-studied-100-devtool-landing-pages-here-is-what-actually-works-in-2025">https://evilmartians.com/chronicles/we-studied-100-devtool-landing-pages-here-is-what-actually-works-in-2025</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=567436807e29" width="1" height="1" alt=""><hr><p><a href="https://medium.com/evil-martians/we-studied-100-dev-tool-landing-pages-heres-what-really-works-in-2025-567436807e29">We studied 100 dev tool landing pages — here’s what really works in 2025</a> was originally published in <a href="https://medium.com/evil-martians">Evil Martians</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Can Midjourney AI outperform a human artist? We tried it out at work.]]></title>
            <link>https://medium.com/evil-martians/can-midjourney-ai-outperform-a-human-artist-we-tried-it-out-at-work-acded6e90efb?source=rss----e2969ed68dd3---4</link>
            <guid isPermaLink="false">https://medium.com/p/acded6e90efb</guid>
            <category><![CDATA[illustration]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[midjourney]]></category>
            <category><![CDATA[design]]></category>
            <dc:creator><![CDATA[Richard Turner]]></dc:creator>
            <pubDate>Wed, 01 Feb 2023 13:32:26 GMT</pubDate>
            <atom:updated>2023-02-01T13:32:25.693Z</atom:updated>
            <content:encoded><![CDATA[<p>These days, generating realistic images using text is just a part of reality. So, should human designers start to delegate (at least some of) their tasks to AI? <a href="https://twitter.com/egodyston">Alena Kirdina</a>, Senior Product Designer at Evil Martians, decided to try it at work and find out.</p><h3>Why Midjourney AI?</h3><p>For the experiment we’ll cover here, we’ll go with Midjourney AI. However, there are several other notable AI models for text-to-image are worth mentioning: like the OpenAI backed <a href="https://openai.com/dall-e-2/">DALL-E</a>, and <a href="https://stablediffusionweb.com/">Stable Diffusion</a>.</p><p>But, in our view, <a href="https://www.midjourney.com/">Midjourney</a> offers the coolest creative options. Beginning in November 2022 with version 4&#39;s alpha, it began producing images with amazingly high quality, and it’s almost impossible to distinguish these results from human-created illustrations.</p><h3>Introducing the experiment</h3><p>It wasn’t too difficult to track down a suitable work task to pit humans against machines. Nearly every week, <a href="https://evilmartians.com/chronicles">on our blog at Evil Martians</a>, we publish a new article. And we pair each article with an original, human-created illustration that fits the theme of the article. We work with real illustrators to produce these images, and we usually communicate what we’re looking for via text. Midjourney AI understands text, too. Bingo.</p><p>We’ve worked with our familiar roster of talented, reliable freelancers for quite a while, so the amount of art direction we need to provide them is minimal. Despite this, the turnaround time to get an illustration <em>just right</em> can take around <strong>one or two weeks</strong>.</p><p><strong>Our images also require a particular style</strong>: the vast majority of the images have an isometric 3D view, with a “plastic”, vivid apperance, and solid backgrounds with dimensions usually set at 1200×1000. We’ll use these values as technical parameters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8MTBJP0txJej-kpnvFk5KA.png" /><figcaption>An example of an image in our standard style</figcaption></figure><h3>Defining experiment metrics</h3><p>We’ll need to define some basic parameters in order to properly assess the results:</p><p><strong>Overall creation time.</strong> This includes everything from the initial request to the end result.</p><p><strong>Active art direction time.</strong> We’ll calculate how much time was needed to refine the composition with our human illustrator versus prompt adjustments with Midjourney.</p><p><strong>Cost.</strong> We’ll compare the approxmimate cost of both approaches.</p><p>Finally, <strong>which picture looks better</strong>?</p><h3>The cat’s out of the bag</h3><p>Let’s get started. Here’s (roughly) the prompt we sent the <strong>human illustrator</strong>:</p><blockquote>“We’re writing an article about migrating from CircleCI to GitHub Actions. Their logos are a circle and a cat (see attachments). So this is the idea — the cat is playing with a frisbee, ball, or other round object. Can you design the cutest kitty in the world? You can even make it a little Martian if you want.”</blockquote><p>Four days later, we got back some detailed renders in a lovely “toy” style, which met all technical requirements:</p><figure><img alt="Two black cats, the one on the left is in front of a green background chasing a spherical ball through the air, the right one chases a frisbee" src="https://cdn-images-1.medium.com/max/1024/1*ng1aJ8jpVxu56Wi-Vu3-ig.jpeg" /><figcaption>The human artist’s first draft</figcaption></figure><p>We went with the green version. We did have a small request: change the shape of the cat’s tail and the muzzle size. The adjusted image came the following day, and we were all super happy with it.</p><figure><img alt="A 3D black cat chases a 3D ball through the air in front of a green background" src="https://cdn-images-1.medium.com/max/1024/1*pirp7umznwAr3_xuRsXuUg.jpeg" /><figcaption>The final result after some tweaks</figcaption></figure><p>In the end, the entire process required six days, and half an hour, max, of active direction.</p><p>For our <strong>AI illustrator</strong>, Alena needed to translate our plain English prompt into a text prompt to send via Discord:</p><p>/imagine: pixar style 3d image of the cat in a spacesuit playing with a ball on solid green background --ar 3:2 --v 4</p><p>The last two setting commands are as follows: ar is aspect ratio, and v 4will specify we want to use the latest Midjourney release to get the highest quality results possible. pixar style 3d defines the style that I’d like the AI to reference.</p><p>Here are the results, which were <em>immediately</em> sent back:</p><figure><img alt="Four 3D renderings of realistic, yet cartoony cats. They are all in astronaut suits playing with a large green ball." src="https://cdn-images-1.medium.com/max/1024/1*PX-V9fMiRyV9mkWSSNAXiQ.jpeg" /><figcaption>This was pretty far away from what we were after</figcaption></figure><p>Alena thought it looked amusing, but the “plastic” style from the Evil Martians’ blog is missing. She decided to add “plastic”: pixar style 3d of a toy plastic cat in a spacesuit playing with a ball on solid green background --ar 3:2 --v 4</p><figure><img alt="Four 3D images of plastic looking cartoony cats in spacesuits" src="https://cdn-images-1.medium.com/max/1024/1*a5qyFfrgPgxShpArNTnXrQ.jpeg" /><figcaption>Some of these look pretty strange</figcaption></figure><p>The new results were certainly “plastic”, but slightly <em>frightening</em>, too, with some appearing to have extra paws.</p><p>Again, Alena repeated the prompt, trying to turn the cat black and more like GitHub’s mascot: pixar style 3d of a black toy plastic cat in a spacesuit playing with a ball on solid green background --ar 3:2 --v 4</p><figure><img alt="16 3D images of black cats in black space suits playing with balls" src="https://cdn-images-1.medium.com/max/1024/1*ccv62q7Eu2AqAgApha7drg.jpeg" /><figcaption>Where’s the action?</figcaption></figure><p>She repeated this several times, but it seemed to always lack dynamics. Thus, she tried to add some text that would indicate motion: plastic toy cat in a spacesuit jumping and playing with a ball, black on solid green background, Pixar style isometric 3d render --ar 3:2 --v 4</p><figure><img alt="4 3D black cats in black spacesuits playing" src="https://cdn-images-1.medium.com/max/1024/1*76C4re8uM1DKFS2Isl6GHQ.jpeg" /><figcaption>Go kitties!</figcaption></figure><p>Yes! Now it appears quite dynamic, and much more interesting. Adding the term “jumping” instantly gave the results the missing X factor. From here, some variations were generated:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EsdXjbbjgec6lsO7z7XyzQ.jpeg" /><figcaption>A star is born</figcaption></figure><p>From here, Alena upscaled a winning selection.</p><figure><img alt="A 3D black cat in a black spacesuit chasing a black ball." src="https://cdn-images-1.medium.com/max/1024/1*tDhxPp2PMPjj2-7u0Vk-5A.jpeg" /></figure><p>Since Midjourney isn’t so good at working with the solid, uniform backgrounds required by our blog, we needed a tool to smooth things out. Luckily, the AI-powered <a href="https://www.remove.bg/">Remove.bg</a> can do just that.</p><figure><img alt="A 3d black cat in black spacesuit chasing a black ball against a uniform green background" src="https://cdn-images-1.medium.com/max/1024/1*ovIemjXEFtCaS0KDntQZrQ.jpeg" /></figure><p>And there it is! All in all, it took around an hour and a half of focused work.</p><h4>So, who won?</h4><p>For this first experiment, the human illustrator certainly required less art direction, while the AI delivered a final working result <em>days</em> faster. In terms of cost, the AI was also vastly cheaper. As for the quality of the final result, that’s a bit subjective! (For the record, we used the human-made illustration <a href="https://evilmartians.com/chronicles/journey-from-circleci-to-github-actions">for that article</a>.) What do you think?</p><p><strong>And this was just round one!</strong> If you’re interested in seeing more battles, head to <a href="https://evilmartians.com/chronicles/midjourney-vs-human-illustrators-has-ai-already-won">the full article on our blog</a>: we ran the same experiment multiple times, and you’ll also be able to see more detailed technical breakdowns and cost comparisons there. Check it out!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=acded6e90efb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/evil-martians/can-midjourney-ai-outperform-a-human-artist-we-tried-it-out-at-work-acded6e90efb">Can Midjourney AI outperform a human artist? We tried it out at work.</a> was originally published in <a href="https://medium.com/evil-martians">Evil Martians</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PostCSS Second Birthday]]></title>
            <link>https://medium.com/evil-martians/postcss-2nd-birthday-2c76c223c78f?source=rss----e2969ed68dd3---4</link>
            <guid isPermaLink="false">https://medium.com/p/2c76c223c78f</guid>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[postcss]]></category>
            <category><![CDATA[css]]></category>
            <dc:creator><![CDATA[Andrey Sitnik]]></dc:creator>
            <pubDate>Mon, 07 Sep 2015 14:15:59 GMT</pubDate>
            <atom:updated>2021-01-02T22:51:53.820Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-sa/4.0/</cc:license>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/604/1*PuJ5x2OKWBSI_ocNHTn_dw.jpeg" /><figcaption>Artwork: “Forest Festivities” by <a href="https://jahna-vashti.com/">Jahna Vashti</a>; celebration mashup by Vadim Makeev</figcaption></figure><p><strong><em>Author:</em></strong><em> Andrey Sitnik, PostCSS and Autoprefixer author, Lead Front-end Developer at Evil Martians.</em></p><p><strong><em>We’ve moved! Check out </em></strong><a href="https://evilmartians.com/chronicles/postcss-second-birthday"><strong><em>this post</em></strong></a><strong><em> — and other posts by fellow martians — on our new blog, </em></strong><a href="https://evilmartians.com/chronicles"><strong><em>Martian Chronicles</em></strong></a><strong><em>!</em></strong></p><p>PostCSS celebrates its second birthday today. <a href="https://github.com/postcss/postcss/commit/2d96cea96e3a96f616c28f897358086a69caa506">The first commit</a> to the PostCSS repository was made exactly two years ago, on September 7th, 2013. After 3 months, the very first plugin (<a href="https://github.com/robwierzbowski/grunt-pixrem">grunt-pixrem</a>) was released. On December 22nd, 2013, Autoprefixer, that was previously using the Rework framework, finished its migration to PostCSS.</p><p>I’ve started the work on PostCSS with an idea of speeding up the evolution of CSS in the large, with an ambitious idea to make a frontend developer’s environment better. I think that we’ve done an excellent job in that regard!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H69DYtur6zeM2USDdwVGsQ.jpeg" /><figcaption>Russian PostCSS users</figcaption></figure><p>The most popular PostCSS application so far is, of course, Autoprefixer: a tool that allows frontend developers to forget about writing CSS prefixes completely. However, PostCSS has made an impact in many other areas as well. As it turns out, more than a quarter of PostCSS users do not use Autoprefixer at all! Here are some amazing tools and plugins that are built on PostCSS:</p><ul><li><a href="http://glenmaddern.com/articles/css-modules">CSS Modules</a> automatically isolates your classes and allows you to forget about class name conflicts or manual class naming methodologies like BEM.</li><li><a href="https://github.com/maximkoretskiy/postcss-autoreset">postcss-autoreset</a> protects your stylesheets from inherited properties and lets you forget about conflicts — for example when somebody sets `line-height: 0` and breaks your component as a result.</li><li><a href="https://github.com/MohammadYounes/rtlcss">RTLCSS</a> is a must-have tool for any project with Hebrew or Arabic localization support. It is used in production by WordPress and Semantic UI.</li><li><a href="https://github.com/jonathantneal/postcss-font-magician">Font Magician</a> allows you to forget about the @font-face rule.</li><li><a href="http://benfrain.com/floss-your-style-sheets-with-stylelint/">stylelint</a> brings modular design to CSS linters. It is as important for CSS as is ESLint for JavaScript.</li><li><a href="http://cssnext.io/">cssnext</a> brings many “CSS4” syntaxes and properties to current development. It many ways it is like Babel for CSS.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CebOhGMIfpvamzDFOGpARw.png" /><figcaption>Download statistics by npm-stat</figcaption></figure><p>At the moment of writing, there are more than 270 plugins by more than a hundred authors. PostCSS crossed the 850 000 monthly npm downloads mark at August. So now, it is finally my pleasure to say a huge “thank you” to the many people who made PostCSS possible.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GHX8rzQyJJx7fsVDKXQtOQ.jpeg" /><figcaption>Ben Briggs, author of cssnano and many other PostCSS tools</figcaption></figure><p>TJ Holowaychuk introduced the idea of a modular CSS processor in his Rework project. Rework team made an amazing tool and inspired the PostCSS architecture. Rob Wierzbowski, Kyo Nagashima, and Mohammad Younes were the first developers to see a bright future in PostCSS and build the first plugins. Maxime Thirouin helped to jump-start the PostCSS community and authored the cssnext tool. Simon Lydell is the author of the excellent source map support in PostCSS. Vyacheslav Shebanov and my Evil Martians colleague Ravil Bayramgalin are the authors of the PostCSS “performance miracle” — a set of outstanding optimizations that make PostCSS the most performant CSS processor. Ben Briggs made many awesome plugins and tool for other plugins. David Clark and Jonathan Neal write documentation of excellent quality and spend a lot of their time in our Gitter chat to help new users.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s0LSy1r-VNUFwWhArwXEBg.jpeg" /><figcaption>Chinese PostCSS users</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/737/1*HLDv9K40LATsqjQ7576eZw.jpeg" /><figcaption>Masaaki Morishita at Japanese PostCSS birthday party</figcaption></figure><p>PostCSS is a true community project. I would like to say a special “thank you” to each and every PostCSS plugin author. PostCSS core is rather minimal, but the outstanding work of plugin authors is a genuine source of PostCSS power and popularity.</p><p>So bottoms up for the first two years — and here’s to hope that it is only the beginning. PostCSS is about freedom: a freedom to suggest your way of CSS development and freedom to be creative and distinguish from the current dogmas of frontend development process. Thank you so much and jump on in!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2c76c223c78f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/evil-martians/postcss-2nd-birthday-2c76c223c78f">PostCSS Second Birthday</a> was originally published in <a href="https://medium.com/evil-martians">Evil Martians</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[State Machine]]></title>
            <link>https://medium.com/evil-martians/state-machine-3337b8776b49?source=rss----e2969ed68dd3---4</link>
            <guid isPermaLink="false">https://medium.com/p/3337b8776b49</guid>
            <category><![CDATA[design-tools]]></category>
            <category><![CDATA[plugins]]></category>
            <category><![CDATA[sketch]]></category>
            <dc:creator><![CDATA[Roman Shamin]]></dc:creator>
            <pubDate>Thu, 06 Aug 2015 17:09:30 GMT</pubDate>
            <atom:updated>2015-10-28T19:58:08.680Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/192/1*KRDi9b8mQoaiu4oTs40dMQ@2x.png" /></figure><h4>The State Switcher</h4><p><a href="https://medium.com/@romanshamin/bb453f46a788"><em>По-русски</em></a><em> | In English</em></p><p><strong><em>We’ve moved! Check out </em></strong><a href="https://evilmartians.com/chronicles/state-machine-the-state-switcher"><strong><em>this post</em></strong></a><strong><em> — and other posts by fellow martians — on our new blog, </em></strong><a href="https://evilmartians.com/chronicles"><strong><em>Martian Chronicles</em></strong></a><strong><em>!</em></strong></p><p>State Machine is a Sketch plugin. Installing it will allow you to use ⌃⌘S to switch an active tab on a tab bar you’re designing, an active navigation section in a menu, or a page number in a pagination control.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/522/1*hnfdJS1gFDEbwx57DLdm0g@2x.gif" /><figcaption>⌘R, change ID, ⌃⌘S</figcaption></figure><h4>How does it work</h4><p>The designer uses the component title to point to the element he wants to switch to and hits ⌃⌘S. The plugin finds the layer needed, the neighboring layer with the style that differs from it and swaps their styles.</p><p>The more elements a component contains, the more useful State Machine is. It may be excruciating to add a symbol for each state of a ten-page indicator by using <em>Insert → Symbol</em> for that each time. Here’s how it works with State Machine:</p><ol><li>Copy the component.</li><li>⌘R, change its ID.</li><li>⌃⌘S.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/150/1*p8asrtCqafgaAJ1r5zAfcg@2x.png" /></figure><p><em>To understand State Machine better<br>and play with examples a little bit,<br>get</em><a href="https://cdn.rawgit.com/romashamin/statemachine-sketch/master/Examples.sketch"><strong><em>Examples.sketch</em></strong></a><em> right now</em></p><h4>Organizing a component</h4><p>For State Machine to work, you need to organize a component properly. What does a properly organized component consist of, exactly?</p><ol><li>A group of layers, with one of the layers having a distinctive style (the “active” one).</li><li>A key (“::”) and an ID in layer names (see the example).</li><li>A key (“::”) and an ID of one of the layers in the group name (see the example).</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/340/1*I2fL2xqkhUVbx5fSyjSjOw@2x.png" /><figcaption>A component example: key and active layer ID in group name, layers include keys and ID each</figcaption></figure><p>Please note:</p><ul><li>State Machine ignores other groups inside the component, and it ignores layers without a key.</li><li>State Machine won’t do anything if there are less than three layers in a component.</li><li>State Machine assumes that a layer ID is a part of the string that follows the key name.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/420/1*mc4e8qK2oKa32KsYRBgbHw@2x.png" /><figcaption>A key (“::”) and an ID</figcaption></figure><p>The amount of time you invest in creating a proper structure and correctly formed names will pay for itself by the ability to automate further work with components — and the neatness of your Sketch design.</p><blockquote>Try Also: <a href="https://github.com/rodi01/RenameIt">RenameIt</a> plugin in tow with State Machine</blockquote><h4>Suitable components</h4><p>The plugin will work with interface components consisting of a collection of similar elements, with one of them considered “active”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*TAO68mi2_CGic4ebqR3DaA@2x.png" /><figcaption>No need to switch anything manually anymore</figcaption></figure><h4>Be careful with disabled styles</h4><p>If State Machine becomes buggy or will seem like it does not do anything, check if some of the component’s layers have some of their styles disabled. For instance, if you take some similar layers, add a Fill to one of them and turn it off afterward, Sketch will add the disabled fill parameters into the layer style anyway. This layer will look exactly like its neighbors, but technically, it will have a unique style, so State Machine will consider it an “active” element of the group.</p><p>State Machine enables the designer to address the component he’s working with as a whole. Design in once and treat it as a single unit later. Control the component by assigning layer IDs in component names instead of going under the hood every time something needs to be changed.</p><blockquote><a href="https://github.com/romashamin/statemachine-sketch">Download and Install State Machine</a></blockquote><p>State Machine is a free and open-source project <a href="https://github.com/romashamin/statemachine-sketch">hosted on GitHub</a>. Use <a href="https://github.com/romashamin/statemachine-sketch/issues">Issues</a> to report any bugs you find, and feel free to fork the repository if there is any additional functionality you would like to implement.</p><p><a href="https://github.com/romashamin/statemachine-sketch"><em>State Machine</em></a><em> | </em><a href="https://github.com/romashamin/statemachine-sketch/issues"><em>Issues on GitHub</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3337b8776b49" width="1" height="1" alt=""><hr><p><a href="https://medium.com/evil-martians/state-machine-3337b8776b49">State Machine</a> was originally published in <a href="https://medium.com/evil-martians">Evil Martians</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[New feature in Rails 5: render views outside of actions]]></title>
            <link>https://medium.com/evil-martians/new-feature-in-rails-5-render-views-outside-of-actions-2fc1181e86a8?source=rss----e2969ed68dd3---4</link>
            <guid isPermaLink="false">https://medium.com/p/2fc1181e86a8</guid>
            <dc:creator><![CDATA[Ravil Bayramgalin]]></dc:creator>
            <pubDate>Tue, 07 Jul 2015 12:26:49 GMT</pubDate>
            <atom:updated>2015-10-28T19:57:07.139Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*MAWPLF6luamR8QsgMCImcw@2x.png" /></figure><p><strong><em>Author:</em></strong><em> Ravil Bayramgalin, Lead Developer at Evil Martians, Ruby on Rails contributor, Open Source activist.</em></p><p><strong><em>We’ve moved! Check out </em></strong><a href="https://evilmartians.com/chronicles/new-feature-in-rails-5-render-views-outside-of-actions"><strong><em>this post</em></strong></a><strong><em> — and other posts by fellow martians — on our new blog, </em></strong><a href="https://evilmartians.com/chronicles"><strong><em>Martian Chronicles</em></strong></a><strong><em>!</em></strong></p><p>Ruby on Rails has been around a long time but nevertheless continues to evolve, and the most surprising thing is that DHH is still at it — imagine such commitment to the project after 11 years!</p><p>DHH has inspired a lot of new features in Rails 5. By the way, if you want to start contributing to Rails, you can begin doing so by tracking his issues. They provide many opportunities while being very broad in complexity. For example, most recent basic ones are <a href="https://github.com/rails/rails/issues/19082">Enumerable#without</a> and <a href="https://github.com/rails/rails/issues/20339">Enumerable#pluck</a>.</p><p>In this article, I’ll talk about my work on a more complex idea of DHH — <a href="https://github.com/rails/rails/issues/18409">Rendering views outside of actions</a>.</p><p>It needs to have a mention that DHH is not an abstract theoretician; all his ideas come from real-world needs and the continuous desire to improve the state of the framework.</p><p>Specifically, this feature was born out of a wish to render Rails views from background tasks and websocket workers.</p><p>At <a href="https://evilmartians.com/">Evil Martians</a>, we had a couple of use-cases as well: we had a need for async rendering of slow reports, and we needed to generate PDF documents as email attachments as well.</p><p>Rails 5 implements this feature with a <strong>render</strong> method, which is now available as a controller class method.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c253a67500aa63bfeed2f2f80621aaa6/href">https://medium.com/media/c253a67500aa63bfeed2f2f80621aaa6/href</a></iframe><p>It supports the same arguments as an instance method but returns a rendered text of a template.</p><p>Templates usually use instance variables as a way to access data from an action. To render such templates without an action, a new option is now available: <strong>assigns</strong>. It enables you to set instance variables in a template explicitly.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6638249457f877326915db00172234e8/href">https://medium.com/media/6638249457f877326915db00172234e8/href</a></iframe><p>That should be sufficient for the most simple cases. However, for more complex situations we need to introduce something called a Request Environment.</p><h4>Request Environment</h4><p>All templates are rendered in a certain context with supplementary data.</p><p>Let’s say we use the <strong>users_url</strong> helper. How does this helper know the HTTP hostname and schema from if <strong>default_url_options</strong> is empty?</p><p>It has access to the hostname and schema via a request environment. If you are unfamiliar with the term, no worries — a short introduction follows.</p><p>All Rails requests have the environment context in which they perform. This context is a simple Ruby hash containing data associated with the request. Let me give you an example of the basic request environment.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f10254ff430015481a780cba7a372f50/href">https://medium.com/media/f10254ff430015481a780cba7a372f50/href</a></iframe><p>Each request corresponds to a separate environment.</p><p>You can access the environment as <strong>request.env</strong> in Rails action. This feature is not unique to Rails: most Ruby web frameworks are built on top of <a href="http://rack.rubyforge.org/doc/SPEC.html">Rack specification</a> and request environment is a part of the specification.</p><p>Libraries and frameworks use Rack environment as a place to store request related data — Ruby on Rails keeps session data and cookies in there as well.</p><p>But let’s get back to our <strong>users_url</strong> example. HTTP host and schema are fetched from a default renderer environment:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/907b8d50d6991122e5a96c09db13c5cb/href">https://medium.com/media/907b8d50d6991122e5a96c09db13c5cb/href</a></iframe><p>To change the environment in which template is rendered, we need to change <strong>renderer.defaults</strong> or initialize a new renderer in an explicit way.</p><p>Let’s configure our URL helpers to use the <strong>HTTPS</strong> scheme and <strong>evilmartians.com</strong> host with a new renderer:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b5c2ab7de5c93b213856f0a1a43ba1d6/href">https://medium.com/media/b5c2ab7de5c93b213856f0a1a43ba1d6/href</a></iframe><p>This example shows that since templates use helpers, it may be necessary to adjust a request environment even though we render outside of a request-response cycle.</p><h4>Pitfall #1</h4><p>Remember me mentioning that some libraries use the environment to store data? Well, helpers from these gems might depend on the environment to contain data populated by middlewares.</p><p>For example, if you use Devise</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a60197a143f2b11e5e95cf002bf90080/href">https://medium.com/media/a60197a143f2b11e5e95cf002bf90080/href</a></iframe><p>All Devise helpers depend on a properly initialized <strong>warden</strong> key in the environment. However, it is missing here since no middleware has been executed.</p><p>Ideally in situations like these, helpers should use a fallback for a missing value automatically. Hopefully, more gem authors would be aware of situations like these and improve their code if relevant issues are created.</p><p>As a workaround, a missing key can be provided manually. However, it is not always easy to find out what key is missing and what value should an environment hold.</p><p>The task becomes much easier if the environment could be inspected after a middleware stage. A simple hack to achieve this would be:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b1c2929287e92f113bd306483853d147/href">https://medium.com/media/b1c2929287e92f113bd306483853d147/href</a></iframe><p>In this example, I’ve highlighted the key that we were after to fix Devise rendering.</p><p>Hopefully, all gems could provide environment fallbacks, and developers would not spend time fixing helper failures by deducing what’s missing from the environment.</p><h4>Pitfall #2</h4><p>There is one more example of a possible problem when rendering views. <strong>url_for</strong> is sometimes used to rewrite current URL with additional parameters, but it does not work out of the box:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/aa358ccd9078cdd175c644392d9e5cc0/href">https://medium.com/media/aa358ccd9078cdd175c644392d9e5cc0/href</a></iframe><p>This exception happens since <strong>url_for</strong> searches for a current route based on params. No params are specified here (except a default “index” fallback for action), and the only route we do have is a catalog page that does not match such params.</p><p>Therefore, to fix our problem, it should be enough to specify the appropriate params. It will be easy once we remember that route parameters are stored in environment under <strong>action_dispatch.request.path_parameters</strong> key:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ec09f217e4089018aa9e62f24f50103d/href">https://medium.com/media/ec09f217e4089018aa9e62f24f50103d/href</a></iframe><h4>Conclusion</h4><p>A new API to render outside of an action in Rails 5 won’t take long to learn since it is very similar to usual <strong>render</strong> calls.</p><p>The only difference is that templates would use a virtual environment instead of a real one. Using a virtual environment leads to a couple of gotchas that we’ve already discussed. Associated problems will disappear in future.</p><p>By the way, I’ve backported this feature to Rails 4. Just add the <strong>backport_new_renderer</strong> gem to your project Gemfile and you’ll have the same API available.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2fc1181e86a8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/evil-martians/new-feature-in-rails-5-render-views-outside-of-actions-2fc1181e86a8">New feature in Rails 5: render views outside of actions</a> was originally published in <a href="https://medium.com/evil-martians">Evil Martians</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RailsConf 2015 Recap and Thoughts]]></title>
            <link>https://medium.com/evil-martians/it-was-my-first-railsconf-first-both-as-a-speaker-and-attendee-i-ve-been-to-many-other-3d172aade557?source=rss----e2969ed68dd3---4</link>
            <guid isPermaLink="false">https://medium.com/p/3d172aade557</guid>
            <category><![CDATA[conference]]></category>
            <category><![CDATA[railsconf]]></category>
            <category><![CDATA[rails]]></category>
            <dc:creator><![CDATA[Kir Shatrov]]></dc:creator>
            <pubDate>Sat, 25 Apr 2015 16:44:47 GMT</pubDate>
            <atom:updated>2015-10-28T19:55:55.324Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O1EpFJdTsoZfGUhvnHJD1g.jpeg" /></figure><p><strong><em>Authors:</em></strong><em> Kir Shatrov, Lead Developer at Evil Martians, Rails contributor, and Capistrano maintainer; Yaroslav Markin, co-founder and CTO at Evil Martians.</em></p><p><strong><em>We’ve moved! Check out </em></strong><a href="https://evilmartians.com/chronicles/railsconf-2015-recap"><strong><em>this post</em></strong></a><strong><em> — and other posts by fellow martians — on our new blog, </em></strong><a href="https://evilmartians.com/chronicles"><strong><em>Martian Chronicles</em></strong></a><strong><em>!</em></strong></p><p><strong><em>Kir:</em></strong> It was my first time at RailsConf — both as a speaker and as an attendee. I&#39;ve been to many other conferences including RubyConf and even co-organized a Ruby-related conference back in Russia, but the RailsConf experience was the most impressive in my life. Three days and six tracks, that was huge!</p><p>Please note that the videos are currently available only for the talks presented in Room 202. There were five other tracks, and the recorded videos will be published soon. Thanks go to <a href="http://www.confreaks.com/">Confreaks</a> for recording all Rails talks!</p><h3>DHH’s Keynote</h3><p>David’s keynote, a must-watch: <a href="https://www.youtube.com/watch?v=oMlX9i9Icno&amp;feature=youtu.be&amp;t=25m55s">https://www.youtube.com/watch?v=oMlX9i9Icno&amp;feature=youtu.be&amp;t=25m55s</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*twMtZ3rX9fHeXyR205kQRw.jpeg" /><figcaption>David announcing Rails 5</figcaption></figure><p><strong><em>Yaroslav:</em></strong> First and foremost, it’s hard not to <em>/facepalm</em> after seeing this:</p><h3>Aaron Patterson on Twitter</h3><p>It&#39;s really awesome to be on the Rails core team and have no idea that Action Cable existed until today! #RailsConf</p><p>As a team member of the <a href="http://rubynoname.ru/">Ruby NoName Podcast</a>, a Russian Ruby-and-everything-related podcast, I did an interview with Aaron Patterson on his visit to Moscow for RailsClub’2014, a Russian Ruby on Rails conference. The interview is available here (English sound, Russian subtitles): <a href="http://rubynoname.ru/posts/2014/S06E17.html">http://rubynoname.ru/posts/2014/S06E17.html</a>.</p><p>One of the topics (that, of course, just had to be discussed) was if Rails is still led by Basecamp development; and yes, Aaron confirmed — it’s still pretty much Basecamp Rails (and there will be no attempt at making, say, “RedHat Rails”, following Aaron’s new job at RedHat). David is the one calling the shots, plain and simple. While it’s been known for a while now, it’s still surprising — and it’s not a good kind of surprise — to see that while one of the most important Rails maintainers is trying to make a <a href="https://github.com/tenderlove/the_metal">good Node-like API for Rails</a>, the announcement of a full-stack Websockets support can be completely sudden even for him!</p><p>Second, the Rails 5 announcement itself. Mad props go to David for walking the audience through the thought process and decision-making process in deep. While both of main announcements (ActionCable and Turbolinks 3) do sound promising, it’s still impossible to try ActionCable out at the moment of writing (the release is due in a couple of months, I think). The Turbolinks 3 gem seems to be merged <a href="https://github.com/rails/turbolinks">into the repository</a>, and we are going to try it out a bit later.</p><p>The biggest problem with Turbolinks so far, of course, was its “resentment” to all and any JavaScript frameworks. An alumni of Evil Martians, <a href="https://github.com/kossnocorp">Sasha Koss</a>, tried to solve the problem with the <a href="https://github.com/kossnocorp/jquery.turbolinks">jquery.turbolinks plugin</a>, but wasn’t successful much. Still, the biggest question to Turbolinks 3 stays: it’s not about the increased list of features (they do look great for quick development and prototyping — as opposed to starting an application with a full-blown SPA approach), but if Turbolinks still breaks all cooperation attempts with other JavaScript frameworks. Even with the most basic applications you would eventually kill all Turbolinks-related code and switch to do-everything-yourself approach as it would be faster and cheaper than integrating Turbolinks with other frameworks. I hope that it is no longer the case, but I’m not too optimistic.</p><p>To finish, the pros and cons of these two new announcements (not talking about the <em>-- api</em> app generator switch, that is in no way new) are that they are surprisingly not that important for Rails future.</p><p>If Turbolinks does annoy you (from my point of view, that is true for most Rails teams), just don’t use it — it does not matter much. If you like the approach and have an “allergy” for JavaScript as a language and for any JavaScript framework as a consequence of that — the update is definitely for you. I still wonder about how usable exactly ActionCable would be, but the truth is, a lot of Rails applications are already utilizing more than one language at the backend, and people (our team included) have been implementing WebSocket backends for a number of years now. You could go with Node.js, Erlang, a JVM-based language like Scala, Go, or whatever the favor-of-the-month language is. So far, it does not sound like ActionCable would fundamentally change the way things are in that department.</p><p>Ruby on Rails continues to be the best full-stack web framework on the market — miles ahead of competitors — even when used as a mobile API backend, an SPA backend, or a base for a simple micro-service. Unfortunately, the new features introduced in the talk are not new in a fundamental way and they don’t define the future of a framework.</p><p>You can also check out a couple of other write-ups regarding the talk by DHH — an <a href="https://www.amberbit.com/blog/2015/4/22/why-rails-5-turbolinks-3-action-cable-matter-and-why-dhh-was-right-all-along/">optimistic one</a> and a <a href="http://railsbird.tumblr.com/post/117076597115/existential-crisis-at-railsconf">depressing one</a>.</p><p><strong><em>Kir: </em></strong>my notes below summarize the most notable talks (in my humble opinion, of course), and they are listed in the order the talks were presented.</p><h3>Riding Rails for 10 years</h3><p>Video: <a href="https://youtu.be/oMlX9i9Icno?t=2h40m32s">https://youtu.be/oMlX9i9Icno?t=2h40m32s</a></p><p>Great talk by <a href="https://twitter.com/johnduff">John Duff</a> on how did the Shopify app codebase change since Rails 1.2 to 4.2. I did enjoy the slides about how the API has changed version by version and about their Rails upgrade story. This is why I like the Shopify team: they probably have the second oldest Rails app (Basecamp being the first) with up-to-date codebase, and up to 150 developers working on the app at the same time.</p><h3>Scaling Rails for Black Friday or Cyber Monday</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fspeakerdeck.com%2Fplayer%2Fb1b27232484d447abc790ec4e27d8f3c&amp;url=https%3A%2F%2Fspeakerdeck.com%2Fcjoudrey%2Fcyber-monday-at-shopify&amp;image=https%3A%2F%2Fspeakerd.s3.amazonaws.com%2Fpresentations%2Fb1b27232484d447abc790ec4e27d8f3c%2Fslide_0.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=speakerdeck" width="710" height="596" frameborder="0" scrolling="no"><a href="https://medium.com/media/c59b435f35a43810703eb24130d3cb88/href">https://medium.com/media/c59b435f35a43810703eb24130d3cb88/href</a></iframe><p>Another talk by a Shopify developer, Christian Joudrey, was as good as the “Riding Rails for 10 years”. There are not so many companies that share such experience about scaling Rails — for just one day, the Black Friday — and Shopify is one of them. The main idea behind the ability to serve more clients is to reduce Unicorn response time or add new workers. Christian demonstrated their gem for caching that they use at Shopify, called “<em>identity_cache</em>”. I was surprised to learn that people do put serialized ActiveRecord models into Memcache to cut down DB hits; this was one of the solutions Christian did mention.</p><h3>Better callbacks in Rails 5</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fspeakerdeck.com%2Fplayer%2F7cc4bab3d76c4387a3d68d1c7ff4380f&amp;url=https%3A%2F%2Fspeakerdeck.com%2Fclaudiob%2Fbetter-callbacks-in-rails-5&amp;image=https%3A%2F%2Fspeakerd.s3.amazonaws.com%2Fpresentations%2F7cc4bab3d76c4387a3d68d1c7ff4380f%2Fslide_0.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=speakerdeck" width="710" height="596" frameborder="0" scrolling="no"><a href="https://medium.com/media/5b2e3b61588d3f62fe3adbc3531679bf/href">https://medium.com/media/5b2e3b61588d3f62fe3adbc3531679bf/href</a></iframe><p>This talk by Claudio Baccigalupo was one of my favorites. He is a member of Rails team, and he worked a lot on “rethinking” callbacks in Rails 5. Here is an example of how behavior of returned value will change:</p><pre>class User &lt; ActiveRecord::Base<br>  before_save { |u| u.admin ||= false }<br>end</pre><pre># rails 4:<br>User.create! =&gt; ActiveRecord::RecordNotSaved</pre><pre># rails 5:<br>User.create! =&gt; true</pre><p>There is also a new shiny <em>abort</em> method if you’d like to prevent the saving of the record inside the callback in Rails 5. I’ve asked him a tricky question: basically if we should teach new Rails developers how to use callbacks properly and how to avoid “callback hell” in ActiveRecord models. We’ve decided that maybe it’s time to think about a Rails Guide containing “best practices” of using callbacks and about separating logic between MVC layers.</p><h3>Processes and Threads — Rescue vs. Sidekiq</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fspeakerdeck.com%2Fplayer%2F1ba1cdfcad014c2cb7a6cbcc59714bd6&amp;url=https%3A%2F%2Fspeakerdeck.com%2Fjdabbs%2Fprocesses-and-threads-resque-vs-sidekiq&amp;image=https%3A%2F%2Fspeakerd.s3.amazonaws.com%2Fpresentations%2F1ba1cdfcad014c2cb7a6cbcc59714bd6%2Fslide_0.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=speakerdeck" width="710" height="463" frameborder="0" scrolling="no"><a href="https://medium.com/media/44759995c83fbe10c08c65eae377d5fe/href">https://medium.com/media/44759995c83fbe10c08c65eae377d5fe/href</a></iframe><p>Before I came to the talk, I expected James Dabbs only to cover differences between these two queue processors by making some comparison table. But, in fact, he did demonstrate all the internals, how do forking and threads work in Ruby and what are the basic concepts. Also, during the session, he demonstrated stack calls by jumping into the code with the <em>pry</em> gem in both Sidekiq and Resque.</p><h3>Aaron’s keynote</h3><p>Video: <a href="https://youtu.be/wQCda5PBn0A?t=25m19s">https://youtu.be/wQCda5PBn0A?t=25m19s</a></p><p>All Aaron’s talks are awesome. He has a great talent to combine jokes, ideas and code in a single keynote. On this RailsConf he opened the second day by talking about RubyGems/Bundler performance, about how <em>require</em> works in Ruby and how are we going to deprecate controller tests with integration tests — that will be even faster than the controller tests we have now.</p><h3>How Rust helped Us Write Better Ruby</h3><p>This talk was about how does Skylight (a Rails applications profiling and monitoring service, founded by Yehuda Katz) use Rust for their report agent. The agent ships with the “<em>skylight</em>” gem and used by client Rails apps to track performance and report it back to Skylight. Skylight did choose Rust to make the report agent to be able to serve thousands of requests per second and to avoid GC pauses inside this agent. In the talk, Yehuda and Tom did demonstrate a few examples of Rust memory management and how powerful it can be.</p><h3>Designing a Great Ruby API — How We are Simplifying Rails 5</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fspeakerdeck.com%2Fplayer%2F2a56dba370414cd1a48d1aa43d8fffab&amp;url=https%3A%2F%2Fspeakerdeck.com%2Fsgrif%2Fdesigning-a-great-ruby-api-how-were-simplifying-rails-5&amp;image=https%3A%2F%2Fspeakerd.s3.amazonaws.com%2Fpresentations%2F2a56dba370414cd1a48d1aa43d8fffab%2Fslide_0.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=speakerdeck" width="710" height="463" frameborder="0" scrolling="no"><a href="https://medium.com/media/ec41bf9431190f152cdf8f7814c73c91/href">https://medium.com/media/ec41bf9431190f152cdf8f7814c73c91/href</a></iframe><p>This talk was on the last day of RailsConf. I’ve met Sean Griffin at the speakers dinner on Monday, the day before the conference — when he told me about his topic and I’ve been looking forward to watching his talk since that moment for 3 days.</p><p>Sean talked about <em>a lot</em> of ActiveRecord refactoring in Rails 4.2 made by him, about how he changed typecasting and how we are going to make it even better in Rails 5 by shipping the Attributes API.</p><h3>Nothing is Something</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fspeakerdeck.com%2Fplayer%2F8a7c2c1ace3448648d73217d91c3348d&amp;url=https%3A%2F%2Fspeakerdeck.com%2Fskmetz%2Fnothing-is-something-railsconf&amp;image=https%3A%2F%2Fspeakerd.s3.amazonaws.com%2Fpresentations%2F8a7c2c1ace3448648d73217d91c3348d%2Fslide_0.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=speakerdeck" width="710" height="463" frameborder="0" scrolling="no"><a href="https://medium.com/media/1211f0cf8f4c2e57be0d0cf10466bda8/href">https://medium.com/media/1211f0cf8f4c2e57be0d0cf10466bda8/href</a></iframe><p>The last talk on the 3rd day by Sandi Metz was as great as any of her other talks you’ve ever heard. Sandi started by demonstrating Smalltalk ideas that we have in Ruby, and then talked about why inheritance is sometimes not the best solution, and about how we can use advantages of the NullObject pattern in Ruby. I enjoyed all 600 slides with code, and I can say that it was the most “code-oriented” talk at the conference.</p><h3>My talk</h3><p>You can also check out my talk about performance regressions in Rails and about the tool I’ve been working on to track Rails performance.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fspeakerdeck.com%2Fplayer%2F1ef05d2c8fa04bc0a2bc8cb994e566ef&amp;url=https%3A%2F%2Fspeakerdeck.com%2Fkirs%2Fbuilding-a-toolkit-to-detect-performance-regressions-in-ruby-on-rails-core&amp;image=https%3A%2F%2Fspeakerd.s3.amazonaws.com%2Fpresentations%2F1ef05d2c8fa04bc0a2bc8cb994e566ef%2Fslide_0.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=speakerdeck" width="710" height="463" frameborder="0" scrolling="no"><a href="https://medium.com/media/69276705a29f9849180e06b43704dea1/href">https://medium.com/media/69276705a29f9849180e06b43704dea1/href</a></iframe><p>I’ve been preparing for my RailsConf talk for almost three months (five months if we count the benchmarks implementation), and it was one of the most exciting experiences in my life this year. It wouldn’t be possible without help by <a href="http://twitter.com/yaroslav">@yaroslav</a>, <a href="http://twitter.com/samsaffron">@samsaffron</a>, and <a href="http://twitter.com/tgx_world">@tgxworld</a>. Thank you guys!</p><p>I’ve had the most exciting three days in Atlanta, and I’m looking forward to visiting the next RailsConf — in Kansas City:</p><h3>RailsConf 2015 on Twitter</h3><p>Kansas City, MO: home of barbecue, jazz, and RailsConf 2016! We hope to see you there from May 4-6, 2016.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3d172aade557" width="1" height="1" alt=""><hr><p><a href="https://medium.com/evil-martians/it-was-my-first-railsconf-first-both-as-a-speaker-and-attendee-i-ve-been-to-many-other-3d172aade557">RailsConf 2015 Recap and Thoughts</a> was originally published in <a href="https://medium.com/evil-martians">Evil Martians</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rails 5: what’s new]]></title>
            <link>https://medium.com/evil-martians/the-rails-5-post-9c76dbac8fc?source=rss----e2969ed68dd3---4</link>
            <guid isPermaLink="false">https://medium.com/p/9c76dbac8fc</guid>
            <dc:creator><![CDATA[Kir Shatrov]]></dc:creator>
            <pubDate>Tue, 07 Apr 2015 17:05:36 GMT</pubDate>
            <atom:updated>2015-10-28T19:55:04.174Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*bffpWDbmllTNTM3Ws1phLQ@2x.png" /></figure><h4>Test runner, where.or, new test request API, Render From Anywhere and no more alias_method_chain</h4><p><strong><em>We’ve moved! Check out </em></strong><a href="https://evilmartians.com/chronicles/rails-5-whats-new"><strong><em>this post</em></strong></a><strong><em> — and other posts by fellow martians — on our new blog, </em></strong><a href="https://evilmartians.com/chronicles"><strong><em>Martian Chronicles</em></strong></a><strong><em>!</em></strong></p><p>I’ve found a great post regarding the <a href="https://intercityup.com/blog/upcoming-changes-in-rails-5-0.html">upcoming changes in Rails 5</a> by <a href="https://twitter.com/jvanbaarsen">Jeroen van Baarsen</a>, and you should check it out if you’re interested in Rails Edge developments.</p><p>However, I felt like this post is just not enough since there are so many interesting things in the upcoming Rails 5 release. So here goes my very own “yet another review of Rails 5 features”.</p><p><strong>Note: </strong>This post was written before the RailsConf ActionCable/Turbolinks announces. To see our overview of RailsConf 2015 and our thoughts about the new features, check this post: <a href="https://medium.com/evil-martians/it-was-my-first-railsconf-first-both-as-a-speaker-and-attendee-i-ve-been-to-many-other-3d172aade557">RailsConf 2015 Recap and Thoughts</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/100/1*z5k5b4cmvzLaxZgPnHlUzw@2x.png" /></figure><h3>Rails Test runner</h3><p>The new runner is, in fact, my favourite piece of Rails 5. I love minitest, and I always was a bit envy of RSpec users, as they have a great runner that allows you to specify the file and line number of a failing spec.</p><p>Now, <a href="https://github.com/rails/rails/pull/19216">thanks to Yves Senn</a>, we have the same feature when using Rails’ minitest:</p><pre>$ bin/rails test test/models/post_test.rb<br>Run options: — seed 48587</pre><pre># Running:</pre><pre>..FF.</pre><pre>Finished in 0.024376s, 205.1198 runs/s, 287.1677 assertions/s.</pre><pre>1) Failure:<br>PostTest#test_failling_one [test/models/post_test.rb:32]:<br>Failed refutation, no message given</pre><pre>2) Failure:<br>PostTest#test_has_likes [test/models/post_test.rb:23]:<br>Failed assertion, no message given.</pre><pre>5 runs, 7 assertions, 2 failures, 0 errors, 0 skips</pre><pre>Failed test:</pre><pre>rails test test/models/post_test.rb:32<br>rails test test/models/post_test.rb:23</pre><p>At the bottom of this output, you can see the runner suggesting commands to execute only the failing samples line by line.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/100/1*NhdiahnWy3jEFX3kKiNbVA@2x.png" /></figure><h3>ActiveRecord::Base#where.or</h3><p>Previously, to use `OR` conditions with the ActiveRecord query builder, we had to construct the query manually by using Arel:</p><pre>User.where(users[:name].eq(‘bob’).or(users[:age].lt(25)))</pre><p>In 2013, Rails 4.0 <a href="https://robots.thoughtbot.com/activerecords-wherenot">introduced</a> `where.not` chain method in ActiveRecord, and <a href="https://github.com/rails/rails/pull/16052">now in 5.0 we finally have `where.or`</a>:</p><pre>Post.where(&quot;id = 1&quot;).or(Post.where(&quot;id = 2&quot;)) # =&gt; SELECT * FROM posts WHERE (id = 1) OR (id = 2)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/100/1*MHlZx4ODY7zUOaw2TrhpCg@2x.png" /></figure><h3>belongs_to is required by default</h3><p>DHH <a href="https://github.com/rails/rails/issues/18233">wrote</a> that almost every `belongs_to` declaration seemed to be a required association. Later, <a href="https://github.com/rails/rails/pull/18937">@simi implemented it</a>.</p><p>However, if your `belongs_to` association is not required, you could use the `optional: true` option:</p><pre>class User<br>  belongs_to :org, optional: true<br>end</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/100/1*z5k5b4cmvzLaxZgPnHlUzw@2x.png" /></figure><h3>ActiveRecord::Base#has_secure_token</h3><p>Do you use the <a href="http://api.rubyonrails.org/classes/ActiveModel/SecurePassword/ClassMethods.html">`has_secure_password` option</a> introduced back in Rails 3.1?</p><p>From now on, for fields like subscription token, we <a href="https://github.com/rails/rails/pull/18217">have `has_secure_token`</a>:</p><pre>class User &lt; ActiveRecord::Base<br> has_secure_token :token1, :token2, key_length: 30<br>end</pre><pre>user = User.new<br>user.save<br>user.token1 # =&gt; “973acd04bc627d6a0e31200b74e2236”<br>user.token2 # =&gt; “e2426a93718d1817a43abbaa8508223”<br>user.regenerate_token1! # =&gt; true<br>user.regenerate_token2! # =&gt; true</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/100/1*NhdiahnWy3jEFX3kKiNbVA@2x.png" /></figure><h3>No more alias_method_chain</h3><p>`alias_method_chain` method was there since the very early Rails versions and it was used all over the Rails code base and by various gems.</p><p>It was widely used to monkey patch or tweak any previously declared method:</p><pre>class ActionController::Base<br>  # overriding ActionController::Base load from gem<br>  alias_method_chain :params, :patched</pre><pre>  def params_with_patched<br>    result = params_without_patched<br>    # we can access and modify the result here<br>    result<br>  end<br>end</pre><p>But now, with `Module#prepend` available since Ruby 2.0 we can use native Ruby features to achieve the same result:</p><pre>module PatchedParams<br>  def params<br>    result = super<br>    # we can access and modify result here<br>    result<br>  end<br>end</pre><pre>ActionController::Base.prepend(PatchedParams)</pre><p>In Rails 5, <a href="https://github.com/rails/rails/pull/19434">`alias_method_chain` will be deprecated</a> in favor of the native Module#prepend.</p><p>Read more about alias_method chain here:</p><ul><li><a href="http://www.vaporbase.com/postings/alias_method_chain_in_a_module">http://www.vaporbase.com/postings/alias_method_chain_in_a_module</a></li><li><a href="http://yehudakatz.com/2009/03/06/alias_method_chain-in-models/">http://yehudakatz.com/2009/03/06/alias_method_chain-in-models/</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/100/1*MHlZx4ODY7zUOaw2TrhpCg@2x.png" /></figure><h3>Keyword arguments in controller &amp; integration tests</h3><p>Here is an example snippet you could find in a controller test:</p><pre>get :index, { id: 1 }, nil, { user_id: 1 }</pre><p>Does it make a lot of sense what every argument means exactly? Not much, so I proposed the <a href="https://github.com/rails/rails/pull/18323">new syntax with keyword arguments support</a> for request methods:</p><pre>post :create, params: { y: x }, session: { a: ‘b’ }<br>get :view, params: { id: 1 }<br>get :view, params: { id: 1 }, format: :json</pre><p>These changes apply when using any test framework — it doesn’t matter if you use RSpec or Minitest. The old syntax works as well, but it’s considered deprecated and will be removed later in Rails 5.1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/100/1*z5k5b4cmvzLaxZgPnHlUzw@2x.png" /></figure><h3>Render From Anywhere</h3><p>Earlier we had to use gems like <a href="https://github.com/yappbox/render_anywhere">render_anywhere</a> to render any views outside of controller — for example in Rake tasks or background jobs.</p><p>In Rails 5 you’ll have the ability to render your views from anywhere:</p><pre>ApplicationController.render _render_options_</pre><p>Besides the usual rendering options, in Rails 5 there is a new `assigns` option for passing instance variables to templates.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/100/1*NhdiahnWy3jEFX3kKiNbVA@2x.png" /></figure><p>Hope you like these new features. We will try to review more of them as we come closer to Rails 5 release candidates.</p><p>A great way to stay in touch with Edge Rails development is to subscribe to <a href="https://rails-weekly.ongoodbits.com/">This week in Rails</a> to receive weekly e-mail with scoop of interesting commits, pull requests and other stuff that is happening with Rails Core.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/100/1*MHlZx4ODY7zUOaw2TrhpCg@2x.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9c76dbac8fc" width="1" height="1" alt=""><hr><p><a href="https://medium.com/evil-martians/the-rails-5-post-9c76dbac8fc">Rails 5: what’s new</a> was originally published in <a href="https://medium.com/evil-martians">Evil Martians</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An annoying Capistrano, Unicorn and Bundler issue]]></title>
            <link>https://medium.com/evil-martians/an-annoying-capistrano-unicorn-and-bundler-issue-5eaf9e6db73?source=rss----e2969ed68dd3---4</link>
            <guid isPermaLink="false">https://medium.com/p/5eaf9e6db73</guid>
            <dc:creator><![CDATA[Kir Shatrov]]></dc:creator>
            <pubDate>Mon, 23 Mar 2015 11:15:17 GMT</pubDate>
            <atom:updated>2015-10-28T19:53:59.568Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*DOP8DOuEHSu73JCPywPEbg@2x.png" /></figure><h3>An annoying Capistrano, Unicorn<br>and Bundler issue</h3><p><strong><em>Authors:</em></strong><em> Kir Shatrov, Lead Developer at Evil Martians, current Capistrano maintainer; Kirill Kuznetsov, Lead of Operations Team at Evil Martians.</em></p><p><strong><em>We’ve moved! Check out </em></strong><a href="https://evilmartians.com/chronicles/an-annoying-capistrano-unicorn-and-bundler-issue"><strong><em>this post</em></strong></a><strong><em> — and other posts by fellow martians—on our new blog, </em></strong><a href="https://evilmartians.com/chronicles"><strong><em>Martian Chronicles</em></strong></a><strong><em>!</em></strong></p><p><strong>TL;DR:</strong> Always use an absolute path to Unicorn in Capistrano scripts; otherwise your application server will fail to restart after a number of deploys because of Capistrano release cleanups.</p><p>Last month, we came across an interesting problem: sometimes after a successful deploy of one of our Ruby on Rails 4 applications, a Unicorn server could not be restarted using <a href="http://unicorn.bogomips.org/SIGNALS.html">zero downtime deployment signal</a>. That affected all environments we run the application in — unfortunately, including production. As a result, we got annoying exceptions like <strong>ActionView::MissingTemplate</strong> in the production environment. Only a hard restart of Unicorn would fix that kind of exceptions.</p><p>We had no idea what could be the source of the issue, so we decided to check this case out using our monitoring system (Zabbix) to catch such incidents immediately and act on it.</p><p>Here is a simple Rails code snippet we&#39;ve used to detect if Unicorn was properly restarted:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0206bd4faf7d659b2849800d7c021273/href">https://medium.com/media/0206bd4faf7d659b2849800d7c021273/href</a></iframe><p>Note that the <strong>REVISION</strong> file is <a href="https://github.com/capistrano/capistrano/blob/5d059b299a38130562f7a6d56cf63447eb0da06d/lib/capistrano/tasks/deploy.rake#L209">written by Capistrano</a> on every deploy, so we can simply compare the contents of the file with the current application revision we have in memory.</p><p>And here is a snippet of Zabbix configuration we&#39;ve used:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8cd4807f2fd226a3c38a520ff9bcdca4/href">https://medium.com/media/8cd4807f2fd226a3c38a520ff9bcdca4/href</a></iframe><p>Next, we’ve created a Zabbix agent item (“Revision status check”) and used it for a trigger:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/624ffdfb283083aaaa9a014b5a52f019/href">https://medium.com/media/624ffdfb283083aaaa9a014b5a52f019/href</a></iframe><p>Now, how does this trigger work, exactly? It checks for a non-200 HTTP response and ensures that it persists during a period, to prevent false alerts during deploys and rebouncing. Google “Hysteresis in Zabbix” for more details, if you&#39;re interested.</p><p>The first alert we&#39;ve got led us to the following output in the Unicorn log file:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f2c86c9d5324cd8029eec917263d426e/href">https://medium.com/media/f2c86c9d5324cd8029eec917263d426e/href</a></iframe><p>And at that moment I’ve started to get a clear understanding of what’s going on.</p><p>Here is how zero-downtime Unicorn deploy <a href="http://unicorn.bogomips.org/SIGNALS.html">works</a>: it starts the master process and replaces it with a fork on the next deploy.</p><p>On the first deploy, <strong>bundle exec unicorn_rails</strong> command was mapped to <strong>/home/project/releases/1/vendor/bundle/ruby/2.1.0/bin/unicorn_rails</strong>, which started properly. But later, let’s say on 100th deploy, the original Unicorn <em>still</em> pointed to the <strong>/home/project/releases/1</strong> directory from the first release. By default, Capistrano 3 keeps only the last five releases and cleans up older releases (<strong>deploy:cleanup</strong> task runs automatically by default), and obviously <strong>/home/project/releases/1</strong> did not exist anymore.</p><p>Since <strong>/home/project/releases/1/vendor/bundle</strong> is just a symlink to <strong>/home/project/shared/vendor/bundle</strong>, we had to configure Bundler to map commands to the shared directory — which exists forever.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8bb57a9a5767ffc297803637443e0184/href">https://medium.com/media/8bb57a9a5767ffc297803637443e0184/href</a></iframe><p>Here is a problem: <strong>BUNDLE_PATH</strong> is relative, and it maps to <strong>/home/project/releases/1/vendor/bundle</strong>, which would be destroyed later after a few deploys.</p><p>And the fix:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/da93080de64c55f48aaca8100366c4b8/href">https://medium.com/media/da93080de64c55f48aaca8100366c4b8/href</a></iframe><p>In Capistrano 3, this patch can be applied by setting the `bundle_path` option:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9d49175b86e28e0907908ee087714efc/href">https://medium.com/media/9d49175b86e28e0907908ee087714efc/href</a></iframe><p>Done.</p><p>In spite of my history of contributions to Capistrano and Bundler, it was one of the most interesting bugs I’ve found recently.<br>We&#39;ve decided to keep monitoring Unicorn revisions to catch any failed restarts in future.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5eaf9e6db73" width="1" height="1" alt=""><hr><p><a href="https://medium.com/evil-martians/an-annoying-capistrano-unicorn-and-bundler-issue-5eaf9e6db73">An annoying Capistrano, Unicorn and Bundler issue</a> was originally published in <a href="https://medium.com/evil-martians">Evil Martians</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>