<?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 Marcin Hagmajer on Medium]]></title>
        <description><![CDATA[Stories by Marcin Hagmajer on Medium]]></description>
        <link>https://medium.com/@mhagmajer?source=rss-42812af88590------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*kcB06VFIodbyD0LBp4sSVA.jpeg</url>
            <title>Stories by Marcin Hagmajer on Medium</title>
            <link>https://medium.com/@mhagmajer?source=rss-42812af88590------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 05:15:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mhagmajer/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[Easiest way to create GraphQL API for a TypeScript module]]></title>
            <link>https://medium.com/xfaang/easiest-way-to-create-graphql-api-for-a-typescript-module-756783e76c40?source=rss-42812af88590------2</link>
            <guid isPermaLink="false">https://medium.com/p/756783e76c40</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[graphql]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[Marcin Hagmajer]]></dc:creator>
            <pubDate>Sun, 10 Jan 2021 20:07:32 GMT</pubDate>
            <atom:updated>2021-01-18T09:07:20.197Z</atom:updated>
            <content:encoded><![CDATA[<p>GraphQL is a popular API query language that offers more structured, performant and secure ways of accessing data from other services than REST. It requires the server to define a schema that lists all types of data available for clients of the API.</p><p>When building a GraphQL server to allow access to a TypeScript module, one needs to make sure that the types in GraphQL schema reflect accurately what data is expected. Let’s take a look at the following example of a simple bookstore module.</p><h4>Defining bookstore module</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/30cb696b22e61c5a174a17bb1a418e6a/href">https://medium.com/media/30cb696b22e61c5a174a17bb1a418e6a/href</a></iframe><p>We use a custom type alias int here to indicate that the given properties are integers rather than using the generic JavaScript number.</p><p>Here is a simple database for our bookstore:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/df0aeaa42f3b9b90b93132f972242f45/href">https://medium.com/media/df0aeaa42f3b9b90b93132f972242f45/href</a></iframe><p>The functions below allow reading data from the bookstore:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/84dc20b6ff01d97dcf00466b4652a794/href">https://medium.com/media/84dc20b6ff01d97dcf00466b4652a794/href</a></iframe><p>In order to make these functions available in GraphQL, we need to define a GraphQL schema. Let’s compare a few ways of doing this.</p><h4>The native way (~60 lines of code)</h4><p>The GraphQL implementation in JavaScript comes with theGraphQLSchema class which can be used as follows to define the schema.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/873be1fe207a781bb24eb0fa80628be1/href">https://medium.com/media/873be1fe207a781bb24eb0fa80628be1/href</a></iframe><h4>The TypeGraphQL way (~70 lines of code)</h4><p><a href="https://typegraphql.com/">TypeGraphQL</a> is a quite popular solution for creating GraphQL schemas integrated with TypeScript. It depends on decorators, so make sure you have experimentalDecorators turned on in your config file if you wish to use it. Here is how it works in our case.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f9b1f2fc09d61243339c3b517af1c3b2/href">https://medium.com/media/f9b1f2fc09d61243339c3b517af1c3b2/href</a></iframe><h4>Previewing GraphQL schema</h4><p>Having theschema object defined we can use the GraphiQL tool included in express-graphql package to preview the server:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c0508c8760a1b0119354f8e245808494/href">https://medium.com/media/c0508c8760a1b0119354f8e245808494/href</a></iframe><p>Here’s the result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h4hlQ9EaRSvbZWKufLDl6w.png" /></figure><p>As you can see, to define GraphQL schema that accurately reflects the bookstore module <strong>we had to repeat all the type and resolver information</strong> in a way that GraphQL could understand. This form of code repetition is undesirable because it is tedious and error prone. For example, TypeScript won’t be able to check if the GraphQL types you provided are correct.</p><h4>The easy way (~20 lines of code)</h4><p>At <a href="https://xfaang.com/">xFAANG</a> we like finding solutions to problems like this to empower developers to spend more time writing meaningful code. If your module is already written in TypeScript it’s possible to look into its definitions and derive from them what GraphQL types need to be used. We have created <a href="https://www.npmjs.com/package/typescript-graphql">typescript-graphql</a> package that does that automatically!</p><p>When using the package, you first need to export Query object that includes top level resolvers for read-only access or Mutation object for mutating resolvers (if you have any). You may also export additional objects that include field resolvers for your object types. Any additional values exported from the module are ignored.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7445ce77bb06a2fe346fe44ac2cf9c59/href">https://medium.com/media/7445ce77bb06a2fe346fe44ac2cf9c59/href</a></iframe><p>Secondly, you need to provide the absolute path to the module you wish to expose in GraphQL:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7b32c581d59c90661436741e0fc0a85d/href">https://medium.com/media/7b32c581d59c90661436741e0fc0a85d/href</a></iframe><p>Also, if your build phase includes compilation of TypeScript into JavaScript with tsc, you also need to run npx tsgc on any modules that you wish to expose with GraphQL.</p><pre>npx tsgc bookstore.ts</pre><p>This will create bookstore.graphql.json file in your outDir that includes type information necessary to generate schema at runtime. That’s it! <strong>You just saved yourself writing and maintaining a lot of GraphQL code</strong>.</p><p>At the time of writing this article, <a href="https://www.npmjs.com/package/typescript-graphql">typescript-graphql</a> is published in a proof-of-concept alpha version as an open source project licensed under MIT. We’re looking forward to hearing feedback from you both in comments and <a href="https://github.com/xFAANG/typescript-graphql">the repository</a>! Please clap 👏 if you liked the article.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=756783e76c40" width="1" height="1" alt=""><hr><p><a href="https://medium.com/xfaang/easiest-way-to-create-graphql-api-for-a-typescript-module-756783e76c40">Easiest way to create GraphQL API for a TypeScript module</a> was originally published in <a href="https://medium.com/xfaang">Xfaang</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An easy way to write stateful React components]]></title>
            <link>https://medium.com/react-rangers/an-easy-way-to-write-stateful-react-components-f210f253f520?source=rss-42812af88590------2</link>
            <guid isPermaLink="false">https://medium.com/p/f210f253f520</guid>
            <category><![CDATA[redux]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[mobx]]></category>
            <category><![CDATA[flux]]></category>
            <dc:creator><![CDATA[Marcin Hagmajer]]></dc:creator>
            <pubDate>Wed, 10 Oct 2018 16:26:59 GMT</pubDate>
            <atom:updated>2018-10-13T17:43:37.802Z</atom:updated>
            <content:encoded><![CDATA[<h4>Introducing <a href="https://www.npmjs.com/package/@react-rangers/stateful">the stateful package</a> to overcome the limitations of setState</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*g-QIQZFIHGFXItfL" /><figcaption>“orange cupcakes” by <a href="https://unsplash.com/@rodolfomarques?utm_source=medium&amp;utm_medium=referral">Rodolfo Marques</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>React is an innovative UI library that lets you create the most complex dynamic view by only specifying how it looks for the given data. You don’t ever need to worry about the transitions to accommodate the mutation of parameters which is a <strong>milestone</strong> in front-end development. Every React component can either only react to the properties (props) assigned to it by the outside world or also carry some mutable information (state) itself.</p><p>The way React deals with the state as of version 16 has certain limitations. Every piece of application state must be managed by a component and there is no way for other components to access it unless they are passed the information in props. There are some popular third party libraries and architectures to mitigate this, however, something this simple <strong>should not require a complex solution</strong>.</p><p>Developers also need to write their component as a class if they want to use state. Let’s take a look at a simple application with a counter:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/21cc3ec46ea8b4003eb2ba432cdf2125/href">https://medium.com/media/21cc3ec46ea8b4003eb2ba432cdf2125/href</a></iframe><p>Here’s the same application using the <a href="https://www.npmjs.com/package/@react-rangers/stateful">stateful package</a>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6ee27abaf61320b0e0ddd50d902fa3d4/href">https://medium.com/media/6ee27abaf61320b0e0ddd50d902fa3d4/href</a></iframe><p>You can now just wrap any part of your application in a Stateful component, to make it respond to state changes. In the initialState property you can pass a JavaScript object representing the initial state for that section. Then you just need to provide the implementation in children specifying how this part of application should respond to any changes to its state. If you wish to change any property of state, you <strong>can just assign a new value</strong> to it and your view will update. It’s that simple.</p><p><em>Behind the scenes, your initial state is changed into a watchable object using a technique inspired by </em><a href="https://docs.meteor.com/api/tracker.html"><em>Meteor’s reactive system</em></a><em>. Thanks to JavaScript property accessors this is completely transparent to a developer. Basically this sort of magic is only possible due to single-threaded processing of JavaScript runtime.</em></p><p>Actually, your components can now respond to <strong>any watchable data</strong> even outside of components— not only the one that was passed into initialState. This makes <strong>relying on global state</strong> a breeze:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/67639b3abd6e2f551a7d16249f1a085b/href">https://medium.com/media/67639b3abd6e2f551a7d16249f1a085b/href</a></iframe><p>You can easily compose stateful parts of your application the way you like. The component below has two parts that update <strong>independently of each other for best performance</strong>. The compute property, which is the function used for tracking data changes, gets called with a single argument — a dictionary including all information needed to compute the data for the given component. Whatever it returns will be passed into the children function.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9c8ab33b34e55c1fc26a0399bba79490/href">https://medium.com/media/9c8ab33b34e55c1fc26a0399bba79490/href</a></iframe><p>State management doesn’t require class components anymore! You still need classes though if you have to respond to lifecycle events. <strong>However, that should be much easier now when you only need to worry about changes to </strong><strong>props</strong>.</p><p>Please find the <a href="https://github.com/ReactRangers/stateful">complete source code for the stateful package at GitHub</a>. We believe that by stopping requiring people to write classes to build a simple website, we can attract more people towards React development. Contributions are welcome! ❤️</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f210f253f520" width="1" height="1" alt=""><hr><p><a href="https://medium.com/react-rangers/an-easy-way-to-write-stateful-react-components-f210f253f520">An easy way to write stateful React components</a> was originally published in <a href="https://medium.com/react-rangers">React Rangers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implementing snake  in React]]></title>
            <link>https://medium.com/react-rangers/implementing-snake-in-react-a74300a357d3?source=rss-42812af88590------2</link>
            <guid isPermaLink="false">https://medium.com/p/a74300a357d3</guid>
            <category><![CDATA[svg]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Marcin Hagmajer]]></dc:creator>
            <pubDate>Tue, 09 Oct 2018 19:07:35 GMT</pubDate>
            <atom:updated>2018-10-09T19:07:35.037Z</atom:updated>
            <content:encoded><![CDATA[<h4>Recreating a classic mobile game in modern technologies</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*bYGwPvyTmMKmwOCAdknoxw.gif" /><figcaption>Play at: <a href="https://reactrangers.github.io/snake/">https://reactrangers.github.io/snake/</a></figcaption></figure><p>React is a solution for building graphical user interfaces that makes it easy to render any kind of a dynamic view. To illustrate this idea better, we’ll guide you step by step through the process of creating our own version of the game that many have once enjoyed.</p><h4>Groundwork</h4><p>We are going to write code in JavaScript and you will need <a href="https://nodejs.org/en/">the latest stable version of the Node.js, a popular runtime for JavaScript programs</a>. The game itself will run in a browser (another JavaScript runtime), yet its development tools require Node.js.</p><p>To get off to a good start, we’ll use <a href="https://github.com/facebook/create-react-app">create-react-app</a>, a command line tool which offers a convenient environment to work on a new React project.</p><pre>npx create-react-app snake<br>cd snake<br>npm start</pre><p>This will start a local development server available at <a href="http://localhost:3000/">http://localhost:3000/</a> on your computer that will automatically refresh whenever we make changes to the app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SR_opz06HSJuzqG1llNb7A.png" /></figure><h4>Board</h4><p>Websites are built with different HTML elements such us p, div, a, table. Probably the ones best suited for the job are those used for displaying images in <a href="http://Scalable Vector Graphics">Scalable Vector Grapics</a> format.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FHd2w0U_7vP0ZUY7Nx3GPA.png" /><figcaption>Cherries made by <a href="https://www.flaticon.com/authors/smashicons">Smashicons</a> from <a href="http://www.flaticon.com/">www.flaticon.com</a></figcaption></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/20f1c0b9327301996d665ac343570eea/href">https://medium.com/media/20f1c0b9327301996d665ac343570eea/href</a></iframe><p>The goal of the game is to grow the snake (i.e. number of its segments) by directing its head so that it eats as many fruits as possible while not biting its own tail. We’ll use the following collidesWith method to detect collisions:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a614e4ae563a91a77c8d69e133b3db1d/href">https://medium.com/media/a614e4ae563a91a77c8d69e133b3db1d/href</a></iframe><p>Properties x, y are the coordinates of the centre of an object in the game (such as a snake’s segment or a fruit) and r is the radius of the circle that best approximates its shape.</p><h4>State</h4><p>We’re now going to leverage mutable state to make the game respond to user’s action. Here’s what we’ll need to keep track of and update throughout the game:</p><ul><li>fruits — an array of SnakeObject objects representing fruits</li><li>segments — an array of SnakeObject objects representing snake segments ordered by their distance from the head which is the first element</li><li>direction — a direction in which the snake’s head is currently moving (angle between its direction and “up”),</li><li>trail — a list of vectors representing snake’s trail starting from its head</li><li>running — a boolean flag denoting whether the game is currently running</li><li>time — a amount of time that has passed since the start of the game</li><li>growth — a number of segments that the snake will grow in the following turns (one by one)</li></ul><h4>Ruleset</h4><p>Success of the player depends on the choices she or he makes. Every turn (i.e. once another unit of time passes) the state of the game will transform according to the following ruleset:</p><ul><li>snakeMoves snake’s head moves by its length in the direction set by the player</li><li>fruitsDrop a new fruit may appear in a place that doesn’t collide with any other fruit or the snake</li><li>snakeEats any fruit colliding with snake’s head gets eaten and disappears increasing snake’s growth potential</li><li>snakeGrows snake grows by one if it has eaten another fruit</li><li>fruitsAge fruits age and those not eaten for too long will disappear</li><li>noCrossing the game will stop if snake’s head crosses its body</li></ul><p>All these rules will be implemented as functions taking state and props as arguments and returning the transformed state.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7f6cfdb2f7e51cb83189ac8ab31b953d/href">https://medium.com/media/7f6cfdb2f7e51cb83189ac8ab31b953d/href</a></iframe><h4>Putting it all together</h4><p>Every animation frame, we’ll update the state according to the ruleset above.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f9f8d1c38e835644ca5c1a98b23d02c7/href">https://medium.com/media/f9f8d1c38e835644ca5c1a98b23d02c7/href</a></iframe><p><a href="https://github.com/ReactRangers/snake">You can find the complete code for working game on our GitHub</a>. Feel free to fork the repository and add your own rules! Let us know how you liked this article in the comments below.</p><p><em>Shoutout to some very bright attendees of a </em><a href="https://warsawjs.com/workshops"><em>WarsawJS</em></a><em> workshop on Oct 7th, 2018 who spent whole day practising React while implementing this game while being mentored by </em><a href="https://medium.com/u/4750783a224e"><em>Konrad Kowalski</em></a><em> and me! </em><a href="https://github.com/search?q=warsawjs-workshop-25-snake"><em>You can find their work on GitHub as well</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a74300a357d3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/react-rangers/implementing-snake-in-react-a74300a357d3">Implementing snake 🐍 in React</a> was originally published in <a href="https://medium.com/react-rangers">React Rangers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The three heroes of startups]]></title>
            <link>https://medium.com/hagmajer/the-three-heroes-of-startups-d413791f81cb?source=rss-42812af88590------2</link>
            <guid isPermaLink="false">https://medium.com/p/d413791f81cb</guid>
            <category><![CDATA[investing]]></category>
            <category><![CDATA[entrepreneurship]]></category>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[business]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Marcin Hagmajer]]></dc:creator>
            <pubDate>Sat, 03 Jun 2017 18:10:15 GMT</pubDate>
            <atom:updated>2017-06-06T23:08:19.265Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Pf2XUgufOQbBH6e2FtguDg.jpeg" /></figure><h4>Explaining the difference between startups and traditional businesses and the heroic work needed to succeed in this world.</h4><p>Startup is a business. People do business to make money.</p><p>Traditional businesses have solid understanding of what they do, how they do it and who buys from them. If you look at barbershops for example, it’s pretty much the same everywhere — they cut hair with scissors of people who walk in. That means, if you open one yourself, you just need to be a decent hard-working barber to get customers and revenue.</p><p>Startups are nothing like that, though. They’re built around vague high-tech product ideas, not necessarily proven business models. Innovation comes with startups, yet people pay money not for what is cool but for what they really need. This brings up the three big unknowns to the founders team:</p><ol><li>Who will buy our product?</li><li>How do we develop it efficiently?</li><li>What is the best way to acquire customers?</li></ol><p>Each of these areas individually require full-time heroic work. That’s why every startup needs the following three people accordingly.</p><h4>The visionary</h4><p>This is the one who understands dynamics of the given market and envisions the mission and positioning of a new company. They must have vivid imagination to foresee the future, yet both feet on the ground to plan realistically. The best case scenario is to bring an industry veteran on board for this role.</p><p>Guiding a recent venture requires constant weighing of upsides and challenges to lay out the right way forward. The visionary does market research, collects customer feedback and makes strategy pivots to keep the business sound. This involves strict financial discipline and precise accounting.</p><p>Such people need to maintain the global perspective and usually don’t get too involved in the operations. Being the creative genius rarely goes hand in hand with remarkable sales skills.</p><h4>The hacker</h4><p>Programming tools don’t keep up with the demand for technology. There has to be someone in the team who will architect the software in such a way that it is easy to maintain and develop. The essence of startups is that the requirements for products are adjusted based on market responses. Good architecture allows this to be done within budget.</p><p>A person like this, given the choice between two front-end technologies like Angular and React, will be able to confidently say React even before it becomes popular. They also set up means to assure code quality such as linting, static analysis, unit tests and continuous integration.</p><h4>The rainmaker</h4><p>That’s the one who is the living sales machine and actually makes money for the company. The rainmaker carries out the plan made by the visionary. They must be outgoing, well connected and equipped with high social skills.</p><p>Rainmakers do a lot of traveling and hotels, their job is not in the office. They have to be caring to the prospects they meet. People appreciate if someone steps out of their way to find out about their needs and help them. This is what sparks the best form of advertising — recommendation.</p><p>In the best scenario, there are ways to extend their effort with automated tools such us call centres or mailing. Rainmakers constantly think of options to reach more potential customers. They’re supposed to make as many people fall in love with the product as possible.</p><h4>Conclusion</h4><p>While it’s possible for one or two people to have all the traits above, it’s about the work needed in these areas, not only the qualities. All three people must eat, sleep and breathe the company. That’s why the best remuneration for all is equity. In case of the rainmaker, given the nature of the job, it often makes sense to also include equity options or commission to incentivize even greater results. They all should also have excellent leadership skills or be willing to develop them.</p><p>Hard work alone doesn’t go a long way in startups. Heroic work needs to be done in the three areas in order to succeed. In startups, you don’t just do business, you create it. You need to find out a new set of ingredients vital to business: what to sell, to whom and how. And don’t worry about the smaller details. Once the main cogs start to spin, everything becomes easier. Profits solve most of startup problems.</p><p>However, if you’re just hoping for the easy money, don’t do it. If you want to make a change in the world and make money in the process, then startups are something to consider.</p><p>If you liked this article, please hit the recommend button ❤ and share to let more people see it!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d413791f81cb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hagmajer/the-three-heroes-of-startups-d413791f81cb">The three heroes of startups</a> was originally published in <a href="https://medium.com/hagmajer">Hagmajer Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Speaking engagements]]></title>
            <link>https://medium.com/hagmajer/speaking-engagements-9becee68640a?source=rss-42812af88590------2</link>
            <guid isPermaLink="false">https://medium.com/p/9becee68640a</guid>
            <category><![CDATA[conference]]></category>
            <category><![CDATA[speakers]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[public-speaking]]></category>
            <dc:creator><![CDATA[Marcin Hagmajer]]></dc:creator>
            <pubDate>Sun, 28 May 2017 21:21:54 GMT</pubDate>
            <atom:updated>2018-12-05T20:24:35.347Z</atom:updated>
            <content:encoded><![CDATA[<p>I regularly speak at conferences in Poland and abroad. If you’d like to see me at your event, please send me an email at info@hagmajer.com.</p><p>I gladly talk about everything you can read on my blog including: JavaScript, React, Meteor, Node.js and MongoDB and business.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z-9YLI89T0sT8NwXJStNjQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UbKuAIrpEiWBRaHth4Ixww.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YOnL8YXsh2RZXk9k02krag.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6Pb8vq757vazeY2Dklws3g.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PaeHAwqsXS2jZ9nS8G0HfA.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6gp_DEgt9vIx_M5wsJJv2w.jpeg" /></figure><h4>Upcoming events</h4><ul><li>TBA</li></ul><h4>Past events</h4><ul><li><a href="https://speakerdeck.com/mhagmajer/why-well-all-use-react-hooks">Why we’ll all use React hooks</a> , <a href="https://frontend-con.io/">FrontEndCon</a>, Warsaw (Poland), December 4th 2018</li><li><a href="https://youtu.be/G6PCJycpgVs"><em>Dlaczego warto robić front-end w Reactcie?</em></a>, <a href="https://careercon.pl/konferencja/kariera-it-warszawa-29-09-2018/">Kariera IT</a>, Warsaw (Poland), September 29th 2018</li><li><a href="https://youtu.be/G6PCJycpgVs"><em>Dlaczego warto robić front-end w Reactcie?</em></a>, <a href="http://itcareersummit.pl/wawa/">IT Carreer Summit</a>, Warsaw (Poland), September 20th 2018</li><li><a href="https://www.codeeurope.pl/en/speakers/marcin-hagmajer#t-warszawa-managing-asynchronous-code-in-javascript-3450"><em>Managing asynchronous code in JavaScript</em></a><em>, Code Europe, Poznan (Poland), June 12th 2018</em></li><li>7 most common mistakes of React developers, <a href="http://careercon.pl/konferencja/kariera-it-krakow-09-06-2018/">Kariera IT</a>, Cracow (Poland), June 9th 2018</li><li><a href="https://www.codeeurope.pl/en/speakers/marcin-hagmajer#t-warszawa-managing-asynchronous-code-in-javascript-3450"><em>Managing asynchronous code in JavaScript</em></a><em>, Code Europe, Cracow (Poland), May 8th 2018</em></li><li><a href="https://www.codeeurope.pl/en/speakers/marcin-hagmajer#t-warszawa-managing-asynchronous-code-in-javascript-3450"><em>Managing asynchronous code in JavaScript</em></a><em>, Code Europe, Wroclaw (Poland), April 26th 2018</em></li><li><a href="https://www.codeeurope.pl/en/speakers/marcin-hagmajer#t-warszawa-managing-asynchronous-code-in-javascript-3450"><em>Managing asynchronous code in JavaScript</em></a><em>, Code Europe, Warsaw (Poland), April 24th 2018</em></li><li><em>Multi-document transactions in MongoDB</em>, <a href="http://careercon.pl/konferencja/kariera-it-warszawa-24-03-2018/">Kariera IT</a>, Warsaw (Poland), March 24th 2017</li><li>Panel discussion at <a href="https://www.facebook.com/events/1335987766438712/">WarsawJS Meetup #34</a>, Warsaw (Poland), June 14th 2017</li><li><em>Meteor — complete applications in JavaScript</em>, <a href="https://www.codeeurope.pl/en/speakers/marcin-hagmajer">Code Europe</a>, Warsaw (Poland), May 25th 2017</li><li><em>Meteor — complete applications in JavaScript</em>, <a href="https://www.codeeurope.pl/en/speakers/marcin-hagmajer">Code Europe</a>, Wroclaw (Poland), May 23rd 2017</li><li>Mentor at WarsawJS Workshop #6 — Meteor, Warsaw (Poland), May 21st 2017</li><li><em>Introduction to React, </em><a href="https://www.facebook.com/events/1403814556345999/">Meet.js Warszawa #23</a>, Warsaw (Poland), April 27th 2017</li><li><em>Meteor — complete applications in JavaScript</em>, <a href="https://www.codeeurope.pl/en/speakers/marcin-hagmajer">Code Europe</a>, Cracow (Poland), April 26th 2017</li><li><em>React as the basic front-end tool</em>, <a href="http://careercon.pl/konferencja/kariera-it-warszawa-11-03-2017/">Kariera IT</a>, Warsaw (Poland), March 11th 2017</li><li><em>Introduction to JavaScript</em>, <a href="http://careercon.pl/konferencja/kariera-it-warszawa-01-10-2016/">Kariera IT</a>, Warsaw (Poland), October 1st 2016</li><li><em>Rapid prototyping with Parse</em>, <a href="http://www.2014.mobiconf.org/speakers.html#Marcin_Hagmajer">Mobiconf 2014</a>, Cracow (Poland), October 3rd 2014</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9becee68640a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hagmajer/speaking-engagements-9becee68640a">Speaking engagements</a> was originally published in <a href="https://medium.com/hagmajer">Hagmajer Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Talk: Meteor — complete applications in JavaScript]]></title>
            <link>https://medium.com/hagmajer/talk-meteor-complete-applications-in-javascript-b539ece8d127?source=rss-42812af88590------2</link>
            <guid isPermaLink="false">https://medium.com/p/b539ece8d127</guid>
            <category><![CDATA[meteor]]></category>
            <category><![CDATA[prezi]]></category>
            <category><![CDATA[talks]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Marcin Hagmajer]]></dc:creator>
            <pubDate>Sat, 27 May 2017 17:08:20 GMT</pubDate>
            <atom:updated>2017-05-28T21:27:52.933Z</atom:updated>
            <content:encoded><![CDATA[<h4>Meteor is a great choice for building modern web applications.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*KyCzDtSTtoVu7yo9g5_Yuw.jpeg" /></figure><p><em>Following is an abstract of the lecture I gave during the Spring`17 edition of </em><a href="https://www.codeeurope.pl/en"><em>Code Europe</em></a><em> in Poland. I had great time speaking in Cracow, Wroclaw and Warsaw! At the the very end you’ll find the slides made in Prezi which I used for the presentation.</em></p><h4>Current requirements</h4><p>Let’s first understand what are modern web applications. According to the new <a href="https://wearesocial.com/special-reports/digital-in-2017-global-overview"><em>Digital in 2017 Global Overview</em></a><em> </em>from <a href="https://wearesocial.com/">We Are Social</a> and <a href="http://hootsuite.com/">Hootsuite</a>, half of the world population is already connected to the Internet. Despite the regional discrepancies, global trends are clear: mobile usage is taking over desktop. Application developers and marketers need to think mobile first and especially Android first.</p><p>Transforming ideas into apps is a complicated process. What’s more, development of programming tools and frameworks fails to keep pace with the demand for technology. Common problems such us authentication, client-server communication and deployment need standardised solutions, so that developers can focus on the product and not worry about the infrastructure.</p><p>At the same time, users expect great levels of usability and live websites that never need to be refreshed. One example of good modern service is <a href="https://trello.com/">Trello</a>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/1*IVLaQos0o9EYCQyCHksHHg.gif" /></figure><p>At the core of this experience is collaboration. Virtually every useful app depends on it in one way or another. However, something like this is really difficult to accomplish without any web frameworks.</p><h4>Choosing the right technology</h4><p>JavaScript is the most popular language in the world. Apart from Internet browsers, it can also run on Node.js, which makes handling concurrent operations really easy, thanks to the event loop. Although there are other great server technologies, it really pays off to use the same programming language on front-end and back-end.</p><p>Meteor is the flagship project of Meteor Development Group Inc. It’s a well-funded company which employs full-time engineers dedicated to this project. Meteor is open to anyone to use and contribute in accordance to the MIT license. The company makes money on its hosting service called Galaxy.</p><h4>How it works</h4><p>Meteor is more than just a full-stack framework. It comes with its own package manager <a href="https://atmospherejs.com/">Atmosphere</a> that makes adding <a href="http://lesscss.org/">less</a> support as easy as typing:</p><pre>meteor add less</pre><p>This is of course in addition to the first-class support of NPM. You can also test your server-side code with meteor shell just like you would test client-side code in a browser console. It also comes with <a href="https://babeljs.io/">Babel</a> integration that lets you write ES6 code right out-of-the-box.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tqK4uLg6MmOLFkP36rMhrQ.png" /><figcaption>All 6 parts of the talk unveiled</figcaption></figure><p>Once your app gets delivered to desktop and mobile client via HTTP, a DDP (short for Distributed Data Protocol) over WebSocket link is established. This allows for bidirectional client-server communication to happen at any time. It includes calling server methods and subscribing for data updates using publication system. Meteor also uses this to automatically refresh clients whenever a new version of the app is deployed to production.</p><p>Meteor works on MongoDB. If you require SQL support, you should check out <a href="https://www.apollodata.com/">Apollo</a> — another project by MDG.</p><h4>Demo application</h4><p>For a demo project I presented a collaborative whiteboard made with <a href="http://fabricjs.com/">Fabric.js</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*JggwaP3HOvUw_cwwGXLdFA.gif" /></figure><p>You can find it on GitHub:</p><ul><li>Blaze version: <a href="https://github.com/mhagmajer/meteor-whiteboard">https://github.com/mhagmajer/meteor-whiteboard</a></li><li>React version: <a href="https://github.com/mhagmajer/warsawjs-workshop-6-whiteboard">https://github.com/mhagmajer/warsawjs-workshop-6-whiteboard</a></li></ul><p>The initial version took just 1 day to put together which was only possible thanks to Meteor.</p><h4>Scaling</h4><p>Meteor Galaxy comes with a few performance dashboards that helps with scaling. It’s really easy to manage — you just choose the size and number of containers your application will run in. The more different publications your server needs to support at any given time, the more RAM it will need. They also recently acquired Kadira monitoring tools which offer even greater insight into the app performance.</p><h4>Further resources</h4><p>You can find out more about Meteor at:</p><ul><li><a href="https://www.meteor.com/">https://www.meteor.com/</a></li><li><a href="https://www.youtube.com/user/MeteorVideos">https://www.youtube.com/user/MeteorVideos</a></li><li><a href="https://blog.hagmajer.com/">https://blog.hagmajer.com/</a></li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fprezi.com%2Fembed%2Fxi7nky1qqdyr%2F%3Fbgcolor%3Dffffff%26lock_to_path%3D0%26autoplay%3D0%26autohide_ctrls%3D0%26features%3Dundefined%26disabled_features%3Dundefined&amp;url=https%3A%2F%2Fprezi.com%2Fxi7nky1qqdyr%2Fmeteor-javascript-code-europe-spring-2017%2F&amp;image=https%3A%2F%2F0901.static.prezi.com%2Fpreview%2F6464abmushuqdni3nfewuqrwex6jc3sachvcdoaizecfr3dnitcq_0_0.png&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=prezi" width="800" height="581" frameborder="0" scrolling="no"><a href="https://medium.com/media/1142450ace82c4cb3766dbaf55bd973b/href">https://medium.com/media/1142450ace82c4cb3766dbaf55bd973b/href</a></iframe><p><em>To arrange speaking at your event, shoot me a message at: contact@hagmajer.com.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b539ece8d127" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hagmajer/talk-meteor-complete-applications-in-javascript-b539ece8d127">Talk: Meteor — complete applications in JavaScript</a> was originally published in <a href="https://medium.com/hagmajer">Hagmajer Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Server-side routing with authentication in Meteor]]></title>
            <link>https://medium.com/hagmajer/server-side-routing-with-authentication-in-meteor-6625ed832a94?source=rss-42812af88590------2</link>
            <guid isPermaLink="false">https://medium.com/p/6625ed832a94</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[meteor]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Marcin Hagmajer]]></dc:creator>
            <pubDate>Sat, 20 May 2017 19:55:05 GMT</pubDate>
            <atom:updated>2017-06-16T12:16:42.176Z</atom:updated>
            <content:encoded><![CDATA[<h4>Introducing <a href="https://atmospherejs.com/mhagmajer/server-router">mhagmajer:server-router</a> package</h4><h4>Problem statement</h4><p>The ruling trend in modern web development is to build single page applications (usually abbreviated as SPAs). Once such app starts in the client browser, only JSON data is exchanged with the server in order to populate views and process user actions. Meteor makes this a breeze thanks to the two-way communication via <a href="https://github.com/meteor/meteor/blob/devel/packages/ddp/DDP.md">DDP</a> over web sockets.</p><p>Apart from JavaScript, HTML and CSS that make the client bundle, server often needs to provide additional resources. While <a href="https://themeteorchef.com/blog/managing-static-content">serving static files publicly is easy</a>, Meteor lacks a built-in support for providing content dynamically. There is a number of scenarios when this is critical including:</p><ul><li>generating PDF invoices,</li><li>exporting selected data to XLSX,</li><li>tailoring images,</li><li>protecting your commercial publications from unauthorized copying with <a href="https://en.wikipedia.org/wiki/Traitor_tracing">traitor tracing</a>.</li></ul><p>These features either depend on some native C/C++ implementation or need to operate in a controlled environment and therefore must live on the server.</p><p>It’s also common for such functionality to involve user authentication. It would be a serious security flaw to make invoices available to anyone with an order id, wouldn’t it?</p><p>Since <a href="https://blog.meteor.com/why-meteor-doesnt-use-session-cookies-e988544f52c9">Meteor doesn’t use session cookies</a>, clients must explicitly include some sort of user identification in HTTP request for the server to know who they are. This mechanism should be separate from regular Meteor access tokens to prevent session hijacking. Here’s an example url:</p><pre>https://www.yourmeteorapp.com/monthly-invoice-apr-2017.pdf?<strong>_userId</strong>=oPwEZMPDWmdoSCQSi&amp;<strong>_token</strong>=m72JpzQeQSeNs9cTx</pre><p>For increased security, it’s best for the tokens to expire after use and only be valid for the given user within short time.</p><h4>Implementation</h4><p>The idea is pretty straightforward. Server exposes a Meteor method called _ServerRouterGetUserToken that returns a new token for the current user. This token can then be used by the user to access a single server-side resource in the next 60 seconds. Tokens are persisted in MongoDB so that they’re shared across app instances (containers). If invalid token is used or none is provided, client will fetch a new one and redirect to that resource again.</p><p>Every server-side path, apart from the regular <a href="https://en.wikipedia.org/wiki/Query_string">query string</a> arguments following ?,<strong> </strong>may include parameters as specified by the <a href="https://www.npmjs.com/package/path-to-regexp">path-to-regexp</a> package like:</p><pre>/monthly-invoice-<strong>:date</strong>.pdf</pre><p>All path are processed in a defined order, optionally ending the HTTP response. If no path is matched, user gets the regular client bundle.</p><h4>Usage</h4><p>You can install <a href="https://atmospherejs.com/mhagmajer/server-router">mhagmajer:server-router</a> using Meteor’s package management system:</p><pre>meteor add mhagmajer:server-router</pre><p>Start by setting up the router on the server-side. Once created, you need to hook it up with Meteor’s <a href="https://docs.meteor.com/packages/webapp.html">webapp</a> package that allows you to add handlers for HTTP requests:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/76b102a3426052f1ee0c5daeb2b2912d/href">https://medium.com/media/76b102a3426052f1ee0c5daeb2b2912d/href</a></iframe><p>As you can see, path definition includes special args function that maps path params and query objects to handler’s arguments. This allows for greater reuse if you want to make the route accessible via other paths like:</p><pre>/annual-invoices-<strong>:year</strong><br>/last-week-invoices</pre><p>The route is called with special context object (bound to this) which includes:</p><ul><li>this.req: a Node.js <a href="https://nodejs.org/api/http.html#http_class_http_incomingmessage">IncomingMessage</a> providing information about the incoming request;</li><li>this.res: a Node.js <a href="http://nodejs.org/api/http.html#http_class_http_serverresponse">ServerResponse</a> used to write data that should be sent in response to the request (remember to call this.res.end() when you are done);</li><li>this.userId: current user id (<a href="https://docs.meteor.com/api/methods.html#DDPCommon-MethodInvocation-userId">similarly to Meteor methods</a>).</li></ul><p>You can reliably use this.userId to fetch invoices for the exact user who made the request. However, this document will still generate for guest users. To prevent that we need to throw a special exception in the route handler:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9014c4fe66bca20177fecd0a5d41191c/href">https://medium.com/media/9014c4fe66bca20177fecd0a5d41191c/href</a></iframe><p>This will cause user to get the regular client bundle with <a href="https://atmospherejs.com/meteorhacks/inject-data">injected</a> instruction to fetch the token and refresh. For this work, however, we also need to import ServerRouter on the client-side:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/397b0c15468e0c95ce40c2f1f8f41cd3/href">https://medium.com/media/397b0c15468e0c95ce40c2f1f8f41cd3/href</a></iframe><p>Here’s what a logged user will get for the code above:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QfXDzp_dDer77wuPXYXgfg.png" /></figure><h4>Routes and static type checking with <a href="https://flow.org/">Flow</a></h4><p>In addition to regular paths, there are also “routes” which are simply paths that follow a specific form like:</p><pre>/r/<strong>:name</strong>/<strong>:args*</strong></pre><p>They’re really convenient to set up using ES6 import/export statements:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/64225aefd0aeb269509781e0c60ac36a/href">https://medium.com/media/64225aefd0aeb269509781e0c60ac36a/href</a></iframe><p>You can then simply do:</p><pre>serverRouterClient.redirect.math.mul(2, 3, 4);</pre><p>to take users to page displaying 24.</p><p>Flow will verify for you that client calls existing routes and provides correct arguments. You can find <a href="https://github.com/mhagmajer/server-router/blob/master/definitions/flow_v0.46.x/mhagmajer:server-router_v1.x.x.js">Flow library definitions</a> in the package repository. You’ll have to copy them to your project and include in .flowconfig.</p><p>Route arguments are serialized with <a href="https://docs.meteor.com/api/ejson.html">EJSON</a> for transportation, so you can pass objects, arrays and more. This way client code can invoke a server-side route as easily as they were invoking a regular Meteor method.</p><h4>Conclusion</h4><p>Package <a href="https://atmospherejs.com/mhagmajer/server-router">mhagmajer:server-router</a> offers an easy solution for serving additonal content dynamically and securely. You can learn more about it in the <a href="https://mhagmajer.github.io/server-router/">official documentation</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6625ed832a94" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hagmajer/server-side-routing-with-authentication-in-meteor-6625ed832a94">Server-side routing with authentication in Meteor</a> was originally published in <a href="https://medium.com/hagmajer">Hagmajer Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>