<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Andrew Pett on Medium]]></title>
        <description><![CDATA[Stories by Andrew Pett on Medium]]></description>
        <link>https://medium.com/@andrew.pett?source=rss-680a8d98d186------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*hYhSpRDpFIB-vy7Q0y3gZQ.jpeg</url>
            <title>Stories by Andrew Pett on Medium</title>
            <link>https://medium.com/@andrew.pett?source=rss-680a8d98d186------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 20:47:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@andrew.pett/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[Setting Kafka’s pace with Broadway]]></title>
            <link>https://medium.com/@andrew.pett/setting-kafkas-pace-with-broadway-9e2dd410da89?source=rss-680a8d98d186------2</link>
            <guid isPermaLink="false">https://medium.com/p/9e2dd410da89</guid>
            <category><![CDATA[continuous-improvement]]></category>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[parallel-computing]]></category>
            <category><![CDATA[elixir]]></category>
            <dc:creator><![CDATA[Andrew Pett]]></dc:creator>
            <pubDate>Wed, 12 May 2021 01:49:57 GMT</pubDate>
            <atom:updated>2021-05-19T22:07:51.806Z</atom:updated>
            <content:encoded><![CDATA[<h4>Using Broadway to parallelise and stay in control</h4><p>Looking to turn your push dataflow into a pull Broadway pipeline? Here’s an introduction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*XnrK7fIuCqn17qOQTpGGIQ.png" /></figure><p>Recently <a href="https://medium.com/@matthew.lee_11877">my colleague, Matt</a>, and I were faced with a new Kafka experience: roughly a million messages placed on a highly partitioned Kafka topic, and a consumer which does a simple query to the database for each message — what followed was some impressively fast processing, a thrashed database, and some unhappy users.</p><blockquote>This is the story of how we wrangled Kafka using Broadway in an environment where we are unable to change Kafka configuration</blockquote><p><a href="https://sendy.elixir-radar.com/w/EvyA9KEYIVzXIB3LqQyX0g/J8921cxQ4jeEDmbVKDWh02aw/VgvDi33qhTbZhhVmplhybg">This article was also picked up by Elixir Radar in their newsletter</a>.</p><h3>KafkaEx background</h3><p>We use KafkaEx for consuming the Kafka service in our microservice applications. It’s generally easy to set up, and get going with, and we have few complaints about it.</p><p>In order to fully consume messages off a Kafka topic, KafkaEx will create at least one connection per partition. Each connection is in fact a GenConsumer, which is responsible for consuming messages. The implication of this is that if you have an application consuming a topic with 50 partitions, you will automatically end up with a minimum of 50 concurrent consumers. If you naively scale your application horizontally, especially without clustering, you can multiply your instance count by 50 in this case.</p><p>Having <em>instances * partitions </em>consumers per topic isn’t necessarily an issue in and of itself, however the kicker with KafkaEx is that unless you want to manually set up each of your consumers, you’re going to use a ConsumerGroup which doesn’t provide any mechanism for throttling other than by the mechanism of back-pressure.</p><blockquote>The flow of data becomes ‘push’ rather than ‘pull’ from the perspective of our application</blockquote><p>Recall back to the experience we faced where a million messages were coming through, doing a simple database query each. The result was that <em>instances * consumers </em>all competing for a database connection over and over caused a huge load on a small database, and prevented APIs from getting access to a connection to the database in a timely fashion.</p><h3>Cue the next feature</h3><p>While a one-off (ish) of database starvation isn’t the end of the world for this particular application, we had a feature coming up that needed to increase the complexity of this message processor. Instead of a simple database call, it would have to double the database calls and make an outbound API call to another service.</p><blockquote>Having the processing rate unlimited would now be unacceptable as it may interfere with the performance of other systems</blockquote><p>At this point I knew we needed to introduce some artificial back-pressure in order to make sure neither our application, nor the external services, were being overwhelmed. KafkaEx will only grab more messages when it thinks it’s finished processing the messages it has in hand already. If we can convince it that it’s not done for a bit longer, we can slow down the process to be <em>controlled</em>.</p><p><em>Another option could be to use </em><a href="https://github.com/dashbitco/broadway_kafka"><em>broadway_kafka </em></a><em>at this point, but we have built some systems around the use of KafkaEx which would make this a non-trivial transition</em></p><h3>Enter Broadway</h3><p>I am a big fan of <a href="https://hexdocs.pm/flow">flow</a>, which builds on top of <a href="https://hexdocs.pm/gen_stage">gen_stage</a>, so I had at least a little awareness of <a href="https://hexdocs.pm/broadway">Broadway</a>. Broadway is a library used to “Build concurrent and multi-stage data ingestion and data processing pipelines with Elixir.”</p><p>Broadway offers some key functionalities to us that make it perfect for solving our performance problem:</p><p>- <strong>Back-pressure</strong><br>- Automatic acknowledgements at the end of the pipeline<br>- Batching<br>- Fault tolerance with minimal data loss<br>- Graceful shutdown<br>- Built-in testing<br>- Custom failure handling<br>- Ordering and partitioning<br>- <strong>Rate-limiting</strong><br>- Metrics</p><h3>The components of a broadway pipeline</h3><p>A Broadway pipeline needs a producer and a consumer. For us, we already produce data through KafkaEx, and we can easily consume that data. The problem with hooking up KafkaEx to Broadway, is that KafkaEx in a <em>ConsumerGroup</em> configuration moves data through a <strong>push </strong>mechanism, whereas Broadway works on the principle of downstream stages <em>pulling </em>data.</p><p>We can start a simple Broadway pipeline with just the below code, defining the consumer (processor) inline. This is well explained in the Broadway documentation:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e8c47c72694c931df2805668622d05a6/href">https://medium.com/media/e8c47c72694c931df2805668622d05a6/href</a></iframe><p>The part that’s missing is <em>Producer</em>; the glue between KafkaEx and Broadway.</p><h3>The glue</h3><p>As I mentioned before, we need to turn the data flow from <em>push</em> to <em>pull</em>, and we need to force back-pressure on the Kafka consumer. One way to achieve this is a simple GenServer which queues messages from Kafka, and forces Kafka to wait before putting more messages into the queue.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9c8015ecb2ca1b805964c57cbaf66fef/href">https://medium.com/media/9c8015ecb2ca1b805964c57cbaf66fef/href</a></iframe><p>Now we’ve got a process that converts <em>push</em> to <em>pull</em>, we can write a producer. This can simply pull from this queue when downstream stages ask it for demand.</p><p>We also need to store how much demand the producer has been asked for, so that if there are no Kafka messages for a time, then some start being received again, we can kickstart the pipeline once more.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dd9e2535028c886bd80a0afffed6fbf3/href">https://medium.com/media/dd9e2535028c886bd80a0afffed6fbf3/href</a></iframe><p>This is great — now we can change our Kafka consumer to use <em>BlockingBuffer.push(message)</em> and update the <em>BroadwayPipeline.handle_message/3 </em>to do the processing of the Kafka message.</p><p>This will move all the concurrent processing into the Broadway pipeline. As our configuration stands, we’re going to be processing in a single process, at an unlimited rate… but Broadway lets us change this easily in configuration. Let’s alter the way we start the Broadway pipeline now. Let’s imagine we want to process a million messages a day, and we want to restrict the open database connections per instance to five — we can easily configure that like below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/585db558c54176a1c5ee894d025cad13/href">https://medium.com/media/585db558c54176a1c5ee894d025cad13/href</a></iframe><h3>Summary</h3><p>Usually people look to Elixir to parallelise their workload, but sometimes it’s easy to over-parallelise and shoot yourself in the foot. By making use of Broadway, we can easily parallelise while staying in control. This is just a taste of what Broadway offers — I’d encourage you to <a href="https://hexdocs.pm/broadway">check out their documentation</a> to learn more about its functionality and use cases.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9e2dd410da89" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[4 tips for working from home]]></title>
            <link>https://medium.com/@andrew.pett/some-brief-advice-for-working-from-home-2ee17292ebe0?source=rss-680a8d98d186------2</link>
            <guid isPermaLink="false">https://medium.com/p/2ee17292ebe0</guid>
            <category><![CDATA[remote-working]]></category>
            <category><![CDATA[tips]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[featured]]></category>
            <category><![CDATA[working-from-home]]></category>
            <dc:creator><![CDATA[Andrew Pett]]></dc:creator>
            <pubDate>Thu, 19 Mar 2020 00:00:11 GMT</pubDate>
            <atom:updated>2020-03-23T19:54:48.735Z</atom:updated>
            <content:encoded><![CDATA[<h4>Practical ways to do it well</h4><p>We’ve been working from home, or working remotely, for a few years now. Are you moving into a work from home phase? Here are some things we’ve learnt.</p><p>We’ve had wins and losses as our people have worked away from our <a href="https://abletech.nz/">Abletech</a> headquarters. Here are our top tips. (Scroll down to read more from our very remote workers.)</p><p>These changes, methods and ideas can improve the experience for you, your employer and your colleagues.</p><h4><strong>Work / Life Separation</strong></h4><p>It’s crucial to maintain a separation between work and life when you’re not going in to the office for a long period. Use these guidelines to get you on track to a healthy balance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OoQQd6lG0BjU-7QqRJJrEw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kmd9oD1LrTqPADFbZibWvw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hHnfExxHFTe4OtS3LTBv8w.jpeg" /><figcaption>Working from home Karori style and Vancouver style</figcaption></figure><h3>1. Harness your habits</h3><p>We all have habits. Be aware of yours and take control. This is your chance to decide what your rhythm will be. Make your habits great.</p><ul><li>Set work hours and break hours, and try to stick to them</li><li>If possible, assign one work space in your house, ideally one room — don’t make this your bedroom</li><li>Work at a desk or table — working on your bed is not a sustainable position physically or mentally</li><li>Maintain your daily routine; shower, dress, make-up — anything you would normally do on an office day, continue. This will help you feel like you’re still ‘going to work’, and coming home</li><li>Take breaks. You might find it easier to get into the flow while working from home, and you may neglect normal needs. Regularly get up, walk around, drink water, etc</li><li>Go for a walk outside at lunch</li><li>Don’t do chores and other normal home activities during work hours, or break hours. This is important for keeping a separation between work time and relax time. This will both impact your productivity and long term sustainability</li><li>Try new things. While habits are important, variety is too</li></ul><h3>2. Communicate well and often</h3><ul><li>Don’t hesitate to send people messages. People can respond in their own time: You’re not interrupting them</li><li>Conversely, don’t feel the need to respond immediately if you’re in the flow. It’s easy to be distracted by messages: balance your own work and replying to others</li><li>Post in a ‘Watercooler’ instant messaging channel everyday! The best way to avoid feeling isolated in comparison to being in the office is to <em>continue</em> the daily small talks. It might be weird and awkward to start with; battle on — it’ll be easier if everyone is doing it</li><li>Audio/Video calls are a great way to collaborate. Some people may want to be involved in these a majority of their day, and some may not. Individuals will be productive in different ways</li><li>Respect that everyone will be productive with varying levels of communication. Let others know if you are struggling with the level of communication</li></ul><h3>3. Equipment matters</h3><ul><li>Speakers + Microphone is the least ideal setup for voice chats. Audio feedback is the bane of remote collaborative work — try get hold of some headphones, airpods, anything where the audio and microphone are isolated</li><li>Try to emulate your office setup — it’ll be familiar, and you’ll be coming back to it at some point</li></ul><h3>4. Deal with issues</h3><p>Issues will crop up and they’re better tackled sooner rather than later. Communication is key. Talk to your employers, colleagues, friends. Seek out advice from people with experience: it’s unlikely you’re the first person to experience any problem, and it’s unlikely you’ll be the first to solve it! The more we share, the better experience we’ll all have.</p><p>Those are our four top tips to get you humming. It’s taken us years to refine those! They work. May you enjoy your new location and the advantages that working from home will offer you.</p><h4>Read more</h4><ul><li><a href="https://stories.abletech.nz/16-months-remote-in-review-65eae2acc49d">Getting set up to work remotely</a></li><li><a href="https://stories.abletech.nz/a-day-in-the-life-of-an-abletech-developer-90d554e1ebc7">Working from snowy Canada when your team’s in NZ</a></li><li><a href="https://stories.abletech.nz/abletech-vancouver-84dd8ca8c7b3">Remote working — a tour</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_C2jlaAXkK1f5rehBppi3g.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V9SXrEIpOA09_VqOrWr1Wg.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HmjcNo_J3WD_2PuWJXs1mA.jpeg" /><figcaption>Working from home looks different for each of us</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2ee17292ebe0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[16 Months Remote, In Review]]></title>
            <link>https://medium.com/@andrew.pett/16-months-remote-in-review-65eae2acc49d?source=rss-680a8d98d186------2</link>
            <guid isPermaLink="false">https://medium.com/p/65eae2acc49d</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[remote-working]]></category>
            <dc:creator><![CDATA[Andrew Pett]]></dc:creator>
            <pubDate>Sun, 02 Dec 2018 23:27:37 GMT</pubDate>
            <atom:updated>2018-12-02T23:27:37.339Z</atom:updated>
            <content:encoded><![CDATA[<h3>16 months remote: a review</h3><h4>I lived 30% of my working life 13,000km from home</h4><p>Last year, my partner and I moved to Canada, mainly to explore the other side of the world from New Zealand. We wanted to be away one or two years, but we didn’t have funds to do that without working.</p><p>Fortunately, Abletech was keen to have their second go at having someone work remotely.</p><h3>Getting started</h3><p>I had been working at Abletech for about 18 months, and I’d worked with people from Abletech for around three-and-a-half years. While I knew I was working with some of the best people I know, I still wasn’t sure how remote work would <strong><em>work</em></strong>. I did some reading on the subject, and found many contradictory opinions and experiences.</p><p>After a bit of discussion, we came up with three things that would be necessary in order to make remote work as much of a success as possible:</p><ul><li><strong>Join a co-working space</strong> — there was a prevalent opinion that doing so would help with staying focused and engaged in work, while also keeping some face to face interaction in my daily life</li><li><strong>Organise work pre-emptively</strong> — this would be important to keep me busy</li><li><strong>Catch up weekly</strong> — so that we can iterate on any problems we encountered on either side</li></ul><h3>Projects</h3><p>During my time in Calgary, I worked with three different clients with very different setups;</p><ol><li><strong>Large team</strong> of Wellington-based front-end developers, doing Angular in a kanban stream fashion</li><li><strong>Small team</strong> of (mostly) Wellington-based developers, working on Ruby microservices, using scrum</li><li><strong>Medium-sized team</strong> of dispersed developers, working on Elixir microservices and React frontends, using <a href="https://www.scaledagileframework.com/">SAFE</a></li></ol><p>One important commonality between all three of these projects is that I’d had previous exposure to the parties involved.</p><p><strong>The large team</strong><br>Interacting with this team was a breeze. We used Slack, in real-time, and were able to communicate clearly and promptly. Initially I had difficulty keeping busy but we resolved this by improving the story pipeline for our team. Out of the three clients this one had the most amount of friction, due to their networking which resulted in a functional, but slow working environment.</p><p><strong>The small team</strong><br>I had previously worked with this team and overall it was good after some teething trouble. I was working with some codebases I was familiar with, and some that I was not. Unfortunately the ones I was not familiar with, were the ones that I needed to spend the most time in. To add further pain, the expert in this codebase left this client’s company about a week after I started the work.</p><p>It was difficult to get up-to-date with the business logic as I had to find people who could answer my questions. My timezone was offset by a few hours so doing this proved a bit challenging. Once I’d figured out this information, I slid into a good routine. Their scrum backlog was well maintained which made the workflow slick.</p><p><strong>The medium-sized team</strong><br>Projects with this team were my main source of work for the 16 months I worked remotely. We covered a number of different projects. Initially I wasn’t at all familiar with the codebases, or business logic. I spent more time getting information, and clarifying requirements, than expected. Also, I had some teething issues in getting enough work queued-up for Fridays, which were Saturdays in New Zealand.</p><p>We tracked these issues with weekly catch-ups and things improved as time went on.</p><h3>Processes</h3><h4><strong>The bad</strong></h4><p>As alluded to above, not everything ran smoothly all the time. Issues usually boiled down to <em>running out of ready work</em> and becoming <em>too blocked to continue</em>. These issues would usually be quick to resolve in-person, in-timezone. But doing so remotely, in a different timezone, was challenging at times.</p><p>My solution to these issues ended up being ‘time leniency’ on both sides. In order to oil the engine, so to speak, I would spend a small amount of time, late at night, answering questions, asking questions, and ensuring there was work ready to continue the following morning. Sometimes this night-work wasn’t necessary. Other times it was a five-minute job or a half-hour meeting at 10pm. This was a fair solution for me because the advantages of working remotely outweighed this inconvenience.</p><h4><strong>The good</strong></h4><p>By spending that time making sure I was ready for the next day, I was setting myself up for convenience and success. Usually I could start work at a time of day that suited my partner and I. If I had to run errands in the morning, or if I needed a little extra sleep that day, I would simply start a little later. If I was feeling fresh in the morning, I’d get started early and finish early, so that I had more time to spend in the evening relaxing and exploring the city. Not only did the flexibility leave me feeling much healthier in terms of work/life balance, it was a balance that I could adjust on the fly as necessary.</p><p>Abletech was very happy for me to take holidays and explore. The main purpose of the trip was to travel around Canada &amp; USA. We took multiple trips totalling around three months. Our last roadtrip lasted about one-and-a-half months and spanned the whole east coast of North America. This was a once in a lifetime experience for us. I couldn’t have done it without Abletech being generous with the time it took.</p><h4><strong>Ups and downs balanced</strong></h4><p>By operating out of a co-working space, I was also able to meet local people and become more involved in Calgary. It was much easier to feel ‘at home’, in a working sense, by having somewhere to go each day.</p><p>The timezone difference between Calgary and New Zealand varied between four and six hours (plus a day) depending on the time of year. While introducing this gap added challenges, it became less of an issue as all parties became used to it. When the gap was only four hours a day, I could work a little later in the day, and have very similar hours to those in the office in New Zealand. That was pretty comfortable.</p><p>After getting past teething issues in each project, remote work operated very smoothly for me. The advantages outweighed the disadvantages considerably. I wouldn’t hesitate to do it again.</p><h4><strong>Recommendations</strong></h4><p>My suggestions for optimising working remotely would go back to the three initial points I made in this article. But stick to them fiercely. The better you can apply them, the better the outcome in my view.*</p><p>* Disclaimer: Your mileage will definitely vary.</p><p>It’s helpful to know the people you’ll be working with, before you start working remotely. It may have been more difficult for me if I was not familiar with my three teams.</p><p>Communication is very important. It could potentially cause trouble if you don’t get it right. A word or an emoji gone awry could be an issue, especially with people you don’t know.</p><h3>My experience as a whole</h3><p>Having now worked remotely for around 30% of my work-life I can say it’s been a time of good learning for me. It was an extremely valuable experience and allowed me to grow in ways that I didn’t expect it to.</p><p>I’ve become more confident about making decisions within my realm, and more confident about deferring decisions that need to be discussed further.</p><p>I value communication more. I’m now more comfortable talking to those I do know, as well as those I don’t know. I’m an introvert so this is an accomplishment-and-a-half for me.</p><p>I know more about how I like to work, what drives me, what motivates me, what keeps me back, and how to deal with these things.</p><p>That’s not to say that working remotely caused all those improvements but I believe it sped up the process. I’ve matured as a developer and as a person.</p><p>In terms of travel, we were able to see a significant amount of the west and east coasts of North America. We saw the Canadian Rocky Mountains and surrounding areas. We tried new things like snow-mobiling, skiing and snow shoeing, and had a blast. These are memories I’ll cherish forever.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JxFaqFno15D81_Ni586Wvg.jpeg" /><figcaption>Somewhere in the wild, Golden, BC, Canada</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g5WDXyRIfCgvf4esyGz2Gw.jpeg" /><figcaption>Peggy’s Cove, Nova Scotia</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6vUobCRyPYfAKDZm_e5wLQ.jpeg" /><figcaption>Sulphur Mountain, Banff</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0qZ1Xbq0pIJDfnRqRMZTfw.jpeg" /><figcaption>Lake Louise</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Dfb7n74_wQngclruls1-nA.jpeg" /><figcaption>Zion National Park</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=65eae2acc49d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A day in the life of an Abletech developer]]></title>
            <link>https://medium.com/@andrew.pett/a-day-in-the-life-of-an-abletech-developer-90d554e1ebc7?source=rss-680a8d98d186------2</link>
            <guid isPermaLink="false">https://medium.com/p/90d554e1ebc7</guid>
            <category><![CDATA[travel]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[remote-working]]></category>
            <dc:creator><![CDATA[Andrew Pett]]></dc:creator>
            <pubDate>Wed, 21 Feb 2018 22:34:40 GMT</pubDate>
            <atom:updated>2018-04-06T05:00:01.043Z</atom:updated>
            <content:encoded><![CDATA[<h4>Calgary, Canada Edition ✨</h4><p>Working remotely as a developer is a situation many people would love to find themselves in. For the last 6 months, I’ve been lucky enough to do so with Abletech.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UJmgDDJhujfEOGH2jv8lXA.jpeg" /></figure><p>My base location of choice has been Calgary, Canada. While Wellington has been enjoying a unique, spectacularly warm and windless summer, I’ve been enjoying freezing rain, ice, snow and temperatures plummeting to -32ºC. Sounds shocking — but it’s not so bad.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sRwso2J2pAUGeNY8LmJD1g.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wnLy1LwX8qtZ5-pGfkZa7Q.jpeg" /><figcaption>Andrew and Hannah — combining work and travel</figcaption></figure><h4>A day of winter</h4><p>The day usually starts in one of two ways.</p><ol><li>My alarm goes off and I wake up like any normal person</li><li>An extremely loud whirring noise anytime between 4am and 6.30am, caused by two people clearing the paths around our apartment building with snow blowers (imagine leaf blower, but louder).</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QECbuD5APkpcvC-0IA9UjA.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/982/1*SaunsL9dxtMXOaH1px_A_A.png" /><figcaption>Thick snow and a brave snowshoe hare</figcaption></figure><p>While the former is a much nicer way to wake up, the latter means only one thing; snow. I get out of bed and peak out the blinds from our living room. It’s easy to tell just how much snow there is by looking at the balcony railing. Some days it looks like someone sprinkled ground ice delicately on top — and some days it looks like an extra white partition!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qT2VT4gssk_O7T1jMyoICg.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dLEgihHB0L75MjyM1MyQDw.jpeg" /></figure><p>My next stop is a bowl of cereal in front of the weather forecast for the day. The weather here is very changeable, and if you don’t dress right for the day, you can find yourself in a serious spot. Temperatures can rise from -20ºC to positive degrees within a few hours if the <a href="https://en.wikipedia.org/wiki/Chinook_wind">wind blows the right way</a> — or vice versa if we get some cool arctic air blow through. You can <a href="https://andrew.pett.nz/5/dressing-for-a-calgary-winter">read more about how I dress for winter here</a>.</p><p>Once I’m ready to go, I take a short walk to a bus stop downtown and wait in a semi-enclosed shelter, usually arriving around 8am. Depending on the time of year, it’s either starting to get light… or totally pitch black. There’s something a little odd about walking to work at 8am when it’s pitch black — but those days don’t stay around too long thankfully.</p><p>The bus takes 20 minutes or so to get into Kensington, a nice little suburb just outside of downtown. I jump out of the bus — sometimes onto a clear footpath, sometimes into snow deeper than my boots. The paths outside of downtown are often not cleared early in the morning after a good dump of snow, and if they are, there’s a high chance you’re walking on ice, not on pavement. I head inside and grab a coffee (to start the day and to defrost!), chat with a couple of developers around me, sit down, and start catching up on what happened the night before.</p><h4>Remote working</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WghO0BdiptWkRft4_ixZuA.jpeg" /></figure><p>When I agreed with Abletech to work remotely, I was a little nervous about how it might go — there are endless numbers of articles online about the challenges teams face, and the solutions they come up with to tackle them. I was expecting it to be hard. However, what I found in reality wasn’t as difficult as others had made it out to be. I put this down to 3 ideas which have so far helped me stay productive and sane:</p><p><strong>1. Communicate often, and communicate early.</strong></p><p>When you’re not able to talk to someone face to face, it’s important to just <em>be in touch</em>. I like to communicate any problems I anticipate happening as soon as possible so they can be resolved before they happen, or even while I’m asleep 💤</p><p><strong>2. Try and keep the pipeline full</strong></p><p>Truly running out of things to do should be a rarity. Working in another timezone, in another part of the world can make getting extra tasks or detail a challenge. The best way to combat this is to take from <strong>#1</strong> and try to stock up on work before running out. Working in a team that operates scrum or kanban boards with stories which anyone can pick up is a huge help.</p><p><strong>3. Iterate</strong></p><p>In true agile fashion, I believe the most important point is to evaluate what is and is not working, and then improve. Weekly catch ups provide an opportunity to address anything necessary and make changes quickly.</p><figure><a href="https://stories.abletech.nz/elixir-meetup-at-abletech-c12e2c4ff533"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EMP7C5zOCoWDf5ThzsEjdA.jpeg" /></a></figure><figure><a href="https://stories.abletech.nz/elixir-meetup-at-abletech-c12e2c4ff533"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rsfq27m-FYIh5w54gYEnLw.jpeg" /></a><figcaption><a href="https://stories.abletech.nz/elixir-meetup-at-abletech-c12e2c4ff533">Beaming in for a recent Wellington Elixir meetup — read more here</a></figcaption></figure><h4>Lunch</h4><p>My lunch préféré used to be a bottle of Soylent. Soylent is a meal of pretty much everything you need — however — Canada has decided it disagrees about what a meal constitutes, and therefore I can no longer sit inside the warm, cosy office at lunch time... I must venture out into the wildlands. Boots on, jacket on, gloves, beanie (toque?!), sunglasses — check! Often how far I go for lunch is proportional to the temperature. The lower the temperature, the less I’m willing to walk 😎. Do you want to be out grabbing lunch in -25ºC? No. <br>For the warmer days, Kensington is relatively good on choice. There are fast foods, restaurants, cafes, a supermarket. Anything is within reach depending on the weather.</p><h4>End of the working day</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fcU6peGWmt-FZ3kST6HjfQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QkedrinaBIGGoR19D7Ua4A.jpeg" /></figure><p>The sun is setting around 4.30pm. By the time I leave — around there, or 5pm, it’s dark. Start dark, end dark. Thankfully the in-between is almost always sunny: <a href="https://www.currentresults.com/Weather-Extremes/Canada/sunniest-cities.php">Calgary is the sunniest city in Canada!</a></p><p>Getting home is another bus and train (train is faster on the way home). Peak hour C-Train in downtown core is like walking into a container of sardines most days. I walk a short distance, and I’m home again.</p><h4>After hours</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1LdsHpwH5uPzpwi1Z1QBLw.jpeg" /></figure><p>Coming from cities in New Zealand which don’t see snow, I absolutely love the amount of winter activities around Calgary. Skiing is a 20 minute drive away, ice skating a 5 minute walk to the plaza, a toboggan-worthy hill only 10 minutes away. There’s plenty to do in the snow — even taking a walk alongside the river is totally different to the summer. While the river is running, it’s hidden by a thick layer of snow capped ice. The snow around the parks shows the prints of the wildlife; snowshoe hares, squirrels. They’re even cuter in real life than you’d think.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kUjYhJS1R6Z6yw0-FTJ8Vw.jpeg" /><figcaption>1.5x Char Kuey Teow — Cinta — ameal for gods</figcaption></figure><p>Calgary has been a great city in our time so far. It’s clean, easy to get around and has some incredible natural beauty around it. In saying that, it just does not and will not beat Wellington on food and coffee. I look forward to the day I get back to catch up with the team over a coffee from Flight Hangar, Nasi Goreng from Little Penang, or Char Kuey Teow from Cinta.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*waA0--AENUJuHs140NnhhQ.jpeg" /><figcaption>A sneak preview of a Banff post coming soon</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=90d554e1ebc7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Elixir Learnings #2: Simple caching]]></title>
            <link>https://medium.com/@andrew.pett/elixir-learnings-2-simple-caching-4e6ed177c3fb?source=rss-680a8d98d186------2</link>
            <guid isPermaLink="false">https://medium.com/p/4e6ed177c3fb</guid>
            <category><![CDATA[elixir]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[erlang]]></category>
            <dc:creator><![CDATA[Andrew Pett]]></dc:creator>
            <pubDate>Mon, 15 May 2017 01:10:20 GMT</pubDate>
            <atom:updated>2017-05-22T20:08:24.551Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/802/1*gCL82jhpq9JWUaI7v8MEIg.png" /></figure><p>Recently I’ve been working on a side project to relay messages between two messaging services, starting with Slack and IRC.</p><p>I started this project as a pure Elixir application so that I could use some newly learnt Elixir knowledge without having to dive into Phoenix.</p><p>Eventually, I want to add in a web component in order to monitor and configure the application dynamically.</p><p>To model this problem as simply as possible, I came up with the concept of a Pipeline and a Location. A Pipeline connects two Locations and can be one-way or two-way. At first this was not persisted, and the application would boot off of a list of these pipelines. However, when taking a first pass at introducing persistence, I noticed that upon each message dispatch from one location to the other, the application needed to query the database for the pipeline. Not ideal. As this project is a bit of a learning project for me, the obvious following step to reduce these queries is to add caching.</p><p>In Ruby-land, when thinking of caching key-value data, I’d often look to a solution like <a href="https://redis.io/">Redis</a> or <a href="https://memcached.org/">Memcached</a>, but not Elixir or Erlang — no.<br>The first result when googling “elixir cache” was a library called <a href="https://github.com/zackehh/cachex">Cachex</a>:</p><blockquote>Cachex is an extremely fast in-memory key/value store with support for many useful features</blockquote><p>Sweet! I thought. I checked out the README, and getting it running was as simple as adding it as a dependency, and adding a worker to my application</p><pre>worker(Cachex, [:pipeline_lookups, []])</pre><p>Caching was now in my application, and accessible with a very easy to use API.</p><pre># Insert into the cache<br>Cachex.set(:pipeline_lookups, location.id, location.pipeline)<br># And get it back out<br>{:ok, pipeline} = Cachex.get(:pipeline_lookups, location.id)</pre><p>Too easy. Way too easy. I decided to jump into the Github repository and read a little into how it worked. Cachex, as it turns out, is a (very sweet) wrapper around <em>ETS: Erlang Term Storage- </em>something I was in fact already using in my application.</p><p>Cachex was more than I needed, even though its API was nice. My objective is learning Elixir and Erlang, so, just as fast, out Cachex went. Because I’d wrapped Cachex in a module, it was just a matter of refactoring the internals to use the also simple ETS.</p><pre># Insert into ETS<br>:ets.insert(:pipeline_lookups, { location.id, location.pipeline })<br># And get it back out<br>:ets.lookup(:pipeline_lookups, location.id)</pre><p>Being able to take advantage of the existing Erlang and Elixir ecosystem has so far been wonderful. There have been numerous times where I’ve wanted some abstraction or functionality, and found that it was already implemented in Erlang years ago.</p><p>Needless to say, I’m enjoying my adventure in taking this application from nothing to a fully fledge OTP app with a web interface. <br>Lots to do- I’d better get back to it!</p><p>Read my <a href="https://stories.abletech.nz/elixir-learnings-1-480ddf08989d">first post about my first learnings with Elixir</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4e6ed177c3fb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Elixir Learnings #1: First Learnings]]></title>
            <link>https://medium.com/@andrew.pett/elixir-learnings-1-480ddf08989d?source=rss-680a8d98d186------2</link>
            <guid isPermaLink="false">https://medium.com/p/480ddf08989d</guid>
            <category><![CDATA[elixir]]></category>
            <category><![CDATA[erlang]]></category>
            <dc:creator><![CDATA[Andrew Pett]]></dc:creator>
            <pubDate>Tue, 07 Mar 2017 19:45:41 GMT</pubDate>
            <atom:updated>2017-07-13T03:15:05.879Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/423/1*dJ6mOlP27ZMjGFZXta4pRQ.png" /></figure><p><em>TL;DR: Use — no-halt with </em><em>mix run to keep an app with non-blocking processes running!</em></p><p>Recently I re-read <a href="https://pragprog.com/book/elixir13/programming-elixir-1-3">Programming Elixir by Dave Thomas</a>, a book that I read over a year ago when it was in an earlier state. At the time when I first read it, I remember being extremely excited by Elixir, and sharing my excitement with colleagues around me. Unfortunately Elixir wasn’t well known in my community at that point, and although at the time I played with Elixir for a while (pretty bad slack/IRC relay here: <a href="https://github.com/aspett/slackirx">https://github.com/aspett/slackirx</a>), I soon lost motivation, without opportunity to work with it during the day.</p><p>I attended RubyConf AU this year, and Elixir was popping up in most of the talks, both as a solution to some problems that people have been facing in Ruby world, and as a quip about so many people moving to Elixir.<br>This resparked some discussion about Elixir in the local community, and as such I decided to re-read the Programming Elixir book and get back into it.</p><p>One of the first things I’ve tried tackling since, is rewriting a little Ruby script I wrote a couple of months ago. The script is simple; every minute, call an API, filter the results, and output some formatted data to a CSV file.</p><p>My Elixir (still work in progress) solution, after reading about all this OTP (Open Telecom Platform) goodness, is as follows:</p><p>A supervisor which supervises two workers</p><ul><li>A ticker task</li><li>A GenServer class which handles ticks</li></ul><p>Which looks a bit like</p><pre>defmodule App do<br>  use Application</pre><pre>  def start(_type, _args) do<br>    import Supervisor.Spec</pre><pre>    children = [<br>      worker(App.Worker, []),<br>      worker(Task, [App.Worker.tick/0])<br>    ]</pre><pre>    opts = [strategy: :one_for_one]<br>    Supervisor.start_link(children, opts)<br>  end<br>end</pre><p>Pretty simple — the task is just calling my tick function, as follows</p><pre>def tick do<br>  GenServer.cast(__MODULE__, :tick)</pre><pre>  :timer.sleep(@interval)<br>  tick<br>end</pre><p>where @interval is a module attribute with a value of 60000 (60 seconds).</p><p>And finally, the function which handles tick calls to the process, a bit like:</p><pre>def handle_cast(:tick, state) do<br>  fetch_data<br>  |&gt; filter_data # A list of things to be written out<br>  |&gt; Enum.each(&amp;write_to_file/1)</pre><pre>  {:noreply, state}<br>end</pre><p>Awesome! Time to boot it up with mix run.<br>Huh. Why doesn’t it do anything? It just compiles, and exits.</p><p>Well, here’s my learning! If nothing else, this is a note to self. While developing small OTP apps like this locally, there’s a key option to mix run, which is --no-halt! The need for this stems out of having no blocking processes, resulting in the execution of the application stopping immediately after startup, even though there is a timer running.</p><p>Read part two about <a href="https://stories.abletech.nz/elixir-learnings-2-simple-caching-4e6ed177c3fb">Elixir and Simple Caching</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=480ddf08989d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>