<?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 Alexandru Somai on Medium]]></title>
        <description><![CDATA[Stories by Alexandru Somai on Medium]]></description>
        <link>https://medium.com/@alexsomai?source=rss-e591ea0285cc------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*Igbc7la5gcRLfUV9G7Y2fw.jpeg</url>
            <title>Stories by Alexandru Somai on Medium</title>
            <link>https://medium.com/@alexsomai?source=rss-e591ea0285cc------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 14 Nov 2026 16:13:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@alexsomai/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[52 Books, 52 Lessons]]></title>
            <link>https://medium.com/coders-do-read/52-books-52-lessons-eee171e94b2d?source=rss-e591ea0285cc------2</link>
            <guid isPermaLink="false">https://medium.com/p/eee171e94b2d</guid>
            <category><![CDATA[personal-development]]></category>
            <category><![CDATA[self-improvement]]></category>
            <category><![CDATA[life-lessons]]></category>
            <category><![CDATA[reading]]></category>
            <category><![CDATA[books]]></category>
            <dc:creator><![CDATA[Alexandru Somai]]></dc:creator>
            <pubDate>Fri, 04 Jan 2019 11:19:26 GMT</pubDate>
            <atom:updated>2019-01-04T11:19:26.981Z</atom:updated>
            <content:encoded><![CDATA[<h4>What I read this year — 2018 Review</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Cbj_BcK5ePD4Mc4TK4sfvQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@syinq?utm_source=medium&amp;utm_medium=referral">Susan Yin</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>There is a saying: <em>The more you learn, the less you know. </em>After my journey in books (one per week) for 2018, I couldn’t agree more. Completing my reading challenge, I learned many valuable lessons from books, and I feel like there is so much left to learn. Here’s the list of 52 books I read this year. 📚</p><p>For the first half of the list, I invite you to read my other article, <a href="https://medium.com/coders-do-read/26-lessons-ive-learned-reading-26-books-fc0143124e82">26 Lessons I’ve Learned Reading 26 Books</a>.</p><p><a href="https://medium.com/coders-do-read/26-lessons-ive-learned-reading-26-books-fc0143124e82">26 Lessons I&#39;ve Learned Reading 26 Books</a></p><h3>27. You can’t know the man until you know the story.</h3><p>Meet Ove. A grumpy yet lovable man. He has <em>staunch principles, strict routines, and a short fuse,</em> but behind the cranky exterior there is a hidden story and a sadness. In this book you’ll find how love can change someone.</p><blockquote>“He was a man of black and white. And she was color. All the color he had.”</blockquote><p>📕 <strong>A Man Called Ove </strong><em>by</em><strong><em> </em></strong><em>Fredrik Backman</em></p><h3>28. A growth mindset will always push you forward.</h3><p>Based on their mindset, individuals can be placed in two categories: with <strong>fixed</strong> or <strong>growth</strong> mindset. Those that have a fixed mindset believe that their success is based on innate ability — their abilities, intelligence and talents are fixed traits, you are either born with or without them. On the other hand, people with a growth mindset believe that their success is based on hard work, learning and training. Moreover, they understand that their talents and abilities can be developed through effort, good teaching and persistence. They overcome failures easier, because they see them as an opportunity to learn from.</p><p>If you are born with a fixed mindset, don’t despair, you can always change it! Whether it’s about sport, business or relationships, having a growth mindset will bring you closer to a successful life.</p><p>📕 <strong>Mindset: The New Psychology of Success </strong><em>by Carol S. Dweck</em></p><h3>29. Happiness has a formula.</h3><p><strong>H = S + C + V</strong></p><p>The <em>total level of happiness </em>(H) is the sum of your <em>biological set points</em> (S), the <em>conditions</em> <em>of your life</em> (C) and the <em>voluntary activities</em> (V) that you do.</p><ol><li>If you won the <em>cortical lottery</em>, then you are born more optimistic, thus enjoying a happier life — this is the <em>biological setpoint.</em></li><li>Moreover, if you get the <em>conditions of your life</em> right, you can achieve lastingly happiness. The most important ones are <strong>Love </strong>and <strong>Work.</strong></li><li>Because the <em>voluntary activities</em> are something that you choose to do, they increase the overall level of happiness. These include, but they are not limited to: <em>meditation, exercise, reading, learning a new skill, or traveling.</em></li></ol><p>If you want to find out more about the <em>magic </em>formula, access my book summary, below:</p><p><a href="https://medium.com/coders-do-read/did-you-know-that-happiness-has-a-formula-8bb34d2d58e0">Did You Know That Happiness Has a Formula?</a></p><p>📕 <strong>The Happiness Hypothesis: Finding Modern Truth in Ancient Wisdom </strong><em>by Jonathan Haidt</em></p><h3>30. There is always sunshine after the rain.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Bg6cdM7sxRzc103b" /><figcaption>“An isolated man is cast into silhouette on the clifftop at Old Harry Rocks during sunset golden hour.” by <a href="https://unsplash.com/@willvanw?utm_source=medium&amp;utm_medium=referral">Will van Wingerden</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Make the most of your life on earth. Enjoy the little things. Live in the moment. Find beauty in details. Read. Write.</p><p>Remember that pain is not forever. Everybody wants happiness, nobody wants pain, but you can’t have a rainbow without a little rain.</p><blockquote>“I hate depression. I am scared of it. Terrified, in fact. But at the same time, it has made me who I am. And if — for me — it is the price of feeling life, it’s a price always worth paying.”</blockquote><p>📕 <strong>Reasons to Stay Alive</strong><em> by Matt Haig</em></p><h3>31. The power of knowledge is a dangerous thing.</h3><p>The novel of a fantastic and terrifying hypothesis: what if we could enhance our intelligence, artificially? The book tells the story of the mouse Algernon and the human Charlie, both subjects of an experiment to increase their IQ levels, and eventually change their lives.</p><p>📕 <strong>Flowers for Algernon</strong> <em>by Daniel Keyes</em></p><h3>32. Emotional I<strong>ntelligence is what separates </strong>mediocre leaders from great <strong>leaders.</strong></h3><p>Great leaders excel not just through skill and smarts, but by connecting with others using <em>Emotional Intelligence</em> (EQ). The four core components of EQ are:</p><ul><li><strong>Self-Awareness </strong>—<strong> </strong>how accurately you can assess your emotions.</li><li><strong>Self-Management — </strong>your ability to control your emotions (when you are aware of them, trough self-awareness).</li><li><strong>Social Awareness — </strong>the level of empathy you have, how well you relate with the feelings of others.</li><li><strong>Relationship Management —</strong> serve as an inspiring leader and catalyst for change, collaborate with a high-performing team, and manage conflict.</li></ul><p>The best leaders have “resonance” — a powerful ability to drive emotions in a positive direction to get results. A leader can fluidly interchange among a variety of leadership styles as the situation demands. From the ones that favor <em>resonance:</em></p><ul><li><strong>Visionary</strong> — motivate people to achieve common goals.</li><li><strong>Coaching</strong> —make a bond between one&#39;s wishes and the organization&#39;s goals.</li><li><strong>Affiliative</strong> — create emotional bonds and harmony.</li><li><strong>Democratic</strong> — build consensus through participation.</li></ul><p>To the ones that generate <em>dissonance,</em> if applied incorrectly:</p><ul><li><strong>Pacesetting </strong>—<strong> </strong>expect excellence and self-direction.</li><li><strong>Commanding </strong>—<strong> </strong>demand immediate compliance.</li></ul><p>Keep in mind that the actions of leaders and their moods have an overwhelming impact on those they guide.</p><blockquote>“People Don’t Leave Companies — They Leave Leaders!”</blockquote><p>📕 <strong>Primal Leadership: Learning to Lead with Emotional Intelligence </strong><em>by Daniel Goleman, Annie McKee, Richard Boyatzis</em></p><h3>33. The lack of authority can lead to dangerous chaos.</h3><p>At the dawn of the next world war, a plane crashes on an uncharted island, stranding a group of schoolboys. Their freedom is something to celebrate; this far from civilization the boys can do anything they want. Anything. They attempt to forge their own society, failing, however, in the face of terror, sin, and evil. But what could be the adventure of their lives, with no adult supervision, turns into a dreadful nightmare: hatred is the place of innocence and murder is rushing over a world that wanders its compass. A parable of an incredible force that gives us an equally cruel and realistic response to the question: <strong><em>is absolute freedom the way to paradise?</em></strong></p><p><strong>📕 Lord of the Flies</strong> <em>by William Golding</em></p><h3>34. We may soon become the only species that will knowingly attend its own extinction.</h3><p>Over the last half-billion years, there have been five mass extinctions, when the diversity of life on earth suddenly and dramatically contracted. Scientists around the world are currently monitoring the sixth extinction, predicted to be the most devastating extinction event since the asteroid impact that wiped out the dinosaurs. This time around, the cause is <em>“one weedy species” — </em>us. Human beings have altered life on the planet in a way no species has before.</p><p>📕 <strong>The Sixth Extinction: An Unnatural History </strong><em>by Elizabeth Kolbert</em></p><h3>35. <em>What is essential is invisible to the eye.</em></h3><p>Probably you know or heard of the famous tale of <em>The</em> <em>Little Prince</em>. It is a title accessible to all age groups, a simple and charming anecdote, spoken in simple but poetry language. The book brings to the fore the human values, the responsibility and the bond between people, the tolerance and the spirit of adventure. A delightful story about childhood, loneliness, and friendship.</p><blockquote>“All grown-ups were once children… but only few of them remember it.”</blockquote><p>📕 <strong>The Little Prince</strong> <em>by Antoine de Saint-Exupéry</em></p><h3>36. All children need superheroes.</h3><p>We don’t have to be Spider-Man, an X-Men mutant, or any other Marvel character to be a superhero. Every human could turn into a superhero for any kid. Their superpowers could be anything from being strong, tall, loved by everyone, super tidy, or the opposite, being really messy.</p><p>Elsa, seven years old and her grandmother, seventy-seven years old and crazy, are best friends. But after her grandmother passes away, Elsa’s greatest adventure begins. Her grandmother’s letters lead her to an apartment building full of drunks, monsters, attack dogs, and totally ordinary old crones, but also to the truth about fairy tales and kingdoms and a grandmother like no other.</p><p>📕 <strong>My Grandmother Asked Me to Tell You She’s Sorry </strong><em>by Fredrik Backman</em></p><h3>37. Working remote has its perks, but it’s a trade-off.</h3><p>A few <strong>advantages</strong> of working remote are:</p><ul><li>You don’t waste time while commuting.</li><li>Escape the 9am — 5pm routine.</li><li>Have the chance to work in different environments: your home office, coffee shops, parks, co-working spaces, etc.</li></ul><p>But, as mentioned, it comes with some <strong>trade-offs, </strong>which you must be aware of:</p><ul><li>There are many distractions at home, leading you to procrastination.</li><li>Or if you don’t waste time, you can get into the opposite, and <em>overwork.</em></li><li>Involuntary, you may isolate yourself by having less social interactions.</li></ul><p>📕 <strong>Remote: Office Not Required </strong><em>by David Heinemeier Hansson and Jason Fried</em></p><h3>38. It’s within our nature to be eager for knowledge.</h3><p>In seven brief lessons, Italian theoretical physicist Carlo Rovelli guides readers with admirable clarity through the most transformative physics breakthroughs of the twentieth and twenty-first centuries. This playful, entertaining and mind-bending introduction to modern physics, explains <em>general relativity, quantum mechanics, elementary particles, gravity, black holes, the complex architecture of the universe, and the role of humans in this strange</em> <em>world</em>. It’s a book about the joy of discovery.</p><p>📕 <strong>Seven Brief Lessons on Physics </strong><em>by Carlo Rovelli</em></p><h3>39. You can’t predict the future. Stop trying.</h3><p>I became sure of this after reading Taleb’s book, <strong><em>The Black Swan — </em></strong>a metaphor used to describe a highly improbable event with three principal characteristics: it’s <em>rare (1)</em>; it carries a <em>massive impact (2)</em>; and, despite its unpredictability, we strive to find <em>explanations</em> <em>after (3) </em>it happened, to convince us that it was, in fact, predictable.</p><p>Black Swans underline almost everything about our world, from the rise of religions to events in our own personal lives. The stock market crash of 1987, the 9/11 attacks, the astonishing success of Google — they are all <em>Black Swans</em>.</p><p>Our mind has a (wrong) tendency to predict what will happen in the future by using our past as an explanation. Based on the only things we can be certain of — what has happened in our lives in the past — we weave a narrative that makes sense and expect that the future simply must unfold this way. But there are many unknown factors that could change it.</p><p>For example, imagine you’re a turkey, and for 1000 days you live on a farm and get free food from the farmer. You would expect the next day to be the same. But tomorrow’s Thanksgiving, and — surprise! You’ll be killed, stuffed and roasted. The very same thing happened to everyone who lost a fortune during the financial crisis — people believed markets would go up forever, because that’s all they had done for years.</p><p>Imagine you had known about the 2008 financial crisis, then you wouldn’t have been shocked and surprised. But you can’t predict a Black Swan — <strong>you can’t predict the future. </strong><em>But what can yo do?</em></p><p><em>The central idea of uncertainty </em>is, that in order to make a decision, you need to focus on the consequences (which you can know) rather than the probability (which you can’t know).</p><blockquote>“We are quick to forget that just being alive is an extraordinary piece of good luck, a remote event, a chance occurrence of monstrous proportions … Remember that you are a Black Swan.”</blockquote><p>📕 <strong>The Black Swan: The Impact of the Highly Improbable</strong> <em>by Nassim Nicholas Taleb</em></p><h3>40. Believe in yourself, and chase that “big fish”.</h3><p>A clear and simple story but at the same time deep, emotional and full of meaning. It’s a true parable of man’s invincibility, willing to overcome his human condition: physical, psychic, and material.</p><p>An old fisherman, Santiago, sails out in the sea, grieving that he has not caught any fish for almost three months. Like any true fisherman, he does not give up a second to the dream of a huge catch that will break his bad luck and get him out of hunger.</p><blockquote>“But man is not made for defeat,” he said. “A man can be destroyed but not defeated.”</blockquote><p>The old man gives us a life lesson about courage, perseverance, and optimism. Santiago believes in his chance and lets himself in foreign waters waiting for the right moment to enjoy the capture of his life.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PesTIMBwv5kLbbjR59pHvA.png" /><figcaption>Photo by <a href="https://unsplash.com/photos/ZR48YvUpk04?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Alex</a> on <a href="https://unsplash.com/?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p><strong>📕 The Old Man and the Sea </strong><em>by Ernest Hemingway</em></p><h3>41. You can easily be fooled by appearances.</h3><p>One of the most popular novels in the English literature, <em>Pride and Prejudice </em>by Jane Austen approaches the middle class bourgeoisie life. The comedy of the writing lies in the depiction of manners, education, marriage, and money during the British Regency period.</p><p>The action of the novel is centered around the Bennet family composed of Mr. and Mrs. Bennet and their five daughters: Jane, Elizabeth, Mary, Kitty, and Lydia. Having no son to inherit their property in Longbourn, Hertfordshire, Mrs. Bennet is desperate for at least one of her daughters to make a brilliant match.</p><p>The comical situations, the humorous dialogues, the style in which they are written will definitely delight you, just like the two heroes of the book, Elizabeth — generous, sensitive, intelligent and spiritual, and Darcy — a fair man with high principles moral, very smart but arrogant. During the book, unexpected encounters and new details overwhelm the young woman’s view of Mr. Darcy, and the question everyone is asking is: will Elizabeth succeed in seeing Lord Darcy’s true face or hide in detail?</p><p>📕 <strong>Pride and Prejudice </strong><em>by Jane Austen</em></p><h3>42. Life is simple. Live it.</h3><p><em>Oscar And The Lady In Pink</em> is not just a sympathetic narrative, a sick child, an old nurse, and some naive letters. It’s enough to go beyond the story to get its message, restless and mysterious: any of us can be an Oscar with a few more days left.</p><p>A book that shows you the joyfulness of life, rather than <em>“living each day as if it was your last”, </em>Oscar encourages us to <em>“look at the world every day as if you were to see it for the </em><strong><em>first</em></strong><em> time”.</em> Although there are many solutions to “Life”, the only one is <em>to live</em>.</p><p>📕 <strong>Oscar And The Lady In Pink </strong><em>by Éric-Emmanuel Schmitt</em></p><h3>43. Public speaking is a skill that you learn through practice.</h3><p>The fact is that everyone is initially nervous about public speaking. Being able to deliver a well-crafted and interesting speech is not the result of some innate talent that only a few possess; rather, it’s a skill that anyone can learn.</p><p>Preparation and frequent practice are the main keys to become an exceptional public speaker. Moreover, it’s important to know your speech well enough so that you don’t have to rely on your notes.</p><p>The critical parts of a speech are the introduction and the conclusion. Start your talk by arousing your audience’s curiosity, tell a story, or ask a question. Close it with a summary of your key points, a call to action or a joke — that (hopefully) leaves them laughing. Last, but not least, pay attention to the words that you use and improve your vocabulary every day.</p><p>The power to affirm your personality, including what you say is essential to your success. The techniques by which you can master an audience can help you in any kind of existence. Make the words you say one of your strengths.</p><p><strong>📕 How to Develop Self-Confidence And Influence People by Public Speaking </strong><em>by Dale Carnegie</em></p><h3>44. Know the question, and you’ll understand the answer.</h3><p>An intergalactic story that has as protagonists a human, Arthur Dent and his friend Ford Prefect, from a small planet in the vicinity of Betelgeuse. They travel through space along with their fellow travelers: Zaphod Beeblebrox — the two-headed, three-armed ex-hippie and totally out-to-lunch president of the galaxy; Trillian, Zaphod’s girlfriend and Marvin, a paranoid, brilliant, and chronically depressed robot.</p><p>Although the book is humorous and full of nonsense, it has some truths to reflect on. The inhabitants of an ancient planet, Magrathea, built a computer in order to find out the answer to <em>the</em> <em>Great Question of Life, the Universe, and Everything. </em>The citizens are confused with the answer they get, but the computer gives them a simple explanation:</p><blockquote>“I think the problem, to be quite honest with you, is that you’ve never actually known what the question is … So once you do know what the question actually is, you’ll know what the answer means.”</blockquote><p>📕 <strong>The Hitchhiker’s Guide to the Galaxy </strong><em>by Douglas Adams</em></p><h3>45. We need chaos in our lives to the same extent that we need order.</h3><p>The order is good for us — it’s our comfort zone. It’s when we feel safe. Nothing bad happens, even more, nothing extraordinary happens. And that’s why we need chaos — to escape our comfort zone. It’s when we grow. We get wings and fly! But if we’re not well prepared, the disorder could prove to be (almost) catastrophic. How can we keep our clear thinking when chaos surrounds us? By following strict rules when life is at ease. As the old Latin expression says: “<em>Si vis pacem, para bellum” — “If you want peace, prepare for war”.</em></p><p>To prepare for the <em>war </em>in your life, you need strict rules to guide you when it’s <em>peace</em>. That’s why I think the <em>12 Rules for Life </em>is really a valuable book. We all need rules, standards and values. Very briefly, these are: (1) stand up straight, (2) respect and take care of yourself, (3) make friends that help you grow, (4) aim to be better than you were yesterday, (5) raise your children well, (6) judge yourself before judging others, (7) think long term — don’t be fooled by ephemeral joys, (8) be honest with yourself, (9) learn to listen, (10) precisely express your weaknesses, (11) be a man!, and last but not least — (12) enjoy the little things in life.</p><p>📕 <strong>12 Rules for Life: An Antidote to Chaos </strong><em>by Jordan B. Peterson</em></p><h3>46. Storytelling is what makes a business great.</h3><p>Why the <em>Four </em>succeeded when other similar companies failed? Amazon was not the first online shop, Facebook was not the first social network platform, there were other search engines before Google, and Apple didn’t invent computers nor smartphones. But there is something that differentiates them. Amazon came up with ratings and reviews, Facebook had photos, Google was simple, friendly and easy to use and Apple distinguished as a luxury brand.</p><p>Furthermore, they had a vision, a great storytelling that got them access to cheap capital. Their statement is simple: Google — <em>Organizing the world’s information, </em>Facebook<em> — Connecting the world, </em>Amazon — <em>Earth’s Biggest Store </em>and Apple’s mission is to always have <em>sleek, modern, minimalist designs that are intuitive and simple.</em></p><p>Towards the end of the book, <em>Scott Galloway </em>has some good carer tips on how to succeed in a world ruled by the <em>Four</em>. One of the most important is:</p><blockquote>“Don’t follow your passion, follow your talent.”</blockquote><p>In other words, do what you are good at, invest in your strengths, and spend modest effort to get your weaknesses to average so they don’t hold you back. Always be eager for learning, don’t settle, because:</p><blockquote>“Curiosity is crucial to success.”</blockquote><p>📕<strong> The Four: The Hidden DNA of Amazon, Apple, Facebook, and Google</strong> <em>by Scott Galloway</em></p><h3>47. Journaling leads to huge insights about oneself.</h3><p>At the age of thirteen, Anne Frank began to write an extraordinary diary, for a period of two years, while she and her family were hiding from the Nazis.</p><p>Facing hunger, fear of discovery and death, and the petty frustrations of such confined quarters, Anne writes with adult wisdom and views beyond her years. Suddenly she discovers reflection, and with tremendous clarity, she is able to see the beauty in things:</p><blockquote>“I’ve found that there is always some beauty left — in nature, sunshine, freedom, in yourself; these can all help you.”</blockquote><p>Her story is that of every teenager, lived out in conditions few teenagers have ever known.</p><p>📕 <strong>The Diary of a Young Girl </strong><em>by Anne Frank</em></p><h3>48. “Smart creatives” are the essence of Google.</h3><p>The rise of the internet, mobile, and cloud computing have shifted the balance of power from companies to consumers. In order to succeed in this new era, the companies must hire the so-called “smart creatives”. They are a new breed of multifaceted employees who combine ideas from different areas, businesses, and tech expertise in creative ways. They are competitive, curious and very ambitious.</p><p>How Google Works is a book about how and why Google hires smart creatives, how it builds a free-thinking company-culture and how it creates a climate for innovation and open spaces for collaboration. The company promotes discussions over decisions and encourages 10X, not 10% thinking.</p><blockquote>“Innovative people do not need to be told to do it, they need to be allowed to do it.”</blockquote><p>📕 <strong>How Google Works </strong><em>by Eric Schmidt &amp; Jonathan Rosenberg</em></p><h3>49. Our universe has more black holes than stars!</h3><p>There are about <strong>100 billion stars</strong> in our observable universe. And the black holes could be more numerous than that!</p><p>In <em>A Brief History of Time, </em>Stephen Hawking explains the most complex concepts and ideas of physics, such as gravity, planets, stars, black holes and the space-time theory. Read this book if you like to better understand how our universe was created, where it came from, and where it’s going.</p><p>📕 <strong>A Brief History of Time</strong> <em>by Stephen Hawking</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QoDpvbGEpabyToyDhtzUwg.png" /></figure><h3>50. <em>“Remember that if you don’t prioritize your life someone else will.”</em></h3><p>You have the ability to make your own choices, or else other people will decide for you. Even the act of not doing anything is a decision.</p><p>The Way of the Essentialist is to do more with less. Although, keep in mind that it’s a trade-off. You have to give up something in order to get something. But this is alright, as long as you pursue what you truly want. Do only those actions that bring value to your life. Learn to be effective by saying no. There is German saying for this:</p><p><em>“Weniger aber besser. The English translation is: Less but better.”</em></p><p><strong>📕 Essentialism: The Disciplined Pursuit of Less </strong><em>by Greg McKeown</em></p><h3>51. The only sin is … theft.</h3><blockquote>“There is only one sin … And that is theft … When you tell a lie, you steal someones right to the truth.”</blockquote><p><em>The Kite Runner</em> is a sweeping story about friendship and betrayal that carries readers through Afghanistan over the last days of the monarchy and up to those of today’s atrocities. Amazing changes of situation make this book memorable, both a political chronicle and an emotional story about childhood and maturity.</p><blockquote>“There are a lot of children in Afghanistan, but little childhood.”</blockquote><p>It is about the power of reading, the price of betrayal, and the possibility of redemption; and an exploration of the power of fathers over sons — their love, their sacrifices, their lies.</p><blockquote>“It always hurts more to have and lose than to not have in the first place.”</blockquote><p>📕 <strong>The Kite Runner</strong><em> by Khaled Hosseini</em></p><h3>52. Be kind.</h3><p>Published for the first time in 1843, <em>A Christmas Carol</em> commends the spirit of this holiday. It’s the story of Ebenezer Scrooge, an old and scratchy cheese-scrawl that hates everyone around. On a frozen Christmas Eve, he receives three phantom visitors: the Ghost of Christmas Past, the Ghost of Christmas Present and the Ghost of Christmas Yet to Come. They carry him on a stunning and scary journey, after which the grumpy old man changes —he treats his fellow human beings with kindness, generosity, and warmth.</p><p>📕 <strong>A Christmas Carol </strong><em>by Charles Dickens</em></p><p>These were the lessons I’ve learned while reading a book per week this year. Looking forward to seeing what the next year brings in terms of learning. 😊</p><p><em>What is the most valuable lesson that you’ve learned from books in 2018? Share your answer</em> <em>in the comments below.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eee171e94b2d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coders-do-read/52-books-52-lessons-eee171e94b2d">52 Books, 52 Lessons</a> was originally published in <a href="https://medium.com/coders-do-read">codersDoRead 👨🏻‍💻📚</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Did You Know That Happiness Has a Formula?]]></title>
            <link>https://medium.com/coders-do-read/did-you-know-that-happiness-has-a-formula-8bb34d2d58e0?source=rss-e591ea0285cc------2</link>
            <guid isPermaLink="false">https://medium.com/p/8bb34d2d58e0</guid>
            <category><![CDATA[personal-development]]></category>
            <category><![CDATA[education]]></category>
            <category><![CDATA[books]]></category>
            <category><![CDATA[self-improvement]]></category>
            <category><![CDATA[happiness]]></category>
            <dc:creator><![CDATA[Alexandru Somai]]></dc:creator>
            <pubDate>Wed, 08 Aug 2018 06:20:05 GMT</pubDate>
            <atom:updated>2018-10-06T16:00:52.406Z</atom:updated>
            <content:encoded><![CDATA[<h4>The Happiness Hypothesis — Summary</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7GKEb27KKBiWh2wQ" /><figcaption>Photo by <a href="https://unsplash.com/@phammi?utm_source=medium&amp;utm_medium=referral">MI PHAM</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>We all want to find happiness, don’t we? But what if there isn’t anything to find? You can’t buy happiness from the grocery store like you get milk, nor you can’t find it on the shelves of Walmart. However, there are some things that you can do in order to increase your general level of happiness.</p><p>📖 In the following article I’ll guide you through a few ideas that I’ve read in the book <strong>The Happiness Hypothesis: Finding Modern Truth in Ancient Wisdom</strong> <em>by</em> <em>Jonathan Haidt.</em></p><h3>The Divided Self</h3><p>Jonathan Haidt begins the book by offering a good perspective of yourself: <em>a rider on the back of an elephant. </em>Your conscious mind is the rider — the one responsible for the rational thinking, while the unconscious mind is the elephant — in charge of your emotions and basic instincts. The rider holds the reins, but the elephant is the one that drives.</p><p>Sometimes, the elephant may want different things than the rider. For example, the elephant desires money and fame, in spite of the fact that more money (or fame) don’t make you happier. So how do you tame the elephant? By teaching the rider to train the elephant. Slowly, make the elephant strive for things that are proven to make you happy. And this is the <em>magic</em> formula that will aid you.</p><h3>The Happiness Formula</h3><p><strong>H = S + C +V</strong></p><p>The <em>total level of happiness </em>(H) is the sum of your <em>biological set points</em> (S), the <em>conditions</em> <em>of your life</em> (C) and the <em>voluntary activities</em> (V) that you do. Now let’s dive deep into each of these:</p><h4>1. The Biological Set Points</h4><p>It is proven that a major part of your level of happiness is given by your genes. If you were lucky enough and won the <em>cortical lottery</em>, you were born more optimistic than others. <strong>Optimists</strong> have, by default, a higher happiness setpoint, they can overcome adversity easier because they look on the bright side of things, finding silver linings in every situation.</p><p>If you were born a pessimist, you have <strong>three</strong> <strong>options</strong> that could make you more resilient to failure, learn, and eventually grow from it: <em>meditation</em>, <em>cognitive therapy</em>, or (even) <em>Prozac</em>. I highly encourage you to try <em>meditation,</em> however, I personally don’t like the idea of the third one, even though the author has good arguments (I’ll let you read them in the book) for Prozac, which he says is <em>“a way to compensate for the unfairness of the cortical lottery.”</em></p><h4>2. The Conditions of Your Life</h4><p>It turns out that there are some external conditions that could affect our well-being. To achieve lasting happiness, you should aim to <strong>remove </strong>(or reduce)<strong> </strong>some of them:</p><ul><li><strong>Noise</strong> — It interferes with concentration and increases stress; strive to remove the sources of noise in your life.</li><li><strong>Commuting </strong>— Long commutes to/from work, especially if it involves driving in heavy traffic can increase your general level of stress; you should improve your commute as much as possible.</li><li><strong>Lack of control </strong>— Improve your sense of control (autonomy) in order to increase your sense of engagement, energy, and happiness.</li></ul><p>On the other hand, there are some external conditions that you should strive to <strong>enrich</strong> in your life: <strong>Love and Work</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FVuDpauIoQsbAVU_LP0yvQ.png" /><figcaption>Photo by <a href="https://unsplash.com/photos/XBxQZLNBM0Q?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Todd Quackenbush</a> on <a href="https://unsplash.com/search/photos/tree?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p><strong>Love. </strong>We are social beings who need love and long-lasting attachments. Having strong social relationships strengthens the immune system, extends life, speeds recovery from surgery, and reduces the risks of depression and anxiety disorders. <em>Good relationships make people happy.</em></p><p><strong>Work</strong> can be approached in one of three ways: as a job, a career or a calling. Although, it doesn’t mean that you have a calling only if you do some very important work, like putting humans on Mars. You can, for example, be a nurse assistant. Some people may find it as a job, but if you think that your work help doctors save the lives of other people, then your job is a calling. You should find a sense of meaning in what you do, something that is beyond yourself.</p><blockquote>“Work itself is but what you deem it.” — Marcus Aurelius</blockquote><h4><strong>3. The Voluntary Activities</strong></h4><p>Last but not least, you can do voluntary activities that will increase your happiness, overall. These are the things like <em>meditation, exercise, reading, learning a new skill, or traveling.</em> Because such activities must be chosen, they offer much greater promise for increasing happiness.</p><h3>Money and Happiness</h3><p>There is a common saying that money doesn’t make you happy. Well, this is partly true. If you live in poverty, and you don’t have enough money to provide your basic needs like food, water, and shelter, then money will make you happier! But, if you have more than enough to satisfy these needs, more money won’t help you very much. As Jonathan Haidt says in the book, you must know where to shop:</p><blockquote>“Those who think money can’t buy happiness just don’t know where to shop … People would be happier and healthier if they took more time off and spent it with their family and friends, yet America has long been heading in the opposite direction. People would be happier if they reduced their commuting time, even if it meant living in smaller houses, yet American trends are toward even larger houses and ever longer commutes. People would be happier and healthier if they took longer vacations even if that meant earning less, yet vacation times are shrinking in the United States, and in Europe as well. People would be happier, and in the long run and wealthier, if they bought basic functional appliances, automobiles, and wristwatches, and invested the money they saved for future consumption; yet, Americans and in particular spend almost everything they have — and sometimes more — on goods for present consumption, often paying a large premium for designer names and superfluous features.” — Jonathan Haidt</blockquote><h3>Conclusion</h3><p>Even though you weren’t born optimistic, you can improve your conditions to make your life happier. Among the most important ones are <strong>Love </strong>and <strong>Work</strong>. Nurture strong relationships with yourself and others while working for something that gives a sense of purpose and meaning.</p><p>Here is one quote that I really enjoyed from the book, and is, somewhat, the main idea of the book:</p><blockquote>“Happiness is not something that you can find, acquire, or achieve directly. You have to get the conditions right and then wait. Some of those conditions are within you, such as coherence among the parts and levels of your personality. Other conditions require relationships to things beyond you: Just as plants need sun, water, and good soil to thrive, people need love, work, and a connection to something larger. It is worth striving to get the right relationships between yourself and others, between yourself and your work, and between yourself and something larger than yourself. If you get these relationships right, a sense of purpose and meaning will emerge.” — Jonathan Haidt</blockquote><p>📕 These were just some ideas from the book <strong>The Happiness Hypothesis: Finding Modern Truth in Ancient Wisdom</strong> <em>by</em> <em>Jonathan Haidt, </em>which I highly encourage you to read!</p><p>🤔 <em>In the end, I have a question: </em><strong><em>What makes you happy?</em></strong><em> Share your answers</em> <em>in the comments below.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8bb34d2d58e0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coders-do-read/did-you-know-that-happiness-has-a-formula-8bb34d2d58e0">Did You Know That Happiness Has a Formula?</a> was originally published in <a href="https://medium.com/coders-do-read">codersDoRead 👨🏻‍💻📚</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[26 Lessons I've Learned Reading 26 Books]]></title>
            <link>https://medium.com/coders-do-read/26-lessons-ive-learned-reading-26-books-fc0143124e82?source=rss-e591ea0285cc------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc0143124e82</guid>
            <category><![CDATA[life-lessons]]></category>
            <category><![CDATA[personal-development]]></category>
            <category><![CDATA[reading]]></category>
            <category><![CDATA[books]]></category>
            <category><![CDATA[self-improvement]]></category>
            <dc:creator><![CDATA[Alexandru Somai]]></dc:creator>
            <pubDate>Fri, 13 Jul 2018 06:43:25 GMT</pubDate>
            <atom:updated>2018-12-31T14:07:04.702Z</atom:updated>
            <content:encoded><![CDATA[<h3>26 Lessons I’ve Learned Reading 26 Books</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1Z9VgMkehuH_bOZthwjH5g.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/photos/Oaqk7qqNh_c?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Patrick Tomasso</a> on <a href="https://unsplash.com/collections/2273053/26-things-26-books/ace5eff0872616fe58f2f4685aed1d3e?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>One of my challenges in terms of personal development for 2018 is to read one book per week, that is 52 books by the end of the year. Until now I’ve managed to read half of them. Here are the most valuable 26 lessons I’ve learned from each of the books.</p><h3>1. Don’t try to change others, change yourself</h3><p>A relationship is not about finding the right person. A relationship is about becoming the right person. Don’t look for the person you want to spend your life with. Become the person you want to spend your life with.</p><p>📕 <strong>The Truth: An Uncomfortable Book About Relationships </strong><em>by Neil Strauss</em></p><h3>2. You should follow good practices for a fulfilling life</h3><p>Here are <strong>seven</strong> virtues of an enlightened life:</p><ul><li><strong>(1) Master your mind</strong> — cultivate your mind to focus and meditate, develop positive thinking.</li><li><strong>(2) Follow your purpose — </strong>you can do so only if you establish clearly defined personal, professional and spiritual goals.</li><li><strong>(3) Practice Kaizen </strong>— The Japanese art of continuous learning and improvement, by doing the things that you fear.</li><li><strong>(4) Live with discipline </strong>— consistently perform small acts of courage.</li><li><strong>(5) Respect your time</strong> — Learn to say NO.</li><li><strong>(6) Selflessly serve others </strong>— practice daily acts of kindness.</li><li><strong>(7) Embrace the present </strong>—Savor the journey and live each day as your last.</li></ul><p>📕 <strong>The Monk Who Sold His Ferrari</strong> <em>by Robin S. Sharma</em></p><h3>3. Your time matters, manage it well</h3><p>Your life on this planet is short, so the way you spend your time really matters. Don’t let others make your schedule or waste your time. Prioritize your options, follow your vocation and do the things that you love. Don’t procrastinate and spend your time wisely. Learn to say no to the things that don’t matter to you.</p><p>📕 <strong>Musai List</strong> <em>by Octavian Pantiș</em></p><h3>4. Everything that you desire, is within yourself</h3><p>People try to find God in different objects, to invoke Him through prayers and they get anxious or frustrated if God doesn’t answer their requests. But what if God is not out there? What if God is within each of us? Pause for a moment and look inside yourself; maybe that’s where you’ll find God.</p><p>📕 <strong>Conversations with God: An Uncommon Dialogue, Book 1 </strong><em>by Neale Donald Walsch.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9y7cGYm-rNDkjam1" /><figcaption>Photo by <a href="https://unsplash.com/@sammgrdichian?utm_source=medium&amp;utm_medium=referral">Sam Mgrdichian</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>5. Sometimes, a human’s life isn’t worth more than a pocket watch</h3><p>You find this in a touching story about a fifteen-year-old Lithuanian girl, named Lina. She lives a happy life with her family, until one night of 1941, Lina’s home is invaded by the terrifying Soviet police, and they are given a few minutes to pack their belongings before being taken away into the night. Separated from her father, Lina, her mother and her brother have to fight and stay together in order to survive. Loaded into cattle cars and transported hundreds of miles to Siberia to serve hard labor in unimaginable conditions, then again to the Arctic Circle, Lina’s story is one of pain, endurance, and survival.</p><blockquote>“Have you ever wondered what a human life is worth? That morning, my brother’s was worth a pocket watch.”</blockquote><p>📕 <strong>Between Shades of Gray </strong><em>by Ruta Sepetys</em></p><h3>6. Understand how habits work, and you have the power to change them</h3><p>At the core of every habit, there is a loop made up of <strong>three</strong> elements: <strong>1. Cue, 2. Routine, 3. Reward</strong>. Understand each of them, keep the cue and the reward, but change the routine, and you’ll be able to reshape a bad habit. On top of that, you may need some willpower to change it.</p><p>📕 <strong>The Power of Habit</strong> <em>by Charles Duhigg</em></p><p>I’ve written my thoughts on this book in more detail, <a href="https://medium.com/coders-do-read/the-power-of-habit-review-ebb347ffffd8">here</a>:</p><p><a href="https://medium.com/coders-do-read/the-power-of-habit-review-ebb347ffffd8">Understand and change your habits</a></p><h3>7. Firstly look to develop personal effectiveness, only then grow healthy relationships with other people</h3><p>(1) You have the freedom to choose. When you understand that you are responsible for your choices, (2) make a choice and (3) take action towards it.</p><p>After you have improved yourself, look forward to (3) respect and (4) understand others. Only at this point you’ll be able to accomplish (6) synergetic creations.</p><p>Keep doing all the above, with (7) continuous growth and improvement in mind.</p><p>📕 <strong>The 7 Habits of Highly Effective People </strong><em>by Stephen R. Covey.</em></p><h3>8. Starting a business is really “easy”</h3><p>All you have to do is follow these <strong>seven</strong> steps:</p><p>Create a breakthrough technology — at least 10x better than the nearest substitute (<strong>1. Engineering</strong>), at the right time (<strong>2. Timing</strong>), that will give you a big share of a small market (<strong>3. Monopoly</strong>). Gather the right team (<strong>4. People</strong>), sell the product in the most efficient way (<strong>5. Distribution</strong>) while maintaining your defensible position 10 and 20 years from now (<strong>6. Durability</strong>). All these, after you’ve found a unique opportunity that others don’t see (<strong>7. Secret</strong>).</p><p>Good luck!</p><p>📕 <strong>Zero to One: Notes on Startups, or How to Build the Future </strong><em>by Peter Thiel, Blake Masters</em></p><h3>9. Do more with less</h3><p>Core ideas:</p><ul><li>If you’re going to start a business, do it right. If selling your business is your only goal, don’t even start, because you’ll never get there.</li><li>Build something you really want to see in the world. Something you can be incredibly proud of, something you want to take a stand for — <strong>a thing worth fighting for</strong>.</li><li>Staying small and flexible is preferable to growing a company quickly. Real prototypes are always better than design documents.</li><li>Working long does not always mean working hard. Instead of promoting a culture of overtime, promote a culture of focused work by cutting away the things that may interrupt people.</li><li>Meetings are the worst kind of interruption. They should be avoided as much as possible.</li></ul><p>📕 <strong>Rework<em> </em></strong><em>by Jason Fried and David Heinemeier Hansson</em></p><h3>10. Greed and selfishness is in our nature</h3><blockquote>“All animals are equal, but some animals are more equal than others.”</blockquote><p>📕 <strong>Animal Farm</strong> <em>by George Orwell</em></p><h3>11. You should have fun while doing business</h3><p>Personal take-aways from Richard Branson’s story, the founder and chairman of Virgin Group:</p><ul><li>Life is not always a smooth sailing, you may face several obstacles as an entrepreneur but you must keep pursuing your goals in spite of the obstacles.</li><li>See profits where most people don’t even see business. Seize opportunities and take calculated risks on them.</li><li>Business shouldn’t be just a way to make money. Business must be fun and you should enjoy doing it.</li><li>Don’t settle, take challenges, even if they’re out of your scope (like he managed to build an airline, Virgin Atlantic).</li><li>Takes life by the horns and chose to trust your gut when it comes to business.</li></ul><blockquote>“You will either go to prison or become a millionaire.”</blockquote><p>📕 <strong>Losing My Virginity</strong><em> by Richard Branson</em></p><h3>12. You can find meaning in life in three ways</h3><p>According to Viktor Frankl, there are three sources to find meaning in life:</p><ol><li>Creating a work or doing a deed.</li><li>Experiencing something or encountering someone (love).</li><li>The attitude towards unavoidable suffering.</li></ol><p>The first one is pretty obvious, it’s defined as “life purpose”. It’s about doing something significant, beyond ourselves. The second one, love, is the strongest bond between people and will lead to wonderful inspiration and great sacrifice. It makes experience a legitimate alternative to achievement in a society built around achieving. The third gives suffering a meaning, but <em>what </em>meaning?</p><p>Enduring extreme hunger, cold and brutality, first in Auschwitz then Dachau, Viktor Frankl himself was under constant threat of going to the gas ovens. Despite Frankl’s horrific experiences, he is able to find meaning in a place full of unbelievable suffering. As he points out, you can find meaning through suffering, but don’t suffer unnecessary to find meaning:</p><blockquote>“Let me make it perfectly clear that in no way is suffering <em>necessary</em> to find meaning. I only insist that meaning is possible even in spite of suffering — provided, certainly, that the suffering is unavoidable. If it <em>were</em> avoidable, however, the meaningful thing to do would be to remove its cause, be it psychological, biological, or political. To suffer unnecessarily is masochistic rather than heroic.”</blockquote><p>📕 <strong>Man’s search for meaning</strong> <em>by Viktor E. Frankl</em></p><p>❗️There is a lot to learn from this book, so I <strong>highly</strong> <strong>recommend</strong> <strong>it❗️</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Am9KkgmV4WzxqG8H" /><figcaption>“A piece of paper with “mindfulness” written in cursive” by <a href="https://unsplash.com/@jblesly?utm_source=medium&amp;utm_medium=referral">Lesly Juarez</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>13. The best antidote against stress is focus on today</h3><p>We tend to worry too much about the past. What’s done is done. There is no way to change the past. Accept the fact, and move on.</p><p>When we don’t carry the burden of the past, we worry about the future. We are too concerned about what may happen. What are the chances that what burdens us, may actually happen? Probably towards zero. The outcome will prove to be very different than what we’ve thought of.</p><p>So the best remedy against stress is to let go of the past, don’t worry about the future and live for today. If you do your best today, the future will take care of itself.</p><p>Moreover, we tend to be stressed about all the things that we don’t have. We should instead feel grateful for what we have:</p><blockquote>“Count your blessings, not your troubles.”</blockquote><p>Keep in mind that stress is the root cause of many diseases. Live in the moment, be thankful for what you have, and stop worrying.</p><p>📕 <strong>How to Stop Worrying and Start Living </strong><em>by Dale Carnegie</em></p><h3>14. Consider a company’s <em>value when buying a stock, and not its price</em></h3><p>When investing, you must take into consideration a few factors:</p><ul><li>always think long-term— at least 20 years.</li><li>diversify your investments , thus you protect yourself from losses — this is where comes in handy the low-cost index funds.</li><li>focus on safe and steady returns instead of get-rich-quick schemes.</li></ul><p>Moreover, control your emotions and don’t let yourself influenced by Mr. Market — that’s Benjamin Graham’s famous analogy, where he pictures the entire stock market as a single person. Don’t buy a stock just because it went up, or don’t sell it if it goes down. You will never be able to time or predict the market right.</p><p>Lastly, to further remove you from the emotional stress of investing with the market, you should always stick to a strict formula when investing. For example, set a fixed budget you’re going to invest every month or quarter, no matter the price. This is known as <em>dollar cost averaging</em>, and it’s a great way to protect yourself if you happen to invest a big sum right before a crash.</p><p>📕 <strong>The Intelligent Investor</strong> <em>by Benjamin Graham</em></p><h3>15. The system could become really sick</h3><p>The classic novel <em>Nineteen Eighty-Four </em>is a dystopian science-fiction that takes place (you’ve guessed) in the year 1984. It pictures a world where most of the population has become victims of perpetual war, omnipresent government surveillance and public manipulation.</p><blockquote>“War is peace. Freedom is slavery. Ignorance is strength.”</blockquote><p>I’d rather not spoil this book with any summary —better give it a read.</p><p>📕 <strong>1984</strong> <em>by </em>George Orwell</p><h3>16. Think from inside-out</h3><p>They key idea in a nutshell:</p><blockquote>“People don’t buy what you do; they buy why you do it.”</blockquote><p>Take for example Apple’s great example. First they tell you <strong>why</strong> they’re doing it — <em>“We aim to challenge the status quo. We aim to think differently.”, </em>then they tell you <strong>how</strong> they do it —through “<em>user-friendly, beautifully designed, and easy to use” </em>products, and finally you find out <strong>what</strong> they make — <em>“great computers”.</em></p><p>To inspire others, start by telling them <strong>why</strong> you do the things you do, instead of what you do. Make people feel a sense of belonging, to believe in something above and beyond themselves, and then they will support you, with their time, money, and in the cases of some movements, even with their lives.</p><p><strong>📕 Start with Why</strong> <em>by Simon Sinek</em></p><h3>17. Dataism could become the religion of the future</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*e7bwtB9__i3_JcvU" /><figcaption>“A robot named Pepper holding an iPad” by <a href="https://unsplash.com/@agkdesign?utm_source=medium&amp;utm_medium=referral">Alex Knight</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Until the 21st century, humanity has reduced mortality caused by hunger, diseases and violence — we are now looking to defeat death, to gain <strong>immortality. </strong>Poverty is decreasing — we now want to achieve eternal <strong>happiness. </strong>We have risen above animal fights and wars — we will transform humans into <strong>Gods. </strong>Based on the past, and present, we could (try to) predict the future —we will change humans into gods, and transform <em>Homo Sapiens</em> into <em>Homo Deus.</em></p><p>Artificial intelligence is on the rise (self driving cars, speech and face recognitions, etc.), and it could, slowly, replace humans in all their cognitive tasks. As artificial intelligence gets smarter, more humans are pushed out of the job market — it could create a ‘useless class’ of people.</p><p>But robots are here to help and protect us, you may think, right? Well, better think about the following lines:</p><blockquote>“You want to know how super-intelligent cyborgs might treat ordinary flesh-and-blood humans? Better start by investigating how humans treat their less intelligent animal cousins. It’s not a perfect analogy, of course, but it is the best archetype we can actually observe rather than just imagine.”</blockquote><p>We are better than this, we have feelings and conscience. Think for a minute, what if your ‘conscience’ and ‘feelings’ are nothing more than some elaborated algorithms? Because of some inputs, you respond with specific outputs — therefore, it becomes a matter of data.</p><p>Organisms are algorithms, and life is all about data processing. The more data you can process, the better you can understand humans. And this is what dataism is about:</p><blockquote>“… an emerging ideology or even a new form of religion, in which ‘information flow’ is the ‘supreme value’.”</blockquote><p>The book ends with one deep question to reflect on:</p><blockquote>“What happens to society, when non-conscious algorithms know us better than ourselves?”</blockquote><p>📕 <strong>Homo Deus: A Brief History of Tomorrow</strong><em> by Yuval Noah Harar</em>i</p><h3>18. Transformational change is the key to growth</h3><p>If you truly want to grow and improve yourself, you must make changes.</p><p>Perform consistent actions towards your well defined goals. Do not look for motivation, because you may not find it everyday. Discipline will lead you to great achievements, not motivation.</p><blockquote>“Life begins at the end of our comfort zone.”</blockquote><p>Do not fear failure, take it as an experience, learn from it, and do not repeat the same mistakes again.</p><p><strong>📕 The 15 Invaluable Laws of Growth</strong> <em>by John C. Maxwell</em></p><h3>19. Improve yourself by following strong virtues</h3><p>Benjamin Franklin created a framework for himself, based on thirteen virtues that helped him succeed in politics, invention, music, business, science and diplomacy. His virtues are: <strong>Temperance, Silence, Order, Resolution, Frugality, Industry, Sincerity, Justice, Moderation, Cleanliness, Tranquillity, Chastity, Humility.</strong></p><p>Do you want to become the best version of yourself? Write your own virtues! They could be five, ten, or fifteen, it doesn’t matter. But make sure that you stick to them! Write a journal to keep track of the actions you take every day and see if they are aligned with your values. Don’t get overwhelmed, start simple — in the first week track one value, then gradually track new virtues.</p><p>📕 <strong>The Autobiography of Benjamin Franklin</strong> <em>by Benjamin Franklin</em></p><h3>20. A simple, balanced approach is the key to a longer, happier life</h3><p>Simple actions, such as doing regular exercises, sleeping well, eating healthy (and varied), creating strong social relationships are among the factors that contribute to a longer and happier life.</p><p>Don’t expect to find something revealing about how to live longer and happier lives. There are a few common sense tips that you probably hear (and ignore) every day 🙃. Apply them!</p><p>📕<strong> The Nordic Guide to Living 10 Years Longer: 10 Easy Tips For a Happier, Healthier Life</strong> <em>by Bertil Marklund</em></p><h3>21. A good speech is a journey both the speaker and the audience make together</h3><p>When holding a speech, your main purpose should be to <em>give </em>something to the audience, not to take. If you are speaking to brag, to raise money or to uplift yourself, you can forget about it. It’s crucial to remember the most important thing: <em>give, not take.</em></p><p>Here are a few tips to have a good speech: connect with your audience through jokes, stories or anecdotes and make eye contact. Wear something comfortable that reflects your personality. Be careful if you are using visuals, not to defocus your audience from what you are saying.</p><p>And rehearse, rehearse, rehearse. If you are confident enough, you could speak based on a structured list, but if not, you’d better learn your speech by heart.</p><p><strong>📕 TED Talks </strong><em>by Chris Andersen</em></p><h3>22. Very quick decisions can be as good as those you make cautiously and deliberately — or even better</h3><p>Surprisingly or not, sometimes you are able to make better, smarter decision relying solely on your instinctive thinking. Take for example, when you meet someone for the first time: unconsciously you make a general idea of that person — is he mean, kind, gentle, nervous, etc. You are able to quickly “read” his mind (more or less), based on his facial expressions and body language — sad, angry, happy, etc.</p><p>However, your fast thinking can lead you to biases that you aren’t event aware of. For example, you tend to think that tall people are smarter and better leaders than the short ones — even though there isn’t a proven correlation between height and IQ.</p><p>Another circumstance when your instinctive thinking can be affected is in conditions of stress. In a stressful situation, you tend to develop a sort of tunnel vision, focusing solely on the most imminent, threatening piece of information. This will lead your gut to make the wrong call many times, so it should be prevented whenever possible.</p><p>Therefore, what type of thinking should I rely on when taking decisions? When should I trust my gut and when should I allow myself some time to think? 🤔</p><p>As the author suggests it, the best solution is to find a balance between rational and instinctive thinking. In case of simple choices — rational thinking is better. When faced with more complex decisions and options — the unconscious process of thinking can serve you better. This may sound counterintuitive, the exact opposite of normal and conventional thinking. The truth is, no one knows for sure — the problem it’s too complex.</p><p>📕 <strong>Blink: The Power of Thinking Without Thinking </strong><em>by Malcolm Gladwell</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kQ_DvifLLIMm-LvX" /><figcaption>“A large number of books covering the walls of a room with an old double door” by <a href="https://unsplash.com/@eugi1492?utm_source=medium&amp;utm_medium=referral">Eugenio Mazzone</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>23. Through books, you can escape the cruel reality</h3><p>The novel is based on an incredible story about a fourteen-year-old girl, Dita Kraus, who was sent to Auschwitz-Birkenau along with her mother and father in December, 1943.</p><p>In a place where nothing grows, at Auschwitz, Dita agrees to take charge of <strong>eight </strong>books that the prisoners have managed to sneak past the guards. It’s the smallest, but the most precious library in history. She is willing to risk her life to keep the magic of books alive during the Holocaust.</p><blockquote>“Books are extremely dangerous; they make people think.”</blockquote><p>While reading, you will learn, little by little, not only the story of Dita, but also the story of the other supervisors and teachers in Block 31.</p><p>📕 <strong>The Librarian of Auschwitz </strong><em>by Antonio Iturbe</em></p><h3>24. (Dark) humor can help you out</h3><p>A tragicomic story about a boy, Mihai, that can’t find meaning in a meaningless world. Sometimes you want to cry with the character, sometimes you want to laugh with him, and other times you want to punch him in the face.</p><p>📕 <strong>Reset </strong><em>by Mihai Păduraru</em></p><h3>25. Minimize the time spent in the feedback loop</h3><p>In his book, <em>Eric Ries </em>suggests a new approach when starting a business. A core component of his methodology, <em>Lean Startup, </em>is the <strong>build-measure-learn</strong> feedback loop. One of the goals is to minimize the total time spent in this loop.</p><p>You firstly start by building a <strong>minimum viable product (MVP) </strong>— it shouldn’t be perfect, it should be good enough to ship it to your clients, with some minimum features that you think are vital. Afterwards, based on your specific <strong>measurements</strong> and your clients’ feedback, you learn — this is called <strong>validated learning</strong>.</p><p>If the above process of measuring and learning is done correctly, it will be clear that your company is either moving in the right direction or not. If not, it’s a sign that it is time to pivot or make a structural course correction to test a new fundamental hypothesis about the product, strategy and/or engine of growth.</p><p>There are many more lessons to learn from the book — like what are the three types of engine of growth a company could use or how to effectively rely on A/B testing— but I’ll let you read about them by yourself.</p><p>📕 <strong>The Lean Startup </strong><em>by Eric Ries</em></p><h3>26. The world needs *passionate* leaders</h3><p>Not managers, but leaders. Because leaders use passion and ideas to drive people, while managers use threats and bureaucracy.</p><p>To become a leader you must challenge the status quo, propose an idea, even if it might fail, to stand up in front of strangers. You should’t settle and always embrace change. And remember:</p><blockquote>“The only thing holding you back is your own fear.”</blockquote><p><strong>📕 Tribes</strong> <em>by Seth Godin</em></p><p>These are the 26 books that I’ve read this year, so far, and the lessons learned from them. Looking forward to complete my challenge, and by the end of the year to learn at least 52 valuable lessons.</p><p><em>Have you read some of the books mentioned above? What is your favorite book that you’ve read in 2018, so far? How are the challenges that you’ve set this year going? Share your thoughts in the comments below.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc0143124e82" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coders-do-read/26-lessons-ive-learned-reading-26-books-fc0143124e82">26 Lessons I&#39;ve Learned Reading 26 Books</a> was originally published in <a href="https://medium.com/coders-do-read">codersDoRead 👨🏻‍💻📚</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[3 Takeaways from Devoxx UK 2018]]></title>
            <link>https://medium.com/coders-do-read/3-takeaways-from-devoxx-uk-2018-190132af2e62?source=rss-e591ea0285cc------2</link>
            <guid isPermaLink="false">https://medium.com/p/190132af2e62</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[conference]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Alexandru Somai]]></dc:creator>
            <pubDate>Tue, 29 May 2018 07:57:18 GMT</pubDate>
            <atom:updated>2018-08-05T09:13:27.638Z</atom:updated>
            <content:encoded><![CDATA[<h3>3 Takeaways From Devoxx UK 2018</h3><h4>My favorite topics from the developer community conference</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JMGfeiwtEdc2LXI_O7c-HQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/photos/cvUIv9j5wDg?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Jess Watters</a> on <a href="https://unsplash.com/search/photos/notebook?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p><a href="https://www.devoxx.co.uk/">Devoxx UK</a>, a conference by developers, for developers, took place this year in London, 9th - 11th May, 2018. It covered topics on Programming Languages, Big Data &amp; AI, Modern Web, Architecture, and many more. In this post I wrote about my top three favorite subjects discussed at Devoxx UK, with links to a few video recordings. Give it a read!</p><h3>1. Spring goes Reactive 😮</h3><p>Spring follows the functional and reactive programming shift and comes with <a href="https://projectreactor.io/">Project Reactor</a>. It’s an implementation of the <a href="http://www.reactive-streams.org/">Reactive Streams</a> specification, capable of building event-based architectures for handling large volumes of service requests, asynchronously.</p><p>Reactor uses the same approach and philosophy as <a href="https://github.com/ReactiveX/RxJava">RxJava</a> despite some API differences. Its two main types are the Flux&lt;T&gt; and Mono&lt;T&gt;. A <em>Flux</em> is the equivalent of an RxJava Observable, capable of emitting 0 or more items. On the other hand, a <em>Mono</em> can emit <strong>at most</strong> once. It corresponds to both Single and Maybe types on the RxJava side.</p><p>Reactor Project it’s a great tool to assist you building fully Cloud Native apps based on asynchronous architectures. It offers non-blocking and backpressure-ready embeddable for HTTP, TCP and UDP.</p><p>Quick <strong>example</strong>:</p><p>Go to Spring Initializer <a href="https://start.spring.io/">page</a> and generate a Spring Boot project. Choose the dependency management tool (could be Maven), a group and artifact name for your application (I’ve named mine com.example.game-of-thrones-reactive) and as dependencies, make sure to selectReactive Web<strong> </strong>and<strong> </strong>Reactive MongoDB.</p><p>Open your main application file (in this case, GameOfThronesReactiveApplication) and write the code below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/716aecc4f34a68a080bc20285765af99/href">https://medium.com/media/716aecc4f34a68a080bc20285765af99/href</a></iframe><p>In the class above, we have a basic repository interface, that extends from ReactiveCrudRepository, providing us with the main crud operations, in a reactive manner.</p><p>Our basic model class is Character, that has an id, and a name. Method load<em>, </em>starting at<em> line #37, </em>populates MongoDB with some initial data.</p><p>Notice the CharacterController, it exposes /characters method, which returns a Flux (stream of events) from the repository.</p><p>When calling the API, the result is an event-stream, as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RTsCs9oxs2SKjs0KnQZHuQ.gif" /></figure><p>This is just a glimpse of what you can do using Spring in a reactive way. If you want a more in depth knowledge and usage examples of Project Reactor, I’d suggest you to watch <a href="https://twitter.com/MkHeck">Mark Heckler</a>’s Deep Dive session on <a href="https://www.youtube.com/watch?v=BC2BcYviBZM">Reactive Spring</a>.</p><h3>2. Java 8, you’re lazy! 😴</h3><p>Probably the only time when it’s good to be lazy is when you’re a programming language. Thanks to <em>Lamba Expressions</em>, Java 8 became lazy.</p><p>But what does it mean to be lazy, as a programming language? Of course it’s not lazy in terms of performance, as you may think. It’s <strong>lazy in terms of evaluation.</strong></p><p>Here’s an <strong>example</strong>:</p><pre>public void execute() {<br>    int x = 2;<br>    if (x &gt; 10 &amp;&amp; compute(x) &gt; 20) {<br>        System.<em>out</em>.println(&quot;First path invoked&quot;);<br>    } else {<br>        System.<em>out</em>.println(&quot;Second path invoked&quot;);<br>    }<br>}<br><br>private int compute(int n) {<br>    System.<em>out</em>.println(&quot;Compute method called...&quot;);<br>    return n;<br>}</pre><p>If we call the execute method, the output is:</p><pre>Second path invoked</pre><p>Notice that when the first expression x &gt; 10 is evaluated to false, the second expression is never evaluated, therefore compute method <strong>is not called.</strong></p><p>What if we change the code, and extract the compute method into a variable?</p><pre>public void execute() {<br>    int x = 2;<br>    int temp = compute(x);<br>    if (x &gt; 10 &amp;&amp; temp &gt; 20) {<br>        System.<em>out</em>.println(&quot;First path invoked&quot;);<br>    } else {<br>        System.<em>out</em>.println(&quot;Second path invoked&quot;);<br>    }<br>}<br><br>private int compute(int n) {<br>    System.<em>out</em>.println(&quot;Compute method called...&quot;);<br>    return n;<br>}</pre><p>Guess what? Here’s the output:</p><pre>Compute method called...<br>Second path invoked</pre><p>The compute method <strong>is called</strong>, no matter the result of x &gt; 10. But how can we overcome this? If only we had a lazy keyword, like <strong>Scala</strong>:</p><pre>lazy int temp = compute(x);</pre><p>We’re in Java 8 world, and we don’t have such features. Let’s see how we could make use of <em>Lambdas:</em></p><pre>public void execute() {<br>    int x = 2;<br>    Supplier&lt;Integer&gt; temp = () -&gt; compute(x);<br><br>    if (x &gt; 10 &amp;&amp; temp.get() &gt; 20) {<br>        System.<em>out</em>.println(&quot;First path invoked&quot;);<br>    } else {<br>        System.<em>out</em>.println(&quot;Second path invoked&quot;);<br>    }<br>}<br><br>private int compute(int n) {<br>    System.<em>out</em>.println(&quot;Compute method called...&quot;);<br>    return n;<br>}</pre><p>Notice the <em>Supplier </em>interface. We can use it to achieve laziness. As expected, compute method is not invoked, and the output is:</p><pre>Second path invoked</pre><p>This is just a basic example of using <em>Lambdas </em>to get lazy.</p><p>If you like to discover the true power and usefulness of being lazy with <em>Lambda Expressions</em> in Java 8, I invite you to watch <a href="https://twitter.com/venkat_s">Venkat Subramaniam</a>’s talk on the <a href="https://www.youtube.com/watch?v=ekFPGD2g-ps">Real Power of Streams</a>.</p><h3>3. Java 9, 10 and beyond 🚀</h3><p>With Java 9 shift to modular systems, it may difficult to migrate your application. Luckily, at Devoxx UK 2018, there were some talks in regards to this topic:</p><ul><li><a href="https://twitter.com/@jodastephen">Stephen Colebourne</a> talked about the basics of Java 9 module system, <a href="https://www.youtube.com/watch?v=eTcjU5JlEpI">here</a>.</li><li><a href="https://twitter.com/@nipafx">Nicolai Parlog</a> did a live migration to Java 9. Watch his video <a href="https://www.youtube.com/watch?v=ZF_WLtbEfqA">here</a>.</li><li><a href="https://twitter.com/@karianna">Martijn Verburg</a> had a guide how to survive the twisted world of Java 9 and 10, <a href="https://www.youtube.com/watch?v=yUFqLkzD7WE">here</a>.</li></ul><p>What’s gonna be next?</p><p>Oracle is planning to perform Java releases every six months, meaning that by September 2018 we should already have Java 11. The plan is to offer support for short period of times for each version (6 months), and some versions (like 11) will have a long-term-support (LTS — 3 years+).</p><p>For future Java plans, watch <a href="https://twitter.com/mreinhold">Mark Reinhold</a>, the Chief Architect of Java, <a href="https://www.youtube.com/watch?v=HqxZFoY_snQ">talk</a> about how important change is, in order to be in pace with the latest programming languages.</p><h3>Wrap-up</h3><p>There were a lot of good talks at Devoxx UK 2018, which I didn’t cover in this post. Many more topics were involved, like Artificial Intelligence and Modern Web Applications.</p><p>For more talks, I’d suggest you to have a look at Devoxx UK 2018 video sessions that are published on Youtube, <a href="https://www.youtube.com/watch?v=BC2BcYviBZM&amp;list=PLRsbF2sD7JVpRvLpv_Cub94zsM1aHm-Op">here</a>.</p><p><em>What’s your opinion on the general trend of shifting from imperative programming to a more functional/reactive style? What talks did you find interesting from Devoxx UK 2018? Which other talks you’d suggest from Devoxx conferences, in general? Share your thoughts in the comments below.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=190132af2e62" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coders-do-read/3-takeaways-from-devoxx-uk-2018-190132af2e62">3 Takeaways from Devoxx UK 2018</a> was originally published in <a href="https://medium.com/coders-do-read">codersDoRead 👨🏻‍💻📚</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Implement an Encrypted Distributed Cache]]></title>
            <link>https://medium.com/coders-do-read/how-to-implement-an-encrypted-distributed-cache-87be4e506f8e?source=rss-e591ea0285cc------2</link>
            <guid isPermaLink="false">https://medium.com/p/87be4e506f8e</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[encryption]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Alexandru Somai]]></dc:creator>
            <pubDate>Sat, 21 Apr 2018 11:21:55 GMT</pubDate>
            <atom:updated>2018-08-04T17:16:35.866Z</atom:updated>
            <content:encoded><![CDATA[<h4>A step-by-step guide to write your own implementation of Encrypted Cache on top of Hazelcast</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CXNQW2ZhXOKhjBHMqxPT0A.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/photos/8yYAaguVDgY?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Jason Blackeye</a> on <a href="https://unsplash.com/search/photos/lock?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>In this tutorial I’ll show you how to use the open-source in-memory data grid solution offered by Hazelcast, to write your own implementation of <strong>encrypted distributed cached.</strong></p><p>Here’s a generic script that may happen at your company:</p><p>Your Manager 👴: Our security department wants us to encrypt the data that we store into our distributed cache.</p><p>You 👨🏻‍💻: Sure thing. We currently use in-memory data grid solution offered by Hazelcast. Their enterprise edition comes with encryption support.</p><p>Your Manager 👴: We don’t want to buy the enterprise solution. What other options do we have?</p><p>You 👨🏻‍💻: We could write our own implementation of encrypted distributed cache on top of open-source Hazelcast.</p><p>Your Manager 👴: Sounds like a plan!</p><p>I’ll show you, step-by-step, how to create your own implementation of Encrypted Hazelcast Cache Manager! Off we go! 🚀</p><p>Knowledge required:</p><ul><li>Java and Spring</li></ul><p>Prerequisites installed:</p><ul><li>JDK 8</li><li>Gradle — for dependency management (or you could use Maven)</li></ul><p>Here are the steps that we need to follow:</p><ol><li>Set-up a Spring Boot demo project that uses Hazelcast as a distributed caching mechanism.</li><li>Write a Cipher Service implementation that performs hashing, encryption and decryption.</li><li>Extend the existing Hazelcast cache — it provides additional capabilities of encrypted caching.</li><li>Finally, configure the application to use our freshly created distributed caching mechanism.</li></ol><p>The demo application <strong>source code</strong> may be found <a href="https://github.com/alexsomai/encrypted-hazelcast-app">here</a>.</p><h3>Step 0. Set-up a demo app</h3><p>I<em>f you already have a Spring application that is configured to use Hazelcast for distributed cache, you may skip this part, and jump straight to Step 1.</em></p><h4>Start a project</h4><p>Firstly, create a new project directory, let’s call it encrypted-hazelcast-app.</p><p>Jump it into and set-up a basic Gradle project, using your favorite IDE, or by using the command line, as below:</p><pre>gradle init --type java-application</pre><p>Modify your generated build.gradle file with the following:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7a640f15d209eb29b1ff8e60e029f536/href">https://medium.com/media/7a640f15d209eb29b1ff8e60e029f536/href</a></iframe><p>We use Spring Boot to quickly spin-up our application.</p><p>Moreover, we’ll need a few dependencies:</p><ul><li><a href="https://hazelcast.org/">Hazelcast</a> — for distributed caching.</li><li><a href="https://www.bouncycastle.org/">Bouncy Castle</a> — provides a lightweight API for encryption.</li><li><a href="https://github.com/google/gson">GSON</a> — for JSON serialization/deserialization.</li></ul><h4>Configure the application</h4><p>Next, let’s create the Spring Boot main application class. In this example, we add it in com.alexsomai.blog root package (feel free to use whatever package structure you may like). The Application.java looks like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a4a60b1373902cf2965fda57c1818bdf/href">https://medium.com/media/a4a60b1373902cf2965fda57c1818bdf/href</a></iframe><p>A few configs are needed to enable caching on a Spring managed bean:</p><ul><li><em>Line #21 — </em>use the @EnableCaching annotation to enable Spring’s annotation-driven cache management capability.</li><li><em>Line #31</em>— set our cacheManager as HazelcastCacheManager.</li><li>L<em>ine #44 — </em>configure network settings for our distributed cache. Disable multicast discovery, and enable TPC/IP localhost discovery.</li><li><em>Line #55 — </em>store the users’ details into a cache named users<em>. </em>It has a TTL (Time to Live) of 10 minutes, and uses LFU (Least Frequently Used) as eviction policy.</li></ul><p>This basic config is enough to get a project started. I will not focus on how to configure your Hazelcast instance. For more details, you can check the <a href="http://docs.hazelcast.org/docs/latest-development/manual/html/Integrated_Clustering/Integrating_with_Spring/Configuring_Spring.html">documentation page</a>.</p><p>Later on, we will start two application instances on our local environment, to demonstrate the capabilities of distributed caching.</p><h4>Create a Controller</h4><p>Following, let’s define a dummy controller that serves the incoming requests:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3783aa3fd71f25ca8e07cafb22974217/href">https://medium.com/media/3783aa3fd71f25ca8e07cafb22974217/href</a></iframe><p>The controller has a API method, that will map GET requests for /users/{accountId} and will return a matching User from the service.</p><h4>Implement a Service</h4><p>UserService is a Java interface, exposing one simple method, with its signature below:</p><pre>User getUser(long accountId);</pre><p>Let’s write a dummy implementation for this interface.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c2968d3b43b772559f98e86a5b2bb1cc/href">https://medium.com/media/c2968d3b43b772559f98e86a5b2bb1cc/href</a></iframe><p>What’s<strong> worth mentioning</strong> about the Service implementation, is that, at <em>line</em> <em>#23</em>, we use the @Cacheabe Spring annotation. This indicates that the result of the method is stored into a cache, so on subsequent invocations (with the same arguments), the value in the cache is returned without having to actually execute the method. Each time the method is called, the cache is checked to see whether the invocation has been already executed and does not have to be repeated.</p><p>Concrete example: first time we call the getUser method with accountId=1, it will execute the body of the method — sleeps for three seconds, then parses the JSON file and returns the user. This user, will be stored into our cache, which is nothing more than a Map, having as key the accountId and as value the user. Next time we call it, with the same accountId, the method will not be executed, because our user will be retrieved from the cache.</p><p>But you may ask: who controls and manages this Cache? This is where the CacheManager comes into action— it’s an entity that controls and manages Caches.</p><p>This was just a basic idea of how Spring handles caching. There are many other annotations, such as: @CacheEvict,@CachePut,@Caching, @CacheConfig, but they are out of this tutorial’s scope.</p><p>You can read more about Cache Abstraction in Spring, <a href="https://docs.spring.io/spring/docs/current/spring-framework-reference/integration.html#cache">here</a>.</p><p>Let’s get back to our UserServiceDummyLocalFileImpl. It parses a JSON file, containing the “database” of users, and tries to find a matching user for the given accountId. If no user is found, it returns null.</p><p>Under src/main/resources, create a file called users.json, that will act as our dummy database (add as many user objects as you’d like to):</p><pre>[<br>  {<br>    &quot;accountId&quot;: 1,<br>    &quot;username&quot;: &quot;johnsnow&quot;,<br>    &quot;email&quot;: &quot;johnsnow@gameofthrones.com&quot;,<br>    &quot;firstName&quot;: &quot;John&quot;,<br>    &quot;lastName&quot;: &quot;Snow&quot;,<br>    &quot;about&quot;: &quot;I know nothing!&quot;<br>  },<br>  {<br>    &quot;accountId&quot;: 2,<br>    &quot;username&quot;: &quot;daenerys&quot;,<br>    &quot;email&quot;: &quot;daenerys@gameofthrones.com&quot;,<br>    &quot;firstName&quot;: &quot;Daenerys&quot;,<br>    &quot;lastName&quot;: &quot;Targaryen&quot;,<br>    &quot;about&quot;: &quot;I&#39;m the Mother of Dragons&quot;<br>  }<br>]</pre><h4>The Model</h4><p>Our model is the User, a POJO, having the fields below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/227bfcba746f69ce2a91549898f249e7/href">https://medium.com/media/227bfcba746f69ce2a91549898f249e7/href</a></iframe><p><strong>Note </strong>that the User class implements Serializable. This is required because Hazelcast has to serialize the Java objects that you put into the cache. Hazelcast has many other serialization options, but I’ll not get into detail. You can read more about Hazelcast serialization <a href="http://docs.hazelcast.org/docs/latest-development/manual/html/Serialization/Overview.html">here</a>.</p><h4>View the cached data</h4><p>To view how the data is stored into the cache, let’s create a helper method, that uses <em>Java Reflection</em> to access the objects stored in memory by the CacheManager implementation.</p><p><strong>❗️</strong>DO NOT<strong> </strong>do this in production! It’s only for demo purposes.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c0d9198299c5cdefc10dfe08359c5628/href">https://medium.com/media/c0d9198299c5cdefc10dfe08359c5628/href</a></iframe><h4>Run the app</h4><p>We start two instances of the application, on different ports, to view the distributed cache in action.</p><p>Into our working directory, firstly build the project:</p><pre>$ ./gradlew build</pre><p>And start the application, on port 8080:</p><pre>$ java -jar build/libs/encrypted-hazelcast-app.jar \<br>--server.port=8080</pre><p>And in a new terminal session (don’t close the first one), start another application instance, this time on port 8090:</p><pre>$ java -jar build/libs/encrypted-hazelcast-app.jar \<br>--server.port=8090</pre><p>When starting the second instance, you should see in the first application’s logs, that you have two members in the Hazelcast cluster, like below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QSqkwTui2ZiFEtNyO9tXpA.png" /><figcaption>Shows the members from the Hazelcast cluster</figcaption></figure><h4>Testing</h4><p>Let’s make a basic call to our service. We want to retrieve the users associated whose account id is 1 (we will also time our request):</p><pre>$ time curl 0:8080/users/1</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mVUWSm5FZCBwUfglgxR9FA.png" /><figcaption>API invocation response</figcaption></figure><p>As seen in the screenshot above, the first time when we make the call to retrieve the users, we get a response time of about 3 seconds! This is due to the sleeping time that we have explicitly set into the service.</p><p>But the second time when we make the call, the response is almost instantaneous, because our user is retrieved, this time, from the cache.</p><p>The third time, we make a call to the other application instance, on port 8090. As expected, we get an almost instantaneous response, because of our <strong>distributed cache </strong>— the user object was replicated onto our second instance.</p><p>But how does the cached data look like? We can view it using our helper API:</p><pre>$ curl 0:8080/users/cached</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EYWKWEoCxrdBqjtFnuD2DA.png" /><figcaption>Cached data in plain text</figcaption></figure><p>We can see the values stored into our cache, in plain text. We also notice that the cache is nothing more than a Map, having as key the accountId, and as value the user object.</p><p>In order to avoid storing the data in plain text, <strong>we need to encrypt our distributed cache</strong>. All this, in the steps below. 👇</p><h3>Step 1. Write the Cipher Service</h3><p>The Cipher Service is responsible for performing three basic operations: <strong>hashing</strong>, <strong>encryption</strong><em> </em>and <strong>decryption<em>. </em></strong>We use these functions later, when we have to store/access the data into/from our cache.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c996215ef1224bfca8bbe11d8d9726b7/href">https://medium.com/media/c996215ef1224bfca8bbe11d8d9726b7/href</a></iframe><p>👈 This is how the service interface looks like, exposing the three common operations: hash, encrypt and decrypt.</p><p><em>We use as helper the Java library called </em><a href="https://www.bouncycastle.org/"><em>Bouncy Castle</em></a><em>. It provides a lightweight API for cryptography.</em></p><h4>Hash</h4><p>Let’s write the implementations of these three methods. First of all, we start with the easiest one, hash:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9c6f68cc78905576362321c99acdf953/href">https://medium.com/media/9c6f68cc78905576362321c99acdf953/href</a></iframe><p>As you have probably noticed, at <em>line #14</em>, we use for hashing the <em>SHA-256</em> algorithm (from <a href="https://en.wikipedia.org/wiki/SHA-2">SHA-2</a> family).</p><p>Moreover, we use a custom utility method (<em>line #16</em>), for <em>serializing</em> our object into a stream of bytes, before applying the hashing algorithm.</p><p>Find the SerializationUtil class, with its serialize and deserialize methods below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e9340f9ece0d5614f544715eac8c895d/href">https://medium.com/media/e9340f9ece0d5614f544715eac8c895d/href</a></iframe><p>Note that we make use of the InternalSerializationService that comes with Hazelcast when serializing and deserializing data. Some objects may be added into cache relying on the Hazelcast serialization features, thus we need to support it.</p><h4>Encrypt and Decrypt</h4><p>For encryption we use a symmetric-key algorithm, more specifically the <a href="https://en.wikipedia.org/wiki/Advanced_Encryption_Standard">AES</a> algorithm.</p><p>When encrypting, we firstly serialize the object into a byte array, apply the encryption algorithm and then convert the stream of bytes into hex format. At decryption, we do the same process, but in reverse: decode from hex, apply the decryption algorithm, and deserialize the bytes.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9a9e58f4e32e055f606c57fdf8fdd257/href">https://medium.com/media/9a9e58f4e32e055f606c57fdf8fdd257/href</a></iframe><p>At <em>lines #23 and #35</em>, we call the applyAlgorithm function differently, once, for encryption, we set the forEncryption flag to true, while at decryption, set forEncryption flag to false.</p><p>Next, let’s see how does the applyAlgorithm looks like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/24b282350cc8a1fd3d814a70506ddae8/href">https://medium.com/media/24b282350cc8a1fd3d814a70506ddae8/href</a></iframe><p>I will not go into much details here, as most of the work is done by the Bouncy Castle library, we simply call some API methods.</p><p>What is worth noticing is how we initialize the PaddedBufferedBlockCipher (<em>line #40):</em></p><ul><li>We use the forEncryption flag, set by the caller methods, when implementing encrypt/decrypt methods.</li><li>We need a secret key, used for the symmetric encryption. We set the secretKey from properties file and its length must be 128/192/256 bits (8, 12 or 32 characters). You should set it now, in the application.properties file:</li></ul><pre># key length must be 128/192/256 bits - 8, 12 or 32 characters<br>cipher.service.secret-key=abcdefgh12345678</pre><p><strong>Don’t forget</strong> to annotate the CipherServiceImpl with @Componenet. This will tell Spring that it’s a bean, and we’ll be able to inject it later, when constructing our encrypted cache.</p><p><em>Note that you are not limited only to the algorithms that I’ve used for hashing, encryption and decryption. They are just for demo purposes, and you are free to use whatever hashing or encryption algorithms you find more appropriate.</em></p><h3>Step 2. Implement the Encrypted Cache</h3><h4>Write the EncryptedHazelcastCache</h4><p>Now that we are done writing our hashing, encryption and decryption implementations, we can proceed to write our cache, that we’ll make use of these methods.</p><p>For creating our own implementation of EncryptedHazelcastCache, we will override a few methods from HazelcastCache. You can find the methods below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/35dd96be5e3ea3aaa6970f3f2a5c9a89/href">https://medium.com/media/35dd96be5e3ea3aaa6970f3f2a5c9a89/href</a></iframe><p>For the get, put, and evict method, instead of storing the Map keys in plain text, we will <em>hash</em> them. Based on the implementation, the hashing algorithm can be anything from <em>MD5</em> (currently unsafe), <em>SHA-256</em>, etc.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/09b334ea5f8f629b87a8cb570118fdaf/href">https://medium.com/media/09b334ea5f8f629b87a8cb570118fdaf/href</a></iframe><p>As you have already noticed, we have added the CipherService argument to the constructor. It’s the interface for which we have written an implementation at Step 1. It handles hashing, data encryption and decryption.</p><p>Further, we still have to encrypt the values (objects) associated with the keys, that are stored into our cache. This is why we will override:</p><ul><li>toStoreValue(Object value) — firstly retrieve the object from cache, then encrypt it, before returning.</li><li>fromStoreValue(Object value) — firstly decrypt the cached object, then retrieve it from cache, before returning.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/adb5be3fdb48fb6ed492e215a56a4bfb/href">https://medium.com/media/adb5be3fdb48fb6ed492e215a56a4bfb/href</a></iframe><p><em>We rely solely on the </em><em>CipherService interface, thus you can use whatever implementation you like. That’s the beauty of Spring — loose coupling.</em></p><h4>Write the EncryptedHazelcastCacheManager</h4><p>Now that we are done writing our encrypted cache, we still need to write our implementation of CacheManager that controls and handles the EncryptedHazelcastCache.</p><p>We will extend the HazelcastCacheManager and override one specific method: getCache(String name), as in the implementation class below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/397fddf218a2b7edf21ddc3c799bf5e3/href">https://medium.com/media/397fddf218a2b7edf21ddc3c799bf5e3/href</a></iframe><p>We add a new argument to the constructor, that is the CipherService, which contains the basic methods for encryption. What is different from the base class implementation, is that we create a new instance of EncryptedHazelcastCache, if needed. We pass as argument, besides the hazelcastInstance’s distributed map, a second parameter, that is the injected CipherService(<em>line #28).</em></p><h3>Step 3. Configure and get started.</h3><p>Finally, we have to set the our EncryptedHazelcastCacheManager to be used as a cacheManager within our application. We do this by changing the bean, as in the configuration class below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fd83bb597ee4394eb46ce8423e520518/href">https://medium.com/media/fd83bb597ee4394eb46ce8423e520518/href</a></iframe><p>Note that we also pass as parameter to the cacheManager function, the CipherService, which is the bean that handles de hashing, encryption and decryption.</p><p>Start your application, and you’re done. You now have an Encrypted distributed cache on top of Hazelcast! 🔐</p><h4>Testing</h4><p>Remember the /users/cached method that we’ve exposed in our Controller at Step 0. We’ll use it again, this time, to check that our cached data is, indeed, encrypted.</p><pre>$ curl 0:8080/users/cached</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UhmwLQMzQSQgOOb6U8udUg.png" /><figcaption>Encrypted data in Hazelcast cache</figcaption></figure><p>As seen in the screenshot above, we have <em>hashed</em> our keys, and <em>encrypted</em> our user objects.</p><p>That’s it for this tutorial. Here’s the wrap-up:</p><ol><li>First of all, we’ve set-up a basic Spring Boot demo project, configured to use distributed caching with Hazelcast.</li><li>We then wrote our Cipher Service implementation that does hashing, encryption and decryption.</li><li>We later used this service to write our own implementation of Encrypted cache extending the open-source Hazelcast distributed cache.</li><li>We configured the application to use our implementation of encrypted distributed cache.</li></ol><p><em>If you’ve found this guide useful, or if you have any questions or suggestions, let me know in the comments below. Any improvements to the source code are welcomed </em><a href="https://github.com/alexsomai/encrypted-hazelcast-app"><em>here</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=87be4e506f8e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coders-do-read/how-to-implement-an-encrypted-distributed-cache-87be4e506f8e">How to Implement an Encrypted Distributed Cache</a> was originally published in <a href="https://medium.com/coders-do-read">codersDoRead 👨🏻‍💻📚</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understand and Change Your Habits]]></title>
            <link>https://medium.com/coders-do-read/the-power-of-habit-review-ebb347ffffd8?source=rss-e591ea0285cc------2</link>
            <guid isPermaLink="false">https://medium.com/p/ebb347ffffd8</guid>
            <category><![CDATA[reading]]></category>
            <category><![CDATA[book-review]]></category>
            <category><![CDATA[review]]></category>
            <category><![CDATA[education]]></category>
            <category><![CDATA[books]]></category>
            <dc:creator><![CDATA[Alexandru Somai]]></dc:creator>
            <pubDate>Tue, 20 Mar 2018 09:40:21 GMT</pubDate>
            <atom:updated>2018-08-08T09:14:53.514Z</atom:updated>
            <content:encoded><![CDATA[<h4>The Power of Habit — Summary</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kzoy4fTLy_MD6V5vJSlqRA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/photos/9guR2Vmh1C4?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">James Connolly</a> on <a href="https://unsplash.com/search/photos/stream?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>The following post is more like a journal, personal notes, rather than a book review of <strong>The Power of Habit</strong><em>, by Charles Duhigg</em>. It gives you a basic idea about what you will learn by reading this book.</p><h3>If I had to summarize this book</h3><h4>In one sentence, that sentence would be:</h4><p><em>By understanding how habits work, we have the power to change them. </em>👊</p><h4>In one image, that image would be:</h4><p>A river, a steady stream of water, flowing everyday, being able to make its way through the rocks it encounters.</p><p>So are habits, through small and constant improvements, we can move mountains.</p><p>As William James points out, the best analogy for how a habit works is water, it …</p><blockquote>… hollows out for itself a channel, which grows broader and deeper; and, after having ceased to flow, it resumes, when it flows agains, the path traced by itself before.</blockquote><h3>What I’ve learned from this book</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/241/1*irHhzUhSNLDzYRSZLmAAXA.png" /></figure><p>At the core of every habit, there is a loop made up of three elements:</p><ol><li>Cue</li><li>Routine</li><li>Reward</li></ol><p>If you understand the implications of each element, you’ll be able to <strong>reshape</strong> a habit. You can’t quit an old habit, but you can replace it, as Charles Duhigg<em> </em>says:</p><blockquote>“The Golden Rule of Habit Change: You can’t extinguish a bad habit, you can only change it.”</blockquote><p>The author gives a really good example of how he managed to change one of his bad habits. I’ll let you read the book, but the main idea is the following:</p><ol><li>Firstly, you need to identify the<em> </em><strong><em>routine</em></strong><em>. </em>What’s that one thing that you want to change? Like going every day to the cafeteria to eat a cookie.</li><li>Secondly, what is that good feeling that you get by completing the routine? What’s the <strong>reward</strong>? Is it the satisfaction that you’ve got sugar running through your blood?</li><li>Thirdly, what is the <strong>cue?</strong> What triggers the routine? It could be anything from <em>location, time, emotional state, other people or immediately preceding actions</em>. Try to isolate it.</li><li>Finally, after you’ve identified the core elements, <strong>make a plan</strong> to change the habit, because only you have the power to do so.</li></ol><p>And <strong>remember:</strong></p><blockquote>“Change might not be fast and it isn’t always easy. But with time and effort, almost any habit can be reshaped.”</blockquote><p><strong>But that’s not all! </strong>Habits have many more implications. To make a routine from needing a specific reward, you must be <em>carving</em> for it. Companies know that, and they take advantage of it. Furthermore, to be able to change a bad habit, you must posses strong willpower.</p><h3>What I’d give bonus points for</h3><p>Besides the good explanation of how habits work in our daily life, the book gives a few examples of how companies take advantage of our habits. For example:</p><ol><li>Starbucks teach their employees, through habits, how to treat the customers. A good application used by the company is the LATTE method (no, not the ☕️🥛). It stands for <strong><em>L</em></strong><em>isten, </em><strong><em>A</em></strong><em>cknowledge the problem, </em><strong><em>T</em></strong><em>ake problem-solving action, </em><strong><em>T</em></strong><em>hank</em> them, and <strong><em>E</em></strong><em>xplain</em> <em>what you’ve done.</em></li><li>Target Corporation is able to know what you want to buy before you even buy it, by predicting (and manipulating) your habits.</li></ol><p>The author also presents many experiments, demonstrating the involvements of habits and willpower, into our daily activities. A very good example, showing the long term effects of a strong willpower that an individual may have, is the marshmallow test. Probably you’ve heard about it. A group of four-year-olds kids were brought into a room and were offered a deal: they could eat one marshmallow right away, or, if they waited a few minutes, they could have two marshmallows. The long-term outcome is really fascinating. The kids who didn’t eat the marshmallow right away, showed the ability to delay their instant gratification, performed way better in life and obtained higher SAT scores versus the ones who couldn’t abstain eating the marshmallow.</p><h3><strong>Read this book if…</strong></h3><ul><li>You have a bad habit that you can’t quit; you are aware of it, but maybe you don’t have the willpower to do so.</li><li>You want to understand how our brains (and habits) work.</li><li>You simply enjoy reading <strong>good</strong> books. 😃</li></ul><p>📕 If I’ve made you curious about the book, go ahead and read it: <strong>The Power of Habit</strong><em>, by Charles Duhigg.</em></p><p><em>What’s your opinion on this book? What do you think about habits, in general, and the ability to change them? Are habits helpful or harmful? Share your </em>thoughts <em>in the comments below.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ebb347ffffd8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coders-do-read/the-power-of-habit-review-ebb347ffffd8">Understand and Change Your Habits</a> was originally published in <a href="https://medium.com/coders-do-read">codersDoRead 👨🏻‍💻📚</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Fanatic Badge on Stack Overflow — Part Two: Email Notification]]></title>
            <link>https://medium.com/coders-do-read/fanatic-badge-on-stack-overflow-part-two-email-notification-820f5394f8f0?source=rss-e591ea0285cc------2</link>
            <guid isPermaLink="false">https://medium.com/p/820f5394f8f0</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Alexandru Somai]]></dc:creator>
            <pubDate>Fri, 09 Mar 2018 12:28:58 GMT</pubDate>
            <atom:updated>2021-01-15T14:10:00.135Z</atom:updated>
            <content:encoded><![CDATA[<h3>Fanatic Badge on Stack Overflow — Part Two: Email Notification</h3><h4>Send automatic emails after a long period of inactivity on Stack Overflow</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*69l93AZoNGpXxz-CL_J9vw.jpeg" /></figure><p>In this step-by-step guide we’ll set-up a scheduler to notify us, via email, if we haven’t logged into Stack Overflow for at least <em>twelve hours</em>. Thus, we’ll know that something went wrong with our automatic login process, and we’ll be able to save our login streak.</p><p><em>This blog post is a continuation of the first part, in which we’ve </em><a href="https://medium.com/coders-do-read/earn-the-fanatic-badge-on-stack-overflow-828d2c46930"><em>set-up an automatic login process on Stack Overflow</em></a><em>:</em></p><p><a href="https://medium.com/coders-do-read/earn-the-fanatic-badge-on-stack-overflow-828d2c46930">Earn the Fanatic Badge on Stack Overflow</a></p><p><strong>How can we do this?</strong></p><p>We’ll use the Stack Exchange API to retrieve the last access date on Stack Overflow. If the difference between today’s date and the last access date is greater than <em>twelve hours</em>, we’ll be notified via email.</p><p><strong>The steps</strong> are the following:</p><ol><li>Obtain the Stack Exchange access token</li><li>Retrieve and validate the last access date</li><li>Send a notification email if more than <em>twelve hours</em> have passed since our access date on site</li></ol><p><strong>The complete source code is available </strong><a href="https://github.com/alexsomai/stackoverflow-fanatic-badge"><strong>here</strong></a><strong>.</strong></p><h3>Step 1. Obtain Stack Exchange access token</h3><p>First things first. To use the Stack Exchange Authentication API, you must register an application on their platform. For this, you must complete the following form: <a href="https://stackapps.com/apps/oauth/register">https://stackapps.com/apps/oauth/register</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wvuu0HjCWn42LGKGdaSJUg.png" /><figcaption>Register the Application on Stack Exchange</figcaption></figure><p><strong>Two items must be exactly </strong>the same as in the above screenshot:</p><ul><li>Set <em>OAuth Domain</em> to <strong>stackexchange.com</strong></li><li><strong>Activate</strong> the <em>Enable Client Side OAuth Flow </em>checkbox</li></ul><p>After submitting the form, you should receive a <em>Client Id </em>and a<em> Key.</em><strong><em> </em>Write these two down</strong>, because we’ll use them later when making calls to the <a href="https://api.stackexchange.com/docs/authentication">Authentication API</a>.</p><p>In our script, we’re going to use the <em>implicit OAuth 2.0 flow.</em></p><p>The first step is to open a new window at https://stackexchange.com/oauth/dialog with the query string parameters: client_id, scope and redirect_uri. We’ll make use of the requets_oauthlib; therefore, install it:</p><pre>pip install requests_oauthlib</pre><p>… and append the library to the requirements.txt file (to be able to use it on Heroku):</p><pre>...<br>requests_oauthlib==1.3.0</pre><p>In the project that we’ve created in the <a href="https://medium.com/coders-do-read/earn-the-fanatic-badge-on-stack-overflow-828d2c46930">first part</a> of this tutorial, let’s create a new file called stack_exchange_api.py. The file shall define a method called get_authorization_url(), as below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5295a3565a1e5c2a09d9ef7d16be5fc3/href">https://medium.com/media/5295a3565a1e5c2a09d9ef7d16be5fc3/href</a></iframe><p>Before running it, we must set our client_id as environment variable. You’ve got the <em>Client Id </em>after registering your app on Stack Exchange:</p><pre>$ export STACK_EXCHANGE_CLIENT_ID=&#39;3***1&#39;</pre><p>The script will print in the console output the authorization URL, needed to access to obtain your access_token. After running it:</p><pre>python3 stack_exchange_api.py</pre><p>… you should see in the console output a message like below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I8MVzOAr9e-GuATZTtQFig.png" /><figcaption>The Authorization URL on Stack Exchange</figcaption></figure><p>Access, from the browser, the URL that you got in the console output. After authorizing the application, you will be redirected to the redirect_uri, with the access_token in the <em>hash.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cxdaVc4Cv1iONW57RtzNOg.png" /><figcaption>The Access<em> Token on Stack Exchange</em></figcaption></figure><p>This is your <em>Access</em> <em>Token </em>that you’ll use in the next step. <strong>Write it down</strong>.</p><h3>Step 2. Validate the last access date</h3><h4>Retrieve user details</h4><p>Using the <em>Key</em> and the <em>Access Token</em> that we’ve got at step one, we’ll access the <a href="https://api.stackexchange.com/docs/me"><em>/me</em></a> method. For making the request programmatically, we’ll use requests lib. You know the standard procedure:</p><pre>pip install requests</pre><p>Plus the requirements.txt file:</p><pre>...<br>requests==2.20.0</pre><p>In the stack_exchange_api.py file that we’ve created above, we’ll add a new method, get_user_details(). <em>Le code</em>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8ab61579fecc85456ce294dc67d05e49/href">https://medium.com/media/8ab61579fecc85456ce294dc67d05e49/href</a></iframe><p>If we run this method, it will return (and print) a JSON containing the details of our stackoverflow <a href="https://api.stackexchange.com/docs/types/user">user</a>. The field of interest from the returned object is last_access_date. It’s the <a href="https://api.stackexchange.com/docs/dates">date</a>, expressed in <a href="https://en.wikipedia.org/wiki/Unix_time">unix epoch time</a>, when we accessed the Stack Overflow page last time.</p><p>Set the <em>Key</em> and <em>Access Token </em>as environment variables, before running the script:</p><pre>$ export STACK_EXCHANGE_KEY=&#39;j4d******************Q((&#39;<br>$ export STACK_EXCHANGE_ACCESS_TOKEN=&#39;MIe******************Q))&#39;</pre><pre>$ python3 stack_exchange_api.py</pre><h4>Validate last access date</h4><p>Next, we will create another method for validating the last_access_date. It will check whether the user has logged in for the last delta_time hours or not.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3ab5a1af3d67cf7b6d8e8f201c6dabbf/href">https://medium.com/media/3ab5a1af3d67cf7b6d8e8f201c6dabbf/href</a></iframe><p>We will call this method on a regular basis (let’s say hourly), checking if we’ve logged into Stack Overflow in the last <em>twelve hours </em>(delta_time=12). If the function returns False, we’ll trigger an email to notify us that something went wrong with the login process. All these in the <strong>next step.</strong></p><h3>Step 3. Email notification</h3><p>We will use <a href="https://elements.heroku.com/addons/sendgrid">SendGrid</a> to send emails from the Heroku platform.</p><blockquote><a href="https://elements.heroku.com/addons/sendgrid">SendGrid</a> is an <a href="https://elements.heroku.com/addons">add-on</a> for providing scalable email delivery and analytics for apps.</blockquote><p>In the working directory, firstly <a href="https://devcenter.heroku.com/articles/sendgrid#provisioning-the-add-on">install the add-on</a>:</p><pre>$ heroku addons:create sendgrid:starter</pre><p>Next, obtain a SendGrid API key. Follow the steps documented here: <a href="https://devcenter.heroku.com/articles/sendgrid#obtaining-an-api-key">https://devcenter.heroku.com/articles/sendgrid#obtaining-an-api-key</a>.</p><p>After you’ve got the API key, you have to set it as environment variable:</p><pre>$ heroku config:set SENDGRID_API_KEY=xxxx_api_key_xxxx</pre><p>In the working directory, install the sendgrid library. Note that sendgrid requires the dependency python-http-client , so let’s install that one, as well:</p><pre>$ pip install sendgrid<br>$ pip install python-http-client</pre><p>… and the dependencies to the requirements.txt file:</p><pre>...<br>sendgrid==6.3.1<br>python-http-client==3.2.7</pre><p>In our project, we’ll create a new helper class that will provide a basic API to send emails: send_email(subject, content). Let’s create a new file sendgrid_helper.py, with the following implementation:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/29ac66f647f81352bdab1dc1898ec1ae/href">https://medium.com/media/29ac66f647f81352bdab1dc1898ec1ae/href</a></iframe><p>The above, will send a notification to our Stack Overflow email.</p><p>The final touch: write a <em>new</em> <em>hourly</em> scheduler that will verify if we’ve logged into Stack Overflow. If we haven’t logged in for at least <em>twelve hours, </em>it will notify us via email:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/28f826edb3e370d90455a30f59b0c7e0/href">https://medium.com/media/28f826edb3e370d90455a30f59b0c7e0/href</a></iframe><p>It’s a wrap! Push the code to Heroku and we’re done!</p><pre>$ git add .<br>$ git commit -m &quot;Deploy to Heroku - part two&quot;<br>$ git push heroku master</pre><p>This blog post is an improvement to the <a href="https://medium.com/coders-do-read/earn-the-fanatic-badge-on-stack-overflow-828d2c46930">first part</a>, where we’ve set-up a basic automatic login process into Stack Overflow. If we haven’t logged into Stack Overflow for at least <em>twelve hours</em>, we’ll retrieve an email notification knowing that something went wrong.</p><p><em>If you’ve found this guide useful, or if you have any questions or suggestions, let me know in the comments below. Any improvements to the source code are welcomed </em><a href="https://github.com/alexsomai/stackoverflow-fanatic-badge"><em>here</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=820f5394f8f0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coders-do-read/fanatic-badge-on-stack-overflow-part-two-email-notification-820f5394f8f0">Fanatic Badge on Stack Overflow — Part Two: Email Notification</a> was originally published in <a href="https://medium.com/coders-do-read">codersDoRead 👨🏻‍💻📚</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Earn the Fanatic Badge on Stack Overflow]]></title>
            <link>https://medium.com/coders-do-read/earn-the-fanatic-badge-on-stack-overflow-828d2c46930?source=rss-e591ea0285cc------2</link>
            <guid isPermaLink="false">https://medium.com/p/828d2c46930</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Alexandru Somai]]></dc:creator>
            <pubDate>Sun, 04 Feb 2018 10:24:28 GMT</pubDate>
            <atom:updated>2021-01-15T14:08:13.930Z</atom:updated>
            <content:encoded><![CDATA[<h4>A step-by-step guide to schedule automatic logins with Heroku</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0pY_6oCiHZ_eLh0vfg5rDA.jpeg" /></figure><p>In the following post I’ll show you how to deploy a <strong>Python</strong> <strong>script</strong> to <strong>Heroku</strong> that performs <strong>automatic logins </strong>on <strong>stackoverflow.com</strong> on a regular basis, so that you can earn the Fanatic badge, effortlessly.</p><p>If you’re an avid programmer, and a stack overflow user, as well, most probably you know about the <a href="https://stackoverflow.com/help/badges/83/fanatic">Fanatic</a> badge. To earn it, you must:</p><blockquote>Visit the site each day for 100 consecutive days. (Days are counted in <a href="http://en.wikipedia.org/wiki/Coordinated_Universal_Time">UTC</a>.)</blockquote><p>Have you ever struggled to earn it? Did you had a <em>login streak of 67 days,</em> and on the 68<em>th</em> you went on a trip and <strong>forgot to login? </strong>Then you had to start all over again.</p><p>Instead of this, let’s do what every <strong>lazy </strong>programmers does. Automate. Automate everything.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*A_uAt1yXVaA9HtQTTbtIwg.jpeg" /></figure><p>We can achieve this in <strong>three easy steps:</strong></p><ol><li>Write the script that logs into stack overflow</li><li>Schedule the script</li><li>Deploy everything to Heroku</li></ol><p>“But wait, I don’t want to follow your boring steps, just show me the code!”</p><p>Sure, <strong>the complete source code is available </strong><a href="https://github.com/alexsomai/stackoverflow-fanatic-badge"><strong>here</strong></a><strong>.</strong></p><p>If you still want to go through the steps, let’s kick off!</p><h3>Step 1. Write the script</h3><p>The easy part — writing the script that logs into stack overflow.</p><p>Before writing and running the script, we need some <strong>prerequisites</strong>:</p><ul><li><a href="https://www.python.org/downloads/">Python 3.6</a>+ (along with pip) installed</li><li>a browser of choice installed (we’ll use <strong>Chrome</strong> for this example)</li><li>the selenium driver for the used browser (in this case, <strong>ChromeDriver</strong>). You can download the latest from here <a href="https://sites.google.com/a/chromium.org/chromedriver/downloads">https://sites.google.com/a/chromium.org/chromedriver/downloads</a>. After you unzip it, for convenience, on <em>unix</em>, you should place the <em>chromedriver</em> file under /usr/local/bin/</li><li>and because we’ll use Selenium, install the Python dependencies: pip install selenium</li></ul><p>Firstly, we’ll create a project directory called <em>so-fanatic-badge-your-name </em>(for later on, when we deploy it to Heroku, I suggest you to have a unique name for the directory).</p><p>In our project directory, let’s create a file called stack_overflow_page.py in which we’ll define a method for logging on stack overflow.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2512a5fca067f46a73f1764994d0ffed/href">https://medium.com/media/2512a5fca067f46a73f1764994d0ffed/href</a></iframe><p>The above code should be quite easy to follow. After it instantiates the driver (<em>line 9</em>), it accesses the stackoverflow.com page, follows the ‘Log in’ link, fills in the email and password that are taken from environment variables and submits the form. After successfully logging in, it goes to ‘My Profile’ page and checks if the display name matches with the given environment variable.</p><p>Before running the script, we firstly need to set our local environment variables. Will be useful later, when we run the script on the Heroku platform.</p><pre>$ export STACK_OVERFLOW_EMAIL=&#39;your_stackoverflow_email&#39;<br>$ export STACK_OVERFLOW_PASSWORD=&#39;your_stackoverflow_password&#39;<br>$ export STACK_OVERFLOW_DISPLAY_NAME=&#39;Your Display Name&#39;</pre><p>In the same terminal window, run the script:</p><pre>$ python3 stack_overflow_page.py</pre><p>You should see the Chrome browser opening and performing the login action.</p><h3>Step 2. Schedule the script</h3><p>Scheduling the easy part - run the script on a regular basis.</p><p>After we’ve managed to login into stack overflow page using the script from step one, we’ll schedule it to run on a regular basis.</p><p>For scheduling it, we’re going to use a lightweight library, <em>APScheduler</em>. Firstly, install it with pip:</p><pre>$ pip install apscheduler</pre><p>In our project that we’ve created at step one, let’s create a new file, clock.py, in which we define our schedule:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c436a3c5a09c80c4282482488e946dbd/href">https://medium.com/media/c436a3c5a09c80c4282482488e946dbd/href</a></iframe><p>We’ve configured the APScheduler to invoke the login method defined in our stack_overflow_page.py file every hour. The scheduling interval <em>(line 8)</em> may be customized, as shown in the <a href="http://apscheduler.readthedocs.io/en/3.0/userguide.html">APScheduler documentation</a>, but for simplicity (and because selenium may fail from time to time) we’ll run it hourly.</p><p>To run the scheduler locally, simply run:</p><pre>$ python3 clock.py</pre><p>In our example, the scheduler will access, hourly, the stack overflow site.</p><h3>Step 3. Deploy to Heroku</h3><p>The tricky part — deploying everything to Heroku.</p><p>For the final step, we need a few more dependencies installed:</p><ul><li>Heroku CLI — Heroku Dev Center offers details how to <a href="https://devcenter.heroku.com/articles/heroku-cli#download-and-install">download and install it</a></li><li>and <a href="https://git-scm.com/downloads">Git</a> — for pushing our code to Heroku</li></ul><p>After you’ve installed the Heroku CLI, perform the login heroku login and provide your Heroku credentials.</p><p>Into our project directory created at step one, that is <em>so-fanatic-badge-your-name, </em>we have to initialize an empty git repository and to create the heroku application, with the built-in <em>buildpack</em>, python.</p><pre>$ git init <br>$ heroku create <em>so-fanatic-badge-your-name </em>--buildpack heroku/python</pre><p>To be able to run the application on the Heroku stack, we have to install Chrome and chromedriver, as well. For this, we’ll define two <em>buildpacks </em>within our application<em>:</em></p><pre>$ heroku buildpacks:add https://github.com/heroku/heroku-buildpack-google-chrome<br>$ heroku buildpacks:add https://github.com/heroku/heroku-buildpack-chromedriver.git</pre><p>We also have to make a minor change to the webdriver initialization. In stack_overflow_page.py file, when we initialize the <em>webdriver</em>, we have to install the chrome driver manager. You might also need to install the webdriver_manager dependency:</p><pre>$ pip install webdriver_manager</pre><p>The changed lines of code are like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ba321ac755ca773a8fd0ced134893b99/href">https://medium.com/media/ba321ac755ca773a8fd0ced134893b99/href</a></iframe><p><em>Note: At the time of writing, the applications were created using heroku-16 stack. For different heroku stacks, the buildpacks and configs may be slightly different.</em></p><p>If you remember from the first step, before actually running the login script, we had to define locally a few environment variables. We have to define them also in the Heroku environment:</p><pre>$ heroku config:set STACK_OVERFLOW_EMAIL=&#39;your_stackoverflow_email&#39;<br>$ heroku config:set STACK_OVERFLOW_PASSWORD=&#39;your_stackoverflow_pass&#39;<br>$ heroku config:set STACK_OVERFLOW_DISPLAY_NAME=&#39;Your Display Name&#39;</pre><p>We’re close to deploying our application to Heroku, a couple more files to be added and we’re done.</p><p>We have to create a new file called requirements.txt. This file will be used by Heroku to install our python dependencies. The file contains the following lines:</p><pre>APScheduler==3.6.3<br>selenium==3.8.1<br>webdriver_manager==3.1.0</pre><p>Last, but not least, we must define the Procfile(the name must be exactly like this). <a href="https://devcenter.heroku.com/articles/procfile">Procfile</a> it’s a mechanism for declaring what commands are run by your application’s <a href="https://devcenter.heroku.com/articles/dynos">dynos</a> on the Heroku platform:</p><pre>clock: python3 clock.py</pre><p>In the Procfile, we’ve defined a process called <em>clock</em>, that will run our scheduler.</p><p>The final touch consists in pushing our application code to Heroku repository:</p><pre>$ git add .<br>$ git commit -m &quot;Deploy to Heroku&quot;<br>$ git push heroku master</pre><p>You should see many console output logs until the required dependencies are installed on the Heroku platform. After completion, we need to scale our dyno formation:</p><pre>$ heroku ps:scale clock=1</pre><p>You can view the Heroku logs by simply typing heroku logs --tail. They should print that you’ve successfully logged into stack overflow site.</p><p>And that’s it! After 100 days, you’ll earn the Fanatic badge without doing anything else.</p><p>I hope that this blog post has helped you to easily achieve the Fanatic badge on stack overflow.</p><p>I’m planning to write a second part, in which we’ll use the Stack Exchange API to retrieve the last time we’ve accessed the stack overflow site. If the date is below a specific threshold (for example twelve hours), we’ll be notified via email, therefore we know that something went wrong with the login script.</p><p><strong>Update: </strong>I’ve written a second part, in which we are notified by email in case we don’t login into Stack Overflow for more than <em>twelve hours.</em></p><p><a href="https://medium.com/coders-do-read/fanatic-badge-on-stack-overflow-part-two-email-notification-820f5394f8f0">Fanatic Badge on Stack Overflow — Part Two: Email Notification</a></p><p><em>If you’ve found this guide useful, or if you have any questions or suggestions, let me know in the comments below. Any improvements to the source code are welcomed </em><a href="https://github.com/alexsomai/stackoverflow-fanatic-badge"><em>here</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=828d2c46930" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coders-do-read/earn-the-fanatic-badge-on-stack-overflow-828d2c46930">Earn the Fanatic Badge on Stack Overflow</a> was originally published in <a href="https://medium.com/coders-do-read">codersDoRead 👨🏻‍💻📚</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>