<?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 Théo Carrive on Medium]]></title>
        <description><![CDATA[Stories by Théo Carrive on Medium]]></description>
        <link>https://medium.com/@theo.carrive?source=rss-2ce34ca7e31a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Dynz1L2us0d5Y3-10uhg5g.jpeg</url>
            <title>Stories by Théo Carrive on Medium</title>
            <link>https://medium.com/@theo.carrive?source=rss-2ce34ca7e31a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 19:17:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@theo.carrive/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[How we work]]></title>
            <link>https://medium.com/cheerz-engineering/how-we-work-4157e918f20?source=rss-2ce34ca7e31a------2</link>
            <guid isPermaLink="false">https://medium.com/p/4157e918f20</guid>
            <category><![CDATA[scrum]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[organization]]></category>
            <dc:creator><![CDATA[Théo Carrive]]></dc:creator>
            <pubDate>Thu, 28 Jan 2021 17:25:21 GMT</pubDate>
            <atom:updated>2021-02-01T10:56:44.131Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Cheerz Engineering &amp; Product organisation</blockquote><p>Very often, I find myself being asked how our team is working: <em>How are you structured, what are the relations between product and development, who are the managers, who make sure that you deliver at the right pace?</em></p><p>Well, if many aspects of our organisation are similar to those of other tech companies (yes, we have squads, and we practice Scrum), some details make quite a big difference!</p><p>This is why I wanted to describe here how we work, but also some of the reasons why we chose to do so.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G1gRQMqMlAafVK3QENWq-g.png" /></figure><h3>🛤 <strong>One Roadmap to rule them all</strong></h3><p>Each quarter, we build a Product Roadmap for the whole company.</p><p>This roadmap is carefully crafted by our amazing Product Team, and describing this process would require another entire story. (<em>Please do email 📩</em><a href="/service/mailto:laure@cheerz.com"><em>Laure Bachy</em></a><em>, our CPO, to tell her that you would love her to write it</em>).</p><p>However, the key point here is that we have one global Product Roadmap.</p><p>Its purpose is to give vision to all members of Cheerz of what we want to address and what we plan to build in the following months, so that people can project themselves, prevent project collisions, reduce dependencies, and increase the belonging sense to the whole Cheerz project.</p><h4>70 / 20 / 10</h4><p>This is our recipe for a good roadmap.</p><ul><li>70% of the time allocated for features and “product” user stories</li><li>20% kept for technical user stories (platform projects, refactoring, etc.)</li><li>10% for quickwins, quickfixes.</li></ul><p>This allows us to continuously improve the quality of our platforms instead of piling up features.</p><h4>Solve a problem, not a solution</h4><p>We try to<strong> allocate time to solve a user pain-point, not to implement one solution: <br></strong>In our experience, projects too carefully detailed almost always led to a lot of frustration from the teams who lacked flexibility to adapt, and thus to project being late. Each “solution” or detailed project can reveal itself much longer to implement than expected, we think that what matters is to know approximately how much time we would be ready to invest if it could improve our most important “problem”.</p><h4><strong>🙅‍♀ </strong>Not a release plan</h4><p><strong>️This roadmap is not a release plan</strong>. The team does not commit on deadlines and their ability to end all the projects. Actually, we ended up estimating that if we achieved ~80% of our roadmap, we would be quite proud of the work done.</p><p>Actually, the roadmap would probably change during the quarter. Because we have new priorities that we could not predict, because we have a better understanding of some business aspects once we start working on them, there are many reasons for that. This is why, along the road, we try to communicate very frequently about our progress: <strong>Every 2 weeks, we send an update to the whole company, explaining what has been released, and what are the next topics we will work on.</strong></p><p><em>Alright, so, now that you have that roadmap for the next few months, how to make it happen? </em>🤓</p><p>Let’s not be too hasty. Before we can actually build things, we have a bit more work to do.</p><h3><strong>(🛤x4) From one to four roadmaps</strong></h3><p>We split our roadmap into four roadmaps. Each of those roadmaps would then belong to a team (= squad).</p><p><strong>One roadmap should try at all costs to not depend on the work of another</strong>. Every time we failed to do so, we ended up doing a lot of painful and valueless synchronisation work, and the projects almost every time ended much later than expected.</p><p>At Cheerz, here is how we decided to split our roadmap in 4:</p><ul><li><strong>“MadMen” squad:</strong> Onboarding of the users, until they start creating a Product</li><li><strong>“Evolution” squad:</strong> Help our users have the best experience when customising a product</li><li><strong>“Replay” squad:</strong> Make sure our users have the smoothest experience after customising their product, including payment and account management.</li><li><strong>“Deliver” squad:</strong> Once a purchase has been placed, Deliver make sure we print it, ship it, and communicate well to the customers.</li></ul><p>Now, I can tell you a bit more about those squads.</p><h3><strong>👨‍👩‍👦‍👦 One squad per roadmap</strong></h3><p>Once we know what we want to do and who will do it, we need to make it happen!</p><p>This is the squad role. This is the team that is going to refine each project of the roadmap, find concrete solutions, build, deploy, monitor, analyse, and iterate.</p><p>A typical squad is composed of:</p><ul><li>1 or 2 developers for each platform (platform = [backend, frontend, iOS, Android]). Ideally two developers of each to foster more collaboration per platform.</li><li>One Product Manager</li><li>One QA Tester</li><li>One UI/UX Designer</li></ul><p>If some of these roles could not be in the squad (because we don’t have enough Designers or QA for instance), those roles can eventually be shared, but we try to avoid this as much as possible, especially for Developers and Product Managers.</p><p><em>**</em><strong><em> If we can keep things even simpler, we do.</em></strong><em> For instance, our “Deliver” squad only has two back-end developers. No QA, no designer, no Product Manager. Because they work on very important tools, but mostly internal and with almost no UI and no API to mobile apps, we were able to build this very autonomous squad. **</em></p><p>In the team, we generally also have a role of Scrum Master. This is a role, not a job: Sometimes, this role will be played by one developer of the team, or the team will have set up a rolling-role (we assign one scrum master per sprint, and change each sprint).</p><p>And since we speak about Scrum Master, you might ask us: “Are you doing Scrum?”<br><strong>Absolutely</strong>. As close to <a href="https://www.scrumguides.org/scrum-guide.html">the book</a> as we can.</p><h3><strong>Scrum</strong></h3><p>I won’t go into too much details about Scrum, since the literature about it is far from being scarce, but to still give you some insights:</p><p><strong>We use 2-weeks sprints.</strong><br>Sprints start and end on wednesday, because we experienced that Friday was too much of the week-end already, and that Monday was too much stress to start the week with.</p><p><strong>But with an “intersprint”:</strong></p><p>Something new that we try this year: After two sprints, for one week, we do what we call an “intersprint”. During this week, we will encourage platform teams to work together on training and some technical projects while this should help the Product Team to be ahead, and always have enough backlog ready for development.</p><p><strong>Our main rituals include:</strong></p><ul><li>Daily Standup Meetings: 5 minutes exchange every morning to sync-up</li><li>Groomings: ~ 1h. To discuss the business goals of the project to come, refine the tasks.</li><li>Review: ~ 40 min. To show to the stakeholders what has been done, and what’s next to come.</li><li>Retrospective: ~1h. Inspect how the sprint well, and plan actions to improve.</li><li>Planning: ~1h. Plan what’s to be done in the next iteration.</li></ul><h3><strong>Squad autonomy</strong></h3><p>It’s key that we make sure that the squad is as much autonomous as possible. <strong>The squad must be able to deploy autonomously, to create new API, to take architecture decisions, etc</strong>. Of course, sometimes, things must be decided in a broader way than just at the squad level, but this should be for some big topics only, and not a regular situation for the squad.</p><p>OK. So far so good, but, if you read carefully, you might poke me with two main questions:</p><ul><li><em>I don’t see any manager in the squad! Who is working on developing the developers? </em>🤔</li><li><em>The developers of each platform are split into different teams, how do you unify the technical guidelines, create a vision for the platform, and take care of technical debt? </em>🧐</li></ul><p>And you would be completely right, those are two very valid questions. Here’s a free cake for you 🍩.</p><p>The answer to those two questions is actually the same: This is the job of Engineering Managers.</p><h3><strong>Engineering Management</strong></h3><p>For each platform (back, front, iOS, Android), we have one Engineering Manager.</p><p>Engineering Managers are the glue of the platforms.</p><p>They are in charge of developing the technical &amp; human skills of each people of its platform, to give vision.</p><p>In some companies, a “Chapter Lead” would be in charge of federating people working on a same discipline. At Cheerz, this is the job of the Engineering Manager.</p><h3><strong>So, 1 developer = 2 teams?</strong></h3><p>Exactly.</p><p>You guessed it right. And this a key takeaway of our organisation. Each developer belongs to:</p><ul><li><strong>1 project team:</strong> This is the day-to-day team with which the developer will work.</li><li><strong>1 platform team:</strong> This is what is also referred to as a “chapter” in some companies.</li></ul><p>I see you going “But, what exactly is a platform team?”</p><h3><strong>Platform Teams</strong></h3><p>Well, a platform team is simply a group of people who work on the same expertise (iOS, Android, Front-End, Backend, etc.).</p><p>The main goal of having a team is to be able to exchange with the team. To collaborate with the team. And this is what Engineering Managers make sure we organize: Opportunities for the team to gather, and work together.</p><p>For instance, a Platform Team can meet twice a week, with an agenda shared to all in advance, on which a member could have written technical questions he wants to discuss with the whole team: Style guide, technical debt, organization, etc.</p><p>It’s also the role of the Engineering Managers to make sure that the whole platform team share the same technical long-term vision, that each member is involved enough in working on the technical debt, etc.</p><h3>🛠 Platform Days</h3><p>Every year, during december and until Christmas, we have a huge pike of traffic. During this period that is highly strategic for us, we take the occasion to take a break from the fast-paced rythm of the year, and work on long term projects while minimizing risks: We dissolve squads, and work by platform on the platform backlogs.</p><p>This allows us to minimize risk by not releasing new features, while breaking the routine and investing in long-term technical projects.</p><h3>Product + Tech = 1 or 2 teams?</h3><p>For a long time, we had one Chief Technical Officer (me), directly managing the Product Managers, in addition to the Engineering Managers.</p><p>Product Management is key to align teams, reduce frictions and create business value. But Product Management is also hard. Like really really hard. Maybe I just didn’t have enough time to do it well, but what I can say for sure is that I did quite poorly at it.</p><p>One of the recent choices that I’m the happiest of, is my decision to hire a Head of Product, 18 months ago, who then structured the Product team (QA, Design, PM) and its processes.</p><p>With the time, we decided to promote the job of Head of Product to a job of Chief Product Officer, so that the Product Team would be directly represented in our Executing Committee, to reflect our vision of how key the Product Management is at a company level.</p><p>We (CPO &amp; CTO) work together closely, to setup methodologies, processes, work on culture, organisation and projects, so that not only we deliver well, but that we also always improve.</p><p>In the history of Cheerz, since Tech and Product have long been only one team, we didn’t have much trouble making Product work well with Engineering, but by speaking often with other companies who are not in this situation, I have strong clues that making Product work well with Engineering is one key component in our success.</p><h3>Next steps</h3><p>Adding more squads, more layers of engineering management, setting up Impact Teams, OKR, try Shape-Up methodology, improve our Career ladder system: If we have the feeling that things work quite well for us right now, the road is still endless.</p><p>Choices that we made at a given time won’t be valid a bit further down the road, because we would have became more demanding, because the team would have grown, because the technology would have changed, because our product organisation would have changed, etc.</p><p>Our journey to arrive at the current organisation has been long, but we know that we still have a long road ahead of us, and even if our organisation works really well for us right now, we know that we need to continue improving and changing, adapting our way out, but we are eager to come back to you when things will have changed again!!</p><h3>😘 Merci</h3><p>A big thanks to all the people who have contributed to our journey, and those who continue to do so: <a href="https://medium.com/u/60aadc102bc1">Olivier Bazin</a>, Laure Bachy, <a href="https://medium.com/u/5e245cb12a99">Cyril Leroux</a>, <a href="https://medium.com/u/d16e6fb7a3c0">Florian Bruniaux</a>, Alexandre Parisot, <a href="https://medium.com/u/42472d8eb19e">Hugo Perrier</a>, and many others!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4157e918f20" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cheerz-engineering/how-we-work-4157e918f20">How we work</a> was originally published in <a href="https://medium.com/cheerz-engineering">Cheerz Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[String encoding One-o’-One]]></title>
            <link>https://medium.com/cheerz-engineering/string-encoding-one-o-one-b9f4492d2664?source=rss-2ce34ca7e31a------2</link>
            <guid isPermaLink="false">https://medium.com/p/b9f4492d2664</guid>
            <dc:creator><![CDATA[Théo Carrive]]></dc:creator>
            <pubDate>Thu, 24 Sep 2020 22:06:45 GMT</pubDate>
            <atom:updated>2023-10-06T14:45:48.488Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Hands-on introduction on strings encoding with Ruby 💎</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YEX4IiRGUPKrOQgtPFmbqQ.jpeg" /></figure><p>Strings are a key-part of every programming language and interaction between systems. Learning how strings work in details is far from being impossible, but a lot of developers avoid it so much, that when they stumble upon an encoding problem, they let it ruin their life for hours, if not days.</p><p>So, let’s take you to a journey to discover the joy of how encoding works, so that when the day will come, you’ll be ready for that.</p><h3>Step 1. Disassemble the string</h3><p>Let’s start small. To analyze a string, a good place to start is to split it in an array of its individual characters. After all, a string is nothing more than a concatenated array of characters, right ?</p><p>Alright. Let’s start with an easy one :</p><pre>&quot;Hello&quot;</pre><p>With not much surprise, you use the “chars” method :</p><pre>&quot;Hello&quot;.chars<br>=&gt; [&quot;H&quot;, &quot;e&quot;, &quot;l&quot;, &quot;l&quot;, &quot;o&quot;]</pre><p>That was easy. 🙃</p><p>Let’s skip to a more challing part: Let’s analyze the data that actually represents our string:</p><pre>&quot;Hello&quot;.bytes<br>=&gt; [72, 101, 108, 108, 111]</pre><p>Alright, now we’re talking.</p><p>What we see here is an array of bytes, and what is really interesting with this method, is that it exposes the real data that is behind the characters you see when you print your string.</p><p>I won’t spend much time explaining how binary numeration work, people have done it way better elsewere on the internet, the only important part to know here is that a byte is itself an array of 8 bits, thus, a byte can hold a value of 2⁸ = 256 different values. Thus, we could say that<strong> a byte represents a value from 0 to 255</strong>. This is what you see in this tiny array.</p><h3>Step 2. Understand what encoding is</h3><p>But the Ruby string contains something else than just those bytes: It also contains the encoding which is used to interpret those bytes.</p><p>Let’s check the name of the encoding our string actually uses:</p><pre>&quot;Hello&quot;.encoding<br>=&gt; #&lt;Encoding:US-ASCII&gt;</pre><p>You can see that the current encoding for this string is US-ASCII. OK, but what is this encoding for?</p><p>Well, you’ve got yourself your string broken apart into bytes. And each of those bytes is actually mapped to a character. Encoding is just the way you map bytes into characters.</p><p>Here, our encoding is ASCII, and the main parts of the ASCII encoding are the mapp:</p><ul><li>The byte value 48 maps to the digit “0”. Thus, 49 maps to “1”, 50 to “2”, etc., until 57 that maps to “9”.</li><li>The byte value 65 maps to the uppercase letter “A”, (so 90 = “Z”)</li><li>The byte value 97 maps to the lowercase letter “a” (so 122 = “z”)</li><li>Other byte values correspond to other characters (like a space, or “%”, return carriage, etc.)</li></ul><p>So if we look again at our array:</p><pre>&quot;Hello&quot;.bytes<br>=&gt; [72, 101, 108, 108, 111]</pre><p>We can guess that in ASCII, 72 maps to “H”, 101 to “e”, etc.</p><p>Great.</p><p>But… Wait a minute! If we only have 256 values, is it really enough to contain two times the alphabet (lower and uppercase), special characters, numbers, accents, chinese characters, japanese characters, and even worst… emojis 🥺🥺🥺🥺?</p><p>No.</p><p>They just can’t hold in 256 values.</p><p>Actually, ASCII stands for American Standard Code for Information Interchange, and didn’t take in account all those non-american characters at this time. And by the way, for historical reasons, ASCII don’t even contain 256 characters, but only 128, and can fit in 7-bits only. It means that in ASCII, chinese characters, emojis, arabic characters, etc., they just don’t simply exist.</p><p>This is why we had to came up with other encoding than ASCII, like UTF-8.</p><p>So, how is UTF-8 different than ASCII ?</p><p>Well, in UTF-8, if you read an array of bytes, and that one byte has a value &gt; 192, you know that <strong>you need to read the next byte to know which character those bytes represents</strong>.</p><p>And actually, if the value of the first byte is &gt; 240, you would even have to read up to the next three bytes, since UTF-8 can store a character on up to 4 bytes.</p><p>Wait, would it mean that <strong>the number of bytes in a string is no longer equal to the number of chars</strong>?</p><p>YES.</p><h3>Step 3. The multi-bytes characters</h3><p>You understand me well, we will now have the chance to play with nothing less than multi-bytes characters! 🎉🎉</p><pre>&quot;Voilà&quot;.chars<br>=&gt; [&quot;V&quot;, &quot;o&quot;, &quot;i&quot;, &quot;l&quot;, &quot;à&quot;]</pre><p>That was easy. Now, let’s look at the bytes:</p><pre>&quot;Voilà&quot;.bytes<br>=&gt; [86, 111, 105, 108, 195, 160]</pre><p>We have one more byte than the number of chars.</p><p>Without surprise, you can see that I didn’t lie that much, since the first byte of the “à” is 195, and that 195 is &gt; 192, and this is how your machine will know that when it will read the 195, it also has to read the next byte (the 160).</p><p>Another way to look more easily at how the chars are decomposed:</p><pre>&quot;Voilà&quot;.chars.map{ |c| c.bytes }<br>=&gt; [[86], [111], [105], [108], [195, 160]]</pre><p>You can there see that each “american” character is represented by one byte, and that the “à” is actually represented by two bytes.</p><p>If you wanted to analyze quickly a very long string, you could even push it just a bit further and take advantage of the nice Ruby syntax:</p><pre>&quot;Voilà&quot;.chars.map{ |c| [c, c.bytes] }.to_h<br>=&gt; {&quot;V&quot;=&gt;[86], &quot;o&quot;=&gt;[111], &quot;i&quot;=&gt;[105], &quot;l&quot;=&gt;[108], &quot;à&quot;=&gt;[195, 160]}</pre><p>Great. But since we are converting string to its actual bytes values, could we do it the other way around?</p><p>Absolutely. This is why the <a href="https://apidock.com/ruby/v2_6_3/Array/pack">Ruby “pack” method</a> is for.</p><h3>Step 4. Pack your bytes, back to a string</h3><p>With the pack method, you can take an array of values, and tell to Ruby to consider that each value is a byte, and convert it as a String:</p><pre>[86, 111, 105, 108, 195, 160].pack(&#39;C*&#39;)<br>=&gt; &quot;Voil\xC3\xA0&quot;</pre><p>Mmmh. This is not great. What happened to our last letter “à” ?</p><p>Actually, in a Ruby string, when your machine displays “\xC3”, it’s not 4 chars, but one. It’s the Ruby way of telling you that at this character position, the byte value is “C3” (in Hexadecimal), but that it didnt manage to map it to a character.</p><p>Let’s take a look at what is the integer value of the hexadecimal “C3” and “A0”:</p><pre>&quot;C3&quot;.to_i(16)<br>=&gt; 195</pre><pre>&quot;A0&quot;.to_i(16)<br>=&gt; 160</pre><p>Ah. Those are our original bytes.</p><p>If Ruby had used the proper UTF-8 encoding, we would’nt see this problem, so let’s just tell Ruby which encoding to use when reading the string:</p><pre>[86, 111, 105, 108, 195, 160].pack(&#39;C*&#39;).force_encoding(&#39;UTF-8&#39;)<br>=&gt; &quot;Voilà&quot;</pre><p>Great. That’s it. When you know how to decode a string, you can manage to display it well.</p><p>In web API response for instance, the remote server can give you the hint, by specifying the encoding in the “Content-Type” header of the response:</p><pre>Content-Type: text/html; charset=utf-8</pre><p>This tells the client that receives the bytes of the response that it should use UTF-8 to decode it.</p><h3>Step 5. Bytes vs codepoints</h3><p>One last thing before you stop reading: Let’s talk about codepoints, and Unicode.</p><pre>&quot;Voilà&quot;.codepoints<br> =&gt; [86, 111, 105, 108, 224]</pre><p>When you play with this method “codepoints”, it will return an array. So far, it looks like an array of bytes. But let’s apply it on a different string, with some funnier stuff inside:</p><pre>&quot;Voilà🥕&quot;.codepoints<br> =&gt; [86, 111, 105, 108, 224, 129365]</pre><p>Et voilà! You can see that there is a value that is way superior to 255: It means that those numbers are not bytes values, but good old decimal numbers!</p><p>Indeed, codepoints are just decimal numbers, that represent each character. And the mapping has been established and is <a href="https://home.unicode.org/">a standard called Unicode.</a> It means that each character in the world, has its number associated with it. But this number is not an encoding, since it’s not about how systems should read bytes, it’s just a standard.</p><p>Recently, while working with the API of a provider, we have seen something confusing. The response string of the API was something like:</p><pre>&quot;Cl\xE9ment&quot;</pre><p>The response was supposed to be in UTF-8, but we have this decoding error. We tried to change the encoding, but it didn’t help:</p><pre>str = &quot;M\xE9chant&quot;<br>str.force_encoding(&#39;UTF-8&#39;)</pre><pre> =&gt; &quot;M\xE9chant&quot;</pre><p>We played a bit with the string:</p><pre>&quot;M\xE9chant&quot;.chars<br> =&gt; [&quot;M&quot;, &quot;\xE9&quot;, &quot;c&quot;, &quot;h&quot;, &quot;a&quot;, &quot;n&quot;, &quot;t&quot;]</pre><pre>&quot;M\xE9chant&quot;.chars.map{|c| c.valid_encoding? }<br> =&gt; [true, false, true, true, true, true, true]</pre><p>We clearly see that there is an encoding problem.</p><p>Let’s try to brute-force the encoding (the entire list is available <a href="https://en.wikibooks.org/wiki/Ruby_Programming/Encoding">here</a>):</p><pre>encoding_formats = %w[ASCII UTF-7 UTF-8 UTF-16 UTF-32 BIG5]<br>str = &quot;M\xE9chant&quot;<br>encoding_formats.map do |encoding|<br>  {encoding =&gt; str.force_encoding(encoding).valid_encoding?}<br>end</pre><pre> =&gt; [{&quot;ASCII&quot;=&gt;false}, {&quot;UTF-7&quot;=&gt;true}, {&quot;UTF-8&quot;=&gt;false}, {&quot;UTF-16&quot;=&gt;false}, {&quot;UTF-32&quot;=&gt;false}, {&quot;BIG5&quot;=&gt;true}]</pre><p>Meh. 😕</p><p>But a quick search on the internet tells us that “E9” (or 233 in decimal representation) is actually the codepoint of “é”.</p><p>The good solution is to understand why you received codepoints instead of UTF-8 encoded bytes in a first place, but a quick solution to this problem would be the following:</p><pre>bytes = &quot;M\xE9chant&quot;.bytes<br> =&gt; [77, 233, 99, 104, 97, 110, 116]</pre><pre>bytes.pack(&#39;U*&#39;)<br> =&gt; &quot;Méchant&quot;</pre><p>Victory. 🍾</p><p>Yes, we take the bytes, that should not be read as UTF-8 bytes but as Unicode codepoints, and we pack them back, specifying that those are Unicode codepoints.</p><h3>Let’s wrap it up</h3><h4>Useful methods to break strings appart</h4><pre>&quot;Hi 🧀&quot;.chars<br> =&gt; [&quot;H&quot;, &quot;i&quot;, &quot; &quot;, &quot;🧀&quot;]<br></pre><pre>&quot;Hi 🧀&quot;.bytes<br> =&gt; [72, 105, 32, 240, 159, 167, 128]<br></pre><pre>&quot;Hi 🧀&quot;.chars.map{ |c| [c, c.bytes] }.to_h<br> =&gt; {&quot;H&quot;=&gt;[72], &quot;i&quot;=&gt;[105], &quot; &quot;=&gt;[32], &quot;🧀&quot;=&gt;[240, 159, 167, 128]}</pre><pre>&quot;Hi 🧀&quot;.codepoints<br> =&gt; [72, 105, 32, 129472]</pre><h4>Useful methods to change encoding</h4><pre>&quot;Hi&quot;.encode(&#39;ASCII&#39;)<br> =&gt; &quot;Hi&quot;</pre><pre>&quot;Hi 🧀&quot;.encode(&#39;ASCII&#39;)<br>Traceback (most recent call last):<br>Encoding::UndefinedConversionError (U+1F9C0 from UTF-8 to US-ASCII)</pre><pre>&quot;M\xC3\xA9chant&quot;.force_encoding(&#39;UTF-8&#39;)<br> =&gt; &quot;Méchant&quot;</pre><h4>Useful methods to reassemble strings</h4><pre>[72, 105, 32, 129472].pack(&#39;U*&#39;)<br> =&gt; &quot;Hi 🧀&quot;</pre><pre>[72, 105, 32, 240, 159, 167, 128].pack(&#39;C*&#39;).force_encoding(&#39;UTF-8&#39;)<br> =&gt; &quot;Hi 🧀&quot;</pre><p>That’s it.</p><p>Now, you know how to analyze a string, how to change its decoding, convert it to bytes, or codepoints, convert bytes back to a string. Suddenly, your understanding of universe is a bit better, and the sun shines somewhere on the planet.</p><p>Thanks for reading! 😘</p><p><em>(2023 update: Great related reading here </em><a href="https://tonsky.me/blog/unicode/"><em>https://tonsky.me/blog/unicode/</em></a><em>)</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b9f4492d2664" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cheerz-engineering/string-encoding-one-o-one-b9f4492d2664">String encoding One-o’-One</a> was originally published in <a href="https://medium.com/cheerz-engineering">Cheerz Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Treat yourself with a “polish day”]]></title>
            <link>https://medium.com/cheerz-engineering/treat-yourself-with-a-polish-day-3564484cfd9f?source=rss-2ce34ca7e31a------2</link>
            <guid isPermaLink="false">https://medium.com/p/3564484cfd9f</guid>
            <category><![CDATA[product-management]]></category>
            <category><![CDATA[product]]></category>
            <category><![CDATA[bugs]]></category>
            <category><![CDATA[agile-methodology]]></category>
            <category><![CDATA[scrum]]></category>
            <dc:creator><![CDATA[Théo Carrive]]></dc:creator>
            <pubDate>Fri, 26 Jul 2019 09:30:06 GMT</pubDate>
            <atom:updated>2019-07-26T10:11:51.929Z</atom:updated>
            <content:encoded><![CDATA[<h4>Or how to tackle those 1000 small bugs that get stuck in your head and pollute your backlog</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_ZOoOZi_IaWsZ56z" /></figure><blockquote>The first 90 percent of the code accounts for the first 90 percent of the development time. The remaining 10 percent of the code accounts for the other 90 percent of the development time.<br><a href="https://en.wikipedia.org/wiki/Ninety-ninety_rule">the Ninety-Ninety rule</a>, <strong>Tom Cargill</strong></blockquote><h3>👹 Devil is in the details</h3><p>You are agile, you are iterative, you deliver quickly.</p><p>To succeed in that, sometimes you need to make the tough choice of delivering something that is not perfect.</p><p>It breaks your heart to see your product go live without being perfect, but hey, delivering quickly and iterating is crucial, so yes, it seems like a completely valid choice.</p><p>But then, how can we deal with all the small glitches that are released in our apps? All those small details, that are nothing one by one, but that can turn your app into a sick product if you accumulate too much?</p><p>You know, all those very small tasks that should theoretically cost you nothing to fix, but the context-switch it involves is a high price to pay…</p><p>This small typo on the website that should take 2 seconds to fix, that you fix, and then have to wait for the CI to complete, you see some deprecations in the CI, you update deprecated use in the CI, thus break the CI, you fix the CI, your fix is live, you wake up and you have lost half a day. 😱</p><p>Make them go through the whole prioritization/grooming/development process?</p><p>Meh, it would require more time to talk about them than to actually fix.</p><p>Instead, why not wait until you have enough, and try to make solving them fun?</p><h3>Welcome to the Polish days!</h3><p>At Cheerz, we have launched what we call the “Polish days”.</p><p>No, not like this kind 🇵🇱of polish, but in the sense that you actually polish your app during this day.</p><p>Every once in awhile (~1/month), we announce a polish day. The goal? Tackle the biggest amount of bugs and small glitches we can tackle in one day.</p><p>We stop the sprint for 1 day, prepare a Jira board with all those small tasks, and have everyone in the biggest meeting room we have, in which we have the chance to still be able to approximately fit in.</p><p>The day starts, and now, the contest is live :</p><ul><li>Each opened Pull Request is worth 1 point</li><li>Each fix that has been validated and merged is worth 3 points</li></ul><p>As time moves on, we note all the scores on a big whiteboard in the room.</p><p>At 6 pm, the winner, the King of the Polish, is announced and prizes handed out.</p><h4>The prize</h4><p>The prize is important. It has to be good enough so that you want it, and silly enough so that you don’t really resent the game if you don’t win.</p><p>During our last edition for instance, in addition to a bottle of champagne, we offered the winner one additional anniversary: On one day of his choice, everybody in the company should act as if it was his birthday. Singing, congratulating, etc. 🎂</p><p>Plus, we hang a giant print of the winner in our office, as an everyday reminder of his glorious victory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ncptnzd4eQy4KZaIlHMjtg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/668/1*gH9I55QEl7AIMI-U79pKWA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*crpA0WeNWRh0tpkR_7sw6A.png" /><figcaption>The team. The scoreboard. The leader.</figcaption></figure><h4>Be careful</h4><p>The only thing to be careful about is to not make the people with only a few points feel bad.</p><p>Not everyone has the same knowledge of the codebase, some people are more junior or recently arrived, and some just made poor strategic choices by picking harder or longer tasks.</p><p>This day will, of course, hugely benefits the company, but it’s also a game. And the game and its points should not be turned into a way to evaluate developers or measure one’s velocity or skills. It would be wrong, both in term of relevancy and how it could make people feel.</p><h3>Conclusion</h3><p>So far, we have heard nothing but good about the polish day.</p><p>It allows us to tackle a huge number of small problems in way less time than it could take if dispatched in a sprint. It helps us break the routine, focus and thus reduce the cost of context-switching. And especially, it helps us make the “experience debt” melt.</p><p>And all of that by having a fun day.</p><p>So why not give it a try your self, and tell us how it went?</p><p>Do you want to see more than what we’ve shown here, join the team or just talk around a cup of coffee or a drink 🍻 in <a href="https://www.google.com/maps?q=cheerz&amp;um=1&amp;ie=UTF-8&amp;sa=X&amp;ved=0ahUKEwj1_f2cotLjAhWOA2MBHfHKBO8Q_AUIEigC">our office</a>?</p><p>Don’t hesitate to <a href="/service/mailto:jobs@cheerz.com?source=post_page---------------------------"><strong>contact us</strong></a>!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3564484cfd9f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cheerz-engineering/treat-yourself-with-a-polish-day-3564484cfd9f">Treat yourself with a “polish day”</a> was originally published in <a href="https://medium.com/cheerz-engineering">Cheerz Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stop debugging Analytics yourself!]]></title>
            <link>https://medium.com/cheerz-engineering/visualize-the-tracking-of-your-ios-app-e23201a731c0?source=rss-2ce34ca7e31a------2</link>
            <guid isPermaLink="false">https://medium.com/p/e23201a731c0</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[tracking]]></category>
            <dc:creator><![CDATA[Théo Carrive]]></dc:creator>
            <pubDate>Wed, 27 Feb 2019 05:17:50 GMT</pubDate>
            <atom:updated>2019-02-27T09:25:11.147Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Or how to allow non-technical people to troubleshoot tracking events themselves, directly from their iPhone camera roll!</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XtIAFUQIIDUGuvokBEeJ1g.png" /></figure><h3>The pain of tracking</h3><p>Tracking the way your users interact with your application is great. But maintaining, troubleshooting, checking the code implementation and documenting how your tracking plan is done on your app can be a huge pain.</p><ul><li>Is this event well plugged? 🤔</li><li>What is the name of the event? 🥶</li><li>When is it triggered exactly? 🥺</li><li>Is this event triggered once or twice? 😱</li></ul><p>If you recognize yourself in this situation, if you see people coming at you with very relevant yet very time-consuming questions, then, this article is for you!</p><h3>We need to track tracking 🤯</h3><p>To answer all of those questions, you can create documention. However, documentation can be vague, inacurate, and requires a lot of discipline and efforts to be kept up-to-date.</p><p>Wouldn’t it be great to instead allow marketing people to easily test the tracking plan, to check that it matches what they expected?</p><p>What we want, is to be able to say, proudly and the hands on our hips:</p><blockquote>“Just play with the app, and all the tracking events will be saved in your photoroll! What an amazing world we live in, isn’t it?”</blockquote><p>And if we think about it, that does not seem that hard… So, let’s do it!</p><h3>Implementation</h3><p>We have created a very silly and simple <a href="https://github.com/cheerz/eventshot">Pod called “EventShot”</a> that:</p><ul><li>Takes a screenshot of the main view</li><li>Adds a layer with some text information on it</li><li>Saves it on your photoroll</li></ul><p>So, let’s import this in our Podfile:</p><pre>pod &#39;EventShot&#39;</pre><p>Now we just have to trigger the screenshots for each event we track. We hook it in our tracking class :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/29f0711875f034d8104b30e15d926c76/href">https://medium.com/media/29f0711875f034d8104b30e15d926c76/href</a></iframe><p>Now, let’s build on our phone, let’s launch the app, navigate it to into it, and just go back in our camera roll:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*im3ZfZAYJK6SYLeJvTmtrQ.png" /><figcaption>Visualize your tracking plan from your camera roll</figcaption></figure><p>That’s it! We can now visualize the events that are sent directly from our camera roll! 🎉🎉🎉🎉🎉🎉🎉</p><h3>Conclusion</h3><p>Now, we can hand this app in the hands of any person of our company : Just a launch, and they will be able to see in their photos all the events that are sent to Google Analytics, or whatever tracker we use.</p><p>Tracking plan won’t ever be a mistery anymore!</p><h4>Going further</h4><ul><li>⚠️️️️⚠️️ You don’t want to enable EventShot recording in production. If you want to use this often and be able to keep it in your codebase you might want to enable EventShot recording based on your target.</li><li>If your app doesn’t include it already, don’t forget to add the appropriate key/value to your info.plist to request permission to access the photo library, otherwise, your app will crash!</li><li>The <a href="https://github.com/cheerz/eventshot">EventShot Pod</a> is just a POC. Don’t hesitate to contribute to make it become something better!</li></ul><p>Do you want to see more than what we’ve shown here?</p><p>Don’t hesitate to contact us, it would be a pleasure to talk, or even to welcome for you for a coffee at our office (France 🇫🇷-&gt; Paris 🏙-&gt; Place de Clichy / Saint Lazare 🚊)!</p><p>Just so you know, <strong>we are hiring engineers</strong>! Don’t hesitate to <a href="/service/mailto:jobs@cheerz.com"><strong>contact us</strong></a>, or check <a href="https://welovedevs.com/app/company/cheerz">our page here</a>!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e23201a731c0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cheerz-engineering/visualize-the-tracking-of-your-ios-app-e23201a731c0">Stop debugging Analytics yourself!</a> was originally published in <a href="https://medium.com/cheerz-engineering">Cheerz Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Monitor what developers write in your Rails console]]></title>
            <link>https://medium.com/cheerz-engineering/monitor-what-developers-write-in-your-rails-console-71a286d891c9?source=rss-2ce34ca7e31a------2</link>
            <guid isPermaLink="false">https://medium.com/p/71a286d891c9</guid>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[monitoring]]></category>
            <category><![CDATA[slack]]></category>
            <dc:creator><![CDATA[Théo Carrive]]></dc:creator>
            <pubDate>Wed, 20 Feb 2019 14:58:28 GMT</pubDate>
            <atom:updated>2019-02-20T17:54:31.904Z</atom:updated>
            <content:encoded><![CDATA[<h4>Or how to tune Pry to send all user input to slack</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Rsz-ncwP5i6Cir1jEd6oVA.jpeg" /><figcaption>Pry console to Slack channel</figcaption></figure><h3>Why?</h3><p>We try to avoid manual actions on our production console as much as we can.</p><p>However, it happens that for some reasons, we absolutely have to do something on our production console. Configuring something that is not accessible from the admin, doing an extract, debugging some weird problem.</p><p>It happens. But at some point, we want to:</p><ul><li>Share knowledge about what other people do</li><li>Avoid an increasing amount of manual actions</li></ul><p>The right thing to do then, is to monitor it. So, let’s do it!</p><h3>What do we want exactly?</h3><p>We want something:</p><ul><li>Simple to set-up</li><li>Easily accessible by our development team</li><li>That centralizes information for many servers</li></ul><p>We had many options in mind, like sending information to NewRelic, Datadog, or by email, but the one that seemed to be the best for us was something that every developer has access to and check multiple times per day, so, very simply… Slack.</p><p>OK great, so, let’s implement it!</p><h3>Implementation</h3><h4>Pry hook</h4><p>First of all, we need to think about how we are going to hook into Pry.</p><blockquote>When pry starts, it checks for a pryrc file […] in the current directory(./.pryrc).</blockquote><p>Neat! And what are we going to do with this?</p><blockquote>Pry.config.input is an option determining the input object.<br>Pry accepts any object that implements the readline method. <br>When creating a custom object, you may also want to implement the completion_proc= and completion_proc methods.</blockquote><p>OK that’s it. We have everything we need. We create a .pryrc file in our project, in which we will override the input by an instance of a class that we will create : ReadlineLogger.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1fb02a66f571319191efb7742e0f4a84/href">https://medium.com/media/1fb02a66f571319191efb7742e0f4a84/href</a></iframe><h4>The logger</h4><p>Ok nice. So let’s implement that ReadlineLogger. What we want is a class that will implement 3 methods:</p><ul><li>readline(value)</li><li>completion_proc</li><li>completion_proc=(value)</li></ul><p>Let’s rely on the original Readline class to do its job, while we just send notification to Slack with another class that we will create soon:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e6190e9b824cdddebc594ac30a149e03/href">https://medium.com/media/e6190e9b824cdddebc594ac30a149e03/href</a></iframe><h4>The Slack notification service</h4><p>Great! The only thing remaining is the Slack notification itself.</p><p>Easy peasy 🍋.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/42108bb66382ad87e1647fdc6a668356/href">https://medium.com/media/42108bb66382ad87e1647fdc6a668356/href</a></iframe><p>Et voilà!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*HBd8kXI3L8sMQw4kqqpD3A.png" /><figcaption>Send Rails console input directly to slack</figcaption></figure><p>You can find the gist here: <a href="https://gist.github.com/rocketlobster/0ba9dbf14b5957e9bc3cab12d56608fb">https://gist.github.com/rocketlobster/0ba9dbf14b5957e9bc3cab12d56608fb</a></p><h3>Thoughts</h3><ul><li>We found it quite interesting to see what you can do when Pry loads.</li><li>Having everything is on Slack is great to monitor what should be automated when your team has more than a few developers</li><li>Having everything on Slack is a great way to share knowledge.</li></ul><p>Do you want to see more than what we’ve shown here?</p><p>Don’t hesitate to contact us, it would be a pleasure to talk, or even to welcome for you for a coffee at our office (France 🇫🇷-&gt; Paris 🏙-&gt; Place de Clichy / Saint Lazare 🚊)!</p><p>Just so you know, <strong>we are hiring engineers</strong>! Don’t hesitate to <a href="/service/mailto:jobs@cheerz.com"><strong>contact us</strong></a>, or check <a href="https://welovedevs.com/app/company/cheerz">our page here</a>!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=71a286d891c9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cheerz-engineering/monitor-what-developers-write-in-your-rails-console-71a286d891c9">Monitor what developers write in your Rails console</a> was originally published in <a href="https://medium.com/cheerz-engineering">Cheerz Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Make your microservices converge]]></title>
            <link>https://medium.com/cheerz-engineering/make-your-ruby-microservices-converge-9e9e49f3a3a4?source=rss-2ce34ca7e31a------2</link>
            <guid isPermaLink="false">https://medium.com/p/9e9e49f3a3a4</guid>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[microservices]]></category>
            <dc:creator><![CDATA[Théo Carrive]]></dc:creator>
            <pubDate>Wed, 09 Jan 2019 18:01:10 GMT</pubDate>
            <atom:updated>2019-01-21T21:58:10.941Z</atom:updated>
            <content:encoded><![CDATA[<h4>How to share code, configuration and dependencies between services</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/976/1*FQxrGFS39LHu-VU7-p-aEw.png" /></figure><h3>From nothing to a monolith</h3><p>In our life of developers, we start a project with just one very small piece of code with a very small scope.</p><p>With the time, thousand of requests from marketing later, your codebase has grown, to become a fully grown project. And very often, this fully grown project turns into a kind of monster with thousands of features and even more classes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m3ggpfkLFf2SBU9xWnjdig.png" /></figure><p>This is the creepy monolith that everyone is talking about, and tries to get rid off.</p><p>This situation has many flaws:</p><ul><li>Huge codebase</li><li>Very little isolation</li><li>Tight coupling between all business logic</li><li>Very hard to scale because the project has many different needs and constraints</li><li>It’s almost impossible for one single person to have extensive knowledge of the codebase and of the side effects code changes could lead to.</li></ul><p>I won’t go further into detail why one would want to run away from a monolith, many articles on the web explain that quite well already.</p><p>OK, so we have a monolith, so what do we do?</p><p>We split.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/623/1*Mz-2iQm5rq6Wmnw_I3Mc3Q.png" /><figcaption>The natural process of cell division</figcaption></figure><h3>From one monolith to many services</h3><p>This split is the microservices that we are going to talk about.</p><p>To sum-up what microservices are, they consist of different isolated services (ideally: different codebases, different hosting, different deployment pipelines), communicating together with APIs:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xNxSx7JKOWlmeqMeMUe4wQ.png" /><figcaption>Services communicating together with APIs</figcaption></figure><p>At Cheerz, for instance, this is what our microservices architecture looks like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LYkOMT1v1TCM5in3evQClg.png" /><figcaption>Cheerz services architecture</figcaption></figure><p>(If you&#39;re interested, we go much more into the details of our architecture in this <a href="https://medium.com/cheerz-engineering/architecture-of-cheerz-services-23f3bedcde9b">article</a>)</p><p>Great. Now, we have :</p><ul><li>Code isolation</li><li>Simplified deployment pipelines</li><li>Shorter build times</li><li>Simpler onboarding</li></ul><p>And especially, we can scale services individually, and thus, much more easily and in a more optimized way.</p><p>Great.</p><p>But…</p><p>Each time we had to create one of those microservices, it has been a huge pain to do all the boilerplate to handle: monitoring, logging, deployment, test configuration, the toolchain, administration tools, authentification, etc.</p><p>We clearly have a problem with boilerplate when we spawn up a new microservice.</p><p>But boilerplate is not the main problem we have here. With time, each change that we make to CI, project configuration, linter, dependencies, etc., will be done on a per-codebase basis. Thus, with the time, we have more and more discrepancies between them. And this is not only valid for configuration, tooling, and dependencies, but also for a lot of small utils that we develop per codebase.</p><p>What we have here is the phenomenon of divergence between our microservices.</p><h3>Here come the divergence</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*719AJKSiZLpcnRQJlk2E3A.png" /></figure><p>We end up with a collection of microservices that we would expect to be of the same species because we all created them to be based on the same technological stack, but we find ourselves with :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*54idf7g6JDaYVigwINknOA.png" /><figcaption>divergence between services</figcaption></figure><p>By splitting our microservices, we have lost an easy way to have one single version of the standard toward which we make our microservices go.</p><p>The question we have to ask ourselves now is:</p><h3>How to make our microservices converge again?</h3><p>For that, we have a few leads.</p><h4>The bootstrap project</h4><p>First, we could at least prevent us all the boilerplate needed to setup a new service, so that at least, we start the life of a new service the right way. That is to say, we could create a base project for our company, that will already have everything configured. This is basically what Thoughtbot did with their “Suspenders” project: <a href="https://github.com/thoughtbot/suspenders">https://github.com/thoughtbot/suspenders</a>.</p><p>This is a good start, but this doesn’t really solve our problem, that will happen later in the lifecycle of our codebase.</p><h4>The middleware layers</h4><p>Another solution would be to extract all the logic we can and use a maximum number of tools shared by all of our microservices.</p><p>This would be what serverless architecture tend to do, with providers like Google Cloud or AWS, or that you can setup with platforms like Kong:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O957eU2P1QrSYWW-S9KjOw.png" /></figure><p>This is interesting, but first, this can strongly lock you in a cloud provider, and especially, this does not solve a big part of the problem, that is more related to the business logic.</p><p>We need a homogenization solution that is closer to the codebase.</p><h4>Share some code with submodules</h4><p>This is interesting. It could solve a big part of the problem, however, we would try to avoid sub-modules for many reasons.</p><ul><li>Git submodules can be hard to deal with on a daily basis, especially for junior programmers who can see this as an additional complexity on top of the regular git flow.</li><li>Integrating them properly could require a lot of small hacks.</li></ul><h4>Open source your libraries</h4><p>Oh! This one is nice. If we would have a published a new library each time we wanted to share some code or configuration between our projects, integration would be seamless thanks to package managers (Bundler, Yarn, Cabal, etc.), and we would have good isolation.</p><p>However, if this means that each time we want to share some code, we have to:</p><ul><li>Create a new library</li><li>Create a new repository</li><li>Configure the library, specs, and pipeline (CI, linting, …)</li><li>Publish the library</li><li>Integrate it into the project</li></ul><p>This seems like a lot of overhead. Even more than the overhead of duplicating code. And thus, we can think that people won’t naturally tend to this solution since it does not seem that efficient in the end.</p><p>In addition to that, a lot of the problems that we want to solve are very company-specific (configuration, business-logic helpers, dependency management, …), and thus, won’t have a lot of interest for the open-source community</p><h4>Make your corporate library</h4><p>What we can do, is to create one library, and only one library, that will be the “corporate library” in a sense that this will be the one centralizing the standard of our company.</p><p>Let’s call it “cheerz_on_rails”.</p><p>This library will hold for us:</p><ul><li>All the dependencies shared by our microservices: byebug, newrelic agent, bugsnag agent, capistrano, …</li><li>All the configuration shared by our microservices, including the configuration of the previously listed dependencies (bugsnag, newrelic, etc.) but also linting (rubocop), rspec, and plenty others.</li><li>Simple utils that we re-use from one project to another: helpers to manipulate data structures, errors, …</li></ul><p>If at some point, we see that some part of this corporate library could have an interest by itself for the outside world, we will continue open-sourcing it, and we will then include it as a dependency of our corporate library.</p><p>That’s it, we have our final candidate. Now, let’s implement it.</p><h3>Make your corporate Ruby library</h3><p><strong>In the following, we explain how we have implemented it for a Ruby stack. If implementing it for other stacks is different, the methodology remains the same.</strong></p><p>First, we need to create the gem.</p><pre>bundle gem cheerz_on_rails</pre><p>That’s it. Bundler takes care of the job and creates the gem for us. We now just have to create a repository on Github and configure our project to track it.</p><p>Now, we need to add this gem to all of our projects.</p><p>Adding a private gem is very simple, we can just specify the path to its Github repository, and bundler will fetch it directly through SSH:</p><pre><strong>./microservice/Gemfile:</strong></pre><pre>(...)</pre><pre>gem ‘cheerz_on_rails’, git: &#39;git@github.com:cheerz/cheerz_on_rails.git&#39;, branch: :master</pre><pre>(...)</pre><p>Great.</p><p>Now, the question is: What do we put inside this gem?</p><p>First of all, we are going to manage common dependencies with this gem.</p><p>In the gem project, there is a “cheerz_on_rails.gemspec” file, in which we can specify the dependencies we want:</p><pre><strong>./cheerz_on_rails/cheerz_on_rails.gemspec:</strong></pre><pre>(...)</pre><pre>spec.add_dependency ‘bugsnag’, ‘~&gt; 6.10.0’<br>spec.add_dependency ‘config’, ‘~&gt; 1.7.0’<br>spec.add_dependency ‘newrelic_rpm’, ‘~&gt; 5.6.0’<br>spec.add_dependency ‘pry’, ‘~&gt; 0.12.0’<br>spec.add_dependency ‘pry-rails’, ‘~&gt; 0.3.0’<br>spec.add_dependency ‘rubocop’, ‘~&gt; 0.62.0’</pre><pre>(...)</pre><p>Super. We now share dependencies versions through our different projects, thanks to this gem.</p><p>Now, we want to share boilerplate configuration. One very simple example is how we setup Bugsnag to report errors:</p><pre><strong>./cheerz_on_rails/lib/cheerz_on_rails/bugsnag.rb:</strong></pre><pre>require &#39;bugsnag&#39;</pre><pre>module CheerzOnRails</pre><pre>  module Bugsnag</pre><pre>    extend self</pre><pre>    def setup(api_key:)<br>      app_version = capistrano_release<br>      ::Bugsnag.configure do |config|<br>        config.api_key = api_key<br>        config.app_version = app_version if app_version.present?<br>        config.notify_release_stages = %w[production staging]<br>        config.ignore_classes &lt;&lt; ActiveRecord::RecordNotFound<br>      end<br>    end</pre><pre>    private</pre><pre>    def capistrano_release<br>      return if !Rails.env.production? &amp;&amp; !Rails.env.staging?<br>      current_dir = Dir.pwd<br>      return unless current_dir =~ %r{releases/([0-9]+)\z}<br>      Regexp.last_match(1)<br>    end</pre><pre>  end</pre><pre>end</pre><p>And now, in our microservice, if we want to add Bugsnag, well configured, we just have to add the following initializer:</p><pre><strong>./microservice/initializers/cheerz_on_rails.rb:</strong></pre><pre>CheerzOnRails::Bugsnag.setup(api_key: Settings.bugsnag.api_key)</pre><p>Great. We see that we can share code and dependencies. The only thing that remains is to share pure configuration. Example: Linting!</p><p>We want all of our projects to share the same linting configuration. Thus, we add the rubocop configuration to our Gem:</p><pre><strong>./cheerz_on_rails/cheerz-rubocop-main.yml:</strong></pre><pre>inherit_mode:<br>  merge:<br>    - Exclude</pre><pre>AllCops:<br>  CacheRootDirectory: &#39;tmp/cache&#39;<br>  Exclude:<br>    - &#39;db/schema.rb&#39;<br>    - &#39;db/**/schema.rb&#39;<br>  TargetRubyVersion: 2.3</pre><pre>Layout/AlignHash:<br>  EnforcedHashRocketStyle: key<br>  EnforcedColonStyle: key<br>  EnforcedLastArgumentHashStyle: ignore_implicit</pre><pre>(...)</pre><p>And now, in our microservice, we just have to reference it in our rubocop configuration:</p><pre><strong>./microservice/.rubocop.yml:</strong></pre><pre>inherit_gem:<br>  cheerz_on_rails: .rubocop.cheerz-main.yml</pre><p>And voilà!</p><p>🎉🎉🎉🎉🎉🎉🎉</p><h3>Conclusion</h3><p>We now have a library that allows us:</p><ul><li>To homogenize dependencies</li><li>To share code between codebases</li><li>To share configuration</li></ul><p>This approach has the great benefit of giving each developer a direction of where we want to go. What are the libraries that we want to use everywhere? What are the pieces of configuration that we chose? What is the style that we try to enforce?</p><p>Developers don’t have to ask themselves “OK. I’m on the microservice XX, what are the debugging tools that are setup? Which version? What is the style guide already?”</p><p>This makes it way much easier for everyone to jump from one project to another. Homogenization removes mental workload, for our greatest happiness!</p><h4>Going further</h4><ul><li>When we presented this approach, someone asked us: “<em>How do you deal with this problem, when the microservices use entirely different technology stacks?</em>”. Unfortunately, this question is a bit more complex and would require another article for us to answer it. <em>This might happen soon ;)</em></li><li>If you try to do the same, you might notice that iterating on a Ruby gem of yours while checking how well it integrates into your project can be a bit of a pain. In <a href="https://medium.com/cheerz-engineering/test-your-ruby-gem-locally-2e577ca9582a">this article, we explain how we try to solve this problem</a>.</li><li>At some point, we thought that having one single gem for all environments can be a problem if we don’t want to include dev tools in your production environment. For that problem, we thought about splitting the gem into two: one for dev+test, one for staging+production.</li><li>With the time, we thought that our corporate gem could grow too much. If this happens, we plan to split it, exactly like we split our initial codebase in the first place.</li></ul><p>Thanks to <a href="https://medium.com/u/8438a2ed7090">Maxime Garcia</a> with whom I have made this work!</p><p>Do you want to see more than what we’ve shown here?</p><p>Don’t hesitate to contact us, it be a pleasure to talk, or even to welcome for you for a coffee at our office (France -&gt; Paris -&gt; Place de Clichy)!</p><p>Just so you know, <strong>we are hiring engineers</strong>! Don’t hesitate to <a href="/service/mailto:jobs@cheerz.com">contact us</a>, or check <a href="https://welovedevs.com/app/company/cheerz">our page here</a>!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9e9e49f3a3a4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cheerz-engineering/make-your-ruby-microservices-converge-9e9e49f3a3a4">Make your microservices converge</a> was originally published in <a href="https://medium.com/cheerz-engineering">Cheerz Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Test your Ruby gem locally]]></title>
            <link>https://medium.com/cheerz-engineering/test-your-ruby-gem-locally-2e577ca9582a?source=rss-2ce34ca7e31a------2</link>
            <guid isPermaLink="false">https://medium.com/p/2e577ca9582a</guid>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[bundler]]></category>
            <category><![CDATA[gem]]></category>
            <category><![CDATA[ruby]]></category>
            <dc:creator><![CDATA[Théo Carrive]]></dc:creator>
            <pubDate>Wed, 09 Jan 2019 17:48:21 GMT</pubDate>
            <atom:updated>2019-01-21T21:52:00.267Z</atom:updated>
            <content:encoded><![CDATA[<h4>How to resolve the pain of commit/push/pull to test how your gem fits in your project</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/470/1*uHOD632-DD5BLu-ptcFgvA.png" /></figure><p>For many reasons that we won’t list here, at some point, in our life of Ruby developers, we have started to create some gems.</p><p>Gems are a great way to share code and to modularize our codebase while leveraging the power of Bundler. This is great.</p><p>Of course, our gem will have unit tests of its own.</p><p>However, while we develop it, we want to test it in our project to check if it integrates well. And very often, we want to do many iterations. And each time we do an iteration, right now, in addition to develop &amp; test, we have to:</p><ul><li>Commit the gem</li><li>Push the gem</li><li>Pull the gem from a microservice to test its usability</li></ul><h3>😰</h3><p>This is a pain.</p><p>And we want to solve that pain.</p><h3>Solution #1</h3><p>Quick and dirty.</p><p>In the microservice Gemfile, we replace the git URL with a local path:</p><pre><strong>./microservice/Gemfile:</strong></pre><pre># TODO: Change me before commiting anything!!<br>gem &#39;cheerz_on_rails&#39;, path: &#39;../cheerz_on_rails&#39;</pre><p>Ok, this works well, and allow us to make changes to our gem and directly see the change in our microservice.</p><p>However, this is what we risk to see very soon when a giddy developer will forget to check the work he commits:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VhCrBnLsXwltxMbSWQL-LQ.png" /><figcaption>Manual checks to do before commit = mental workload = errors</figcaption></figure><h3>Solution #2</h3><p>Let’s try to make something a bit cleaner.</p><p>What we want is to have a special way of using our microservice, so that it loads the gem from local instead of fetching it from SSH.</p><p>We cannot use a condition in the Gemfile, based on the environment, otherwise, it would modify the Gemfile.lock.</p><p>If we look at the config/boot.rb of any Rails project, we see that we could pass a Gemfile path, thanks to an environment variable:</p><pre>ENV[&#39;BUNDLE_GEMFILE&#39;] ||= File.expand_path(&#39;../../Gemfile&#39;, __FILE__)</pre><pre>require &#39;bundler/setup&#39; if File.exists?(ENV[&#39;BUNDLE_GEMFILE&#39;])</pre><p>This is the technique that we are going to use.</p><p>First, we create this new Gemfile, that we will call Gemfile-dev, and for each rails command that we are going to launch, we are going to prefix it with BUNDLE_GEMFILE=Gemfile-dev.</p><p>Example:</p><pre>BUNDLE_GEMFILE=Gemfile-dev bundle exec rails server</pre><p>Now, what we want, is to have a variable that will be overridden in the Gemfile-dev, to specify that we take the gem from local.</p><p>First, we modify the regular Gemfile to take an argument from a variable:</p><pre><strong>./microservice/Gemfile:</strong></pre><pre>(...)</pre><pre>@cheerz_on_rails_params ||= {<br>  git: &#39;git@github.com:cheerz/cheerz-on-rails.git&#39;,<br>  branch: :master<br>}<br>gem &#39;cheerz_on_rails&#39;, @cheerz_on_rails_params</pre><pre>(...)</pre><p>And now, we just have to setup our Gemfile-dev file:</p><pre><strong>./microservice/Gemfile-dev:</strong></pre><pre>@cheerz_on_rails_params = {path: &#39;../cheerz_on_rails&#39;}</pre><pre>eval_gemfile &quot;./Gemfile&quot;</pre><p>Our Gemfile-dev will just override the @cheerz_on_rails_params variable and then, eval the regular Gemfile.</p><p>Great. If we bundle install with the following command, it works:</p><pre>BUNDLE_GEMFILE=Gemfile-dev bundle install</pre><p>However, all the versions in your Gemfile-dev.lock will be different from the one present in the regular Gemfile.lock, because bundler won’t have read the Gemfile.lock in the first place. Thus, we modify our Gemfile-dev file to perform a last trick:</p><pre><strong>./microservice/Gemfile:</strong></pre><pre># Copy to ensure same version for gems<br>FileUtils.cp(&quot;Gemfile.lock&quot;, &quot;Gemfile-dev.lock&quot;)</pre><pre># Override the variable that will be used in the Gemfile<br>@cheerz_on_rails_params = {path: &#39;../cheerz_on_rails&#39;}</pre><pre># Read the regular Gemfile<br>eval_gemfile &quot;./Gemfile&quot;</pre><p>Et voilà! Everything works and is safe to be committed!</p><p>🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉</p><p>Thanks to <a href="https://medium.com/u/8438a2ed7090">Maxime Garcia</a> with whom I have made this work!</p><p>Do you want to see more than what we’ve shown here?</p><p>Don’t hesitate to contact us, it will be a pleasure to talk, or even to welcome for you for a coffee at our office (France -&gt; Paris -&gt; Place de Clichy)!</p><p>Just so you know, <strong>we are hiring engineers</strong>! Don’t hesitate to <a href="/service/mailto:jobs@cheerz.com">contact us</a>, or check <a href="https://welovedevs.com/app/company/cheerz">our page here</a>!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2e577ca9582a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cheerz-engineering/test-your-ruby-gem-locally-2e577ca9582a">Test your Ruby gem locally</a> was originally published in <a href="https://medium.com/cheerz-engineering">Cheerz Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Simple cohort analysis with SQL]]></title>
            <link>https://medium.com/cheerz-engineering/simple-cohort-analysis-with-sql-4840e6bf31da?source=rss-2ce34ca7e31a------2</link>
            <guid isPermaLink="false">https://medium.com/p/4840e6bf31da</guid>
            <category><![CDATA[cohorts]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[postgres]]></category>
            <dc:creator><![CDATA[Théo Carrive]]></dc:creator>
            <pubDate>Wed, 21 Nov 2018 19:12:35 GMT</pubDate>
            <atom:updated>2018-11-22T18:12:25.880Z</atom:updated>
            <content:encoded><![CDATA[<h3>📈 How to build cohorts with SQL</h3><blockquote>Here is a short story of how you can extract cohorts with just your PostgresSQL database and a few lines of Ruby.</blockquote><p>Cohorts, cohorts, cohorts, cohorts, cohorts…</p><p>Cohorts is a word that I have heard a lot. From analysts during fundraisings, from people from marketing, from the product team, from everyone. And actually, it seems quite legit: we all want to know how much our users interact with our platform.</p><p>A few years ago however, we didn’t have any fancy BI tool like Looker, Tableau or Periscope to help us extract those cohorts. We only had one PostgreSQL server, a terminal, and the urge to extract those cohorts.</p><p>I won’t go too much in the details of what a cohort is and is for, I think that others have gone enough into these kinds of details.</p><h3>The model</h3><p>To make things easier, we take here a simplified model of our business logic with:</p><ul><li>🙂 One table “user”</li><li>🛒 One table “orders” ( ) with a “paid_at” field and a “user_id” reference to the users table.</li></ul><p>What we want to have in the end, is cohorts for each month, telling us month by month the percentage of customers who have now turned into repeating customer.</p><p>For instance, if we look at the table below, we see that after 4 months, among the customers who made their first order in January, 37% have ordered again at least once, and one month later, 40,4%.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CGGum-zf_sJwbB4KnQB5jQ.png" /><figcaption>Repeaters cohort : percentage of customers who have &gt; 1 orders</figcaption></figure><h3>1. Generate the time segments</h3><p>PostgreSQL has a neat feature called “generate_series” that allows us to generate all the values of an interval.</p><pre>SELECT generate_series AS start,<br>        (generate_series + interval &#39;1 month&#39; - interval &#39;1 second&#39;)       AS stop<br>      FROM generate_series(&#39;2015-01-01 00:00&#39;::timestamp, &#39;2017-10-30&#39;, &#39;1 month&#39;)</pre><p>Thanks to this, with a few lines of code, we get a list of time ranges on which we want to run our study :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/652/1*uSPdizYwQtz8h_MPRVL5Ag.png" /></figure><p>For our study, we need to have all the combinations of those timeranges with themselves:</p><pre>WITH time_serie AS (<br>  SELECT generate_series AS start,<br>  (generate_series + interval &#39;1 month&#39; - interval &#39;1 second&#39;) AS stop<br>  FROM generate_series(&#39;2018-01-01 00:00&#39;::timestamp, &#39;2018-06-30&#39;, &#39;1 month&#39;)<br>  ), <br>first_order_serie AS (<br>  SELECT start AS first_order_start, stop AS first_order_stop<br>  FROM time_serie<br>)<br>SELECT * FROM time_serie, first_order_serie</pre><p>Et voilà ! 🎉</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nUc3hvFX9fRPgDQQ1KUL4g.png" /></figure><h3>2. Select the new users for each time range</h3><p>Now that we have all the time data of our study, for each line of this table, we want to select the users having their first order in the specific interval:</p><pre>WITH new_customers AS (</pre><pre>SELECT orders.user_id<br>FROM orders<br>INNER JOIN (<br>  SELECT user_id<br>  FROM orders<br>  WHERE orders.paid_at BETWEEN <br>    time_table.first_order_start AND time_table.first_order_stop<br>) AS period_orders<br>ON period_orders.user_id = orders.user_id<br>GROUP BY orders.user_id<br>HAVING MIN(orders.paid_at) BETWEEN time_table.first_order_start AND time_table.first_order_stop</pre><pre>)</pre><h3>3. Count the percentage of repeaters compared to the customers</h3><p>Now that we have all the customers who made their first order in a given period (in the “new_customers” Common Table Expression), we have to check the percentage of them who have strictly more than 1 order before the end of the studied interval:</p><pre>SELECT 100 * COUNT(*)::float/(SELECT COUNT(*) FROM new_customers) as repeat_percent <br>FROM (<br>      SELECT COUNT(*), orders.user_id<br>      FROM orders<br>      INNER JOIN new_customers <br>      ON new_customers.user_id = orders.user_id<br>      WHERE orders.paid_at &lt;= time_table.stop<br>      GROUP BY orders.user_id<br>      HAVING COUNT(*) &gt; 1<br>) AS REPEATS</pre><h3>4. Wrap the SQL together 📦</h3><p>Now that we have all the bricks, we just need to wrap them up together:</p><pre>SELECT time_table.*, (</pre><pre>WITH new_customers AS (<br>    SELECT orders.user_id<br>    FROM orders<br>    INNER JOIN (<br>      SELECT user_id<br>      FROM orders<br>      WHERE orders.paid_at BETWEEN time_table.first_order_start AND time_table.first_order_stop<br>    ) AS period_orders ON period_orders.user_id = orders.user_id<br>    GROUP BY orders.user_id<br>    HAVING MIN(orders.paid_at) BETWEEN time_table.first_order_start AND time_table.first_order_stop<br>  )</pre><pre>SELECT 100 * COUNT(*)::float/(SELECT COUNT(*) FROM new_customers) as repeat_percent <br>  FROM (<br>    SELECT COUNT(*), orders.user_id<br>    FROM orders<br>    INNER JOIN new_customers <br>    ON new_customers.user_id = orders.user_id<br>    WHERE orders.paid_at &lt;= time_table.stop<br>    GROUP BY orders.user_id<br>    HAVING COUNT(*) &gt; 1<br>  ) AS REPEATS</pre><pre>)</pre><pre>FROM (<br>  WITH time_serie AS (<br>    SELECT generate_series AS start,<br>      (generate_series + interval &#39;1 month&#39; - interval &#39;1 second&#39;) AS stop<br>    FROM generate_series(&#39;2018-01-01 00:00&#39;::timestamp, &#39;2018-06-30&#39;, &#39;1 month&#39;)<br>  ), first_order_serie AS (<br>    SELECT start AS first_order_start, stop AS first_order_stop<br>    FROM time_serie<br>)<br>SELECT * FROM time_serie, first_order_serie) AS time_table</pre><h3>5. Export the data</h3><p>A matter of seconds with the great “COPY” <a href="https://www.postgresql.org/docs/9.2/sql-copy.html">function</a> that Postgres provides.</p><p>Just wrap the previous request in a COPY block and download it (or use the client-based \COPY):</p><pre>COPY (<br>...<br>) TO &#39;output.csv&#39; WITH CSV HEADERS &#39;;&#39;;</pre><h3>6. Unflatten the table</h3><p>Almost done! We just need to re-arrange the data, to go from a flatten table to the output we expect.</p><p>Here, we do it with a few lines of Ruby:</p><pre>require &#39;CSV&#39;<br>require &#39;time&#39;</pre><pre>cohort_lines = CSV.<br>  read(&#39;input.csv&#39;, col_sep: &#39;;&#39;, headers: true).<br>  map{|line| line.to_h }</pre><pre>months = cohort_lines.map{ |row| row[&#39;registration_start&#39;] }.uniq.sort</pre><pre>time_formatter  = -&gt;(str){ Time.parse(str).strftime(&#39;%B-%Y&#39;) }<br>float_formatter = -&gt;(str){ sprintf(&#39;%.1f&#39;, str.to_f).gsub(&#39;.&#39;, &#39;,&#39;) }</pre><pre>CSV.open(&#39;output.csv&#39;, &#39;wb&#39;, col_sep: &#39;;&#39;) do |csv|<br>  csv &lt;&lt; [nil] + months.map{ |str| time_formatter[str] }<br>  months.each_with_index do |month, i|<br>    columns = cohort_lines.<br>      select{ |r| r[&#39;registration_start&#39;] == month }.<br>      sort_by{ |r| r[&#39;start&#39;]}.<br>      map{|r| float_formatter[r[&#39;repeat_percent&#39;]] }.<br>      drop(i)<br>    csv &lt;&lt; [time_formatter[month]] + columns<br>  end<br>end</pre><p>Tadaaam! 🎉🎉🎉🎉</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CGGum-zf_sJwbB4KnQB5jQ.png" /></figure><h3>‍🕵 ️To go further</h3><p>Once you have this very simple extract working, you still have plenty in front of you.</p><p>What we have done after that with this system:</p><ul><li>Automate the extract so that it runs every month 🕐</li><li>Display cohorts of revenue instead of percentages</li><li>Filter the cohort by country, device, product, and plenty of other dimensions</li></ul><p>The only limit then is the imagination of people you work with!</p><p>This way of extracting cohorts might not be the most efficient technique in terms of the CPU you use, but it has the advantage of being simple and easy to customize!</p><h3>🧠 Conclusion</h3><p>There are thousands of tools on the market right now to help you better understand your users.</p><p>A lot them are very powerful, and really allow non-technical people to analyze user behaviors the way they need. But almost none of these tools are free, and almost all of them are even very expensive. If you can afford the tool that fits your need, fine for you.</p><p>But for the others, remember that with a few dozen lines of code, you can still get great results and priceless insights!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4840e6bf31da" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cheerz-engineering/simple-cohort-analysis-with-sql-4840e6bf31da">📈 Simple cohort analysis with SQL</a> was originally published in <a href="https://medium.com/cheerz-engineering">Cheerz Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The architecture of Cheerz services]]></title>
            <link>https://medium.com/cheerz-engineering/architecture-of-cheerz-services-23f3bedcde9b?source=rss-2ce34ca7e31a------2</link>
            <guid isPermaLink="false">https://medium.com/p/23f3bedcde9b</guid>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[software-architecture]]></category>
            <dc:creator><![CDATA[Théo Carrive]]></dc:creator>
            <pubDate>Thu, 02 Aug 2018 10:34:14 GMT</pubDate>
            <atom:updated>2019-01-11T16:26:35.056Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YPFo-ZMBhuxgehXFHJtuwg.png" /></figure><blockquote>September 2013, in the chaos of a small coworking space of Paris, 11th arrondissement, after a few weeks of work, our first microservice was born. 🐣</blockquote><p>Since then, this baby microservice has grown, and plenty of others services have popped up at Cheerz. This article is a short overview of how we have split our different services.</p><h3>Microservices</h3><p>I won’t go into the details of the microservice philosophy, that has already been detailed in billions of articles on the web. But to quote Martin Fowler:</p><blockquote>The microservice architectural style is an approach to developing a single application as a suite of small services, each running in its own process and communicating with lightweight mechanisms, often an HTTP resource API.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/937/1*MrDMARKuvUCZliIvT5XtGg.png" /><figcaption>From: <a href="https://www.martinfowler.com/microservices/">https://www.martinfowler.com/microservices/</a></figcaption></figure><p>Some people seem to argue about the appellation “microservices” for services depending on their size (and not miniservices, macroservices nor whateverservices). But more than a debate on naming, what actually matters to us is that:</p><ul><li>Services are independent: isolated codebases, isolated databases, independent deployment, and resilient to others failures.</li><li>Communication between them is technology-agnostic, like with HTTP APIs. This way, each microservice can implement its own stack, depending on its needs.</li><li>Size of projects remain small enough so that the development/testing/deployment cycle remains as short as possible</li></ul><h3>Cheerz Architecture</h3><p>Cheerz architecture mainly relies on 6 main services :</p><ul><li>E-business</li><li>Factory management</li><li>Photo management</li><li>Customer support</li><li>Monitoring</li><li>Events</li></ul><p>During the last 5 years, others services were born that we then decided to take down (often with a bit of nostalgia and sadness). Most of the time, when we decided to stop a microservice, it was to instead use existing tools, despite their drawbacks, to not lose focus on our core business.</p><p>Something that I find worth to note, is that while speaking to other startups that have adopted microservices and have approximately the same size (15 to 100 people), most of them also have around 6 services. Is it a magic number of microservices? Question to be followed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Yukm5OqZ1-HekpTd3axPFQ.jpeg" /><figcaption>Cheerz services architecture</figcaption></figure><h3>Service #1 - The E-Business core</h3><p>Because we are an e-business company, it would seem quite logic that we start by the core of our e-business!</p><p>The e-business core is the back-end application that supports everything about our product catalog, our users, and all the actions they make on our website or apps: This is the main API with which all our consumer-facing apps have to deal with.</p><p>Many times, we have considered splitting this service to split the logic of the catalog from the logic of user interactions. However, if we think this split would be great for code isolation and would allow us to have a more specific infrastructure for each, so far, we could not see a solution that would compensate all the drawbacks it would also bring, especially about data sharing between these new microservices. Indeed, in some use cases, s<a href="https://segment.com/blog/goodbye-microservices/">plitting services can induce complexity</a>.</p><h3>Service #2 - The factory service</h3><p>Since we have always believed that mastering the production of our orders is key to deliver quality products and quickly to our customer, factory has been one of our top investments. This service has been the first one to be created, out of the main application, back in 2013.</p><p>Right now, this is the service in charge of :</p><ul><li>Providing the interface with which factory operators scan products they ship</li><li>Allowing grouping of orders to reduce the number of parcels we ship</li><li>Generating machine-specific files, with cutting marks, enhanced color profiles, and all the needed printing informations, based on the machine on which the product will be printed</li><li>Being a gateway to all the carriers APIs (DHL, Colissimo, TNT, Laposte, etc.)</li><li>Handling all the paperwork for the different carriers</li><li>Allowing stock management</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*orbhVHXbeSswEBaKx5Q0Vg.png" /><figcaption>The main blocks of Factory service</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Yj37FuG3SH4zbMS9QjpWBA.png" /><figcaption>How we configure shipping modes per country &amp; weight</figcaption></figure><h3>Service #3 - Customer Support</h3><p>Being able to answer quickly and efficiently to our customers is a hard task, but nevertheless one of the most important ones for us. This is why we decided to create this service.</p><p>Every Customer Support member has a private Chrome Extension that converts every email or order number on Zendesk, into a link that points to this service. Once arrived on this service, our Customer Support members can perform quickly all the main actions needed when communicating with our customers, like:</p><ul><li>Manage emails (subscription to newsletters, re-send confirmation email, etc.).</li><li>Find information about the state of the order (printing, shipping, etc.), and eventually take actions (reprint, cancel, etc.).</li><li>Troubleshoot something that happened during the order, and open a ticket for another department.</li></ul><h3>Service #4 - The events</h3><p>After a while, Cheerz became a quite sustainable company, with a strong production facility, and the tools to be efficient with our factory and in with our customers.</p><p>We then decided to broaden our activities by launching <a href="https://live.cheerz.com/">Cheerz Live</a>, a branch of Cheerz that animates events with an amazing photo booth that we have created.</p><p>However, administrating those events, dealing with the machines availability, and especially configuring the booths for each event was very time consuming. This is why we have developed the events service that allows us to:</p><ul><li>Configure the booths remotely and easily</li><li>Follow the project cycle for each event</li><li>Configure galleries after the events, where users can see their photos (and download, share, etc.)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cCscxekWpIGWGyvNL_4Mgw.png" /></figure><h3>Service #5 - The Monitoring</h3><p>Once you got many services arises the question of “how you will monitor all of them easily”, ie: in a same place. This is why we have developed a very simple tool that gathers and caches information from a lot of different places and then displays it on dashboards that everyone in the company can access: one dashboard for developers, one for marketing, one for customer support, one for the factory, etc.</p><p>This allows us to give real-time updates to all people from Cheerz to metrics like:</p><ul><li>State of our workers queues (number of workers in progress, stales, etc.)</li><li>Errors &amp; error rates traced by TrackJS and NewRelic</li><li>Sales of the day, week, month, and real-time progress of our objective (%)</li><li>Analysis of pages from tools like Google PageSpeed Insights or Search Console</li><li>Conversion rates of our last app versions</li><li>Datas about servers states and deployments</li></ul><p>Et voilà! We have other small services, but we won’t go into details about them right now.</p><h3>The risks</h3><p>Microservices have drawbacks. Without going deeper in the overhead it can introduce if your team is not mature enough, we had to re-implement small pieces of configuration on each project, like user authentication, or some boilerplate that we didn’t feel like it should be put in a common module.</p><p>I have seen many debates about microservices. At which stage should we start thinking about it, partially, strictly, not at all? From what we have experienced, like in general in software engineering, <strong>there is no universal architecture for all problems</strong>. It’s all about granularity!</p><p>Depending on the size of your engineering team, the nature of your problems, the maturity of your team, you could consider having one monolith or thousands of services. Especially, our ability to succeed with microservices depends on the pain you have to spawn and monitor new services, and thus on the stack you rely on: Creating a new service could require to have a database, thus it means you have to monitor it, replicate it, have backups, etc, and unwinding it can be endless if your stack does not provide you automations for all of that.</p><h3>The good parts</h3><p>However, all in all, we clearly see the benefits we have gained by keeping separated services for our main problem domains.</p><ul><li>Onboarding of newcomers has been much easier because of relatively small and isolated codebases.</li><li>Team work is more fluid, with less collisions in the codebases. No more weird side effects between different problem domains.</li><li>We have been able to test upgrades of frameworks (or whole new frameworks or languages) on less critical services, to have a smooth migration and learning.</li><li>When trying to scale, it has been way much easier for us to maintain high availability on our different services, that have very different resources needs.</li><li>It has allowed us to keep the development/test/deployment cycle very short, and to deploy dozens of time per day with great confidence.</li></ul><p>If you want to tell us your story of microservices and architecture, join us, or just have a coffee, <a href="/service/mailto:tech.list@cheerz.com">contact us</a>!</p><h4>Further readings:</h4><p><a href="https://www.martinfowler.com/microservices/">Martin Fowler blog</a><br><a href="https://www.thoughtworks.com/radar/techniques/microservice-envy">Microservice Envy</a><br><a href="http://microservices.io/patterns/index.html">Microservices Patterns</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=23f3bedcde9b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cheerz-engineering/architecture-of-cheerz-services-23f3bedcde9b">The architecture of Cheerz services</a> was originally published in <a href="https://medium.com/cheerz-engineering">Cheerz Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The tale of Cheerz technical stack]]></title>
            <link>https://medium.com/cheerz-engineering/the-tale-of-cheerz-technical-stack-c7ce4faca5b1?source=rss-2ce34ca7e31a------2</link>
            <guid isPermaLink="false">https://medium.com/p/c7ce4faca5b1</guid>
            <category><![CDATA[rails]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[ruby]]></category>
            <dc:creator><![CDATA[Théo Carrive]]></dc:creator>
            <pubDate>Wed, 01 Aug 2018 14:04:12 GMT</pubDate>
            <atom:updated>2020-03-31T14:04:22.925Z</atom:updated>
            <content:encoded><![CDATA[<p>From Cheerz’ very beginning (2012) to the present day, we’ve worked with many technologies before converging on our current stack. Here is the short story of our experience.</p><h4><strong>(Updated in February 2020)</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Rm7fdYWKMEYEy4kmgq1CcA.png" /><figcaption>Cheerz technical stack</figcaption></figure><h3><strong>iOS app</strong></h3><p><em>~100K Lines Of Code</em></p><p>Initially developed in Objective-C, we have fallen in love with Swift language, from its type system great features to its concise syntax.</p><p>The last line of code of Objective-C has been removed in 2019 🎉!</p><p>Because it was a great match with Fastlane and Cocoapods, and because this is our main scripting &amp; backend language, the tools and utils around our app are written in Ruby.</p><h3>Android app</h3><p><em>~100K LOC</em></p><p>Intially written in Java, we’ve started development with Kotlin a few years ago (way before Google announced its support). In a similar way as Swift did, the Kotlin language has really convinced us, all developments are done in Kotlin, and Kotlin now represents more than 80% of our codebase.</p><h3>Android + iOS</h3><p>We are absolutely convinced that Android and iOS applications should share as much as possible: If not code, at least architecture, interfaces, naming, configurations, etc.</p><p>Since the introduction of Kotlin Multiplatform and Kotlin/Native, we have followed very carefully its development, since we see great potential in it for cross-platform development. We have even shipped a small brick of Kotlin-based code on our iOS app, but so far, we haven’t got further and we even think of removing it to simplify the stack.</p><p>On the same kind of philosophy, we have also tried to introduce React Native in a small non-strategic part of our app, but have removed it in 2019 : We understand all the benefits React Native could theoretically bring, but at Cheerz, because it’s maintained by non-web developers and because it brought the complexity of another stack on top of the iOS stack, we tend to think that React Native has given us more trouble than worth.</p><p>We use git submodules to share configuration (in JSON format) between our iOS and our Android apps.</p><h3>Front-End</h3><p><em>~60K LOC</em></p><p>We started the current version of our web application as a part of a Rails project back in 2013. At this time, the choice of a framework was basically between Angular, Backbone, and Ember. We started with Angular, and were very happy with it for a long time.</p><p>Over that period though, we actually aimed to have less and less logic relying on it. In addition to that, we had performance issues with our version of Angular and in the same time, we really believed in Component-Based Design: It was the moment for us to move to another framework that would fit all of those needs. We really liked the <a href="https://vuejs.org/v2/guide/single-file-components.html">Single File Component</a> approach, and at the time we made this choice, Facebook still kept React in <a href="https://medium.freecodecamp.org/facebook-just-changed-the-license-on-react-heres-a-2-minute-explanation-why-5878478913b2">BSD+Patent</a> : Vue.js was the winner, and the migration had begun.</p><p>Independently of Vue.js, we had faced a lot of challenges migrating big parts of our application because our Angular code was very coupled. However, after a while, we had the great opportunity of writing from scratch a very strategic part of our web application : the customization. At this time, because of the tooling around the framework and because our engineers were more comfortable with React, we decided to continue the migration, not toward Vue, but toward React… But this might be the story of a whole other article!</p><p>Long story short: All new parts of our web-app are developed on React, and we try to push to a heavy use of <a href="https://storybook.js.org/">Storybook</a>, that we happen to love.</p><p>On the language side, we have started with Coffeescript, before converting all of our codebase to ES6 in 2018, before introducing TypeScript.</p><p><strong>Current stack (March 2020):</strong></p><ul><li>TypeScript</li><li>React</li><li>Storybook</li></ul><h3>The back-end services</h3><p>~100K LOC</p><p>After the clients, comes of course the question of what there is behind them! On the back-end side, we currently have a few services that have slightly different environments, but all of them rely on Ruby, and the Ruby on Rails framework.</p><p>We have had some experiments, and even more, some backend services in production, that were relying on other technologies (ES6/Express and Go), but with the time, we decided to make everything converge to the Ruby on Rails stack.</p><p>We know that Rails and Ruby have their defaults. Enough so that we at least gave a try to other technologies… But we still happen to love them ❤️. Rails framework and Ruby language allow us to craft complex applications quickly so that we can focus on core business features. The ecosystem is amazing, and Ruby language is very straightforward, yet extremely expressive.</p><p><strong>Current stack (March 2020):</strong></p><ul><li>Ruby (≥ 2.6)</li><li>Rails (≥ 6)</li></ul><h3>The Databases</h3><p>We have used MySQL, PostgreSQL and MongoDB in our different services, but the only DBMS that really got our heart so far is PostgreSQL.</p><p>At some point, we did decide to migrate one of our biggest databases from MySQL to PosgreSQL. The whole process of converting the dump from MySQL format to PostgreSQL took more than 6 hours 😴(mostly to run huuuge Sed scripts). But in the end, we really enjoy working with PostgreSQL. It provides us good performance and really useful features (like JSON data type).</p><p>We also use Redis to store data for background processing with <a href="https://github.com/mperham/sidekiq">Sidekiq</a>.</p><p><strong>Current stack (March 2020):</strong></p><ul><li>PostgreSQL (11)</li><li>Redis (5)</li></ul><h3>Key takeaways</h3><blockquote>We love our stack. It has its defaults and thousands of competitors, but in the end, <strong>we truly believe that good engineers should not focus too much on the stack</strong>, but instead on how to solve problems efficiently, with good data structure, architecture and methodologies.</blockquote><blockquote>All stacks can be valid, the only things that matter is how productive it makes you, and the pleasure you get from it!</blockquote><p><em>You want to join our team to write with us the future of Cheerz technical story? <br></em><a href="/service/mailto:jobs@cheerz.com"><em>Contact us!</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c7ce4faca5b1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cheerz-engineering/the-tale-of-cheerz-technical-stack-c7ce4faca5b1">The tale of Cheerz technical stack</a> was originally published in <a href="https://medium.com/cheerz-engineering">Cheerz Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>