<?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 Emil Severin Moen Ramsvik on Medium]]></title>
        <description><![CDATA[Stories by Emil Severin Moen Ramsvik on Medium]]></description>
        <link>https://medium.com/@emilseverin93?source=rss-a6460597d712------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*1D47_o819LTqm009.jpg</url>
            <title>Stories by Emil Severin Moen Ramsvik on Medium</title>
            <link>https://medium.com/@emilseverin93?source=rss-a6460597d712------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 04:00:35 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@emilseverin93/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[Some thoughts around mental models.]]></title>
            <link>https://medium.com/@emilseverin93/some-thoughts-around-mental-models-9893a08e239d?source=rss-a6460597d712------2</link>
            <guid isPermaLink="false">https://medium.com/p/9893a08e239d</guid>
            <dc:creator><![CDATA[Emil Severin Moen Ramsvik]]></dc:creator>
            <pubDate>Thu, 16 Feb 2023 22:58:12 GMT</pubDate>
            <atom:updated>2023-02-16T23:02:44.775Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/845/0*56pJSlTuy0tKaPju.png" /><figcaption>Understanding the way our brain perceives information.</figcaption></figure><p>When observing the world around us, we are using mental models to simplify information and make decisions. However, if you do not understand the underlying principles of the mental models you are inherently using, how you can assess their validity to the problems you are analyzing?</p><p>The mental models you are applying are defined by your background and experiences. An engineer thinks in systems, an economist uses incentives as a background and a hunter thinks in terms of behavior. The information you have available to you is not necessarily unbiased information but rather filtered information from your predefined notions.</p><p>I think one of my greatest weaknesses has been my inability to properly understand how my mental models inherently shape my worldview. If all the information gets parsed through models that transform the information to confirm my previous assumptions, the risk of massive mistakes increases. Furthermore, it is intellectually dishonest to not break out of your perception jail to widen your horizon.</p><p>One of the greatest advantages of diverse teams is the fact that they have different mental models which they apply to the same set of problems with the same information available. To make an allegory, if you are lost on a deserted island, and search for shelter by only looking at places with trees, you have immediately reduced the chance of ever finding the best place of making a home. Altering the way the problem is perceived immediately alters the solution space as well.</p><p>Sometimes you can not call upon a group of diverse thinkers to help you analyze and filter all available information. Therefore, to combat your preconceived notions you need to be aware of the mental models that guide your thinking and how they will affect the information you are receiving. Most of the time, we are quickly making decisions without deep and concentrated effort, so-called <a href="https://thedecisionlab.com/reference-guide/philosophy/system-1-and-system-2-thinking">System 1 thinking</a>. System 1 thinking makes use of the mental models we have already and makes quick decisions based on some criteria. From an evolutionary perspective, this makes sense, as if we had to stop and use considerable levels of energy to assess every situation, then most likely we had been driven to extinction a long time ago. The beauty of applying System 1 thinking is when making repeated decisions where being right gives a small reward but by being wrong the consequences might be drastic.</p><p>It takes effort to analyze oneself from a meta-perspective, and further effort to apply different methods of perception to analyze the problem. This System 2 type of thinking is a limited resource and should be applied to the correct types of tasks. Mental models will help reduce the cognitive load and therefore they should not be abandoned. You should therefore strive to apply different kinds of mental models to the same problem. That way you have a better way of comparing not only the solutions to the problem but also the nature of the problem.</p><p>Mental models shape how we perceive the world. A socialist and a conservative can both look at the same information and make drastically different conclusions set from the same evidence. But rarely will they seek to understand how in light of their worldview model they will make assumptions to get to their conclusions. This is where you can gain an enormous advantage as a decision-maker. If you understand how you think and process information, you can also understand the weaknesses and strengths of your mental model framework.</p><p>Remember, tricking yourself is the easiest thing in the world. You need to deeply think about how you are tricking yourself. You can be the greatest analyst the world has seen but it does not matter if the assumptions you use are all wrong.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9893a08e239d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Goals and Expectations]]></title>
            <link>https://medium.com/@emilseverin93/goals-and-expectations-864a0f1458ae?source=rss-a6460597d712------2</link>
            <guid isPermaLink="false">https://medium.com/p/864a0f1458ae</guid>
            <category><![CDATA[goals]]></category>
            <category><![CDATA[habits]]></category>
            <category><![CDATA[goal-setting]]></category>
            <dc:creator><![CDATA[Emil Severin Moen Ramsvik]]></dc:creator>
            <pubDate>Sat, 28 Jan 2023 14:23:27 GMT</pubDate>
            <atom:updated>2023-01-28T14:23:27.533Z</atom:updated>
            <content:encoded><![CDATA[<p>Everyone makes goals, mostly around the period of late December, or early January. Few goals are reached, and the once hopeful attempts at becoming better at work, relationships, athletics, or life in general end in bitter disappointment.</p><p>There are of course a lot of different systems out there for creating stable goals, and the amount of books, articles and youtube clips you can watch on the topic is insurmountable. But is working purely with goals the right way of approaching the problem?</p><p>I think that having goals that are binary is wrong. A goal should be a shining star, a near utopian condition in which you have reached the desired state. Instead of measuring yourself against extremely harsh and maybe insurmountable goals. I propose to look at goal setting in a different light, where you split the target and the focus. And make the goal your ideal condition, and have a baseline expectation which should always be reached.</p><p>If your goal is to work out every single day, make the expectation that you will near miss two days in a row. If your goal is to run marathons, make the expectation that you 3 times a week take on your running shoes and walk out the door. If the goal is to become a millionaire, make the expectation that you each day do something to increase your wealth. If your goal is to create a book, the expectation should be that sentences are written every day. The expectations should drive your daily improvements, they should be the bedrock on which the foundations are laid. And by doing that, you give yourself an opportunity to celebrate the gains you have had. If the expectation is that you walk out that door to run, every time your running shoes hit the ground that day is a small but significant victory.</p><p>James Clear writes in atomic habits about the two-minute rule. The two-minute rule in “Atomic Habits” is a technique for making small changes in behavior that are easy to implement and maintain over time. The idea is that by starting with a small, manageable action that can be accomplished in two minutes or less, it becomes easier to build momentum and establish a new habit. For example, instead of trying to immediately change a habit like exercise, you could start by committing to doing two minutes of exercise every day. As you build momentum and become more comfortable with the behavior, you can gradually increase the time and intensity of the exercise. This approach makes it easier to establish a new habit because it eliminates the excuse of not having enough time and makes it easier to stick to the habit in the long term.</p><p>I think the expectations are the drivers of the habit, it is the simple yet clear threshold in which you gain the intrinsic reward by each day completing simple routines that trigger som sort of warning. The expectations should be the triggers that iniate the habit. If the goal is to stop smoking, the expectation should be that you never relapse more than one day in a row. The expectation should be so easily obtained that losing out is something you can not accept.</p><p>If the goal defines the speed in which you attempt to fulfill it, you will drive towards it with such a relentless speed that either you will become exhausted, or you will make a goal that you can effortlessly stroll towards and be stuck in a quagmire of unrealized potential. Rather, think of the goal as the signs showing the distance left, and the expectations being the minimum speed that you need to maintain to steadily progress towards your destinations. The way the goal is reached is not with the sprints of the hare, but rather a slow efforted walk of the tortoise, always steadily improving.</p><p>In order to improve, we must first put ourselves in a place where we can steadily celebrate each improvement but still be aware that the road ahead is long. We want to continuously be at a point where we are challenged but not fall into the despair by not seeing any measurable progress.</p><p>The argument of this article is to highlight that the lofty goals should not be the same as the grounded expectations. The argument is that you define where you want to go in the goal and the distance to reach it, while defining the minimum consistently obtainable speed in the expectations related to that goal. By having a minimum standard of performance, you can celebrate each single step towards the goal, which makes the journey so much easier.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=864a0f1458ae" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Books and Articles that influenced me in 2022]]></title>
            <link>https://medium.com/@emilseverin93/books-and-articles-that-influenced-me-in-2022-3a3e8c9ad0d4?source=rss-a6460597d712------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a3e8c9ad0d4</guid>
            <category><![CDATA[books]]></category>
            <category><![CDATA[best-book-to-read]]></category>
            <category><![CDATA[book-review]]></category>
            <dc:creator><![CDATA[Emil Severin Moen Ramsvik]]></dc:creator>
            <pubDate>Sun, 01 Jan 2023 17:31:30 GMT</pubDate>
            <atom:updated>2023-01-01T17:31:30.466Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_GGKmf2S1wb9BOrdt3g7Gg.jpeg" /></figure><p>I love to read, and I strive to read every day. I have now for the last two years, focused a lot on finding the inner joy of reading. After over 70 books last year I slipped back down to 52 this year. I guess in 23 I need to read many short stories again. Some books leave a stronger impression than others, i want to share some of the books that share</p><p>In 2021, I focused on taking a lot of notes and while I continued this system in parts of 2022, I moved away from taking pages upon pages of notes. The reason is that it took away my immersion in the books, and the continuous breaks let my attention float toward temptations (Mostly on my phone). When I started focusing on reading books in 2021, I was astonished by my lack of attention. After a couple of minutes of reading, I reached for my phone to doomscroll on some social media app. In 2022, I have become better at just immersing myself in the book and the story. I would like to share some books that made reading a whole lot easier in 2022 and if you might take up your reading glasses sometime in 2023, I would highly recommend them.</p><h3>The Professor in the Cage</h3><p><em>By Jonathan Gottschall</em></p><p><a href="https://www.amazon.com/Professor-Cage-Fight-Like-Watch/dp/0143108050">The Professor in the Cage: Why Men Fight and Why We Like to Watch</a></p><p>This book revolves around one professor&#39;s quest of fighting in an MMA tournament. As I could recommend reading it just for the description of fear, confidence and adrenaline described in the preparation before the fight, the parts describing fighting during different parts of history bring insight into maybe an under-discussed subject in modern times. The countless tales of painful deaths due to a lead bullet in the stomach during duels are gut-wrenching (pun intended). The deaths are multiplied in tragedy by the sometimes trivial slights leading to the fatal shots that felled great mathematicians, poets, politicians and laymen alike.</p><h4>What sticks with me</h4><p>The descriptions of the anticipation before the fight. And the hilarious description of the fight itself. In the words of the great life philosopher Mike Tyson: “Everybody has a plan until they get punched in the face”. On a more serious note I still think a lot about how men deal with aggression and how I behave compared to the descriptions in the book.</p><h3>A random walk down Wall Street</h3><p><em>By Burton G. Malkiel</em></p><p><a href="https://www.amazon.com/Random-Walk-Down-Wall-Street/dp/0393358380/ref=sr_1_1?keywords=a+random+walk+down+wall+street&amp;qid=1672502367&amp;s=books&amp;sprefix=a+random%2Cstripbooks-intl-ship%2C224&amp;sr=1-1">A Random Walk Down Wall Street: The Time-Tested Strategy for Successful Investing</a></p><p>One of the most boring books I have read on finance, in which there are no exciting and fast ways of making money being a stock market aficionado. Reading the book makes gives the feeling that only funds consistently beating the index are either lucky or crocked, most likely both. As a simple engineer, it was interesting to understand how financial mechanisms work. Of particular note was learning that EBITDA was an acronym for <em>Earnings Before I Tricked the Dumb Auditor.</em></p><p>Insights from this book, highlighted by quotes like “Lethargy bordering on slowth remains the best investment strategy” from Warren Buffet himself are that you cannot beat the market, all technical analyses are equivalent to astrology, and if you want the make money as a retail investor you need to cheat the tax man (Legally). This book made me put my investment money in a tax-deductible pension fund.</p><h4>What stuck with me</h4><p>This entire book just hammers down all investment strategies and reinforces my impression that sometimes it is best to let the professionals (In this case the market) handle things. <em>You cannot lose if you do not play.</em></p><h3>Kitchen Confidential</h3><p><em>By Anthony Bourdain</em></p><p><a href="https://www.amazon.com/Kitchen-Confidential-Anthony-Bourdain/dp/B00005AAQ7/ref=sr_1_1?crid=2MPVXXU2G3WGP&amp;keywords=kitchen+con&amp;qid=1672503579&amp;s=books&amp;sprefix=kitchen+con%2Cstripbooks-intl-ship%2C178&amp;sr=1-1">Kitchen Confidential: Adventures in the Culinary Underbelly</a></p><p>A gripping tale, to say the least, Anthony Bourdain&#39;s book about the dirty inner workings of a restaurant kitchen is a fascinating story of backbreaking work, fascinating characters, and wonderful insights into kitchen life. However, these stories are, like the characters themselves, buried beneath a mountain of coke, heroin and curse words.</p><p>Anthony Bourdain is brutally honest, and his countless tales of hobby chefs pursuing to buy a restaurant because they make great dinner hosts only to fall brutally short reinforce the notion of leaving things to professionals. Furthermore, his small insights into great cooking techniques used by professional chefs are a well-received respite from the mountains of coke, heroin and curse words that apparently make the restaurant business go around.</p><h4>What stuck with me</h4><p>“Monter au beurre” — Adding some butter at the end to the sauce to make the finishing touch. Mostly, adding salt, cream, sugar and butter is the clue to great food.</p><h3>An article that really influenced me</h3><p><a href="https://mcfunley.com/choose-boring-technology">Choose Boring Technology</a></p><p>Choose boring technology was an article that changed how I approached technology and how decisions on technology are a fundamental question and one of the primary reasons why projects either succeed or fail. Suddenly my thoughts changed from what technology could do to how well can we as a team employ that said technology. Innovation tokens are now a stable of my vocabulary. After reading this article, I almost transformed myself into a technology Luddite.</p><p>That&#39;s it, hope if you read the books they will be as enjoyable to you as they were to me.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a3e8c9ad0d4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Calling Bullshit]]></title>
            <link>https://medium.com/@emilseverin93/calling-bullshit-3f2ff2451040?source=rss-a6460597d712------2</link>
            <guid isPermaLink="false">https://medium.com/p/3f2ff2451040</guid>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[fake-news]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[science]]></category>
            <dc:creator><![CDATA[Emil Severin Moen Ramsvik]]></dc:creator>
            <pubDate>Thu, 02 Jun 2022 18:45:34 GMT</pubDate>
            <atom:updated>2022-06-02T18:45:34.475Z</atom:updated>
            <content:encoded><![CDATA[<h4>In the age of big data</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xcOmTfdglqEMcJm-GXvqww.jpeg" /></figure><p>In today’s world, our newsfeeds, papers, and information systems are drowning in bullshit. Bullshit is everywhere, and now more than ever it is important to learn how to spot and call out bullshit.</p><p>There is actually a college course on the subject of calling out bullshit, furthermore, the lectures are available on youtube. I watched the whole of the lectures and tried to narrow down the main points into an overview article.</p><p>Although this article gives a nice overview, I highly recommend the lecture series which is informative, easy to understand even for statistical laymen, and also pretty funny. The links to the web pages and the youtube playlist are located at the bottom of the article. The lecturers have also made a book about the subject.</p><p><a href="https://www.penguinrandomhouse.com/books/563882/calling-bullshit-by-carl-t-bergstrom-and-jevin-d-west/">Calling Bullshit by Carl T. Bergstrom, Jevin D. West: 9780525509202 | PenguinRandomHouse.com: Books</a></p><h3>Spotting Bullshit</h3><p>It is extremely difficult to, without extensive domain expertise quickly understand the nature of the results presented to you in articles, opinions, and podcasts. To navigate this abyss of misinformation, we need tools to spot and filter out the bullshit.</p><blockquote>The amount of energy needed to refute bullshit is an order of magnitude larger than to produce it. -Brandolini´s principle.</blockquote><h4>Too good to be true</h4><p>If it looks too good to be true, it most likely is too good to be true. A good example is a tweet going viral about gender discrimination in academia, but the hypothesis, not the result was what was tweeted. This was a mistake that was pointed out in the replies, but the replies did not get the traction the tweet got, which is in line with Branolini´s principle.</p><p>Another problem with this is the confirmation bias, we tend to accept facts that are in line with our prenotions of what is true. We want the facts that support the narrative we like. This is a very human fallacy, and we need to take extra measures to make sure we believe bullshit just because we want to.</p><h4>Unfair comparison</h4><p>Is the comparison reasonable, or are you comparing apples to oranges?</p><p>Actually, media reports are falling for unfair comparisons all the time. For example small countries such as Singapore and Norway with big countries such as India. The comparisons and assumptions do not scale. Be vary comparisons across scale, categories, or time as they are not applicable and give us false conclusions.</p><h4>Fermi estimation</h4><p>Fermi estimation is thinking in orders of magnitude. Fermi estimation is something that is appearing in job interviews all the time. It is also an extremely good tool for understanding numbers and validating assumptions without too much work.</p><p>An example is the case of Food stamp fraud. The story was that the US wasted 72 million dollars on the food stamp program every year due to fraud. What a waste! What happens when Fermi estimation is applied to this number:</p><ul><li>What fraction of Americans receive food stamps: ~ 10 %</li><li>They receive ~1000 $ annually.</li><li>There are ~ 300 million people in the US.</li><li>300000000 x 0.1 x 1000 $ = 30000000000</li><li>70000000 / 30000000000= 0.2 %</li></ul><p>Ask anyone in the retail business if 0.2 % is a bad number? They would be in fact ecstatic to get such a number. This shows that such behind-the-napkin calculations might serve as a quick validation of the arguments and assumptions presented.</p><p>An important rule is to remind oneself, that if a number is being presented, what is the fraction. If a fraction is presented, what is the actual number? Ask why the data is presented that way.</p><h4>Entertain multiple hypotheses</h4><p>Understand that there are a lot of multiple hypotheses that might explain the phenomena we are witnessing. As humans, we have a tendency to quickly categorize everything we witness, and while this might be advantageous it is extremely</p><p>An example is that men self-cite a lot more than women in academia. The explanation given in the headline was that men were jerks, and that was the one spread in mass media. However, that is just one plausible explanation for why men self-cite more than women. However, there might be that men might have been in the field longer and have more reasons to self-cite, there are more men in academia than women, or a multitude of other factors. Entertain multiple hypotheses so that you don&#39;t fall into a categorical trap.</p><h4>Post hoc ergo propter hoc</h4><p>Since event Y <em>followed</em> event X, event Y must have been <em>caused</em> by event X.</p><p>This is a logical fallacy that correlated parameters are causational parameters because they appeared before in time.</p><p>Remember that if we are correlating enough different phenomena, we will find high correlations just by pure chance. A monkey on a typewriter will eventually, given infinite time, produce War and Peace by Leo Tolstoy. It is therefore important to be skeptical of correlations that do not actually have any relationship.</p><p><a href="https://www.tylervigen.com/spurious-correlations">Spurious Correlations</a></p><h4>Common causes</h4><p>Do storks deliver babies? Data shows that stork pair and annual births by countries are correlated with a p-value less than 0.008. However, there might be a common cause, such as the size of the country in question. The larger the country the higher number of births and the more storks are in it. When exercising yourself on correlations, notice that there might be a common cause of the relationships shown from the correlations.</p><h4>p-value and the prosecutor&#39;s fallacy</h4><p>The prosecutor&#39;s fallacy is when you are using the wrong conditional probability. This fallacy is not named without reason, a particular damning case of prosecutor&#39;s fallacy is portrayed in the Sally Clark case, which is superbly written about in this article:</p><p><a href="https://idatassist.com/prosecutors-fallacy-what-happened-to-sally-clark/">Prosecutor&#39;s Fallacy: What Happened to Sally Clark? - Datassist</a></p><p>The p-value is not an indicator of the correctness of the hypothesis you are proposing, but rather if the null hypothesis is rejected or not. We usually do not know the probability of the proposed hypothesis. An example dear to a lot of people is the issue with false positives, as a positive test for an uncommon disease might have a higher chance of being a false positive than a true positive.</p><p>A p-value is therefore not a measure of whether the hypothesis you are proposing is right, but rather if the null hypothesis is likely to be false.</p><h4>Right Censoring</h4><p>Right censoring is a statistical pitfall where we do not have sufficient information on the subject, maybe due to factors such as time.</p><p>An interesting example is the case of the age of death by the musical genre. As the below graph shows, the life expectancy of rappers and heavy metal artists is surprisingly low. However, as rap and metal are pretty recently established musical genres, there might be a lot of rappers and metal rockers that have not died yet and therefore do not count. Is the proportion of people dying in the rap genre higher than in the country genre across age groups?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*Savrxxgd7AK0gW65mon_ag.png" /><figcaption>Why does the age of death decrease with the time the genre has been alive?</figcaption></figure><p>On the callingbullshit.org webpage, there are some case studies that can be used to test your bullshit spotting skills.</p><p><a href="https://www.callingbullshit.org/case_studies.html">Calling Bullshit: Case Studies</a></p><h3>Big Data</h3><p>Big data is the product of faster connectivity, cheaper storage, and our willingness to send information, personal or other to the data storage companies. This leads to a wide range of appliances that can be investigated by data scientists and analysts. Data exhaust, the byproduct of measured human activity is a way of describing appliances for things it wasn&#39;t primarily built for. Examples of this include the Google Flu Tracker, which used search queries and geolocations to track flu outbreaks. Data exhausts have become a viable business income strategy, where often the data provided by users are more valuable than the user itself. An example of selling data is that Gillette, the shaving razor manufacturer used tinder analytics to sell more razors.</p><blockquote>The idea that a sufficiently large pile of horseshit will, with probability one, somewhere contains a pony. — Alternative definition of Big Data</blockquote><p>Big data has grown exponentially in the last few years, maybe only surpassed by big data hype. However, contrary to what some <a href="https://www.wired.com/2008/06/pb-theory/">pundits claim</a>, there are some key takeaways and points that should be considered.</p><h4>The scientific method is not dead.</h4><p><strong>Machines are not bias-free.<br></strong> You don&#39;t really need to know if an algorithm is bullshit or not, but rather investigate the inputs and then outputs. If you look at the training data you can uncover a lot of inherent biases. <br><strong>Garbage in, garbage out. <br></strong> In machine learning, it doesn&#39;t matter how well-performing the algorithms you are developing are, if the data quality is poor, your algorithms will have poor accuracy. <br> As an example, the xkcd cartoon on the significance of days in the year was that while September 11th was in very high frequency mentioned in the books, all other 11th dates were mentioned in very low frequency. This raised a lot of debate, while the reason for the low mentioning is that the 11th was confused with other characters such as ll and n in the optical scanning of the books. This is an example of the garbage in-garbage out phenomenon. Deep neural nets might be accurate, but a consequence of these complex algorithms is instability.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wQcvVVxzDJpPvqNcW76gWw.jpeg" /><figcaption>XKCD cartoon on the significance of different dates from historical books.</figcaption></figure><p><strong>Google Flu trends<br></strong> In an article in 2009, google researchers claimed they could predict flu trends by looking at data. The article and algorithm became the poster child for the age of big data, which later became the poster child of the fallibility of big data.<br> The google flu project failed because google overestimated the flu trends by over 50 % over two-thirds of the time. It turned out that just taking a measurement of the temperature at random times would create a better algorithm. Big data hubris is that only big data is enough. The google flu project is a classic example of overfitting. Overfitting is taking the data we have too seriously, where we trust that the data we have is perfectly representing the phenomena we are trying to represent.</p><p><strong>Ethics of machine learning algorithms. <br></strong> It is very difficult to assess the ethics of AI and machine learning, there is a fine line between being biased and being correct. One of the greatest pitfalls is the fact that we are particularizing from generalities. However, should we not judge the algorithm on accuracy? If for example, an adolescent follow up program is biased towards certain backgrounds but it is accurate, i.e. People who are deserving of help are getting it, is this not a better metric than what type of background the ones in need are from.</p><h3>Data Visualization in the popular media</h3><p>Data visualization has been present in scientific papers for well over a century. However, in popular media, there has not been a lot of history using data visualization. Therefore people are not that used to visualizations and might be susceptible to a lot of bullshit.</p><h4>Types of data visualization bullshit</h4><ul><li><strong>Misleading axis<br></strong> One of the cheapest tricks in the data visualization book is the truncation of the axis of the dependent variable. This is a very common mistake in data visualization. A misleading axis can be manipulated to show what the author wants it to show.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TlVHoLGcodGPRdJ8GvZE_w.jpeg" /><figcaption>A misleading axis might show a completely different story than the one that is actually true. Notice that the difference are not as large as the graphs make them out to be.</figcaption></figure><ul><li><strong>Misleading bin sizes<br></strong> If the bins vary widely in size, they can be manipulated. For example, by increasing bar size we can add artificial high bar columns to manipulate the graphs to tell the story the author wants it to. Graphs should be portrayed so that subtle changes are not drastically affecting the story the graph tells.</li><li><strong>Data viz ducks<br></strong> A data duck is when style gets in the way of substance. “<em>It is right to decorate constructions, but never construct decoration.</em>” — Venturi et. Al. Data ducks are not interested in telling the data story, but rather displaying how good they are at styling graphs.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6dJRmRs75VQIuBVQqhiUhQ.jpeg" /><figcaption>Looks like a duck, and quacks like a duck…</figcaption></figure><ul><li><strong>Glass slippers<br></strong>Try to shoehorn data into structures that were not meant to display such information. Examples could be making a periodic table of courses and boot camps for data science education or other etc. Making a subway map of investments in a portfolio and so forth. Easily explained it is bullshitting no meaning into structures meant to portray information.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O903H9KBIHvi99K7OdRL3Q.jpeg" /><figcaption>Glass slippers.</figcaption></figure><ul><li><strong>Principle of proportional ink</strong></li></ul><blockquote>“The representation of numbers, as physically measured on the surface of the graphic itself, should be directly proportional to the numerical quantities measured”- Edvard Tufte.</blockquote><p>This leads directly to the principle of proportional ink:</p><blockquote>When a shaded region is used to represent a numerical value, the area of that shaded region should be directly proportional to the corresponding value.</blockquote><h3>Science is amazing but…</h3><p>We are creatures of narrow understanding, and science has allowed us to understand the universe and create amazing things.<br>It would be a mistake to rely on science as a tool we use now to make it the only way of understanding how the world works. It is highly arbitrary and as such, we can improve it. Because of the arbitrariness, there is of course a lot of bullshit.</p><h4>Replicability and reproducibility</h4><p>One of the biggest issues is centered around replicability and reproducibility. Replication is one of the most important tenants of science.</p><ul><li>Reproducing is taking the exact same experiment and getting the same result.</li><li>Replication is getting the same result when the parameters are slightly different.</li></ul><p>There is a crisis of replication, where there is decreasing return on investment in replicating a study. This is a big deal. We have difficulties replicating studies in economics, neuroscience, psychology, and other fields. The reproducibility of psychological studies in a paper was only 39/100.</p><p>One of the most obvious and damning examples of this issue is the Reinhart example. Reinhart et. al. showed that countries with a debt to GDP ratio above 90 % showed a drastic reduction in growth, which was used as an argument for austerity. However, a grad student showed that the paper had major errors and the result of the corrected paper was actually the opposite of the conclusion of the original article.<br>The unspoken rule is. That at least 50% percent of studies published in top journals can&#39;t be replicated. <br>In economic papers, 33 % of papers could be reproduced without contacting the authors and 49% could be replicated by contacting the authors. This is a crisis, the bastion of truth that science is supposed to be cannot be reproduced.</p><p><a href="https://www.bbc.com/news/magazine-22223190">Reinhart, Rogoff... and Herndon: The student who caught out the profs</a></p><p>The student, Thomas Herndon, explains in a good way the issue with the paper. Most interestingly, he had to choose an article for a term paper and chose the Reinhart article because it was one of the most cited papers at the time.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FCAcUvXjM14c%3Fstart%3D324%26feature%3Doembed%26start%3D324&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DCAcUvXjM14c&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FCAcUvXjM14c%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/8b8d72cb921044be1b16ceafafaf0d98/href">https://medium.com/media/8b8d72cb921044be1b16ceafafaf0d98/href</a></iframe><h4>Publication Bias</h4><p>The causes of this crisis are mostly due to publication bias. Publication bias occurs when authors preferentially report and journals preferentially publish positive results. Peer review filters out crackpots, mistakes, and unfortunately all the negative results from studies that showed that nothing happened.<br>In clinical trials, where results are mandated to be reported to the FDA, the articles published showed that while in the papers there were 40+ positive and only 3 with negative results. The FDA results showed that most of the results from clinical trials were negative.<br>However, there is a cumulative effect on papers, where interesting papers are built upon and therefore get tested by having similar studies. This serves as a sort of replicability test.</p><h4>Tricks to publish</h4><p>As a consequence of the reputation of science, other actors want to drape themselves within the veil of science and spread misinformation, intentionally or not. An issue is that non-science masquerading as science might be easy to detect by subject matter experts it might be more difficult to understand for people outside of the field. Understanding what motivates scientists are important, and scientists are incentives by recognition and fame within their field that can be translated into job security and money. To do that, they gotta get that p&lt;0.05 and publish articles. Common tricks to get papers through are:</p><ul><li><em>P hacking</em>: This is also known as data dredging, where multiple different parameters are checked and only the ones that show significant correlations are reported. In the words of Ronald H. Coase: “if you torture the data long enough it will confess to anything”</li><li><em>Outcome switching</em>: Switching the assumptions of the article to fit the results.</li><li><em>Garden of forking paths</em>: Your hypothesis are following the data.</li></ul><p>In the quest for publications, there are of course multiple tricks as well.</p><ul><li><em>Salami slicing</em>: Slicing one meaningful paper into multiple “thinner” papers.</li><li><em>Courtesy authorship</em>: Mentors get cited on paper as a courtesy by their former students.</li><li><em>Medical ghostwriting</em>: Pharmaceutical companies ghostwriting papers that are assumed to be by independent researchers.</li><li><em>Citation rings</em>: People take turns citing each other.</li><li><em>Self-citation</em>: Emil citing Emil et. Al.</li><li><em>Broader authorship</em>: As an example taken from biology, if you happen to walk through the lab during trials, then you get to become a co-author. Contributions to a paper that is minimal might be enough for co-authorship. This also leads to authorship rings akin to citation rings.</li><li><em>Citation inflation</em>: Authors of articles are very generous with citing sources, even though most of the citations are not relevant.</li></ul><p>The company STM hosts 2/3 of all scientific publishing and brings in around 10 billion dollars yearly. At the University of Washington, it cost more for collections to STM than to pay the faculty.</p><p>A new kind of publishing in science is open-access science, akin to open-source software, that attempts to undo some of the issues with big papers and paywalls, making science accessible to everyone. This might solve some of the issues stemming from the overcommercialization of academic journals.</p><h4>Questionable Journals</h4><p>Why are there some many questionable journals and questionable articles flourishing today? This phenomenon might be explained using Goodhart´s law and Campbell&#39;s law.</p><p><strong>Campbell´s law</strong></p><blockquote>The more any quantitative social indicator is used for social decision making, the more subject it will be to corruption pressure and the more apt it will be to distort and corrupt the social processes it is intended to monitor.</blockquote><p><strong>Goodhart&#39;s law</strong></p><blockquote>When a measure becomes a target, it ceases to be a good measure.</blockquote><h3>Fake news</h3><p>The natural ecology of fake news:</p><p>1. Fake news is not new but its societal impact may be.<br>2. Easy money can be made with fake news<br>3. Falsehoods fly extract quickly and the truth comes limping after (Jonathan Swift)<br>4. Social media and a strongly partisan atmosphere have created the perfect storm<br>5. Click-driven revenue exacerbates catchy headlines<br>6. Fightback: FactCheck, PolitiFact, etc.</p><p>Why fake news? Because there is a lot of money to be made from it. <br>If you get around a million hits you might get 5000$, and what if you get 80 million hits. And it is very cheap to make articles with no basis in reality and spread them.</p><h3>Calling Bullshit</h3><p>How do you refute bullshit? Here are some rules and tools that might prove handy in refuting “bullshitian” claims. <br><strong>Rule 1: Be correct</strong></p><ul><li>Have all the information you need</li><li>Double-check the facts</li><li>Run it by a friend or a colleague.</li></ul><p><strong>Rule 2: Be charitable</strong></p><ul><li>Consider the fact you might be the one who is confused.</li><li>Don&#39;t confuse malice with stupidity</li><li>Don&#39;t impute stupidity when an understandable error is sufficient.</li></ul><p><strong>Rule 3: Be clear</strong></p><ul><li>Think as hard about how to present your argument as you did about how to prove your claim in the first place.</li></ul><p><strong>Rule 4: Admit fault<br></strong>Everyone makes mistakes. Just own your own.</p><h4>Tools</h4><p>Tools for refuting bullshit are arguments and strategies used to provide the discussion partner with sound and logical arguments that make the bullshit fall through. Mastering these techniques might prove handy not only in the fight against misinformation but also during discussions and calling yourself on your own bullshit.</p><p><strong>Reductio ad absurdum<br></strong>Show that the assumptions or methods of an argument lead to ridiculous conclusions. An example of a reductio ad absurdum argument would be</p><ul><li>The Earth cannot be flat; otherwise, we would find people falling off the edge.</li></ul><p><strong>Debunking myths<br></strong>How to refute bullshit for others. <br>Some of it is difficult due to Brandolini&#39;s principle previously stated. Interesting reading can be found in <a href="https://www.climatechangecommunication.org/wp-content/uploads/2020/10/DebunkingHandbook2020.pdf">The Debunking Handbook</a>. People are not hard drives, you cannot refute myths by adding new information.</p><p>Once something is settled in the brain, it is very difficult to “remove”/refute it. You need to fill the gap with an alternative explanation. A typical refuting issue is the backfire effect, that more complex arguments and explanations might make other less likely to believe the refutation of the myth.</p><p><strong><em>Toolbox to refute myths</em><br></strong>1. Focus on the core facts.<br>2. Don&#39;t refer to the myth, if reference is necessary, proceed with explicit warnings.<br>3. Fill in the gap with alternative explanations.<br>4. Be clear and concise, more is not always better.<br>5. Use graphics and visualizations.</p><p><strong>Null model<br></strong>When observation A is used as evidence for claim B, show that A has a simpler alternative explanation. <br>The result of a null model is the statement: “You don&#39;t get to cite these data s evidence for your theory”</p><p><strong>Pinpoint where a false claim arose<br></strong>Track a claim back to its source and show where in the game of telephone the claim was altered.</p><p><strong>Counter examples</strong><br>If someone claims that A implies B, find a case in which A is true but B is not. <br>An example of this was during a talk when physicists who had studied just enough immunology to become dangerous proposed that immune systems are essential for large multicellular organisms. This claim was debunked when an actual immunologist sat back and raised his/her/their hand when the talk was over and asked: “What about trees?”</p><p><strong>Analogies</strong><br>Show a parallel example of reasoning that is patently false.</p><p>Finally, know when to walk away. Sometimes arguing on the internet is not worth it.</p><h3>Sources:</h3><p><a href="https://www.callingbullshit.org/">Calling Bullshit</a></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fvideoseries%3Flist%3DPLPnZfvKID1Sje5jWxt-4CSZD7bUI4gSPS&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fplaylist%3Flist%3DPLPnZfvKID1Sje5jWxt-4CSZD7bUI4gSPS&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FA2OtU5vlR0k%2Fhqdefault.jpg%3Fsqp%3D-oaymwEWCKgBEF5IWvKriqkDCQgBFQAAiEIYAQ%3D%3D%26rs%3DAOn4CLAw4ZDdgLaI22p852MbR2LN3sOEig%26days_since_epoch%3D19141&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="853" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/67547ed279366d3dd9438ccdfff123c9/href">https://medium.com/media/67547ed279366d3dd9438ccdfff123c9/href</a></iframe><ul><li><a href="http://www.stat.columbia.edu/~gelman/research/unpublished/p_hacking.pdf">http://www.stat.columbia.edu/~gelman/research/unpublished/p_hacking.pdf</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3f2ff2451040" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Prove a Meeting`s worth]]></title>
            <link>https://medium.com/@emilseverin93/prove-a-meeting-s-worth-743392ac9560?source=rss-a6460597d712------2</link>
            <guid isPermaLink="false">https://medium.com/p/743392ac9560</guid>
            <category><![CDATA[teamwork]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[efficiency]]></category>
            <category><![CDATA[leadership]]></category>
            <category><![CDATA[meetings]]></category>
            <dc:creator><![CDATA[Emil Severin Moen Ramsvik]]></dc:creator>
            <pubDate>Sat, 09 Apr 2022 19:26:48 GMT</pubDate>
            <atom:updated>2022-04-23T13:58:02.457Z</atom:updated>
            <content:encoded><![CDATA[<p>Meetings are a plague. They require time, effort, and focus from a lot of people. For each person added to the meeting, the total time used increases exponentially. Worst of all, most of the meetings probably could have just been a mail. Take a look at the statistics below and see for yourself how much time is considered wasted in meetings.</p><p><a href="https://www.zippia.com/advice/meeting-statistics/">28+ Incredible Meeting Statistics [2023]: Virtual, Zoom, In-Person Meetings And Productivity - Zippia</a></p><h3>Proof of Work</h3><p>One of the fundamental concepts of cryptocurrency is Proof of Work (PoW). Proof of work proves that you are telling the truth or being sincere by imposing a certain amount of computational work to verify your message. In BitCoin, the amount of computational power needed to produce a single block is measured in quintillions of computational operations. (<a href="https://ycharts.com/indicators/bitcoin_network_hash_rate">https://ycharts.com/indicators/bitcoin_network_hash_rate</a>)</p><p>Proof of Work is most famous in relation to cryptocurrency, but the initial implementation was to defend against Denial of Service (DoS) attacks. The thought was that the attacker needed to “prove” that the request was legitimate by spending computational resources. An example use case could be spam mail. If for each mail the sender would have to devote computational resources, for example spending a couple of seconds on each mail, sending a huge amount of emails would be extremely costly. Such measures would probably drastically reduce the number of phishing mails that now plague inboxes around the world.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iv3iqFRAr3NtX23d0RqxLA.jpeg" /><figcaption>Some meetings are dreadful, they should not be</figcaption></figure><h3>Demand work before a meeting</h3><p>How does all this cryptography translate into yet another complaint post about meetings? Well, sending an invite to a meeting is usually not that demanding, you need to invite people, find a time slot that fits all and write some kind of title for the meeting. If you are diligent enough you might even write a couple of sentences explaining why you are taking 3–7 hours of total working time away from the team.</p><p>It should not be so! To prove that the things that need to be discussed are worth the time we should demand that work has been conducted to send the invite.</p><blockquote>A meeting invite should give a clear and structured overview of the purpose, goal, and agenda so that the ones that are invited know that a meaningful amount of work has been contributed before the invite has been sent.</blockquote><p>This work also has two secondary effects. Firstly, it provides a structured way of going through the meeting. This provides the meeting attendees with a clear way of conducting the meeting and aligns everyone on the goal. In my experience, also having a delegated meeting leader (usually the one organizing the meeting) and a note-taker helps drastically on meeting effectiveness.</p><p>Secondly, it gives insight to the meeting organizer, by structuring clearly the intent, purpose, and execution of the meeting, it provides the organizer with valuable insights into how to effectively conduct the meeting. It may also be so that the meeting in itself could be a mail and then most of the mail is already written.</p><p>In the post-pandemic age, where workers are slowly returning to the office it is becoming more important than ever to have a communication flow that is transparent and including for those who work from home. One of the most effective ways of sharing information is to create good meeting minutes and write down the actions and decisions that were created in the meeting. By having a clearly structured plan and agenda in the invite half of the work on the minutes is done before the meeting is started.</p><h3>Proof</h3><p>When structuring a meeting, clear roles should be defined among meeting participants, preferable with a meeting leader that can drive the agenda and cut in if the discussions drift off-topic. Furthermore, delegating a role that handles capturing meeting information, such as decisions and actions as well as important findings, and being responsible for sharing that information is also something that should be required. Furthermore, instead of using 5–10 minutes of introduction, the background and reasoning behind the meeting should be required in the invite. Clearly stating the goals and agenda and delegating responsibility for each point in the agenda removes uncertainty and means everyone in the team is informed about their roles.</p><h4>Example Invite</h4><blockquote><strong>Title:</strong> Discussion around using Infrastructure as Code (IaC) for the phoenix project.</blockquote><blockquote><strong>Meeting Leader:</strong> @ Lastname, Firstname</blockquote><blockquote><strong>Documentation Responsible:</strong> @ Surname, Givenname</blockquote><blockquote><strong>Background:</strong> We are currently struggling with deploying our code and having issues manually creating new secrets and configuring our applications in the cloud. We should discuss if creating infrastructure as code is a better solution than manually configuring each resource. If we go forward with infrastructure as code, we need to map our options in order to create an informed decision on the technology choices for our infrastructure.</blockquote><blockquote><strong>Agenda:</strong></blockquote><blockquote>-Introduction to the current way of working. Discussion of pain points. @Jane Doe</blockquote><blockquote>- Introduction to infrastructure as code @Senior Techlead</blockquote><blockquote>- Discussion</blockquote><blockquote>- Create decisions and actions to be taken.</blockquote><blockquote><strong>Goal:</strong></blockquote><blockquote>Decision made on switching to infrastructure as code and recorded.</blockquote><blockquote>Further actions are delegated.</blockquote><p>The outcome of a successful meeting would be a document that records the decision and why it was taken, as well as actions that the different members of the meeting shall do after the meeting has been completed.</p><h3>Summary</h3><p>Demanding that work has been put into a meeting creates a threshold for the one creating the meeting invite. This threshold might lead to people not calling in baseless and unstructured meetings, but they might also serve as an obstacle for young and inexperienced people that want to reach out for assistance or want to discuss with other team members. Peer-programming sessions and informal conversations should be easy to schedule, while more comprehensive meetings and workshops should require considerable preparatory work.</p><p>Understanding the purpose and why of a work interaction can help provide context around what effort should be required to justify the time taken from your colleagues.</p><h4>The proof of work for meetings principle:</h4><blockquote>The more resources you require (Team working hours), the more resources you should spend on making the meeting as efficient as possible.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=743392ac9560" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create a Twitter Bot using Dev-Ops Principles, Part 2]]></title>
            <link>https://blog.devgenius.io/create-a-twitter-bot-using-dev-ops-principles-part-2-bd2b9d51157d?source=rss-a6460597d712------2</link>
            <guid isPermaLink="false">https://medium.com/p/bd2b9d51157d</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[unittest]]></category>
            <category><![CDATA[twitter]]></category>
            <category><![CDATA[test-automation]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Emil Severin Moen Ramsvik]]></dc:creator>
            <pubDate>Wed, 02 Mar 2022 19:19:57 GMT</pubDate>
            <atom:updated>2022-04-02T13:25:13.268Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Creating Tests and Continuous Integration.</strong></p><p>In part 1 of this article series, we created python code that could deploy quotes from Airtable and post them to Twitter.</p><p><a href="https://medium.com/@emilseverin93/create-atwitter-bot-using-dev-ops-principles-70df5a9ea760">Create aTwitter Bot Using Dev-Ops Principles.</a></p><p>In this article, we will do a thorough check on the code by creating unit tests for the code and also create a framework for linting, checking for security issues and creating a continuous integration cycle for the code.</p><h3>Testing the code using Pytest.</h3><p>In order to be certain that the code performs the way we intend it to and that changes we implement to the code do not cause any breaking changes. to that purpose, we should create unit tests that check each function.</p><p>First of we have the divide_into_tweet function that takes in a text string and divides it into a list of tweets.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2b0c3c4e58b317a9d02d9c799d2550a0/href">https://medium.com/media/2b0c3c4e58b317a9d02d9c799d2550a0/href</a></iframe><p>We want to ascertain that the function returns a list containing the text string divided into lengths allowed in a single tweet. We also should check that the function is dividing the text at appropriate places (i.e. not in the middle of a word).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/942f551d28ada3be4d9744565f54eef6/href">https://medium.com/media/942f551d28ada3be4d9744565f54eef6/href</a></iframe><p>To identify the function as a test, we set a <em>test_</em> before the rest of the function name. Python will then identify the function as a test. We import the function from the python file, define a use case, in the first case it is a text string that is exactly 280 characters long. We then run the function with the desired input and check that it returns the output we expect it to. In the case of the divide_into_tweet function, we wanted to test two cases. The edge case of 280 characters and a case where the function needs to return a list of multiple tweets. In the latter case, we want to check that the text is divided in a logical way (In this case ends the tweet on a period).</p><p>In VS Code, we can use the test suite built in to effectively run the tests and debug them if necessary.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nUyxvPoISrwablvw5rJZWQ.png" /><figcaption>Few things are as satisfying as a green checkmark on your unit tests.</figcaption></figure><h4>Mocking</h4><p>A defining feature of the unit test is that they are easy and fast to run so that you quickly can assess the status of your code. Furthermore, we do not want to run other API calls, either due to load on the system or for security reasons. To do those things, we “mock” the functionality of the modules. The mock module takes the place of the original module, when the code runs, it calls on the mock function instead of the intended. We can then also change the return value of the module so that it returns the value we want it to return.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9768b82532800cb5a2585dcf026e73e6/href">https://medium.com/media/9768b82532800cb5a2585dcf026e73e6/href</a></iframe><p>In this test case, we use the mock functionality to mock the tweepy API module. To mock the module, we use the unittest mock.patch module to mock the tweepy.api module in the authenticate twitter method. In the test function, we tell pytest that all references to the tweepy.api module in post_tweet.py should call on the mock_tweepy module instead. We then apply a return value of the mock_tweepy module as “ok”.</p><p>One of the advantages of mocking is that we can check the usage and compare the number of function calls, what the inputs values were with the expected values. In the test case for the authentication function, we expect the tweepy.API module to be called only once (line 14 in authenticate_twitter.py snippet)</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/865b5297010ea54bf40ff7de5cda5f5a/href">https://medium.com/media/865b5297010ea54bf40ff7de5cda5f5a/href</a></iframe><h4>Mocking multiple modules</h4><p>Sometimes we need to call upon more than one module or API that should be mocked.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ae32b31fb225cccb535a29ef69580850/href">https://medium.com/media/ae32b31fb225cccb535a29ef69580850/href</a></iframe><p>In the test_post_tweet function, we utilize the fact that we already have tested the individual functions beforehand are therefore certain that they are working as intended. We can then mock the functions themselves, and then test the post_tweet function itself, not the underlying functions that have been tested in other tests.</p><p>In the test, we defined 3 cases that should be tested. The test cases are split into 3 quotes, which have different lengths and need to be divided into multiple tweets. The test function loops through a list of quotes and initiates the mock modules and calls on the post_tweet function. We define the mock module for updating the status using tweepy at the beginning of each loop. If we had defined the mock before the call_count would be the sum of all counts done during the test and not for each test case. When patching the get_airtable_data, we mock the return value with the quote we defined at the beginning of the for-loop.</p><p>When we run the test for each scenario, we assert that all relevant modules and functions were called the correct number of times, in the case of the mock_api_update function, we assert that it post the correct number of tweets related to the size of the quote, thereby assessing that the split of the quote was conducted correctly.</p><h3>Continuous integration</h3><p>Continuous integration means that code is continuously merged from local branches back into source code, to perform continuous integration in the right way, it is paramount to have proper systems that can assert that the code is up to par and does not break when deployed. Automatic testing, linting checks and static code analysis are processes that enable continuous integration and help ensure that code deployed is functioning.</p><h4>Linting of code</h4><p>Linting is the process of checking code and looking for errors and code smells and format the code to adhere to formatting standards. To this end, we will use GitHub actions and black to check the code and ensure that formating is the correct way. Black is a code formatter that is self-styled as the “The Uncompromising Code Formatter”, meaning that it does not allow for much customization, making you focus on code quality.</p><p><a href="https://github.com/psf/black">GitHub - psf/black: The uncompromising Python code formatter</a></p><p>To enable workflows in GitHub action, we need to create a YAML file in the .github/workflows directory in the repository.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a7b964d65c1ba4b9e237219e404ca24d/href">https://medium.com/media/a7b964d65c1ba4b9e237219e404ca24d/href</a></iframe><p>In the YAML file, we first declare the name of the workflow that will show up on the GitHub actions page. This workflow should run every time a push is committed to the repo, meaning all times a branch is updated. We then build the workflow, check out the branch we are pushing to, and then set up python. To run black we need to install it using the pip install command. Then we run black — check to see if the code is correctly formatted. If the black check fails, we run black to format the entire branch and then commit a fix and push it to the branch.</p><h4>Automatic testing</h4><p>The testing we have done manually on the computer should also be conducted every time we want to merge code back into the main branch. This along with a review of pull requests ensure that we do not introduce any breaking changes and that the code works as intended.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9be61a39a878c91dca7865943b74667c/href">https://medium.com/media/9be61a39a878c91dca7865943b74667c/href</a></iframe><p>The YAML workflow above is triggered on all pushes. To ensure that we do not experience any errors we create a dummy environment with the correct environment variables. As we mock most of the functionality that depends on the environmental variables we can give them dummy values. If needed, we could import the variables from GitHub secrets using ${{ secrets.VARIABLE_NAME }} instead of the dummy variable. In the jobs flow, we define the operating system and check out the code repository and set up python. We then install the necessary dependencies and run pytest.</p><h3>Summary</h3><p>In this section, we have discussed how to properly ensure that code we are running works as we intended. To do this, we created unit tests and workflows that automatically run linting and tests when we push committed code to the code repository.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bd2b9d51157d" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/create-a-twitter-bot-using-dev-ops-principles-part-2-bd2b9d51157d">Create a Twitter Bot using Dev-Ops Principles, Part 2</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create aTwitter Bot Using Dev-Ops Principles.]]></title>
            <link>https://medium.com/@emilseverin93/create-atwitter-bot-using-dev-ops-principles-70df5a9ea760?source=rss-a6460597d712------2</link>
            <guid isPermaLink="false">https://medium.com/p/70df5a9ea760</guid>
            <category><![CDATA[infrastructure-as-code]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[twitter]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Emil Severin Moen Ramsvik]]></dc:creator>
            <pubDate>Sat, 12 Feb 2022 12:10:24 GMT</pubDate>
            <atom:updated>2022-02-13T18:57:26.154Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*78FbRFcjs1sU6G4ATTGWdg.png" /></figure><p>In this article series, I will go through the steps on how to create a CI/CD pipeline and code for a bot that will automatically publish tweets.</p><h3>Part 1: Overview and Python Code</h3><p>One of the biggest issues with software projects, and software development, in general, is the step from development to operations. People new to the industry are soon made privy to the classic “It works on my computer” conundrum. Dev-Ops is a mindset and a culture that is focused on integrating development with operations. To succeed at Dev-Ops, which has proven to be a driver of more efficient teams, you must be familiar with all the important steps of the process. Knowledge of the drives of successful software projects can empower us to make better decisions and avoid common pitfalls that haunt software projects.</p><p>In this article series, I will go through all the different parts of creating a project using Dev-Ops principles such as Continous Integration (CI) Continuous Deployment(CD), Infrastructure as Code (IaC), and testing.</p><h3>Set-Up</h3><p>The project was structured as follows.</p><ul><li>For source control and versioning — git and Github were the tools that were used. Github was also used for version control</li><li>For Continous Integration, I used GitHub actions and YAML files. Github has a lot of boilerplate code and APIs that make it easy to set up workflows.</li><li>I used Google Cloud Platform as a hosting platform. Other popular options are Amazon Web Services and Microsoft Azure.</li><li>To make and deploy infrastructure I Used Terraform. Terraform is easy to test and deploy and is also cross-platform so it can easily be reconfigured to other platform services.</li><li>For actually making the Twitter bot, I used the python module tweepy to get authenticated and post the tweet.</li><li>To store the tweets in a spreadsheet format, I used Airtable. One of the advantages of Airtable is its easy-to-use API which in this case made it an easy choice.</li></ul><p>The code repo can be found on Github :</p><p><a href="https://github.com/EmilRamsvik/twitter-note-publisher">GitHub - EmilRamsvik/twitter-note-publisher: Repository for automatically posting notes through twitter.</a></p><h3>Setting up the Twitter handler.</h3><p>The Twitter bot needed the following functionality. It should be able to retrieve the unpublished quotes, which were added to an Airtable sheet, divide the quotes into multiple tweets if necessary, and then publish the tweet, either as a single tweet or as a collection of multiple tweets in a string (with numbering). Then it should add the source as a reply to the tweet. Finally, the code needs to update the Airtable sheet so that the quote is marked as tweeted.</p><p>To set up the Twitter handler, all Twitter-related python files were put into their folder in the project.</p><h3>Handling environmental variables</h3><p>In all cloud-based projects, secret management is of importance. In this project, a combination of pydatic, GitHub secrets and Terraform form the basis of handling the environmental variables.</p><p>The Settings class defines all variables and uses the .env file in the project to get the values of all the variables. In this settings file, all the necessary keys and variables are stored.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0eb7becc04b2a1964690b73d358f954e/href">https://medium.com/media/0eb7becc04b2a1964690b73d358f954e/href</a></iframe><p>To import the different environmental variables, the settings class is imported into the different scripts and then environmental variables from the .env file can be stored locally, and in the cloud environmental variables.</p><h4>Get the data from the Airtable API.</h4><p>The Airtable was structured as a sheet with columns representing the author, book, and quote, as well as a column indicating that the tweet has been posted on the Twitter account.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IzOxtPsqJnpBzz6IgynxTg.png" /><figcaption>The Airtable base contains the index of the entry, the Author, Title and Quotes, and a 0/1 value indicating if the quote has been posted to Twitter.</figcaption></figure><p>To retrieve the Airtable base, we need to have an Airtable API key, as well as the base_id and table name.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7425f05d9c643097ffb31cf40cc13e6c/href">https://medium.com/media/7425f05d9c643097ffb31cf40cc13e6c/href</a></iframe><p>The function above gets data from the Airtable, here it is based on the quotes, author and book columns, and returns the data from a single row.</p><p>Airtable API access can be enabled by visiting the Airtable API page.</p><p><a href="https://airtable.com/api">Airtable | Everyone&#39;s app platform</a></p><h4>Divide the quote into multiple tweets if too long.</h4><p>As some of the quotes might be longer than 280 characters, which are the maximum allowed into a single tweet, it is necessary to check the length of the text to be tweeted and divide it into logical parts so that they can be posted in a coherent sequence. We do not want the individual tweets to be split in the middle of a sentence, and certainly not in the middle of a word.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2b0c3c4e58b317a9d02d9c799d2550a0/href">https://medium.com/media/2b0c3c4e58b317a9d02d9c799d2550a0/href</a></iframe><p>The divide into tweets function takes in a text string and returns a list of tweets, which is divided at logical places (Periods, commas, semicolons, or double dashes). We can tweet each item in the list returned. Note that it divides the tweet into 276 character-sized items if the original text is longer than 280. This is because if we have a tweet string, we want to enumerate each tweet in the tweet string.</p><h4>Authenticate Twitter</h4><p>To create a Twitter bot, we need to create code that can authenticate the twitter object, and also utilize the Twitter API. To get access to Twitter API, you need to create a Twitter developer account and create your own API access keys. Just follow the instructions to create an account and save the credentials in the environment file.</p><p><a href="https://developer.twitter.com/en/products/twitter-api">Twitter API | Products</a></p><p>When we have the twitter access and consumer credentials, we need to be able to create an API object using pythons twitter package tweepy, and authenticate.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/354fecb7f244118e5a9168fe356c4c0a/href">https://medium.com/media/354fecb7f244118e5a9168fe356c4c0a/href</a></iframe><p>The function above creates the Twitter API object, to be able to do this it needs to have correct consumer keys and tokens. These keys are found by creating a project in the Twitter developer portal and generating the keys. Remember to give your project full access to the Twitter account so that it can post the tweets.</p><h4>Post the tweet</h4><p>Now that we have created an API and have a list of tweets and a reference string that we want to add to the tweet as a response.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bf4907b8a355b655141276b3742443d5/href">https://medium.com/media/bf4907b8a355b655141276b3742443d5/href</a></iframe><p>In the function send_tweets_to_twitter we take in the tweets we want to be posted, and loop through the list of tweets. If there only is a single item in the tweets list, we just post that and don&#39;t bother to add an enumerator (If we had, we might have caught an error in twitter as the tweet might have been longer than 280 characters). If there a multiple tweets, we add each tweet to the below one as a response to the first tweet using the first tweet`s id tag. Finally, we add a reference as a response.</p><h4>Putting it all together</h4><p>Now that we have created individual parts, we need to tie all the pieces together in order to post a quote to Twitter.</p><p>In this function, we first use the authenticate twitter function to get access to our Twitter account, then we get the quote, author, book and Airtable row id from Airtable. We divide the tweet and post it. After the tweets have been successfully posted, we update the Airtable so that the quote is marked as posted.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/01936d1618ad5aa1445e83735d5c93d7/href">https://medium.com/media/01936d1618ad5aa1445e83735d5c93d7/href</a></iframe><h3>Next up</h3><p>We now have a functional code for posting tweets, but in order to automate it, we need to create a CI/CD pipeline, set up the cloud infrastructure, and deploy fail-safes for deployment. The next section will discuss testing, security, and continuous integration.</p><p>Please feel free to comment on the article or share it if you find it insightful. I also welcome constructive criticism and also suggestions for improvement.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=70df5a9ea760" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The best books I read in 2021]]></title>
            <link>https://medium.com/@emilseverin93/the-best-books-i-read-in-2021-5c0768546dd4?source=rss-a6460597d712------2</link>
            <guid isPermaLink="false">https://medium.com/p/5c0768546dd4</guid>
            <category><![CDATA[book-recommendations]]></category>
            <category><![CDATA[books]]></category>
            <dc:creator><![CDATA[Emil Severin Moen Ramsvik]]></dc:creator>
            <pubDate>Mon, 10 Jan 2022 19:56:01 GMT</pubDate>
            <atom:updated>2022-03-27T10:10:52.877Z</atom:updated>
            <content:encoded><![CDATA[<h3>The Innovators</h3><p>Walter Isaacson</p><p>One of the most informative books i read in 2021. The book covers the people who are most responsible for bringing the computer age to humankind. The book has a lot of funny anecdotes that bring the human element out of the people who ended up as billionaires, Nobel laureates and shapers of the digital future that is today. Reading of Bardeen, that upon discovering the transistor that led to one of his two (!!) Nobel prizes, told his wife while she was peeling carrots that they had discovered something important today. Or how Steve Wozniak&#39;s father berated Steve Jobs for wanting a 50–50 stake in the company even though his contributions were almost zero. In the end, this is the story of innovation, of how when smart people meet together and cooperate, magic happens.</p><h4>You should read this book if:</h4><ul><li>You would like to understand how the technology that shapes our society today was created.</li><li>You like to delve deeper into the people, not the big events of history.</li><li>Understanding how some of the most influential companies today were founded, and how they operate is reflected in the founders&#39; personality and choices during the early days.</li></ul><h3>The Phoenix Project</h3><p>Nicole Forsgren, Jez Humble and Gene Kim</p><p>The phoenix project is a book about IT projects, and more particularly about IT has a tendency to fail spectacularly. It also brings forth the dogma of Dev-Ops, the merging of Development and Operations together to form a set of principles for how to create IT products. A lot of the book is a journey into the common pitfalls of an IT project and how to avoid them. It is written from the perspective of a newly appointed CIO, and this perspective helps the reader relate. One of the defining dogmas is that IT is just another manufacturing process and that enabling tools and processes that speed up manufacturing and ensure quality is the most important goal of management.</p><h4>You should read this book if</h4><ul><li>You are passionate about improvement in the workplace</li><li>You are curious about why IT in your job never seems to work properly, while the large companies like google, apple and Facebook seems to work seamlessly</li><li>You want to know that is not only your own company where things go sideways on a regular basis.</li></ul><h3>Serengeti rules</h3><p>Sean Carrol</p><p>The Serengeti rules are, as the name implies, a book about how ecological rules play a massive role in how nature is affected, and how cascading effects can make a simple change affect the entire food chain. By reading this book, you will get insights into how keystone species, i.e. species that are critical to an ecosystem can drastically affect how the biosphere operates. As an example, wolves were reintroduced to the Yellowstone national park and from there affected how rivers started to behave through secondary effects. In this time of drastic environmental change, it is more important than ever to understand how trophic cascades play an important role in nature.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*ta-mmBFHL5XVeO-z.jpg" /></figure><h4>You should read this book if:</h4><ul><li>You are interested in biology and ecological systems</li><li>Want to understand the dangers of invasive species.</li><li>Want to understand the threats against and defense mechanisms of ecological systems.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5c0768546dd4" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>