<?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 Matt Ha on Medium]]></title>
        <description><![CDATA[Stories by Matt Ha on Medium]]></description>
        <link>https://medium.com/@matthlavacka?source=rss-5c5853bd4d6e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*BCOos3XXix4h-WGEAbEDhg.png</url>
            <title>Stories by Matt Ha on Medium</title>
            <link>https://medium.com/@matthlavacka?source=rss-5c5853bd4d6e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 22:36:53 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@matthlavacka/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to Target Prospects using Sales Navigator through Existing Connections]]></title>
            <link>https://medium.com/@matthlavacka/how-to-target-prospects-using-sales-navigator-through-existing-connections-e1cd00181e9d?source=rss-5c5853bd4d6e------2</link>
            <guid isPermaLink="false">https://medium.com/p/e1cd00181e9d</guid>
            <category><![CDATA[linkedintips]]></category>
            <category><![CDATA[linkedin]]></category>
            <category><![CDATA[linkedin-outreach]]></category>
            <category><![CDATA[linkedin-automation-tool]]></category>
            <category><![CDATA[linkedin-automation]]></category>
            <dc:creator><![CDATA[Matt Ha]]></dc:creator>
            <pubDate>Wed, 03 Aug 2022 21:40:25 GMT</pubDate>
            <atom:updated>2022-08-03T21:40:25.163Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="icereach blog" src="https://cdn-images-1.medium.com/max/500/1*CtcF1xzX-vRZ4YVp3wf1VA.jpeg" /></figure><p>The strategy is typically the same while utilizing Sales Navigator. We do searches depending on the industry or job title and with specific keywords. Then we use the most transparent template imaginable to target the individuals on the list:</p><blockquote>Hello, first name I saw you work at {{company}}. Let’s get in touch!</blockquote><p>Most folks will just ignore you since they are sick of hearing this.</p><p>There is still an opportunity to produce strong results and boost your sales despite the negative effects.</p><h3>Identify customer segments</h3><p>We will employ Sales Navigator for this activity in a unique and unusual way.</p><p>Follow steps below:</p><ol><li>Grab a list of your best customers</li><li>Find them on <a href="https://icereach.com/blog/linkedin-tips-for-salespeople/#maximize-linked-in-sales-navigator">Sales Navigator</a></li><li>Click more and once you’re there click on the View similar</li></ol><figure><img alt="customer segmentation" src="https://cdn-images-1.medium.com/max/602/1*VEcPDNz-Xzo-gehknv8EGA.png" /></figure><p>Voilà! Based on your imported list, a sales nav will provide us with a similar list of clients. Each of these leads can be saved in particular lists (I will note why this is important in a bit)</p><figure><img alt="customer segmentation 2" src="https://cdn-images-1.medium.com/max/602/1*tnLrqIpuFbGN3eO7_2G9ag.png" /></figure><p>You may go on to the next step of the sales process once you’ve added the total number of qualifying prospects.</p><h3>Boost the effectiveness of each sales procedure</h3><p>Everyone is familiar with <a href="https://icereach.com/blog/linkedin-outreach-tools">LinkedIn automation tools</a>, yet the majority of people use them improperly. The only results of the spamming attitude are a lower SSI score and a limit on your request volume.</p><p>But there is a lot more that can be done with <a href="https://icerearch.com/">Icereach</a>. Scaling your outreach with the use of a LinkedIn automation solution like Icereach can help you avoid being blocked or blacklisted. It’s your leverage to success.</p><p>Add your stored list from <a href="https://www.linkedin.com/sales/ssi">Sales Navigator</a> to the platform first.</p><p>Our tool will scrape the prospect list and other publicly accessible data. Think about our strategy before putting them in an outreach campaign.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vtOzNUig2N_Y5h6bX0aHHQ.jpeg" /></figure><p>Although the connection request can be left blank, there is a far lower likelihood of connecting with your prospects.</p><p>Having a solid strategy in place is essential for getting better response rates.</p><p>Using targeted icebreakers is the best way to <a href="https://icereach.com/personalize-linkedin-outreach/">personalize your LinkedIn outreach</a>.</p><p>But let’s first talk about what an icebreaker is.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/1*vXtQnYS0GEjxGap4HgNRxg.gif" /><figcaption>Icebreaker</figcaption></figure><p>It’s not like the image above, so don’t worry.</p><p>Years of cold outreach has shown me that adding your unique value to people’s profiles and employing a new, stylish approach can be a game-changer.</p><p>Not only does it increase the likelihood of receiving responses, but it also effectively closes the deal. Let me share one example of icebreaker that we’re using to sell our tool:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FZTWLcrlnxUidw68IkQqCg.jpeg" /></figure><p>If you don’t know how to write a successful connection message yet, you can check out <a href="https://icereach.com/blog/7-linkedin-outreach-b2b-templates-2021/">LinkedIn outreach templates</a> to get more ideas.</p><p>Creating intro lines for each prospect manually will take a lot of time. Luckily there is a faster way by using <a href="https://www.coldlist.io/">Coldlist</a> platform. We found it pretty handy.</p><p>Coldlist’s platform will automatically create customized intro lines for each of the imported prospects when you upload the list from Icereach.</p><p>It will enable you to draft introductions without devoting a lot of time to manual research.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xgrc5Clh7hjcSQ213bQNZg.png" /><figcaption>Coldlist platform</figcaption></figure><p>Export the list when the procedure is finished, then add it to Google Sheets and import it into Icereach once more.</p><p>It’s vital to know that you may utilize icebreakers as a custom placeholder in your <a href="https://icereach.com/personalize-linkedin-outreach/">personalized LinkedIn messages</a> and invites.</p><h3>Results</h3><p>We advise testing this strategy with your intended audience to determine whether customized opening lines lead to more interactions. We have achieved a very decent 59% acceptance rate and a 39% reply rate.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RhnjCKnMdVTM5IOZEzkAJw.png" /></figure><p>If you’d like to grow more business opportunities and engage with your leads better, take a chance to book a free demo call or directly try our <a href="https://icereach.com/">LinkedIn outreach platform</a> with all features included for a 7-days free trial.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e1cd00181e9d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Zero to $1000/month in 12 months: Part 1]]></title>
            <link>https://medium.com/@matthlavacka/zero-to-1000-month-in-12-months-part-1-416813e3ba6d?source=rss-5c5853bd4d6e------2</link>
            <guid isPermaLink="false">https://medium.com/p/416813e3ba6d</guid>
            <category><![CDATA[startup-journey]]></category>
            <category><![CDATA[saas]]></category>
            <category><![CDATA[entrepreneurship]]></category>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[startup-founders]]></category>
            <dc:creator><![CDATA[Matt Ha]]></dc:creator>
            <pubDate>Fri, 19 Jun 2020 08:31:21 GMT</pubDate>
            <atom:updated>2022-08-03T20:25:10.135Z</atom:updated>
            <content:encoded><![CDATA[<h3>Why I’m Doing Zero to $1000/month in 12 Months Challenge</h3><h4>Build a profitable online business or fail publicly</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XUcRHmYP5sW1tuBl" /><figcaption>Photo by <a href="https://unsplash.com/@marvelous?utm_source=medium&amp;utm_medium=referral">Marvin Meyer</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Back in 2015, wishing to know how to build web apps, but always giving up as things got more difficult, I came up with a challenge to force myself to study consistently — build <a href="https://medium.com/@matthlavacka/6-weeks-tour-to-learn-meteor-js-49d9e3d21560">6 apps in 6 weeks</a> to learn how to code.</p><p>I completed the challenge and ended up taking one hardcore year to launch my own sites, during which I started freelancing with little I knew to actually get paid to learn to code, slept on my friend’s couch for 3 months, and coded at the oddest places.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/537/1*bLpO7SzR_FZQ6r3FaN4l_g.jpeg" /><figcaption>Image courtesy of the author</figcaption></figure><p>As more than 5+ million people used the sites I’ve built, one site sold for 5 figures and I landed a remote job working 4 days a week, I believe that the determination and persistence during this hardcore year have paid off.</p><h3>Things are very different now</h3><p>Being an employee for the last 4 years and starting to work on 5 different projects of which I launched none, it’s embarrassing to admit I failed my initial ambition…</p><blockquote><strong>I don’t want to be a programmer, making useful stuff is my passion.</strong></blockquote><p>How to battle this? I’ve always maintained the belief that if you’re consistent and determined, eventually you reach the goal you’ve set out to achieve. It might take longer, as my roommate Peter struggled to make living with his <a href="https://www.youtube.com/channel/UCnHEz9DZ6EAof1-DaQGD_Xw">Youtube channel</a> for years. Yet by posting videos every month, he’s been able to recently celebrate 500,000+ subscribers.</p><p>As more aligned inspiration with web development and time period, I liked the idea of <a href="https://medium.com/u/75452cb7f664">levels.io</a>’s <a href="https://levels.io/12-startups-12-months/">12 Startups in 12 Months</a> challenge which produced highly successful sites - <a href="https://nomadlist.com/">Nomadlist</a> and <a href="https://remoteok.io/">RemoteOK</a> and couple others that failed.</p><blockquote><strong>The easiest way to figure out what to do is by exposing yourself to the world.</strong></blockquote><p>Because goals matter, for the next 12 months, I’ve set myself a goal to build and grow MVPs going from zero to $1,000+/month (recurring revenue) doing it. However, instead of launching 12 random projects, the focus will be on fewer projects in areas with already an existing market and try to carve out a niche segment.</p><p><strong>Wtf, $1000/month??! You’ll make more at any job</strong></p><p>I see $1k/month as this magic line from where things start to snowball. To get there, you need to find a market fit with at least one of the projects. If you charge $30/month ($1/day) on average, at least 35 people have to find enough value in your software to break $1000 in revenue. Doable??!</p><h3><em>Make your luck by being </em><strong><em>always prepared</em></strong></h3><p>To increase the odds of making this year a success, I considered</p><h4><strong>Monthly Expenses</strong></h4><p>Relocating to central Europe, sharing an apartment, and having some savings allows me to live on $1000 per month for some time to focus on growth.</p><h4><strong>Tech</strong></h4><p>I intend to build subscription-based sites with a similar core: landing page, user accounts, database, payments, docs, live demo, emails… To save time with the setup I use boilerplate <a href="https://github.com/reactGo/reactGo">reactGo</a> adjusted to my needs, which allows me to spin off different projects by just changing the landing page content and the product inside.</p><p>The best idea is to use the tech stack you’re the most comfortable with. For me, that’s React as frontend and Node.js + MongoDB on the backend.</p><h4><strong>Ideas</strong></h4><p>As most of us actively try to note all the potential business ideas we think of, I found the <a href="https://blog.yongfook.com/12-startups-in-12-months.html">Ideas sheet</a> to be very useful to filter them. With such a short time, you need to focus on areas in which there is already a market and focus on creating a better version of the product for a small niche. For example, instead of building just Helpdesk software, you would set out to build Helpdesk software for e-shops using Shopify with 1–10 employees.</p><h4><strong>Work</strong></h4><p>Currently working 4 days/week, this challenge will take up most of my free time. I already switched from being an employee to a freelancer and intend to cut down the working time to 3 days, if possible.</p><h3><strong>Back to work</strong></h3><p>So now that I’ve announced this challenge, I need you to hold me accountable to this goal during the next 365 days.</p><p>I’ll be open with my results and maintain the list here with links to posts about progress. Follow me on <a href="https://twitter.com/MattHlavacka">Twitter</a> for more frequent updates.</p><h4>MVP 1 — <a href="https://databaselog.com/">DatabaseLog</a></h4><p>A MongoDB analytics to track your site performance</p><p>Read more on <a href="https://www.producthunt.com/posts/databaselog">Product Hunt</a> or <a href="https://news.ycombinator.com/item?id=23348760">Hacker News</a>.</p><h4>MVP 2— <a href="https://icereach.com/">Icereach</a></h4><p>A #1 LinkedIn automation tool to scale your LinkedIn outreach</p><p>After using multiple tools to automate LinkedIn outreach and coming across a lots of bugs and overall poor UI experience, my co-founder and I decided to offer a better alternative.</p><p>After lots of initial trial and error we managed to create a platform that helped us sell itself and made the whole process of outreach way easier.</p><p>Now it helps sales reps, lead generation agencies and startups to drive more business from LinkedIn. We love seeing them book more demos every month and skyrocket their growth.</p><p>Read more on our <a href="https://icereach.com/blog/">LinkedIn outreach</a> blog.</p><p>__________________________________________________________</p><h4>Thanks</h4><p><a href="https://www.instagram.com/kamila.pav">Kamila</a> for proof-reading and editing</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=416813e3ba6d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[6 in 6 Challenge Week 5
-
Youtube Downloader Web App]]></title>
            <link>https://medium.com/@matthlavacka/6-in-6-challenge-week-5-25ba3aea979e?source=rss-5c5853bd4d6e------2</link>
            <guid isPermaLink="false">https://medium.com/p/25ba3aea979e</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Matt Ha]]></dc:creator>
            <pubDate>Tue, 15 Sep 2015 18:38:14 GMT</pubDate>
            <atom:updated>2015-09-15T18:41:09.794Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C-8VVsehVLgO5XZeUL6uww.png" /></figure><p>I recently got to spend some time without a WiFi at the apartment and only chance for me to listen music or watch videos was to download stuff at work to watch/listen at home.</p><p>There are dozen of services providing download from Youtube, but as true geek, I started wondering if I can build one myself too. After some research, I found out it’s pretty easy task.</p><p>Therefore I thought it could be great opportunity to finally finish Meteor tutorial series that I started couple month ago and got asked for next part once a week :-) Thanks guys!</p><p>I also put this service called <a href="http://www.saveting.com/"><strong>SaveTing</strong></a><strong> </strong>online for you to use. Tell me in comments what you think.</p><p>We’re about to build simple Youtube Terminal Downloader for downloading videos and music from Youtube, Soundcloud, Vimeo and other mainstream services.</p><blockquote><em>Before we begin, you can try out a live demo of the app </em><a href="http://www.saveting.com/"><strong><em>here</em></strong></a><em>.</em></blockquote><blockquote><em>Github repo </em><a href="https://github.com/mhlavacka/week5"><strong><em>here</em></strong></a><em>.</em></blockquote><p>In order to this tutorial you’ve to have Meteor running on your machine. We’ve already installed it in the part 1. Jump straight to <a href="https://medium.com/@matejhlavacka/6-in-6-challenge-week-1-yik-yak-web-clone-81938f3a033e"><strong>6 in 6 Challenge Week 1 — Yik Yak Web Clone</strong></a><strong> </strong>to see an installation process<strong>. Install Meteor and create your app</strong>.</p><p>It also shows how to execute terminal commands and returns result back to client.</p><h4>Creating Interface</h4><p>Open up html file and type the following:</p><pre>&lt;head&gt;<br>  &lt;title&gt;Terminal&lt;/title&gt;<br>&lt;/head&gt;</pre><pre>&lt;body&gt;<br>  {{&gt; terminal}}<br>&lt;/body&gt;</pre><pre>&lt;template name=&quot;terminal&quot;&gt;<br>  &lt;div class=&quot;box&quot;&gt;<br>    &lt;form id=&quot;command-input&quot;&gt;<br>      &lt;input type=&quot;text&quot; id=&quot;command&quot; class=&quot;command&quot; autofocus=&quot;autofocus&quot;&gt;<br>    &lt;/form&gt;<br>  &lt;/div&gt;<br>&lt;/template&gt;</pre><h4>Client side</h4><p>Now we need to create event that sends data to server and returns executed output back to client.</p><pre>if (Meteor.isClient) {<br>  Template.terminal.events({<br>    &#39;submit #command-input&#39;: function (event, template) {<br>      event.preventDefault();<br>      var input = template.find(&#39;#command&#39;);<br>      var cmd = input.value;<br>      console.log(&#39;command&#39;, cmd);<br>      Meteor.call(&#39;command&#39;, cmd, function(error, result) {<br>        if(result.stdout)<br>          console.log(&#39;Output: &#39;+ result.stdout);<br>        else<br>          console.log(&#39;Error: &#39;+ result.stderr);<br>      });<br>      input.value = &#39;&#39;;<br>      input.focus();<br>    }<br>  });<br>}</pre><h4>Server side</h4><p>On server we need to use asynchronous method, to return the output from terminal back to client after terminal executes our exec command.</p><p>First we need to add meteor package in terminal that allows us to use Npm packages.</p><pre>meteor add meteorhacks:npm</pre><p>Second we need to install on our computer <a href="https://rg3.github.io/youtube-dl/"><strong><em>youtube-dl</em></strong></a>, a small command-line program to download videos from YouTube.com and a few more sites.</p><p>Click <a href="https://github.com/rg3/youtube-dl/#installation"><strong>here</strong></a> to find installation instructions.</p><p>We load exec and future npm packages. We use this.unclock() because some methods take longer time to execute. Command method starts download in terminal and returns progress result back to client.</p><pre>if (Meteor.isServer) {<br>  // load exec<br>  var exec = Meteor.npmRequire(&#39;child_process&#39;).exec;<br>  // load future from fibers<br>  var Future = Meteor.npmRequire(&#39;fibers/future&#39;);<br> <br>  Meteor.methods({<br>    &#39;command&#39; : function(line) {<br>      console.log(“In command method”, line);<br>      // this method call won’t return immediately, it will wait for the<br>      // asynchronous code to finish, so we call unblock to allow this client<br>      this.unblock();<br>      var future = new Future();</pre><pre>      exec(&quot;youtube-dl &quot; + line, function(error, stdout, stderr) {<br>        console.log(‘Command Method’, error, stdout, stderr);<br> <br>        future.return({stdout: stdout, stderr: stderr});<br>      }); <br>      return future.wait();<br>    }<br>  });<br>}</pre><h4>Styling</h4><p>There is also included some additional styling for this app to look better <a href="https://github.com/mhlavacka/week5/blob/master/terminal-app.css"><strong>here</strong></a>.</p><blockquote>I’m on twitter too at <a href="https://twitter.com/mhlavacka"><strong>@mhlavacka</strong></a>, if you want to see what I’m up to next.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=25ba3aea979e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Future Of Money]]></title>
            <link>https://medium.com/@matthlavacka/future-of-currency-2c6b3e6f143?source=rss-5c5853bd4d6e------2</link>
            <guid isPermaLink="false">https://medium.com/p/2c6b3e6f143</guid>
            <category><![CDATA[money]]></category>
            <category><![CDATA[bitcoin]]></category>
            <category><![CDATA[future]]></category>
            <dc:creator><![CDATA[Matt Ha]]></dc:creator>
            <pubDate>Sat, 23 May 2015 18:29:58 GMT</pubDate>
            <atom:updated>2015-05-23T20:53:02.646Z</atom:updated>
            <content:encoded><![CDATA[<p>(Class thesis on Future of USD currency)</p><p><strong>Introduction</strong></p><blockquote>“Lenin is said to have declared that the best way to destroy the Capitalist System was to debauch the currency. By a continuing process of inflation, governments can confiscate, secretly and unobserved, an important part of the wealth of their citizens. By this method, they not only confiscate, but they confiscate arbitrarily; and, while the process impoverishes many, it actually enriches some. The sight of this arbitrary rearrangement of riches strikes not only at security, but at confidence in the equity of the existing distribution of wealth. Those to whom the system brings windfalls, beyond their deserts and even beyond their expectations or desires, become “profiteers,” who are the object of the hatred of the bourgeoisie, whom the inflationism has impoverished, not less than of the proletariat. As the inflation proceeds and the real value of the currency fluctuates wildly from month to month, all permanent relations between debtors and creditors, which form the ultimate foundation of capitalism, become so utterly disordered as to be almost meaningless; and the process of wealth-getting degenerates into a gamble and a lottery.</blockquote><blockquote>Lenin was certainly right. There is no subtler, no surer means of overturning the existing basis of society than to debauch the currency. The process engages all the hidden forces of economic law on the side of destruction and does it in a manner which not one man in a million is able to diagnose.”</blockquote><p>– John Maynard Keynes, The Economic Consequences of Peace <a href="https://medium.com/p/2c6b3e6f143/edit#_ftn1">[1]</a></p><blockquote>“The State should treat its citizens like an enterprise treats its customers. For this to work, the State also needs competition. We therefore support the right of self-determination at the municipal level, in order to end the monopoly of the State over its territory. The traditional state as a monopoly enterprise not only is an inefficient enterprise with a poor price-performance ratio, but even more importantly, becomes more of a danger for humanity the longer it lasts.”</blockquote><p>– Hans-Adam II, HSH Sovereign Prince of Liechtenstein <a href="https://medium.com/p/2c6b3e6f143/edit#_ftn2">[2]</a></p><blockquote>“Attempts to undermine the legitimate currency of this country are simply a unique form of domestic terrorism. While these forms of anti-government activities do not involve violence, they are every bit as insidious and represent a clear and present danger to the economic stability of this country. We are determined to meet these threats through infiltration, disruption, and dismantling of organizations which seek to challenge the legitimacy of our democratic form of government.”</blockquote><p>– Anne Tompkins, U.S. Attorney<a href="https://medium.com/p/2c6b3e6f143/edit#_ftn3">[3]</a></p><blockquote>“The really valuable businesses are monopoly businesses. If you’re a monopoly, you own the market, but you probably don’t want to talk about it. So monopolies pretend they’re not monopolies.”</blockquote><p>– Peter Thiel, PayPal, Facebook, Palantir<a href="https://medium.com/p/2c6b3e6f143/edit#_ftn4">[4]</a></p><h3><strong>Chapter 1 — Value of money</strong></h3><p>Throughout history, the primary method of communicating with someone over long distances was sending a letter. This could take days, weeks, even months, with no guarantee the letter would arrive at all. Even then it was only one-way communication, for a conversation to take place it would take longer still. Email changed communications drastically. Messages were sent and received instantly, from anywhere in the world. Before email, people didn’t even recognize the drawbacks of the old communications system. Once email became widely adopted, the drawbacks were instantly obvious, and we’ve never looked back.</p><p>This is true for our current system of money today. Most people don’t stop to think about the drawbacks of our current monetary system, but a new technology is forming to change that. Perhaps an entirely new form of money may emerge, and perhaps that money is already here.</p><p>Remember last time sending someone money online or over the long distance? It’ll be delivered on the next day, but there are no transaction taking place during weekends. We used to ask our parents, how could they exist in the world without instant communication, but we’re the ones that exist in the world without instant transactions. It’s highly probable, that our kids will ask us similar question.</p><p>However, in order to talk about future of currency, we need to have a broader understanding of money itself at first. Because to understand future of currency, we must understand money.</p><p>Unfortunately, most people don’t. It’s somehow strange, that we spend our life chasing after money and in the same time we have only the most superficial understanding of money.</p><p>What’s money? Is money those papers that we call dollars, euros and everybody carries them around? When we try to observe people and money closely we find out, that most people want as much money as possible and spend fair amount of their life exchanging their limited time for money.</p><p>That sounds like money have really high value for us. Money is good for us, we’re teached from the childhood. The question is what exactly are we using money for? If we take a closer look, we realize that despite everybody wants money, all they do with it is to exchange it for other stuff they want.</p><p>From this perspective money seems like an intermediary between us and stuff that we really want. Let’s say we want a car, we want to eat, we want that new iPhone, that isn’t even marketed yet. But, why exactly are people willing to exchange those things for money? Why would one exchange something valuable and real for something as silly as numbered pieces of papers. On the other side, why we’re willing to ponder tons of our time in exchange for something superficial as dollar, euro, yen or juan?</p><p>Paul Graham distinguish between concepts of wealth and money. He describes money as a way of moving wealth, and in practice something that is usually interchangeable. From his perspective money is just the intermediate stage — just a shorthand — for whatever people want.<a href="https://medium.com/p/2c6b3e6f143/edit#_ftn5">[5]</a></p><p>In order to truly understand money, let’s at first examine reasons behind creation of the most important commodity in the world.</p><h3><strong>Chapter 2 — History of money</strong></h3><p>In schools they teach us, that in the beginning there was bartering system. Caveman number 1 would trade mammoth meat for fresh fish from Caveman number 2. But we learned that there is something wrong with bartering. Jevons in his book describes the problems with barter as Want of Coincidence and Want of a Measure of Value.</p><p>He further describes the problem with Coincidence of Wants in barter is to find two persons whose disposable possessions mutually suit each other’s wants. There may be many people wanting, and many possessing those things wanted, but to allow of an act of barter, there must be a double coincidence, which will rarely happen.</p><p>The second difficulty arises in barter after Jevons called Want of a Measure of Value. At what rate is any exchange to be made? If a certain quantity of beef be given for a certain quantity of corn, and in like manner corn be exchanged for cheese, and cheese for eggs, and eggs for flax, and so on, still the question will arise — How much beef for how much flax, or how much of any one commodity for a given quantity of another?<a href="https://medium.com/p/2c6b3e6f143/edit#_ftn6">[6]</a></p><p>As we understand the power of a marketplace thus we see how strongly barter is limiting trade’s potential. To get around difficulties with barter trade, money was invented and it seems like a reasonable progression. Currency usage became somewhat a social convention, where everyone agrees to trade for money instead of physical objects they actually wants. Money has value, because people are willing to give value to it. The disadvantage of creation of something as superficial as money is the confusion what it creates in people’s minds about real purpose of businesses. People tend to see role of the business as a way to create money, however the reality is that they actually exists to create wealth. The true role is to make something that people want.</p><p>We tend to see money as we know it today as a final point of human progression, where all the ongoing progress stops and we use our superior form of money. We get used to think of dollars, euros or yen as an only proper money and see gold, silver and other forms of money as outdated. Why we see dollars as a physical item, despite nearly all dollars are digital today? Why are there people who believe there is another superior form of money when the form we currently has is the most superior form of money we could possibly have?</p><p>To define the reasons behind money we use nowadays, we have to closely examine attributes of it itself. Money same like other things developed itself over time. By close examination of attributes we can further determine, which attributes would money in future holds.</p><p>The crucial questions arise while examining history of money creation closely. Why were seashells, silver or gold, chosen as money in the first place? What made these things the right medium to improve upon barter trade difficulties? Was there someone who decided it? Was there a vote?</p><p>Another important question to consider, is substitutability of seashells, silver or gold by other commodities. Would have any other commodity worked in the same way for the purpose money is used? Gold was the money of the world until US president Nixon removed the dollar from the gold standard in 1971.<a href="https://medium.com/p/2c6b3e6f143/edit#_ftn7">[7]</a></p><p>Why was it gold and not a leaves or grass? Since there is limited amount of gold, that has been chosen as money and nobody ever seems to have enough money, why weren’t we decided on something more plentiful, like leaves. Leaves as the money, would’ve made everybody who would pick more than million of them up a millionaire. Poverty would’ve been already eliminated. We could’ve been bathing in the tons of money every morning. After considering this, was it still a bright idea to choose gold as the money?</p><p>Most people assume, that people chose to make gold money just randomly and other commodities would’ve worked in the similar way. Is this the fault of general absence of proper education about money in the schools? This is a mistake, because it isn’t arbitrary. Money, exactly same as other goods, competes for the attention of those, that are using it. As Austrian economy proposed, money is selected through a truly natural process with very good reasons behind it.<a href="https://medium.com/p/2c6b3e6f143/edit#_ftn8">[8]</a> The same reasons defining why gold became money. The reasons are described as theory of money based on its attributes. Those attributes made gold highly useful in trade and according to that gold became money, not by any mistake or someone’s vote, but gradually over time.</p><p>Better properties that gold possess than other commodities made it superior basically to everything else. What are these properties, these specific gold’s attributes that led gold to be medium of exchange? Both Reinis Ikass<a href="https://medium.com/p/2c6b3e6f143/edit#_ftn9">[9]</a> and Andrew Hoffman<a href="https://medium.com/p/2c6b3e6f143/edit#_ftn10">[10]</a> defined attributes that led to gold superiority to other commodities.</p><p>We composed the following list of gold’s attributes based on both publications:</p><ol><li>It is relatively imperishable, that means highly durable, which is why we don’t use wheat or corn or rice.</li><li>It is divisible, which is why we don’t use art work.</li><li>It is transportable and easy to store, because it has a high value-to-weight ratio, which is why we don’t use wood</li><li>It is consistent and uniform, which is why we don’t use real estate.</li><li>It supply is relatively steady and predictable, which is why we don’t use paper</li><li>It is scarce, that is limited in the quantity that is available, which is why we don’t use grass or leaves</li><li>It is easily identifiable, all units are similar and it has a long history of acceptance, which is why we don’t use molybdenum or rhodium.</li></ol><p>As we now understand this properties, it’s easier to propose, that there wasn’t any randomness in selection of gold as a money, it simple had superior properties for use in exchange. Also as long as we proved that money developed over time, we are able to imagine, that there might be even better commodity suited for role of money as we use nowadays.</p><h3><strong>Chapter 3 — Money we use nowadays</strong></h3><p>The question might arise, in addition to something better then gold, that we already have and use daily. Money as we use and understand nowadays, we call the United States Federal Reserve Note (also better known as dollar). Implicitly, money we use today is superior to gold, and that’s exactly the reason why are we using it. Some attributes of dollar are similar or better then gold, but let’s explore all of them closely to reach and form our conclusion.</p><p>It’s easier to transport dollars then gold, because they have even higher value-to-weight ratio. They’re easily divisible and uniform. Dollars are easy to identify, most of the units are similar and there is fairly long history of its acceptance.</p><p>However, there is also a darker side of dollar as a currency. Since Federal Reserve started creating dollar, it has lost 98% of their initial value. If a person from the year 1900, with the $100 bill in her wallet, traveled in the future to the year 2010, would now be worth only around $2.00. Basically the purchasing power of $100 bill in 2012, equals to purchasing power of $2.00 in 1900.</p><blockquote>Picture 1.: Purchasing power of the US Dollar (1900–2010)</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*mLTW069UZbygBQFTlq610g.png" /></figure><blockquote>King Byron, “Inflation US Dollar,” Whiskey &amp; Gunpowder, March 01, 2010.</blockquote><p>This process happening during the whole 20th century is called inflation and most of us consider it to be a natural process in economy like the rise of the sun over the horizon every day.</p><p>However, this can’t be more far from the truth, it’s just new amounts of money created every day. Why would anyone optionally want to use money that daily loses on the purchasing power, because it’s created out of nothing? It would be appropriate to ask, why free market choose dollars based on the superior attributes of dollars as the money.</p><p>Well, it didn’t. To support this statement, without going into the further discussion, think of the process called taxation and possibilities in the use of money that this government scheme offers. There is a difference in a usage reason behind these two concepts of money. Gold’s usage originated from the intrinsic value of its specific properties. Unlike the value of dollar, which is based on government coercion.</p><p>We’ve explained the most fundamental concepts behind money, that critical mass of people need to understand in order to create better future of money and life in freedom in general. As Peter Thiel puts it, people nowadays find themselves in an alarming Alice-in-Wonderland-style scenario in which they must run harder — that is, work longer hours — just to stay in the same place. In the next chapter we will explain how does all this relate to the future of money.</p><h3><strong>Chapter 4 — Money in future</strong></h3><blockquote>“A mysterious new technology emerges, seemingly out of nowhere, but actually the result of two decades of intense research and development by nearly anonymous researchers. What technology am I talking about? Personal computers in 1975, the Internet in 1993, and — I believe — Bitcoin in 2014. First, Bitcoin at its most fundamental level is a breakthrough in computer science — one that builds on 20 years of research into cryptographic currency, and 40 years of research in cryptography, by thousands of researchers around the world. The practical consequence of solving this problem is that Bitcoin gives us, for the first time, a way for one Internet user to transfer a unique piece of digital property to another Internet user, such that the transfer is guaranteed to be safe and secure, everyone knows that the transfer has taken place, and nobody can challenge the legitimacy of the transfer. The consequences of this breakthrough are hard to overstate.”</blockquote><p>– Marc Andreessen, Mosaic, Netscape, Andreessen Horowitz VC<a href="https://medium.com/p/2c6b3e6f143/edit#_ftn11">[11]</a></p><p>How does Bitcoin relate to the future of money? Eric Voorhees describes Bitcoin in the following way: “Bitcoin is two things: it is a digital currency unit and it is the global payment network with which one sends and receives those currency units. Both the currency unit and the payment network share the same name: Bitcoin.”<a href="https://medium.com/p/2c6b3e6f143/edit#_ftn12">[12]</a></p><p>We won’t focus on the Bitcoin technical functions, history or details, but on the premise, that Bitcoin could substitute FIAT money, that we use now.</p><p>To understand Bitcoin, we need to understand its value, that is similar like gold’s, which comes from its specific properties. However, unlike gold, Bitcoin could actually be used in daily trade in our modern economy, because it was designed to be — and, in many ways, are — the perfect digital currency. Bitcoin is easy to divide, cannot be counterfeited, it’s highly durable, could be sent instantly anywhere, at almost no cost. Besides that, it doesn’t hold gold’s difficulties with physical form and legal constraints that is behind dollars.</p><p>Most of all it cannot be manipulated by any party, it’s very democratic, because everybody has to use it under its rules. There aren’t any terms of service. As we’ve already stated, that the free market didn’t decide on use of dollar as a currency, but it was inherited by government. There are people who use Bitcoin daily, without any obligation or coercion from any party, because they understood the question why Bitcoin has value. Pedro Franco describes the reason as why people are willing to give it a value, because it’s scarce and useful.<a href="https://medium.com/p/2c6b3e6f143/edit#_ftn13">[13]</a></p><p>The great premise of decentralized Bitcoin is requirement of fewer resources to move money, and thus fewer resources will be consumed, making humanity wealthier. If we examine again what important role money plays in our lives, since it’s half of every transaction happening in the world trade.</p><p>Likewise cars made humanity richer by enabling transportation at lower cost and internet made humanity richer by enabling distribution of information at lower cost, Bitcoin could make the world richer by enabling monetary transfers at lower cost. However, not everyone is literate and owns a car, but we all use money to trade. The great premise is that only superior form of money could overthrown Bitcoin, what would mean we’re all even better off.</p><blockquote>If the “separation of state and money” is a familiar concept to the next generation of children, future of money might be brighter after all.</blockquote><p><a href="https://medium.com/p/2c6b3e6f143/edit#_ftnref1">[1]</a> Gorale, A.: Bitcoin begins the end of 100 years of slavery. 2.6.2015. <a href="https://www.cryptocoinsnews.com/bitcoin-begins-end-100-years-slavery/">https://www.cryptocoinsnews.com/bitcoin-begins-end-100-years-slavery/</a></p><p><a href="https://medium.com/p/2c6b3e6f143/edit#_ftnref2">[2]</a> Hans-Adam II, The reigning Prince of Liechtenstein: The State in the Third Millennium. van Eck Verlag, 2009. ISBN: 9783905881042. Page 2.: 224</p><p><a href="https://medium.com/p/2c6b3e6f143/edit#_ftnref3">[3]</a> Gorale, A.: Bitcoin begins the end of 100 years of slavery. 2.6.2015. <a href="https://www.cryptocoinsnews.com/bitcoin-begins-end-100-years-slavery/">https://www.cryptocoinsnews.com/bitcoin-begins-end-100-years-slavery/</a></p><p><a href="https://medium.com/p/2c6b3e6f143/edit#_ftnref4">[4]</a> Thiel, P. — Masters,B.: Zero to one: Notes on Startups, or How to Build the Future. 2014. ISBN 978–0804139298.</p><p><a href="https://medium.com/p/2c6b3e6f143/edit#_ftnref5">[5]</a> Graham, P.: How to make wealth. 5.2004. <a href="http://paulgraham.com/wealth.html">http://paulgraham.com/wealth.html</a></p><p><a href="https://medium.com/p/2c6b3e6f143/edit#_ftnref6">[6]</a> Jevons, W. S.: Money and the Mechanism of Exchange. 1875. New York: D. Appleton and Co. Page 4.</p><p><a href="https://medium.com/p/2c6b3e6f143/edit#_ftnref7">[7]</a> Paper Money vs. Gold Money. <a href="http://pair.offshore.ai/38yearcycle/">http://pair.offshore.ai/38yearcycle/</a></p><p><a href="https://medium.com/p/2c6b3e6f143/edit#_ftnref8">[8]</a> Various Authors: The Foundations of Modern Austrian Economics. 1976.</p><p><a href="https://medium.com/p/2c6b3e6f143/edit#_ftnref9">[9]</a> Ikass, R.: Characteristics of money. <a href="https://www.scribd.com/doc/13658536/Characteristics-of-money">https://www.scribd.com/doc/13658536/Characteristics-of-money</a></p><p><a href="https://medium.com/p/2c6b3e6f143/edit#_ftnref10">[10]</a> Hoffman, A.: The seven characteristics of money. 23. 3. 2012. <a href="http://blog.milesfranklin.com/the-seven-characteristics-of-money">http://blog.milesfranklin.com/the-seven-characteristics-of-money</a></p><p><a href="https://medium.com/p/2c6b3e6f143/edit#_ftnref11">[11]</a> Andreessen, M.: Why Bitcoin matters. 21. 1. 2014. NY Times. <a href="http://dealbook.nytimes.com/2014/01/21/why-bitcoin-matters/">http://dealbook.nytimes.com/2014/01/21/why-bitcoin-matters/</a></p><p><a href="https://medium.com/p/2c6b3e6f143/edit#_ftnref12">[12]</a> Voorhees, E.: Bitcoin — The libertarian introduction. 13. 4. 2012. <a href="http://moneyandstate.com/bitcoin-libertarian-introduction-used-care/">http://moneyandstate.com/bitcoin-libertarian-introduction-used-care/</a></p><p><a href="https://medium.com/p/2c6b3e6f143/edit#_ftnref13">[13]</a> Franco, P.: Understanding Bitcoin: Cryptography, Engineering and Economics (The Wiley Finance Series). 2014. ISBN-10: 1119019168. Page 17.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2c6b3e6f143" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[6 in 6 Challenge Week 4 — Instagram Clone]]></title>
            <link>https://medium.com/@matthlavacka/6-in-6-challenge-week-4-a4c9c1541006?source=rss-5c5853bd4d6e------2</link>
            <guid isPermaLink="false">https://medium.com/p/a4c9c1541006</guid>
            <dc:creator><![CDATA[Matt Ha]]></dc:creator>
            <pubDate>Sun, 10 May 2015 11:45:55 GMT</pubDate>
            <atom:updated>2015-05-10T11:53:56.416Z</atom:updated>
            <content:encoded><![CDATA[<h2>6 in 6 Challenge Week 4</h2><h2>-</h2><h2>Instagram Clone</h2><figure><img alt="" src="https://cdn-images-1.medium.com/max/399/1*Gz4m-GuWh4vw-P8Xq1hFUw.png" /></figure><p>After longer period of time, it’s time for another Meteor tutorial. For this one we’ll build small mobile app similar to Instagram. Basically what we’re about to do long story short is to create way to upload pictures and display them in one feed of all users and our profile.</p><p>We’ll cover file uploading, storage and displaying, before and after hooks, accessing username.</p><blockquote>Github repo<strong> </strong><a href="https://github.com/mhlavacka/Week-4"><strong>here</strong></a>.</blockquote><p>Assuming you got Meteor already installed, let’s create a new meteor project.</p><pre>meteor create Instagram</pre><p>Open new project in Code Editor of your choice. We can delete the files Meteor pre-generated for us and create the following structure using terminal.</p><pre>mkdir client lib server stylesheet<br>cd client<br>touch main.html navbar.html profile.html login.html layout.html image.html feed.html events.js helpers.js<br>cd ../lib<br>touch collections.js router.js<br>cd ../server<br>touch server.js<br>cd ../stylesheet<br>touch style.css</pre><p>I guess there is Meteor package for pre-generating the structure above, because the basics are mostly similar. Anyways, let’s add packages we’re about to use in this tutorial all at once. We’ll use these :</p><pre>meteor add twbs:bootstrap iron:router accounts-facebook accounts-ui cfs:standard-packages cfs:gridfs cfs:ui</pre><p>Set up the Iron router correctly for our purposes as well :</p><pre>&lt;template name=”layout”&gt;<br>  {{&gt; yield}}<br>  {{&gt; navbar}}<br>&lt;/template&gt;</pre><p>Also open router.js and type the following :</p><pre>Router.configure({<br>  layoutTemplate: &#39;layout&#39;<br>});</pre><pre>Router.map(function(){<br>  this.route(&#39;feed&#39;, {path: &#39;/&#39;} );<br>  this.route(&#39;login&#39;, {path: &#39;/login&#39;});<br>  this.route(&#39;profile&#39;, {path: &#39;/profile&#39;});<br>});</pre><p>Create templates for all above, with the same name as we named them in Iron Router.</p><p>We’ll now start with the upload function. To store and display files, we’ll use <a href="https://github.com/CollectionFS/Meteor-CollectionFS"><strong>CollectionFS</strong></a><strong> </strong>— Meteor web based filesystem handling up and downloads. <a href="https://github.com/Ethaan">Ethaan</a> created simple demo app, that you’ll find live <a href="http://demo.fscollection.meteor.com/"><strong>here</strong></a>. He did a great job describing and explaining the implementation and use so I won’t go into details here and stick to the process he used. Open up navbar.html and type the following code to create file input :</p><pre>&lt;template name=&quot;navbar&quot;&gt;<br>  &lt;div id=&quot;footer-nav&quot;&gt;<br>    &lt;input type=&quot;file&quot; id=&quot;exampleInput&quot;&gt;<br>  &lt;/div&gt;<br>&lt;/template&gt;</pre><p>We need to create Storage for all those nice pictures of our users. In collections.js add the following : (Take a look at Ethaan’s demo and explanation, because you might find this pretty confusing.)</p><pre>imageStore = new FS.Store.GridFS(&quot;imageStore&quot;);</pre><pre>Pictures = new FS.Collection(&quot;Pictures&quot;, {<br>  stores: [imageStore],<br>  filter: {<br>    maxSize: 10000000, // in bytes (10MB)<br>    // allow certain extensions  <br>    allow: {<br>      contentTypes: [&#39;image/*&#39;],<br>      // Allow these extensions<br>      extensions: [&#39;png&#39;,&#39;jpg&#39;,&#39;gif&#39;]<br>    },<br>    onInvalid: function () {<br>      if(Meteor.isClient) {<br>    alert(&quot;Wrong image format. Try using PDF or JPG.&quot;);<br>      } else {<br>        console.warn(&quot;Wrong image format. Try using PDF or JPG.&quot;);<br>      }<br>    }<br>  }<br>});</pre><pre>// Subscribe<br>if(Meteor.isClient){<br>  Meteor.subscribe(&#39;Pictures&#39;);<br>}</pre><p>Next open server.js and add Publish function and make the allow/denys Methods here, to set rules for our users :</p><pre>// Make the allow/denys Method here.<br>Pictures.allow({<br>  insert:function(){return true;},<br>  remove:function(){return true;},<br>  update:function(){return true;},<br>});</pre><pre>//Publish Method.<br>Meteor.publish(&#39;Pictures&#39;,function(){<br>  return Pictures.find();<br>});</pre><p>Alright, let’s create upload function to post those images to the MongoDB.</p><pre>Template.navbar.events({<br>  &#39;change #exampleInput&#39;:function(event, template){</pre><pre>    //jQuery to get the value.    <br>    var file = $(&#39;#exampleInput&#39;).get(0).files[0] <br>    <br>    // Store file as FS.file<br>    fsFile = new FS.File(file);</pre><pre>    //FS.File support metadata. For storing form inputs or username<br>    //Uncomment when you add users<br>    fsFile.metadata = {<br>      //ownerId:Meteor.userId(),<br>      //username:Meteor.user().profile.name,<br>    }</pre><pre>    Pictures.insert(fsFile,function(err,result){<br>      if(!err){<br>        console.log(result)<br>      }<br>    })<br>  }<br>});</pre><p>Now open Console in your Browser and try to upload a picture. You should see uploaded FS.File in console with all additional details. Now we have our pictures in database, but we still need a way to display them.</p><p>Open image.html and feed.html and type the following :</p><pre>&lt;template name=&quot;image&quot;&gt;<br>  &lt;li class=&quot;list-group-item&quot;&gt;<br>    &lt;img src=&quot;{{this.url}}&quot;&gt;<br>    &lt;h5 class=&quot;text-left&quot; {{metadata.username}}&lt;/h5&gt;<br>  &lt;/li&gt; <br>&lt;/template&gt;</pre><pre>&lt;template name=&quot;feed&quot;&gt;<br> {{#each showPictures}}<br>   {{#unless this.isUploaded}}<br>     {{&gt; FS.UploadProgressBar bootstrap=true}}<br>   {{/unless}}<br>     {{&gt; image}}<br> {{/each}}<br>&lt;/template&gt;</pre><p>Also to display Pictures, we need to create helper function.</p><pre>Template.feed.helpers({<br>  showPictures:function() {<br>    return Pictures.find();<br>  }<br>});</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*EBcSQ8i96bI_3k-nK0rsNg.png" /></figure><p>At this point we should see all the pictures we added. But we still lack a way to know who posted those pictures. What Instagram would be without everyone stalking each other ? You don’t do that ? Oh, me neither...but sometimes.</p><p>Now we can use accounts packages we installed earlier. Add the following code to login.html:</p><pre>&lt;template name=&quot;login&quot;&gt;<br>  &lt;div class=&quot;well text-center&quot;&gt;<br>    {{&gt; loginButtons}}<br>  &lt;/div&gt;<br>&lt;/template&gt;</pre><p>Go to your browser and route to login page ( localhost:3000/login). You should see this :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/399/1*KAx-9dBVRtAIw-cvtlm5Ug.png" /><figcaption>Login page</figcaption></figure><p>Configure Facebook login following commands you’ll get once you click on the button. Once you finish it, head to router.js. We need to redirect users to their feed after they’re successfully logged in and allow access to feed only for logged users.</p><p>We’ll use before hooks to do this. You can read more about it <a href="http://www.manuel-schoebel.com/blog/meteorjs-iron-router-filters-before-and-after-hooks"><strong>here</strong></a>. Basically when the new route is called, iron router looks for all before hooks and runs them. Then routes to new location and runs all the after hooks, if any.</p><pre>var OnBeforeActions;</pre><pre>OnBeforeActions = {<br>  loginRequired: function() {<br>    if (! Meteor.userId()) {<br>      this.render(&#39;login&#39;);<br>    }<br>    else {<br>      this.next();<br>    }<br>  }<br>};</pre><pre>Router.onBeforeAction(OnBeforeActions.loginRequired, {<br>  only: [&#39;profile&#39;, &#39;feed&#39;]<br>});</pre><p>Now we need to allow posting pictures only for registered users. We could simply add the following in layout.html:</p><pre>&lt;template name=”layout”&gt;<br>  {{&gt; yield}}<br>  <strong>{{#if currentUser}}<br>    {{&gt; navbar}}<br>  {{/if}}</strong><br>&lt;/template&gt;</pre><p>Also uncomment two lines in change event function to know who posted the Picture. Go to events.js :</p><pre>//FS.File support metadata. For storing form inputs or username <br>fsFile.metadata = {<br>  //User Id<br>  <strong>ownerId:Meteor.userId(),</strong><br>  // Username<br>  <strong>username:Meteor.user().profile.name,</strong><br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*veoV6M06Tx4iYKyd4aLfHQ.png" /><figcaption>User upload</figcaption></figure><p>At this point we’re able to see who posted concrete picture. Let’s add last small tweak and we can wrap it up as mobile application. To see our profile, go to profile.html and add the following :</p><pre>&lt;template name=&quot;profile&quot;&gt;<br>  &lt;div class=container&quot;&gt;<br>    &lt;h4 class=&quot;pull-left&quot;&gt;{{&gt; loginButtons}}&lt;/h4&gt;<br>    &lt;h4 class=&quot;pull-right&quot;&gt;{{picturesCount}} pics&lt;/h4&gt;<br>  &lt;/div&gt;<br>  {{#each userPictures}}<br>    {{#unless this.isUploaded}}<br>      {{&gt; FS.UploadProgressBar bootstrap=true}}<br>    {{/unless}}<br>      {{&gt; image}}<br>  {{/each}}<br>&lt;/template&gt;</pre><p>Also add helpers to display pictures and number of pictures added by us.</p><pre>Template.profile.helpers({<br>  picturesCount: function() { <br>return Pictures.find({‘metadata.ownerId’:Meteor.userId()}).count();<br>  },<br>  userPictures:function() {<br>    return Pictures.find({‘metadata.ownerId’:Meteor.userId()});<br>  }<br>});</pre><p>Okay, this works. Let’s wrap it up as mobile app for both, iOS and Android now. Meteor makes it easy to run your app on mobile, but there is some initial setup to be made, in order to run it. Refer to <strong>official meteor tutorial</strong> on how to run your app on iOS and Android <a href="https://www.meteor.com/try/7"><strong>here</strong></a>.</p><p>When you have initial setup finished — in terminal type the following for iOS support :</p><pre>meteor install-sdk ios<br>meteor add-platform ios</pre><p>And for Android support :</p><pre>meteor install-sdk android<br>meteor add-platform android</pre><p>Now your app can run on both devices.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*SCdiuNLPZOzDeRPtKT62pA.gif" /><figcaption>What device first ?</figcaption></figure><p>Let’s try running on iOS Simulator. It allows you to run iOS app without having the real device.</p><pre>meteor run ios</pre><p>After logging in it should display the same, as it did in browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/374/1*umDGl6d1t9OU2Qcx7w9PCg.png" /></figure><p>Our simple app is finished by now. You can play with it and add other functionality if you want. Also if you want to publish your mobile app for other people to use it, <strong>Stephan Hochhaus </strong>published recently <a href="https://www.yauh.de/the-illustrated-guide-to-mobile-apps-with-meteor/#app"><strong>this useful guide</strong></a> on how to do so.</p><blockquote>Follow me on twitter at <a href="https://twitter.com/mhlavacka"><strong>@mhlavacka</strong></a> to see what I’m up to next.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a4c9c1541006" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[6 in 6 Challenge Week 3 — Pinterest Like App]]></title>
            <link>https://medium.com/@matthlavacka/6-in-6-challenge-week-3-pinterest-like-app-be0ecfeae698?source=rss-5c5853bd4d6e------2</link>
            <guid isPermaLink="false">https://medium.com/p/be0ecfeae698</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[meteorjs]]></category>
            <dc:creator><![CDATA[Matt Ha]]></dc:creator>
            <pubDate>Sat, 04 Apr 2015 00:30:06 GMT</pubDate>
            <atom:updated>2015-04-04T01:29:47.098Z</atom:updated>
            <content:encoded><![CDATA[<h2>6 in 6 Challenge Week 3</h2><h2>-</h2><h2>Pinterest Like App</h2><p><em>Before we begin, you can try out a live demo of the app </em><a href="http://week3.meteor.com/"><strong><em>here</em></strong></a><em>.</em></p><p><em>Github repo </em><a href="https://github.com/mhlavacka/Week-3"><strong><em>here</em></strong></a><em>.</em></p><h4>Setting up Meteor</h4><p>In order to this tutorial you’ve to have Meteor running on your machine. We’ve already installed it in the part 1 so jump straight to <a href="https://medium.com/@matejhlavacka/6-in-6-challenge-week-1-yik-yak-web-clone-81938f3a033e"><strong>6 in 6 Challenge Week 1 — Yik Yak Web Clone</strong></a><strong> </strong>to see an installation process<strong>. Install Meteor and create your app</strong>.</p><p>To create an app’s basic structure type in the terminal the following :</p><pre>mkdir client server lib public stylesheet</pre><p>Let’s add all the Meteor packages we’ll need in the process :</p><pre>meteor add iron:router twbs:bootstrap natestrauser:font-awesome accounts-password ian:accounts-ui-bootstrap-3 sjors:meteor-masonry</pre><h4>Creating the interface</h4><p>As usual we need to set up main.html :</p><pre>&lt;head&gt;<br>  &lt;title&gt;All My Books&lt;/title&gt;<br>  &lt;! — To support mobile-devices →<br>  &lt;meta name=”viewport” content=”width=device-width, initial- scale=1.0 user-scalable=no”&gt;<br>&lt;/head&gt;</pre><p>and header.html :</p><pre>&lt;template name=”header”&gt;<br>  &lt;div class=”navbar”&gt;<br>    &lt;div class=”container”&gt;<br>      &lt;div class=”navbar-inner”&gt;<br>        &lt;a class=”brand btn” href=”/”&gt;&lt;img style=”height: 40px; width: 40px;” src=”/book-icon.png”/&gt; &lt;p&gt;Books&lt;/p&gt;&lt;/a&gt;<br>        &lt;div id=”login-button” class=”btn btn-default pull-right”&gt; <br>          {{&gt; loginButtons}}<br>        &lt;/div&gt;<br>      &lt;/div&gt;<br>    &lt;/div&gt;<br>  &lt;/div&gt;<br>&lt;/template&gt;</pre><p>To insert <a href="https://www.dropbox.com/s/8bghb1hj07t9pfo/book-icon.png?dl=0"><strong>the navbar book icon</strong></a> we need to put it in the public folder of our application. Also add <a href="https://github.com/mhlavacka/Week-3/blob/master/stylesheet/style.css"><strong>style.ccs code on github</strong></a> to the stylesheet folder.</p><p>Now we’ll start with the configuration. Create defaults.js and put this line in :</p><pre>Session.setDefault(‘category’, null);</pre><p>Basically it’s our switch for changing categories. Everytime we switch over the category, we want to show something else in category Session. Null means no category selected. In router.js type the following :</p><pre>Router.configure({<br>  layoutTemplate:&#39;layout&#39;,<br>  yieldTemplates:{<br>  //each yield going to different templates<br>  &#39;books&#39;:{to:&#39;books&#39;},<br>  &#39;categories&#39;:{to:&#39;categories&#39;}<br>  }<br>});<br>Router.map(function(){<br>    this.route(&#39;/&#39;,&#39;layout&#39;);<br>    this.route(&#39;books&#39;, {<br>        layoutTemplate:&#39;layout&#39;,<br>        path:&#39;/:name&#39;,<br>        data: function() {<br>            console.log(this.params.name);<br>            Session.set(&#39;category&#39;,this.params.name);<br>            },<br>        template:&#39;layout&#39;<br>    });<br>});</pre><p>We configure layout template as our yield template and then define two templates — books and categories because we want to use both at one page yield template. Then we do our mapping. If someone comes to our app we want to show our layout template.<br>But with the books it gets little more complicated. We need to switch based on category so that we pull the link out of url. Name of the template is the path for the router.</p><p>Now create other templates. We’ll start with layout template :</p><pre>&lt;template name=&#39;layout&#39;&gt;<br>  {{&gt; header}}<br>  &lt;div class=&#39;container-fluid&#39;&gt;<br>    &lt;div class=&#39;row&#39;&gt;<br>      &lt;div class=&#39;col-xs-12 text-center&#39;&gt;<br>        {{&gt; yield &#39;categories&#39;}}<br>      &lt;/div&gt;<br>      &lt;div class=&#39;col-xs-10 col-xs-offset-1 text-center&#39;&gt;<br>        {{&gt; yield &#39;books&#39;}}<br>      &lt;/div&gt;<br>    &lt;/div&gt;<br>  &lt;/div&gt;<br>&lt;/template&gt;</pre><p>We just told layout template to yield both to categories and books on the single page. Next we need to define those two templates. At first categories.html :</p><pre>&lt;template name=&#39;categories&#39;&gt;<br>  &lt;ul&gt;<br>    {{#each Categories}}<br>      &lt;li id=&quot;categories&quot;&gt;&lt;a class=&quot;btn btn-default&quot; href=&quot;/{{name}}&quot;&gt;{{name}}&lt;/a&gt;&lt;/li&gt;<br>    {{/each}}<br>  &lt;/ul&gt;<br>&lt;/template&gt;</pre><p>Name of a category is basically link pointing to the url of certain category. Router will use it to take our users to category they clicked. Then add books.html :</p><pre>&lt;template name=&#39;books&#39;&gt;<br>  &lt;div id=&#39;books&#39;&gt;<br>    &lt;div class=&#39;page-header&#39;&gt;<br>      &lt;h1&gt;<br>        &lt;small&gt;Books&lt;/small&gt;<br>      &lt;/h1&gt;<br>    &lt;/div&gt;<br>  &lt;/div&gt;<br>&lt;/template&gt;</pre><p>Now we need to define our collections. Make sure they are stored both on client and server ( not in the client or server folder ) :</p><pre>Books = new Mongo.Collection(&#39;books&#39;);</pre><pre>Categories = new Mongo.Collection(&#39;categories&#39;);</pre><pre>Likes = new Mongo.Collection(&#39;likes&#39;);</pre><p>Let’s add some categories to our database. Create server.js and store it in the server folder. We’ll add some dummy categories that will be inserted when we start our application and there is no other data inserted :</p><pre>Meteor.startup(function() {<br>  if(Books.find().count() === 0) {<br>    // Books<br>  }<br>  if(Categories.find().count() === 0) {<br>    // Categories<br>    Categories.insert({name:&#39;Tech&#39;});<br>    Categories.insert({name:&#39;Design&#39;});<br>    Categories.insert({name:&#39;Business&#39;});<br>    Categories.insert({name:&#39;Science&#39;});<br>    Categories.insert({name:&#39;Scifi&#39;});<br>    Categories.insert({name:&#39;Psychology&#39;});<br>  }<br>});</pre><p>Now when we go to the <strong>localhost:3000</strong> in the browser we still can’t see our recently added categories. The reason is that we didn’t write the helper function to retrieve categories from the database. Create helpers.js on client and type the following :</p><pre>Template.categories.helpers({<br>  Categories:function() {<br>    return Categories.find();<br>  }<br>});</pre><p>We successfully displayed the categories. Now we need to do the same for books. We’ll loop through each book and for every we find book template will be called. Also we will put else statement there, because there might be two additional things that could happen. There are no books found in the category or our user haven’t selected the category yet. Let’s put that into the code :</p><pre>&lt;template name=&#39;books&#39;&gt;<br>  &lt;div id=&#39;books&#39;&gt;<br>    &lt;div class=&#39;page-header&#39;&gt;<br>      &lt;h1&gt;<br>        &lt;small&gt;{{#if catnotselected}}Books{{else}}{{category}}  Books{{/if}}&lt;/small&gt;<br>      &lt;/h1&gt;<br>    &lt;/div&gt;<br>    &lt;div id=&#39;mainContent&#39;&gt;<br>      {{#each booklist}}<br>        {{&gt;book}}<br>      {{else}}<br>        {{#if catnotselected}}<br>          &lt;div class=&#39;page-header&#39;&gt;&lt;h1&gt;&lt;small&gt;Select a category.&lt;/small&gt;&lt;/h1&gt;&lt;/div&gt;<br>        {{else}}<br>          &lt;div class=&#39;page-header&#39;&gt;&lt;h1&gt;&lt;small&gt;No books in this category.&lt;/small&gt;&lt;/h1&gt;&lt;/div&gt;<br>        {{/if}}<br>      {{/each}}<br>    &lt;/div&gt;<br>  &lt;/div&gt;<br>&lt;/template&gt;</pre><p>We need to state what catnotselected means. We basically need to tell the computer — look at category Session and if it’s null, the category isn’t selected yet. In helpers.js :</p><pre>Template.books.helpers({<br>  catnotselected:function() {<br>    return Session.equals(‘category’,null);<br>  },<br>  category:function() {<br>    return  Session.get(&#39;category&#39;);<br>  }<br>});</pre><p>Now it’s supposed to display <em>Select a category</em> message as default and when you click on the category, it should display <em>No books in this category</em> message. Also with the second function we get the current category to display in HTML. Now we can see at what category of books we’re at this point of time. Let’s add book template :</p><pre>&lt;template name=&#39;book&#39;&gt;<br>  &lt;div class=&#39;item&#39;&gt;<br>    &lt;ul id=&#39;{{_id}}&#39; class=&#39;nav nav-list text-left&#39;&gt;<br>      &lt;li class=&#39;thumbnail&#39;&gt; &lt;img src=&#39;{{url}}&#39;/&gt; &lt;/li&gt;<br>      &lt;div class=&#39;thumbnail content&#39;&gt;<br>        &lt;li&gt;&lt;strong&gt;{{title}}&lt;/strong&gt;&lt;/li&gt;<br>        &lt;li&gt;{{format}}&lt;/li&gt;<br>      &lt;/div&gt; <br>    &lt;/ul&gt;<br>  &lt;/div&gt;<br>&lt;/template&gt;</pre><p>Now we’re able to add books through the server as we did with categories earlier. Edit server.js with the following code :</p><pre>Meteor.startup(function() {<br> if(Books.find().count() === 0) {<br>   // Books<br>   Books.insert({title:&#39;Beign Mortal&#39;, url:&#39;<a href="http://ecx.images-amazon.com/images/I/91E6exaOufL.jpg&#39;">http://ecx.images-amazon.com/images/I/91E6exaOufL.jpg</a>&#39;, format: &#39;Ebook&#39;,catName:&#39;Psychology&#39;});<br>   Books.insert({title:&#39;Eloquent JavaScript&#39;, url:&#39;<a href="https://yuq.me/users/41/792/YO81mXVMpK.png&#39;">https://yuq.me/users/41/792/YO81mXVMpK.png&#39;</a>, format: &#39;AudioBook&#39;,catName:&#39;Tech&#39;});<br>   Books.insert({title:&#39;Principles Of Web Design&#39;, url:&#39;<a href="https://yuq.me/users/27/445/MXtELWFw17.jpg&#39;">https://yuq.me/users/27/445/MXtELWFw17.jpg&#39;</a>, format: &#39;Ebook&#39;,catName:&#39;Design&#39;});<br>   Books.insert({title:&#39;Beign Mortal&#39;, url:&#39;<a href="http://ecx.images-amazon.com/images/I/91E6exaOufL.jpg&#39;">http://ecx.images-amazon.com/images/I/91E6exaOufL.jpg&#39;</a>, format: &#39;Ebook&#39;,catName:&#39;Psychology&#39;});<br>   Books.insert({title:&#39;Eloquent JavaScript&#39;, url:&#39;<a href="https://yuq.me/users/41/792/YO81mXVMpK.png&#39;">https://yuq.me/users/41/792/YO81mXVMpK.png&#39;</a>, format: &#39;AudioBook&#39;,catName:&#39;Tech&#39;});<br>   Books.insert({title:&#39;Principles Of Web Design&#39;, url:&#39;<a href="https://yuq.me/users/27/445/MXtELWFw17.jpg&#39;">https://yuq.me/users/27/445/MXtELWFw17.jpg&#39;</a>, format: &#39;Ebook&#39;,catName:&#39;Design&#39;});<br>}</pre><p>Now we need to retrieve them from the database to display those properly :</p><pre>Template.books.helpers({<br>  booklist:function(){<br>    return Books.find({catName:Session.get(&#39;category&#39;)});<br>  }<br>});</pre><p>We find and display books based on a category name assigned to the particular book.</p><h4>Adding like button</h4><p>Let’s make our application more social and give our users the way to like particular books. At first edit book template as following :</p><pre>...<br>&lt;div class=&#39;thumbnail content&#39;&gt;<br>  <strong>{{#if currentUser}}<br>    &lt;div class=&#39;like-bar&#39;&gt;<br>      &lt;a href=&#39;#&#39; class=&#39;like&#39;&gt;<br>        &lt;i class=&#39;fa fa-heart-o&#39;&gt;&lt;/i&gt;<br>      &lt;/a&gt;<br>        &lt;span class=&#39;label label-danger&#39;&gt;{{numLikes}}&lt;/span&gt;<br>        &lt;span class=&#39;badge badge-default&#39;&gt;{{likesThis}}&lt;/span&gt;<br>    &lt;/div&gt;<br>  {{/if}}</strong><br>&lt;li&gt;&lt;strong&gt;{{title}}&lt;/strong&gt;&lt;/li&gt;<br>...</pre><p>App now displays like buttons only when the user is logged in. Let’s edit our sign up method and use username as credential instead of an email as a way to login. Add the following to helpers.js :</p><pre>Accounts.ui.config({<br>  passwordSignupFields: &quot;USERNAME_ONLY&quot;<br>});</pre><p>Now we need to display number of likes and whether users have already liked it using helpers :</p><pre>Template.bok.helpers({<br>  numLikes:function() {<br>    return Likes.find({book:this._id}).count();<br>  },<br>  likesThis:function() {<br>    var doeslike = Likes.findOne({muser:Meteor.userId(),book:this._id});<br>    if (doeslike) {<br>      return &#39;You liked this&#39;;<br>    }<br>  }<br>});</pre><p>In the first function we return number of likes for the current book and in the second function we return wheter the current user liked a current book. Also we need to create an event to add likes. In event.js type :</p><pre>Template.book.events({<br>  ‘click .like’:function(event, template){<br>    var curlike = Likes.findOne({ muser:Meteor.userId(), book:template.data._id});<br>    if (!curlike) {<br>      Likes.insert({muser:Meteor.userId(),book:template.data._id});<br>    }<br>      Session.set(‘updated’,new Date());<br>  }<br>});</pre><p>In english language — if current user already liked the book, do nothing, if not, like the book.</p><h4>Pinterest like interface</h4><p>The last thing to add to our humble app is Pinterest like grid interface. It makes all elements fit together in the best way they could. At the beggining we added masonry Meteor package let’s use it now. In helpers.js type the following :</p><pre>function masonize(callback) {<br>  var container = $(&#39;#mainContent&#39;);<br>  container.masonry({<br>    itemSelector: &#39;.item&#39;,<br>    gutter:10<br>  })<br>  if(callback){callback()};<br>}</pre><p>Here we have masonize function. We define items where it should be executed and gutter or margin between each column. Also we need to call it somewhere. As soon as category template renders the function gets called. Add the following to call masonize function :</p><pre>Template.books.rendered = function() {<br>  setTimeout(function(){<br>    masonize(function(){<br>    })<br>  }, 3500);<br>};</pre><p>Now we are ready to deploy our application for everyone to see. To deploy an Meteor app, think of the name for your app and run the following in the terminal :</p><pre>meteor deploy <em>yourappname</em>.meteor.com</pre><p>Congrats ! That’s all for now. I almost forgot to mention that I used <a href="https://www.youtube.com/watch?v=fJTPaauOoCU">this tutorial</a> as a outline. Go check the guy out on Youtube, he made some really interesting and helpful tutorials in Meteor.</p><blockquote><em>I’m on twitter too at </em><a href="https://twitter.com/mhlavacka"><strong><em>@mhlavacka</em></strong></a><em>, if you want to see what I’m up to next.</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=be0ecfeae698" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[6 in 6 Challenge Week 2 - Ask Five Whys]]></title>
            <link>https://medium.com/@matthlavacka/6-in-6-challenge-week-2-ask-five-whys-6254efa395b0?source=rss-5c5853bd4d6e------2</link>
            <guid isPermaLink="false">https://medium.com/p/6254efa395b0</guid>
            <dc:creator><![CDATA[Matt Ha]]></dc:creator>
            <pubDate>Mon, 23 Mar 2015 00:00:12 GMT</pubDate>
            <atom:updated>2015-04-13T21:03:50.678Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yBLlWdl0CfxgTh6yW9NgAw.png" /></figure><h2>6 in 6 Challenge Week 2</h2><h2>-</h2><h2>Ask Five Whys</h2><p>If you’ve ever had to answer a precocious child who wants to know “Why is the sky blue?” and keeps asking “Why?” after each answer, you’re already familiar with what we are going to build. This technique was developed as a <a href="http://www.fastcodesign.com/explore/systematic-problem-solving-tool">systematic problem-solving tool</a> by <a href="http://www.fastcompany.com/person/taiichi-ohno">Taiichi Ohno</a>, the father of the Toyota Production System.</p><p>Yes, you guessed it right, we’ll build a small app to help us easier find and understand roots of our problems in 30 minutes as a <strong>second part </strong>of <a href="https://medium.com/@matejhlavacka/6-weeks-tour-to-learn-meteor-js-49d9e3d21560"><strong>Challenge to build 6 apps in 6 weeks in Meteor.</strong></a><strong> </strong>You can find first part <a href="https://medium.com/@matejhlavacka/6-in-6-challenge-week-1-yik-yak-web-clone-81938f3a033e"><strong>here</strong></a>.</p><p>Again, it will be rather easy to build and you can further extend it as you like. The Five Whys system takes its name from the investigative method of asking the question “Why?” five times to understand what has happened. In this app you can submit a problem and it will ask you five times why the problem is happening to<strong> help you better understand the real root cause of the problem.</strong></p><blockquote><strong>The real cause of the problem is often hidden behind more obvious symptoms.</strong></blockquote><blockquote>Before we begin, you can try out a live demo of the app <a href="http://week2.meteor.com/"><strong>here</strong></a>.</blockquote><blockquote>Github repo <a href="https://github.com/mhlavacka/Week-2"><strong>here</strong>.</a></blockquote><h4>Setting up Meteor</h4><p>In order to this tutorial you’ve to have Meteor running on your machine. I really like that we could start with development just with one command in terminal installing Meteor. In my previous attempt to get around Python and Django, I spent two days only setting up the environment to start. We’ve already installed it in the part 1/6 so jump straight to <a href="https://medium.com/@matejhlavacka/6-in-6-challenge-week-1-yik-yak-web-clone-81938f3a033e"><strong>6 in 6 Challenge Week 1 — Yik Yak Web Clone</strong></a><strong> </strong>to see installation process<strong>. Install Meteor and create your app — </strong>I named mine surprise surprise - <a href="http://week2.meteor.com/problems">week2</a>.</p><p>I know that we just began, but let’s quickly talk about the structure of our application. I found an awesome post on <a href="http://stackoverflow.com/questions/10122977/what-are-the-best-practices-for-structuring-a-large-meteor-app-with-many-html-te">How to structure your Meteor application</a> and it’s good habit to make our application readable for others, for example if it gains traction and we want to further develop it. Since we are now in the app folder, type in terminal the following to create basic structure :</p><pre>mkdir client server lib public stylesheet</pre><h4>Creating interface</h4><p>Now that we have basic structure, let’s dive in the interface creation. I guess I’m allowed to talk more about the whole process, not just coding in Meteor here☺. I started drawing sketches on the paper on my way to school on Monday. This was the first sketch on how the site could look like :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*45DGdryJZrKfE7cVyJ01Fw.jpeg" /></figure><p>Mom says I won national painting contest as a kid, but I don’t really believe her, now you know why. I wanted to see how site would look live and draw first wireframes in Photoshop. Here is the same one you just saw above :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*spDt_HNr6X6vAwK7V4CHMA.png" /></figure><p>And this is how the same site looks now :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1004/1*BBzum_YgaJ5s31ClvBV-4w.png" /></figure><p>You can play a little with <a href="http://week2.meteor.com/problems"><strong>it</strong></a>, to get a better idea of what we are about to build.</p><p>Let’s begin with main.html :</p><pre>&lt;head&gt;<br>  &lt;title&gt;Ask Five Whys&lt;/title&gt;<br>  &lt;!-- To support mobile-devices --&gt;<br>  &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0 user-scalable=no&quot;&gt;<br>&lt;/head&gt;</pre><pre>&lt;body&gt;<br>  {{&gt; problemsAll}}<br>&lt;/body&gt;</pre><p>We added <strong>user-scalable=no</strong> to the <strong>viewport </strong>apart from the part 1, what does make our app look more like an native mobile app on smartphone.</p><p>At first we need to create problems_all.html and type the following into it :</p><pre>&lt;template name=&quot;problemsAll&quot;&gt;<br>  &lt;div class=&quot;main-heading-problems&quot;&gt;<br>    &lt;h1&gt;Problems&lt;/h1&gt;<br>  &lt;/div&gt;<br>  &lt;div class=&quot;text-center&quot;&gt;<br>    {{#each problems}}<br>      {{&gt; problemItem}}<br>    {{/each}}<br>  &lt;/div&gt;<br>&lt;/template&gt;</pre><p>And also problem_item.html :</p><pre>&lt;template name=&quot;problemItem&quot;&gt;<br>  &lt;div class=&quot;problem-items&quot;&gt;<br>    &lt;a href=&quot;/&quot;&gt;<br>      &lt;li class=&quot;problems&quot;&gt;<br>        &lt;h3&gt;{{postProblem}}&lt;/h3&gt;<br>      &lt;/li&gt;<br>    &lt;/a&gt;<br>  &lt;/div&gt;<br>&lt;/template&gt;</pre><p>We created problemItem template where we will store ‘problems’ from database and then iterate over those using {{#each}}.</p><p>We now need to create a collection of problems, to be able to store them in our database. In <strong>lib</strong> folder create <strong>problems.js</strong> and type :</p><pre>Problems = new Meteor.Collection(&quot;problems&quot;);</pre><p>The above code will store all our problems in the database. Doesn’t it sound great ? Since we’re weird and want to show our problems to everybody to see we create <strong>helpers.js </strong>in <strong>client </strong>and type the following :</p><pre>Template.problemsAll.helpers({<br>  problems: function() {<br>    return Problems.find();<br>  }<br>});</pre><p>Navigate to the browser and type <strong>localhost:3000 . </strong>Now we see only the heading Problems. Let’s try to insert some problems into our app to let it care about them instead of us. Open JavaScript console (In Google Chrome Cmd + Alt + J) and type :</p><pre>Problems.insert({postProblem : &#39;My problem&#39;});</pre><pre>Problems.insert({postProblem : &#39;My 2 problem&#39;});</pre><pre>Problems.insert({postProblem : &#39;My 3 problem&#39;});</pre><p>Now that we store three problems in the collection our app displays these on the screen. Let’s make our app look better by copying code from <a href="https://github.com/mhlavacka/Week-2/blob/master/stylesheet/style.css"><strong>https://github.com/mhlavacka/Week-2/blob/master/stylesheet/style.css</strong></a><strong> </strong>and inserting it to style.css in the stylesheet folder. Also add bootstrap from the terminal :</p><pre>meteor add twbs:bootstrap</pre><p>Now we should see something similar to this :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/749/1*i2uiwWOdEoma9QPzY0UuXw.png" /></figure><h4><strong>Submitting problems :</strong></h4><p>We are able to display our problems, but we don’t want to add them through the console in browser forever. Since the point of the site is to help us find the root of our problem through asking about them in dialog. Let’s get to work, we need to create submit_problem.html and submit_problem.js. Those two will be the biggest files we are about to create. We’ll start with the interface :</p><pre>&lt;template name=&quot;submitProblem&quot;&gt; </pre><pre>&lt;!-- don&#39;t allow to submit form only using enter --&gt;<br>&lt;form onkeypress=&quot;return event.keyCode != 13;&quot; class=&quot;form text-center&quot;&gt;<br>  &lt;div id=&quot;submit-problem&quot;&gt;<br>    &lt;div class=&quot;main-heading&quot;&gt;<br>      &lt;h1&gt;ASK FIVE WHYS&lt;/h1&gt;<br>    &lt;/div&gt;<br>    &lt;div class=&quot;part1 dent-main&quot;&gt;<br>      &lt;input autofocus=&quot;autofocus&quot; type=&quot;text&quot; name=&quot;problem&quot; id=&quot;problem&quot; placeholder=&quot;What’s the problem ?&quot;/&gt;<br>      &lt;input type=&quot;button&quot; id=&quot;route&quot; value=&quot;Find Its Route&quot; class=&quot;route btn btn-sample&quot;&gt;<br>    &lt;/div&gt;<br>  &lt;/div&gt;</pre><pre>&lt;div id=&quot;submit-why1&quot; class=&quot;hidden&quot;&gt;<br>    &lt;div class=&quot;main-heading&quot;&gt;<br>      &lt;h1&gt;WHY #1 ?&lt;/h1&gt;<br>    &lt;/div&gt;<br>    &lt;div class=&quot;part2 dent&quot;&gt;<br>      &lt;input autofocus=&quot;autofocus&quot; type=&quot;text&quot; name=&quot;why1&quot; id=&quot;why1&quot; placeholder=&quot;Because …&quot;/&gt;<br>      &lt;input type=&quot;button&quot; value=&quot;Answer #1&quot; class=&quot;btn-sample btn answer1&quot;&gt;<br>      &lt;!-- Back button --&gt;<br>      &lt;button type=&quot;button&quot; class=&quot;btn back1 back-btn&quot;&gt;&lt;i class=&quot;fa fa-arrow-left fa-3x&quot;&gt;&lt;/i&gt;&lt;/button&gt;<br>    &lt;/div&gt;<br>  &lt;/div&gt;</pre><pre>&lt;div id=&quot;submit-why2&quot; class=&quot;hidden&quot;&gt;<br>    &lt;div class=&quot;main-heading&quot;&gt;<br>      &lt;h1&gt;WHY #2 ?&lt;/h1&gt;<br>    &lt;/div&gt;<br>    &lt;div class=&quot;part3 dent&quot;&gt;<br>      &lt;input autofocus=&quot;autofocus&quot; name=&quot;why2&quot; id=&quot;why2&quot; type=&quot;text&quot; placeholder=&quot;Because …&quot;/&gt;<br>      &lt;input type=&quot;button&quot; value=&quot;Answer #2&quot; class=&quot;btn-sample btn answer2&quot;&gt;<br>      &lt;!-- Back button --&gt;<br>      &lt;button type=&quot;button&quot; class=&quot;btn back2 back-btn&quot;&gt;&lt;i class=&quot;fa fa-arrow-left fa-3x&quot;&gt;&lt;/i&gt;&lt;/button&gt;<br>    &lt;/div&gt;<br>  &lt;/div&gt;</pre><pre>&lt;div id=&quot;submit-why3&quot; class=&quot;hidden&quot;&gt;<br>    &lt;div class=&quot;main-heading&quot;&gt;<br>      &lt;h1&gt;WHY #3 ?&lt;/h1&gt;<br>    &lt;/div&gt;<br>    &lt;div class=&quot;part4 dent&quot;&gt;<br>      &lt;input autofocus=&quot;autofocus&quot; type=&quot;text&quot; id=&quot;why3&quot; name=&quot;why3&quot; placeholder=&quot;Because …”/&gt;<br>      &lt;input type=&quot;button&quot; value=&quot;Answer #3&quot; class=&quot;btn-sample btn answer3&quot;&gt;<br>      &lt;!-- Back button --&gt;<br>      &lt;button type=&quot;button&quot; class=&quot;btn back3 back-btn&quot;&gt;&lt;i class=&quot;fa fa-arrow-left fa-3x&quot;&gt;&lt;/i&gt;&lt;/button&gt;<br>    &lt;/div&gt;<br>  &lt;/div&gt;<br>  <br>  &lt;div id=&quot;submit-why4&quot; class=&quot;hidden&quot;&gt;<br>    &lt;div class=&quot;main-heading&quot;&gt;<br>      &lt;h1&gt;WHY #4 ?&lt;/h1&gt;<br>    &lt;/div&gt;<br>    &lt;div class=&quot;part5 dent&quot;&gt;<br>      &lt;input autofocus=&quot;autofocus&quot; type=&quot;text&quot; id=&quot;why4&quot; name=&quot;why4&quot; placeholder=”Because …”/&gt;<br>      &lt;input type=&quot;button&quot; value=&quot;Answer #4&quot; class=&quot;btn-sample btn answer4&quot;&gt;<br>      &lt;!-- Back button --&gt;<br>      &lt;button type=&quot;button&quot; class=&quot;btn back4 back-btn&quot;&gt;&lt;i class=&quot;fa fa-arrow-left fa-3x&quot;&gt;&lt;/i&gt;&lt;/button&gt;<br>    &lt;/div&gt;<br>  &lt;/div&gt;</pre><pre>&lt;div id=&quot;submit-why5&quot; class=&quot;hidden&quot;&gt;<br>    &lt;div class=&quot;main-heading&quot;&gt;<br>      &lt;h1&gt;WHY #5 ?&lt;/h1&gt;<br>    &lt;/div&gt;<br>    &lt;div class=&quot;part6 dent&quot;&gt;<br>      &lt;input autofocus=&quot;autofocus&quot; type=&quot;text&quot; id=&quot;why5&quot; name=&quot;why5&quot; placeholder=&quot;Because …&quot;/&gt;<br>      &lt;input type=&quot;button&quot; value=&quot;Answer #5&quot; class=&quot;btn-sample btn answer5&quot;&gt;<br>      &lt;!-- Back button --&gt;<br>      &lt;button type=”button” class=&quot;btn back5 back-btn&quot;&gt;&lt;i class=&quot;fa fa-arrow-left fa-3x&quot;&gt;&lt;/i&gt;&lt;/button&gt;<br>    &lt;/div&gt;<br>  &lt;/div&gt;</pre><pre>&lt;div id=&quot;submit-solution&quot; class=&quot;hidden&quot;&gt;<br>    &lt;div class=&quot;dent mobile-side part7&quot;&gt;<br>      &lt;input autofocus=&quot;autofocus&quot; type=&quot;text&quot; name=&quot;solution&quot; id=&quot;solution&quot; placeholder=&quot;What could be the best solution ?&quot;/&gt;<br>      &lt;!-- Submit button --&gt;<br>      &lt;input type=&quot;submit&quot; id=&quot;submit-all&quot; name=&quot;submit-all&quot; value=&quot;Answer&quot; class=&quot;btn btn-sample submit-all&quot;&gt;<br>      &lt;!-- Back button --&gt;<br>      &lt;button type=&quot;button&quot; class=&quot;btn back6 back-btn&quot;&gt;&lt;i class=&quot;fa fa-arrow-left fa-3x&quot;&gt;&lt;/i&gt;&lt;/button&gt;<br>    &lt;/div&gt;<br>  &lt;/div&gt;</pre><pre>&lt;/form&gt;<br> <br>&lt;/template&gt;</pre><p>It looks complicated but it’s really only a HTML form. To display the form we’ll add Iron Router, the package build for Meteor, which enables routing in our application. Type the following in the terminal :</p><pre>meteor add iron:router</pre><p>Now we can set routes to our templates and no longer need to put templates in the body tag. Instead it we are going to use dynamic route called {{yield}}. Called templates are automatically inserted into it. Overwrite body tag with the following :</p><pre>&lt;template name=&#39;layout&#39;&gt;<br>  &lt;div class=&#39;containe&#39;&gt;<br>    {{&gt; yield}}<br>  &lt;/div&gt;<br>&lt;/tempalte&gt;</pre><p>We created our dynamic route, but we need to define it using Iron Router. We configure layout template as our interface structure so then we could route different templates into {{yield}}. Create <strong>router.js</strong> in the <strong>lib</strong> folder and type in it :</p><pre>Router.configure({<br> layoutTemplate: &#39;layout&#39;<br>});</pre><pre>Router.route(&#39;/&#39;, {name: &#39;submitProblem&#39;});</pre><pre>Router.route(&#39;/problems&#39;, {name: &#39;problemsAll&#39;});</pre><p>Now we see only the first form question in our browser. It’s because all the other questions are assigned to the class <em>hidden</em>, what makes them invisible for us. What we need to do is that when user clicks the button, it hides current question and shows her next one. We will do this using jQuery, I know, it might be done in more fancy Meteor way, but what do you do when you don’t know better.</p><p>The thing is that we assigned class hidden {display: none} to all questions except the first one, which we see. Every time when user clicks on the button we say to our app — add class hidden to the question I already answered and remove class hidden from the next question to let me see it. Also to be even more fancy we’ll add little JavaScript effect every time new question appears. We will use <a href="http://minimamente.com/example/magic_animations/"><strong>Magic Animations</strong></a><strong> </strong>to do so<strong>. </strong>Copy the code from <a href="https://raw.githubusercontent.com/miniMAC/magic/master/magic.min.css"><strong>here</strong></a><strong>, </strong>create a file <strong>magic.css </strong>in <strong>public</strong> folder and paste it in it.<strong> </strong>We store data that we want to be accessible on every device in public folder. Now we need to reference it into the &lt;head&gt; to make it work. Simply add in the &lt;head&gt; tag the following :</p><pre>&lt;link rel=&#39;stylesheet&#39; href=&#39;/magic.css&#39;&gt;</pre><p>Alright, now open up submit_problem.js and type both to show/hide elements and to make the magic effect work :</p><pre>Template.submitProblem.events({<br>  &#39;click .route&#39;:function() {<br>    if (problem.value != &#39;&#39;) { <br>      //magic effect<br>      $(&#39;.part2&#39;).addClass(&#39;magictime swashIn&#39;);<br>      //show/hide items with removeClass()/addClass() <br>      $(&#39;#submit-problem&#39;).addClass(&#39;hidden&#39;);<br>      $(&#39;#submit-why1&#39;).removeClass(&#39;hidden&#39;);<br>    } else {<br>      alert(&quot;You need to enter problem&quot;);<br>    }<br>  },</pre><pre>  &#39;click .answer1&#39;:function() {<br>    if (why1.value != &#39;&#39;) { <br>      //magic effect<br>      $(&#39;.part3&#39;).addClass(‘magictime swashIn&#39;);<br>      //show/hide items with removeClass()/addClass()<br>      $(&#39;#submit-why1&#39;).addClass(&#39;hidden&#39;);<br>      $(&#39;#submit-why2&#39;).removeClass(‘hidden&#39;);<br>    } else {<br>      alert(&quot;You need to answer why is it problem&quot;);<br>    }<br>  },</pre><pre>  &#39;click .answer2&#39;:function() {<br>    if (why2.value != &#39;&#39;) {<br>      $(‘.part4&#39;).addClass(‘magictime swashIn’);<br>      //show/hide items with removeClass()/addClass()<br>      $(‘#submit-why2&#39;).addClass(‘hidden’);<br>      $(‘#submit-why3&#39;).removeClass(‘hidden’);<br>    } else {<br>      alert(“You need to answer why is it problem”);<br>    }<br>  },</pre><pre>  &#39;click .answer3&#39;:function() {<br>    if (why3.value != &#39;&#39;) {<br>      $(&#39;.part5&#39;).addClass(&#39;magictime swashIn&#39;);<br>      //show/hide items with removeClass()/addClass()<br>      $(&#39;#submit-why3&#39;).addClass(&#39;hidden&#39;);<br>      $(&#39;#submit-why4&#39;).removeClass(&#39;hidden&#39;);<br>    } else {<br>      alert(&quot;You need to answer why is it problem&quot;);<br>    }<br>  },</pre><pre>  ‘click .answer4&#39;:function() {<br>    if (why4.value != ‘’) {<br>      $(‘.part6&#39;).addClass(‘magictime swashIn’);<br>      //show/hide items with removeClass()/addClass()<br>      $(‘#submit-why4&#39;).addClass(‘hidden’);<br>      $(‘#submit-why5&#39;).removeClass(‘hidden’);<br>    } else {<br>      alert(“You need to answer why is it problem”);<br>    }<br>  },</pre><pre>  &#39;click .answer5&#39;:function() {<br>    if (why5.value != &#39;&#39;) {<br>      $(&#39;.part7&#39;).addClass(&#39;magictime swashIn&#39;);<br>      //show/hide items with removeClass()/addClass()<br>      $(&#39;#submit-why5&#39;).addClass(&#39;hidden&#39;);<br>      $(&#39;#submit-solution’).removeClass(&#39;hidden&#39;);<br>    } else {<br>      alert(&quot;You need to answer why is it problem&quot;);<br>    }<br>  }<br>});</pre><p>Everytime the button is clicked and input field isn’t empty do the magic trick, hide current element and show next one. Obviously, this can be done with less lines of codes with few functions, but come on it works so who cares. JK, I would love to see how you would solve it more efficiently.</p><p>Since the code for back button is similar to above, only reversed a bit, it’s your responsibility to make it work now. We still need to insert our inputs into collection and therefore we’ll create submit function inside events for submitted Problems :</p><pre>&#39;submit form&#39;:function(event) {<br>  event.preventDefault();<br>  <br>  var post = {<br>    postProblem: $(event.target).find(&#39;[name=problem]&#39;).val(),<br>    postWhy1: $(event.target).find(&#39;[name=why1]&#39;).val(),<br>    postWhy2: $(event.target).find(&#39;[name=why2]&#39;).val(),<br>    postWhy3: $(event.target).find(&#39;[name=why3]&#39;).val(),<br>    postWhy4: $(event.target).find(&#39;[name=why4]&#39;).val(),<br>    postWhy5: $(event.target).find(&#39;[name=why5]&#39;).val(),<br>    postSolution:$(event.target).find(&#39;[name=solution]&#39;).val(),<br>    submitted: new Date()<br>  };<br>  <br>  var solutionValue = event.target.solution.value;<br>  if (solutionValue != &#39;&#39;) {<br>    Meteor.call(&#39;insertProblem&#39;, post, function(error,result) {<br>      // Only when we don&#39;t get empty object <br>      if(!error){<br>        Router.go(&#39;problemPage&#39;, result);<br>      }<br>    });<br>  }<br>}</pre><p>We insert posts in the collection using server. We called the method insertProblem and now we have to define this method on server. Open up <strong>problems.js</strong> and type :</p><pre>Meteor.methods({<br>  insertProblem: function(post) {<br>    var postId = Problems.insert(post);</pre><pre>    return {<br>      _id: postId<br>    };<br>  }<br>});</pre><p>In this method we insert new post and return its &lt;ID&gt;. Why ? Because we want to route to it using its &lt;ID&gt;, when it’s successfully submitted. Let’s go to <strong>router.js</strong> and create a dynamic route in format <strong>/problems/:_id</strong> for it :</p><pre>// redirect to the current submitted problem<br>Router.route(&#39;/problems/:_id&#39;, {<br>  name: &#39;problemPage&#39;,<br>  data: function() { return Problems.findOne(this.params._id); }<br>});</pre><p>The last step is to create problemPage template to display our newly created problem :</p><pre>&lt;template name=&quot;problemPage&quot;&gt;<br>  &lt;div class=&quot;cent-problem-page spaceing&quot;&gt;<br>    &lt;div&gt;<br>      &lt;li class=&quot;list-group-item&quot;&gt;<br>        &lt;h3&gt;Problem — {{postProblem}}&lt;/h3&gt; <br>      &lt;/li&gt; <br>    &lt;/div&gt;<br>    &lt;div&gt;<br>      &lt;li class=&quot;list-group-item&quot;&gt;<br>        &lt;p&gt;Why? — {{postWhy1}}&lt;/p&gt;<br>        &lt;p&gt;Why? — {{postWhy2}}&lt;/p&gt;<br>        &lt;p&gt;Why? — {{postWhy3}}&lt;/p&gt;<br>        &lt;p&gt;Why? — {{postWhy4}}&lt;/p&gt;<br>        &lt;p&gt;Why? — {{postWhy5}}&lt;/p&gt;<br>      &lt;/li&gt;<br>    &lt;/div&gt;<br>    &lt;li class=&quot;list-group-item&quot;&gt;<br>        &lt;h3&gt;Solution — {{postSolution}}&lt;/h3&gt;<br>    &lt;/li&gt;<br>    &lt;a href=&quot;{{pathFor &#39;problemsAll&#39;}}&quot;&gt;&lt;input type=&quot;button&quot; id=&quot;problem-page-back&quot; name=&quot;problem-page-back&quot; class=&quot;btn btn-sample&quot; value=&quot;All problems&quot;&gt;&lt;/a&gt;<br>  &lt;/div&gt;<br>&lt;/template&gt;</pre><p>We display all the inserted values of the recently submitted post. Let’s now remove all previously inserted problems. Type in terminal :</p><pre>meteor mongo</pre><p>and when the database line opens :</p><pre>db.problems.drop();</pre><p>Now that we have clear database, try the whole process of inserting problem and answering questions, it’s supposed to look like the following :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yBLlWdl0CfxgTh6yW9NgAw.png" /></figure><p>Pretty neat, huh ? As you might know each new Meteor application contents package insecure, which allows us to interact with database using only client. It makes development easier in the beginning, but it’s not that helpful and safe when we put our app in the real world.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/497/1*nx7BaauYpZ-oqc5TwQ10xg.png" /></figure><p>As Sebastian pointed out in the <a href="https://www.facebook.com/groups/1498505377066142/"><strong>Meteor group on Facebook</strong></a>, <a href="https://medium.com/@matejhlavacka/6-in-6-challenge-week-1-yik-yak-web-clone-81938f3a033e"><strong>Week 1 App</strong></a> wasn’t really safe at all, because everybody was able to interact with database from the console in their browser. Since our posts are added through the server, we can remove insecure package from terminal :</p><pre>meteor remove insecure</pre><p>Now when you try to insert, update or remove something from your console, it wouldn’t work. However it doesn’t mean that security is solved forever, but it’s good enough for our humble app right now.</p><p>Now let’s do something really cool with Meteor. When you answer questions, it’s kinda hard to remember previous answer. Since the whole process is based on it, we should be able to display previous answers to our users to make it more easier for them to answer. We could use Meteor reactivity to do this. Check this <a href="http://meteorpad.com/pad/TsHu27WASi6KdqaA6/Leaderboard"><strong>live example</strong></a> to get better idea what are we about to do. Now go to <strong>submit_problem.js</strong> and put the following just after our submit function :</p><pre>&#39;keyup input#problem&#39;:function(event) {<br>  Session.set(&quot;problem&quot;, event.target.value);<br>},<br>&#39;keyup input#why1&#39;:function(event) {<br>  Session.set(&quot;why1&quot;, event.target.value);<br>},<br>&#39;keyup input#why2&#39;:function(event) {<br>  Session.set(&quot;why2&quot;, event.target.value);<br>},<br>&#39;keyup input#why3&#39;:function(event) {<br>  Session.set(&quot;why3&quot;, event.target.value);<br>},<br>&#39;keyup input#why4&#39;:function(event) {<br>  Session.set(&quot;why4&quot;, event.target.value);<br>},<br>&#39;keyup input#why5&#39;:function(event) {<br>  Session.set(&quot;why5&quot;, event.target.value);<br> }</pre><p>As we said in the first tutorial, we use Sessions to store and access data on client, mainly for storing relevant data to current user. In our application we use Sessions to store values of the input fields in real-time. Everytime the user insert a letter in particular input, it’s stored in Session. Now we need to display the recently stored value. In <strong>helpers.js</strong> type :</p><pre>Template.submitProblem.helpers({<br>  problem: function() {<br>    return Session.get(“problem&quot;);<br>  },<br>  why1: function() {<br>    return Session.get(&quot;why1&quot;);<br>  },<br>  why2: function() {<br>    return Session.get(&quot;why2&quot;);<br>  },<br>  why3: function() {<br>    return Session.get(&quot;why3&quot;);<br>  },<br>  why4: function() {<br>    return Session.get(&quot;why4&quot;);<br>  },<br>  why5: function() {<br>    return Session.get(&quot;why5&quot;);<br>  }<br>});</pre><p>Now we get the value of inputs. One thing that still left is to display in interface of the submission process what we’ve just done. Open up submit_problem.html and edit as following :</p><pre>&lt;div id=&quot;submit-why1&quot; class=&quot;hidden&quot;&gt;<br>...<br>  &lt;div class=&quot;part2 dent&quot;&gt;<br>    <strong>&lt;li class=&quot;list-group-item&quot;&gt;<br>      &lt;p&gt;Problem — {{problem}}&lt;/p&gt;<br>    &lt;/li&gt;</strong><br>    &lt;input autofocus=&quot;autofocus&quot; <strong>value=&quot;{{why1}}&quot;</strong> type=&quot;text&quot; name=&quot;why1&quot; id=&quot;why1&quot; placeholder=&quot;Because …&quot;/&gt;<br>...<br>&lt;/div&gt;</pre><pre>&lt;div id=&quot;submit-why2&quot; class=&quot;hidden&quot;&gt;<br> ...<br>  &lt;div class=&quot;part3 dent&quot;&gt;<br>    <strong>&lt;li class=&quot;list-group-item&quot;&gt;<br>      &lt;p&gt;Why #1 — {{why1}}&lt;/p&gt;<br>    &lt;/li&gt;</strong><br>    &lt;input autofocus=&quot;autofocus&quot; <strong>value=&quot;{{why2}}&quot;</strong> name=&quot;why2&quot; id=&quot;why2&quot; type=&quot;text&quot; placeholder=&quot;Because …&quot;/&gt;<br> ...<br> &lt;/div&gt;</pre><pre>&lt;div id=&quot;submit-why3&quot; class=&quot;hidden&quot;&gt;<br>...<br>  &lt;div class=&quot;part4 dent&quot;&gt;<br>    <strong>&lt;li class=&quot;list-group-item&quot;&gt;<br>      &lt;p&gt;Why #2 — {{why2}}&lt;/p&gt;<br>    &lt;/li&gt;</strong><br>    &lt;input autofocus=&quot;autofocus&quot; <strong>value=&quot;{{why3}}&quot;</strong> type=&quot;text&quot; id=&quot;why3&quot; name=&quot;why3&quot; placeholder=&quot;Because …&quot;/&gt;<br>...<br> &lt;/div&gt;</pre><pre>&lt;div id=&quot;submit-why4&quot; class=&quot;hidden&quot;&gt;<br>...<br> &lt;div class=&quot;part5 dent&quot;&gt;<br>   <strong>&lt;li class=&quot;list-group-item&quot;&gt;<br>     &lt;p&gt;Why #3 — {{why3}}&lt;/p&gt;<br>   &lt;/li&gt;<br></strong>   &lt;input autofocus=&quot;autofocus&quot; <strong>value=&quot;{{why4}}&quot;</strong> type=&quot;text&quot; id=&quot;why4&quot; name=&quot;why4&quot; placeholder=&quot;Because …&quot;/&gt;<br> ...<br> &lt;/div&gt;</pre><pre>&lt;div id=&quot;submit-why5&quot; class=&quot;hidden&quot;&gt;<br> ...<br>  &lt;div class=&quot;part6 dent&quot;&gt;<br>    <strong>&lt;li class=&quot;list-group-item&quot;&gt;<br>      &lt;p&gt;Why #4 — {{why4}}&lt;/p&gt;<br>    &lt;/li&gt;</strong><br>    &lt;input autofocus=&quot;autofocus&quot; <strong>value=&quot;{{why5}}&quot;</strong> type=&quot;text&quot; id=&quot;why5&quot; name=&quot;why5&quot; placeholder=&quot;Because …&quot;/&gt;<br> ...<br>&lt;/div&gt;</pre><pre>&lt;div id=&quot;submit-solution&quot; class=&quot;hidden&quot;&gt;<br> ...<br>  &lt;div class=&quot;text-left&quot;&gt;<br>    <strong>&lt;li class=&quot;list-group-item&quot;&gt;<br>      &lt;p&gt;Problem — {{problem}}&lt;/p&gt;<br>    &lt;/li&gt;<br>    &lt;/div&gt;<br>    &lt;li class=”list-group-item”&gt;<br>      &lt;p&gt;Why #1 — {{why1}}&lt;/p&gt;<br>      &lt;p&gt;Why #2 — {{why2}}&lt;/p&gt;<br>      &lt;p&gt;Why #3 — {{why3}}&lt;/p&gt;<br>      &lt;p&gt;Why #4 — {{why4}}&lt;/p&gt; <br>      &lt;p&gt;Why #5 — {{why5}}&lt;/p&gt;<br>   &lt;/li&gt;</strong><br>   &lt;input autofocus=&quot;autofocus&quot; type=&quot;text&quot; name=&quot;solution&quot; id=&quot;solution&quot; placeholder=&quot;What could be the best solution ?&quot;/&gt;<br> ...<br> &lt;/div&gt;</pre><p>When you now go through the process of submitting your problem, it always shows you the previous answer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/425/1*dIL3FT5bLZp4wiaDVjpS8A.png" /></figure><p>We are almost finished, but there are two additional steps left just to make navigation in our application better. At first we need a way to link to clicked problems. Edit template in problem_item.html :</p><pre>&lt;template name=&quot;problemItem&quot;&gt;<br>  &lt;div class=&quot;problem-items&quot;&gt;<br>    <strong>&lt;a href=&quot;{{pathFor &#39;problemPage&#39;}}&quot;&gt;</strong><br>      &lt;li class=&quot;problems&quot;&gt;<br>        &lt;h3&gt;{{postProblem}}&lt;/h3&gt;<br>      &lt;/li&gt;<br>    <strong>&lt;/a&gt;</strong><br>  &lt;/div&gt;<br>&lt;/template&gt;</pre><p>Also we need the way to submit new problem in problems_all.html :</p><pre>&lt;template name=&quot;problemsAll&quot;&gt;<br>  ...<br>  &lt;div class=&quot;text-center&quot;&gt;<br>    <strong>&lt;div class=&quot;button-align&quot;&gt;<br>      &lt;a href=&quot;{{pathFor &#39;submitProblem&#39;}}&quot;&gt;&lt;input type=&quot;button&quot; id=&quot;submit-problem-page&quot; name=&quot;submit-problem-page&quot; class=&quot;btn btn-sample&quot; value=&quot;Ask 5 why&quot;&gt;&lt;/a&gt;<br>    &lt;/div&gt;</strong><br>    &lt;div&gt;<br>      {{#each problems}}<br>  ...<br>&lt;/template&gt;</pre><p>Now we are ready to deploy our small application for everyone to see. To deploy Meteor app, create name for your app and run the following in the terminal :</p><pre>meteor deploy <em>yourappname</em>.meteor.com</pre><p>Congrats ! We are live and also done for #2/6. It was really cool to see that I built this from idea only in 4 days (I was ill for other 2 days ). It’s only a second week but I already look forward to build something one step ahead part #2 in the #3 week. I know this app is not really that useful, but I wanted to have it in order to help me think deeper about problem solving and to question current state of how things work. As <strong>Paul Graham</strong> said :</p><blockquote>If you’re looking for startup ideas you can sacrifice some of the efficiency of taking the status quo for granted and start to question things. Why is your inbox overflowing? Because you get a lot of email, or because it’s hard to get email out of your inbox? Why do you get so much email? What problems are people trying to solve by sending you email? Are there better ways to solve them? And why is it hard to get emails out of your inbox? Why do you keep emails around after you’ve read them? Is an inbox the optimal tool for that ?</blockquote><blockquote>Pay particular attention to things that chafe you. The advantage of taking the status quo for granted is not just that it makes life (locally) more efficient, but also that it makes life more tolerable. If you knew about all the things we’ll get in the next 50 years but don’t have yet, you’d find present day life pretty constraining, just as someone from the present would if they were sent back 50 years in a time machine.</blockquote><blockquote><strong>When something annoys you, it could be because you’re living in the future.</strong></blockquote><blockquote>I’m on twitter at <a href="https://twitter.com/mhlavacka">@mhlavacka</a>, if you want to see what I’m up to next.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6254efa395b0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[6 in 6 Challenge Week 1 - Yik Yak Web Clone]]></title>
            <link>https://medium.com/@matthlavacka/6-in-6-challenge-week-1-yik-yak-web-clone-81938f3a033e?source=rss-5c5853bd4d6e------2</link>
            <guid isPermaLink="false">https://medium.com/p/81938f3a033e</guid>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Matt Ha]]></dc:creator>
            <pubDate>Sun, 15 Mar 2015 01:44:11 GMT</pubDate>
            <atom:updated>2015-09-03T20:29:04.785Z</atom:updated>
            <content:encoded><![CDATA[<h2>6 in 6 Challenge Week 1</h2><h2>-</h2><h2>Yik Yak Web Clone</h2><figure><img alt="" src="https://cdn-images-1.medium.com/max/831/1*5KAZKfIEIIS3HsRPkvBLHQ.png" /></figure><p>We’ll build a small social thoughts sharing app (let’s say <a href="http://www.yikyakapp.com/">Yik Yak</a> clone for better imagination) in 30 minutes as a first part of <a href="https://medium.com/@matejhlavacka/6-weeks-tour-to-learn-meteor-js-49d9e3d21560"><strong>Challenge to build 6 apps in 6 weeks in Meteor. </strong></a>Obviously, we won’t build it with the whole functionally. It will be rather easy to build and you can further extend it as you like. In this app you can <strong>submit a yak</strong> (your thought), <strong>login/log out</strong> to <strong>vote up or down</strong> on a yak and also <strong>comment</strong> on submitted yaks.</p><blockquote><em>Before we begin, you can try out a live demo of the app </em><a href="http://week1.meteor.com/"><strong><em>here</em></strong></a><em>.</em></blockquote><blockquote><em>Github repo </em><a href="https://github.com/mhlavacka/Week-1/"><strong><em>here</em></strong></a><em>.</em></blockquote><h4><strong>Installing Meteor and creating the application</strong></h4><p>If you are on Mac or Linux, install Meteor itself by running the following in your terminal :</p><pre>curl <a href="http://install.meteor.com/">http://install.meteor.com/</a> |sh</pre><p>If you use Windows, jump over to <a href="https://www.meteor.com/install">Meteor site,</a> to find out how to install on Windows. Once you have Meteor installed, we need to create a new project. Type the following to create it :</p><pre>meteor create week-1</pre><p>This command will create a simple app with the following structure :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/651/1*nzMyh4OIvB0415pSVTvRPA.png" /></figure><p>To start the app we’ve created in the previous step, type what terminal shows you :</p><pre>cd week-1<br>meteor</pre><p>Meteor creates a simple demo for you. Now check up your newly created app at <strong>http://localhost:3000/. </strong>You can play with it as you like, but after that delete <strong>week-1.html</strong> and <strong>week-1.js. </strong>We want to use our own code and folders.</p><h4>Creating interface</h4><p>In meteor code from one JavaScript file can run both on the client and the server, but we will now adjust project structure to separate code which runs on client and on server. Open up new terminal window and create client and server folders inside week-1, with following command in terminal:</p><pre>mkdir client server</pre><p>Obviously, all code in client directory will be available for client (in the browser), while code from server folder will remain on server side. There’s no need to do this, but it makes everything more transparent. Now create <strong>main.html</strong> file inside <strong>client</strong> to store our basic HTML.</p><pre>cd client<br>touch main.html</pre><p>Before we get to display anything, we need to add &lt;head&gt; and &lt;body&gt;. This will be our main app template. So open <strong>main.html </strong>and add the following :</p><pre>&lt;head&gt;<br>  &lt;title&gt;Yak&lt;/title&gt;<br>  &lt;!-- To support mobile-devices --&gt;<br>  &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;<br>&lt;/head&gt;</pre><pre>&lt;body&gt;<br>  &lt;div class=&quot;navbar navbar-static-top&quot;&gt;<br>    &lt;div class=&quot;navbar-inner&quot;&gt;<br>      &lt;div class=&quot;container&quot;&gt;<br>        &lt;a class=&quot;brand&quot; href=&quot;/&quot;&gt;Yak&lt;/a&gt;<br>        &lt;a class=&quot;btn btn-primary pull-right&quot; href=&quot;/submit&quot; type=&quot;button&quot;&gt;Send Yak&lt;/a&gt;<br>      &lt;/div&gt;<br>    &lt;/div&gt;<br>  &lt;/div&gt;<br>&lt;/body&gt;</pre><p>Before we go any further, let’s make our app look better by adding Bootstrap and some raw CSS. The simplest way to download Bootstrap in Meteor is to download it as a Meteor package. With the following command Bootstrap install itself :</p><pre>meteor add twbs:bootstrap</pre><p>That’s it ! You don’t have to include any files and links. Meteor just knows where to look for it. You can find more packages available at Atmosphere. Now we can see the reactive side of Meteor. After adding Bootstrap our app changes design without us pushing, deploying or uploading anything.</p><p>Since this tutorial is focused on HTML and JavaScript in Meteor, here is a raw CSS to copy in our css file. App will work without it, but why not make it much nicer ? Just don’t try to go through it, because it’s not based on any conventions at all. It was just me randomly styling the app in less time possible.</p><blockquote>https://github.com/mhlavacka/Week-1/blob/master/style.css</blockquote><p>It’s just very basic design, because I like to make things simple as possible. For example when most people start using cloud storage, they did so because Dropbox made it that simple to use, that 3 years old kid could use it.</p><p>Alright, looking good now, let’s implement some functionality.</p><p>Here we’ll start building the user interface for our application. We need to create first templates, that are used to create a connection between our interface and JavaScript code.</p><p>To display a list of yak items, we have the following template named <strong>yaks_list.html</strong> in <strong>client</strong> folder :</p><pre>&lt;template name=&quot;yaksList&quot;&gt;<br>  &lt;div class=&quot;yaks&quot;&gt;<br>    &lt;div class=&quot;form-style&quot;&gt;<br>      &lt;div class=&quot;container&quot;&gt;<br>        &lt;ul class=&quot;list-group&quot;&gt;<br>          &lt;h3&gt;Live feed of what people are saying around you&lt;/h3&gt;<br>          {{#each yaks}}<br>            {{&gt; yakItem}}<br>          {{/each}}<br>        &lt;/ul&gt;<br>      &lt;/div&gt;<br>    &lt;/div&gt;<br>  &lt;/div&gt;<br>&lt;/template&gt;</pre><p>The template is named yaksList as it displays a list of all yaks. We added all those classes to style it. You might wonder what is this :</p><pre>{{#each yaks}}<br>  {{&gt; yakItem}}<br>{{/each}}</pre><p>We use it to iterate over the array of yak posts and insert a yakItem template we are about to create for each value. Let’s say we have five yakItem elements inside the collection, yakItem element will appear 5 times within the interface.</p><p>Now we want to add font-awesome package to be able to use vote up and down icons in our app. Run the following in terminal :</p><pre>meteor add natestrauser:font-awesome</pre><p>Alright, now we add second template. We will implement interface of each individual yak in it. The content of template yakItem is as following :</p><pre>&lt;template name=&quot;yakItem&quot;&gt;<br>  &lt;div class=&quot;yak&quot;&gt;<br>    &lt;li class=&quot;list-group-item&quot;&gt;<br>      &lt;a class=&quot;yakPost&quot; href=&quot;#&quot;&gt;<br>        &lt;p class=&quot;break-el&quot;&gt;{{yak}}&lt;/p&gt;<br>        &lt;a class=&quot;btn pull-right btn-small no&quot; href=&quot;#&quot;&gt;&lt;i class=&quot;fa fa-chevron-down&quot;&gt;&lt;/i&gt;&lt;/a&gt;<br>        &lt;a class=&quot;btn pull-right btn-small yes&quot; href=&quot;#&quot;&gt;&lt;i class=&quot;fa fa-chevron-up&quot;&gt;&lt;/i&gt;&lt;/a&gt;<br>      &lt;/a&gt;<br>    &lt;/li&gt;<br>  &lt;/div&gt;<br>&lt;/template&gt;</pre><p>It displays all <strong>yaks</strong> property using <strong>{{yak}} </strong>and two buttons with vote up and down icons.</p><h4>Creating collections</h4><p>In Meteor you save data in collections. We will now create Yaks collection to hold a list of yak items. Create <strong>main.js </strong>in<strong> </strong>the <strong>week-1</strong> folder.<strong> </strong>Open it up and add the following line in it :</p><pre>Yaks = new Mongo.Collection(&#39;yaks&#39;);</pre><p>The above code creates a collection in MongoDB, which will store all our yaks. Now we want to display all stored yaks, into our template. To do that we need to create a new file under <strong>client</strong> called <strong>client.js.</strong></p><pre>Template.yaksList.helpers({<br>  yaks: function() {<br>    return Yaks.find();<br>  }<br>});</pre><p>You can pass variables to templates via helpers. Above function simply asks for list of yaks from Yaks collection we’ve just created and returns them using built in <strong>find()</strong> function.</p><p>Finally, we define a route for yaksList so that the template is loaded when someone visit “/”. We will use Meteor package called Iron Router to do this. Type the following into terminal :</p><pre>meteor add iron:router</pre><p>Once it is added, open up <strong>main.js </strong>and add the following code :</p><pre>Router.route(&#39;/&#39;, {name: &#39;yaksList&#39;})</pre><h4>Submitting yaks</h4><p>We basically say, when user visits “/” show her template named yaksList. It’s really that simple. We don’t have any yak items yet, but let’s access http://localhost:3000 anyway. To add some yak items let’s open up MongoDB console and type :</p><pre>meteor mongo</pre><p>Type the following when the mongo console opens up :</p><pre>db.yaks.insert({yak:&quot;first yak ever&quot;});</pre><p>If you keep an eye on your web app, while you are adding this, you will see how site automatically refreshes itself. Try to add more items the same way, to see how it works in realtime.</p><p>Let’s see how we are looking at this point :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/767/1*fOpWeJ7yYBH0BX1BkqlXSw.png" /><figcaption>Our first submitted yaks</figcaption></figure><p>We could add stuff from database or client forever, but to make submitting available also for our users, we need to create different route and template. Create new <strong>yak_submit.html</strong> file on <strong>client </strong>and add in it :</p><pre>&lt;template name=&quot;yaksSubmit&quot;&gt;<br>  &lt;div class=&quot;yaksSubmit&quot;&gt;<br>    &lt;div class=&quot;form-style&quot;&gt;<br>      &lt;div class=&quot;container&quot;&gt;<br>        &lt;form class=&quot;yaksSubmitForm&quot;&gt;<br>          &lt;h3&gt;Send yak. It&#39;s anonymous&lt;/h3&gt;<br>          &lt;input autofocus=&quot;autofocus&quot; type=&quot;text&quot; id=&quot;yak&quot; class=&quot;yak-form form-control&quot; name=&quot;yak&quot; placeholder=&quot;Type your yak here&quot;/&gt;<br>          &lt;input type=&quot;submit&quot; value=&quot;Send yak&quot; class=&quot;btn btn-primary&quot;&gt;<br>        &lt;/form&gt;<br>      &lt;/div&gt;<br>    &lt;/div&gt;<br>  &lt;/div&gt;<br>&lt;/template&gt;</pre><p>Now we have to again create route with Iron Router :</p><pre>Router.route(&#39;/submit&#39;, {name: &#39;yaksSubmit&#39;});</pre><p>If you click on the send yak button in the navbar, it should take you to the “/submit” page. Let’s make that interface you see work, now that template and route are ready. When users create new yak, we need to make a record in the collection. This is done by taking help of events in Meteor. Create <strong>yak_submit.js</strong> on <strong>client </strong>and add the following into it :</p><pre>Template.yaksSubmit.events({<br>  &#39;submit .yaksSubmitForm&#39;: function(event) {</pre><pre>    event.preventDefault();<br>    var yak = event.target.yak.value; // get yak value</pre><pre>    // check if the value is empty<br>    if (yak == &quot;&quot;) {<br>      alert(&quot;You can’t insert empty yak. Try to write something funny instead.&quot;);<br>    } else {<br>      Meteor.call(&#39;yakInsert&#39;, yak);<br>      Router.go(&#39;yaksList&#39;);<br>    }<br>  }<br>});</pre><p>Template events are similar to Template handlers. This event is the callback for all events triggered within yaksSubmit template. In our case we now need to catch the event and submit yak when user type something in the form and press enter or click on the submit button. Meteor.call(); is a method to call server to add a new item to our collection. We will get to that in second. Once everything is submitted, we load our main page so that user can see the newly created yak.</p><p>We will insert a new record via our custom method yakInsert. Create <strong>server.js</strong> in <strong>server</strong> folder and add the following :</p><pre>Meteor.methods({<br>  yakInsert: function(yak) {<br>    var postId = Yaks.insert({<br>      yak : yak, <br>      score : 0, <br>      submitted : new Date(), <br>    });<br>  }<br>});</pre><p>This method yakInsert is called in our event handler on client, and store variable yak, that contains user submitted yak post. We insert new yaks securely on the server. Also, we added initial score 0 for every yak and time, when new yak is submitted.</p><p>Go back to <a href="http://localhost:3000/">localhost:3000</a> and try whole process of submitting new yak.</p><h4><strong>Adding score and vote up or down buttons</strong></h4><p>Now we need to count how many upvotes or downvotes each individual yak get. At first add the following <strong>line of bold code</strong> to <strong>yak_item.html</strong> :</p><pre>&lt;template name=&quot;yakItem&quot;&gt;<br>…<br> &lt;p class=&quot;break-el&quot;&gt;{{yak}}&lt;/p&gt;<br> <strong>&lt;a class=&quot;btn&quot; href=&quot;#&quot;&gt; {{score}} &lt;/a&gt;</strong><br> &lt;a class=&quot;btn pull-right btn-small no&quot; href=&quot;#&quot;&gt;&lt;i class=&quot;fa fa-chevron-down&quot;&gt;&lt;/i&gt;&lt;/a&gt;<br> …<br>&lt;/template&gt;</pre><p>To enable to vote up or down on submitted yaks, we need to add some functionality first. Let’s create <strong>yak_item.js </strong>and make events functions for upvoting and downvoting. At first we need to know where user clicked, so we’ll build an event to find out. Add the following code :</p><pre>Template.yakItem.events({<br>  &#39;click&#39;:function() {<br>    Session.set(&#39;selected_yak&#39;, this._id);<br>  },</pre><pre>  &#39;click a.yes&#39;:function() {<br>    var yakId = Session.get(&#39;selected_yak&#39;);<br>    Yaks.update(yakId, {$inc: {&#39;score&#39;: 1 }}); <br>  },</pre><pre>  &#39;click a.no&#39;:function() {<br>    var yakId = Session.get(&#39;selected_yak&#39;);<br>    Yaks.update(yakId, {$inc: {&#39;score&#39;: -1 }});<br>    var postId = Yaks.findOne({_id:this._id});<br>    if (postId.score &lt;= -3) {<br>      Yaks.remove({_id:this._id})<br>    }<br>  }<br>});</pre><p>Meteor is reactive framework so as data changes, things in app change without doing shitload of work. Session is a way to store and access data on client. It’s perfect for storing data relevant to current user’s version of the app, whether an element is shown or hidden or store currently selected item in a list as we are doing in the code above. At first we store _id or better said we set _id of this particular clicked yak to Session called selected_yak. Then we get data from Session called selected_yak and store it in variable. We update score value, what means initial score : 0 gets overwritten. We either increment or decrement by 1. In case of vote down function, we set if statement to remove all yaks that get negative score of 3. When people don’t like it, we don’t like it too.</p><p>It’s working pretty nice now, but the problem is that everyone could vote 1000 and more times up or down. That’s why we need user accounts, to be sure that our user can get only 1 vote per yak.</p><h4><strong>Adding User Accounts</strong></h4><p>Adding user accounts is really simple in Meteor. We will use two Meteor packages to create accounts. Type the following in terminal to add packages:</p><pre>meteor add accounts-ui accounts-facebook</pre><p>We want only logged in users to be able to vote on yaks, right ? Therefore we need to create <strong>accounts.html </strong>and insert the following code :</p><pre>&lt;template name=&quot;accounts&quot;&gt;<br>  {{#if currentUser}}<br>    {{&gt; yaksList}}<br>  {{else}}<br>  &lt;div class=&quot;form-style&quot;&gt;<br>    &lt;div class=&quot;container&quot;&gt;<br>      &lt;div class=&quot;list-group-item&quot;&gt;<br>        &lt;div class=&quot;pagination-centered&quot;&gt;<br>          &lt;h2&gt;Please login to do this&lt;/h2&gt;<br>          &lt;div class=&quot;btn&quot;&gt;<br>            {{&gt; loginButtons}}<br>          &lt;/div&gt;<br>        &lt;/div&gt;<br>      &lt;/div&gt;<br>    &lt;/div&gt;<br>  &lt;/div&gt;<br>  {{/if}}<br>&lt;/template&gt;</pre><p>If you’re asking what this <strong>{{&gt; loginButtons}} </strong>is, it automatically adds the Facebook login button to our template. Once the user successfully connects, the variable currentUser points to the connected user. So, we can do simple if..else check to show either login button or list of all yaks, if user is already connected.</p><p>Now we need to set routing to ‘/login’ template to display it when not logged in user try to vote :</p><pre>Router.route(&#39;/login&#39;, {name: &#39;accounts&#39;});</pre><p>Go back to <strong>yak_item.html</strong> and edit as following :</p><pre>&lt;template name=&quot;yakItem&quot;&gt;<br>  &lt;div class=&quot;yak&quot;&gt;<br>    &lt;li class=&quot;list-group-item&quot;&gt;<br>      &lt;a class=&quot;yakPost&quot; href=&quot;#&quot;&gt;<br>        &lt;p class=&quot;break-el&quot;&gt;{{yak}}&lt;/p&gt;<br>      {{#if currentUser}}<br>        &lt;a class=&quot;btn&quot; href=&quot;#&quot;&gt; {{score}} &lt;/a&gt;<br>        &lt;a class=&quot;btn pull-right btn-small no&quot; href=&quot;#&quot;&gt;&lt;i class=&quot;fa fa-chevron-down&quot;&gt;&lt;/i&gt;&lt;/a&gt;<br>        &lt;a class=&quot;btn pull-right btn-small yes&quot; href=&quot;#&quot;&gt;&lt;i class=&quot;fa fa-chevron-up&quot;&gt;&lt;/i&gt;&lt;/a&gt;<br>      {{else}}<br>        &lt;a class=&quot;btn&quot; href=&quot;#&quot;&gt; {{score}} &lt;/a&gt;<br>        &lt;a class=&quot;btn pull-right btn-small&quot; href=&quot;/login&quot;&gt;&lt;i class=”fa fa-chevron-down”&gt;&lt;/i&gt;&lt;/a&gt;<br>        &lt;a class=&quot;btn pull-right btn-small&quot; href=&quot;/login&quot;&gt;&lt;i class=&quot;fa fa-chevron-up&quot;&gt;&lt;/i&gt;&lt;/a&gt;<br>      {{/if}}<br>      &lt;/a&gt;<br>    &lt;/li&gt;<br>  &lt;/div&gt;<br>&lt;/template&gt;</pre><p>We simply say that if there is current user, enable vote up or down, else don’t allow user to vote and link to login template instead. Now go to login template and configure the app to use your Facebook app id and app secret key. Just follow instructions given by package developer and it should work. Once you work on that, it will look like usual Facebook login button.</p><p>But as you might noticed, we don’t have a way to logout, because if we are logged in, our login template shows only list of yaks. Let’s just simply add another login button to our submit form, to enable users to log out :</p><pre>&lt;template name=&quot;yaksSubmit&quot;&gt;<br> ...<br>  &lt;form class=&quot;yaksSubmitForm&quot;&gt;<br>    {{#if currentUser}}<br>    &lt;div class=&quot;pull-right&quot;&gt;<br>      {{&gt; loginButtons}}<br>    &lt;/div&gt;<br>    {{/if}}<br>  &lt;h3&gt;Send yak. It’s anonymous&lt;/h3&gt;<br>  ...<br>&lt;/template&gt;</pre><p>Now we can easily log out in submit form. It’s not the super user-friendly solution, but hey, it’s easy and good enough to do so.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*hRAm6gzg8X4tT4dbfyofaw.png" /><figcaption>Newly created Facebook login button</figcaption></figure><p>Now we need to finish work on voting. At first we need a way to check if user voted on particular yak or not. When she already did, we do nothing and when she did not, we update score value and memorize that she has already voted. Sounds easy, let’s rewrite <strong>yak_item.js</strong> to make that happen :</p><pre>Template.yakItem.events({<br>  &#39;click&#39;:function() {<br>  Session.set(&#39;selected_yak&#39;, this._id);<br>},<br>  &#39;click a.yes&#39;:function() {<br>    if(Meteor.user()) {<br>      var postId = Yaks.findOne({_id:this._id})<br>      if ($.inArray(Meteor.userId(), postId.voted) !== -1) {<br>        return &quot;Voted&quot;;<br>      } else {<br>        var yakId = Session.get(&#39;selected_yak&#39;);<br>        Yaks.update(yakId, {$inc: {&#39;score&#39;: 1 }});<br>        Yaks.update(yakId, {$addToSet: {voted : Meteor.userId()}});<br>      } <br>   }<br>},</pre><pre>  &#39;click a.no&#39;:function() {<br>    if (Meteor.user()) {<br>      var postId = Yaks.findOne({_id:this._id})<br>      if ($.inArray(Meteor.userId(), postId.voted) !== -1) {<br>        return &quot;Ok&quot;;<br>      } else {<br>        var yakId = Session.get(&#39;selected_yak&#39;);<br>        Yaks.update(yakId, {$inc: {&#39;score&#39;: -1 }});<br>        Yaks.update(yakId, {$addToSet: {voted : Meteor.userId()}});<br>        if (postId.score &lt;= -3) {<br>          Yaks.remove({_id:this._id})<br>        }<br>      }<br>    }<br>  }<br>});</pre><p>This looks a bit tricky and it actually was. It took me quite longer (so long) to get right. I already decribed basic process above the code, but let’s go through it anyway. First we make sure user is logged in. If build in Meteor function Meteor.user() is true we are good to go. Make sure to check out <a href="https://docs.meteor.com/">official docs</a> to learn such a things. Then we find and store this._id of particular post in variable postId and asks with jQuery function inArray() if userId of current user already voted on current post. If she hasn’t voted yet, we update value of score and add her userId to the array of users who voted called voted. Let’s run it to see how it works. It should allow us to vote only once per yak.</p><p>As yaks in the list might have different value of score. We need to align them in descending order. To do so, edit code in <strong>client.js :</strong></p><pre>Template.yaksList.helpers({<br>  yaks: function() {<br>  return Yaks.find(<strong>{}, {sort : {score: -1}}</strong>);<br>  }<br>});</pre><p>That’s it, now only one part left. Since we are build social app, there has to be a place for commenting on yaks. But before we do that, let’s try to deploy our humble app, to see it live, perhaps try it on mobile device too. To deploy Meteor app, create name for your app and run the following in the terminal :</p><pre>meteor deploy <em>yourappname</em>.meteor.com</pre><h4><strong>Adding comments</strong></h4><p>The goal of a social site is to create a community of users, what will be hard to do without providing a way for people to talk to each other. So now let’s add comments ! At first we need a new collection to store comments in. Open up <strong>main.js</strong> and add following line of code to create new collection :</p><pre>Comments = new Mongo.Collection(&quot;comments&quot;);</pre><p>To display comments on single yak post, we need to create routing to single yaks. Obviously, we need dynamic route to display different yaks. That’s why we create new template named <strong>yakPage</strong> which renders the same yakItem. Insert the following into the <strong>yak_page.html</strong> :</p><pre>&lt;template name=&quot;yakPage&quot;&gt;<br>  &lt;div class=&quot;form-style&quot;&gt;<br>    &lt;div class=&quot;container&quot;&gt;<br>      {{&gt; yakItem}}<br>      &lt;div class=&quot;comment&quot;&gt;<br>        &lt;h4&gt;Comments&lt;/h4&gt;<br>        {{#each comments}}<br>          {{&gt; commentItem}}<br>        {{/each}}<br>      &lt;/div&gt; <br>    &lt;/div&gt;<br>  &lt;/div&gt;<br>&lt;/template&gt;</pre><p>I guess this template is pretty straightforward now. We iterate over comments for every comment item. Let’s create <strong>yak_page.js </strong>and add the following code in it :</p><pre>Template.yakPage.helpers({<br>  comments: function() {<br>    return Comments.find({postId:this._id});<br>  }<br>});</pre><p>To be sure we find the relevant comments, we only find those that are linked to current yak post via the postId attribute. Basically we are saying, display comments linked to this particular yak. We need to define interface for every inserted comment. It’s really easy to do, create new template in <strong>comment_item.html </strong>and add this :</p><pre>&lt;template name=&quot;commentItem&quot;&gt;<br>  &lt;li class=&quot;list-group-item&quot;&gt;<br>    &lt;p class=&quot;break-el&quot;&gt;{{body}}&lt;/p&gt;<br>  &lt;/li&gt;<br>&lt;/template&gt;</pre><p>We only insert the body of the comment to the comment item. Then we will show the number of comments on each posts, which will be also the link to the yakPage template, where we display comments. Open up and edit yakItem template the following way :</p><pre>&lt;template name=&quot;yakItem&quot;&gt;<br>  &lt;div class=&quot;yak&quot;&gt;<br>    &lt;li class=&quot;list-group-item&quot;&gt;<br>      &lt;div class=&quot;yakPost&quot;&gt;<br>        &lt;p class=&quot;break-el&quot;&gt;{{yak}}&lt;/p&gt;<br>      {{#if currentUser}}<br>        &lt;a class=&quot;btn&quot; href=&quot;{{pathFor &#39;yakPage&#39;}}&quot;&gt;{{commentsCount}} comments&lt;/a&gt;<br>        &lt;a class=&quot;btn pull-right btn-small no&quot; href=&quot;#&quot;&gt;&lt;i class=&quot;fa fa-chevron-down&quot;&gt;&lt;/i&gt;&lt;/a&gt;<br>        &lt;a class=&quot;btn pull-right&quot; href=&quot;#&quot;&gt; {{score}} &lt;/a&gt;<br>        &lt;a class=&quot;btn pull-right btn-small yes&quot; href=&quot;#&quot;&gt;&lt;i class=&quot;fa fa-chevron-up&quot;&gt;&lt;/i&gt;&lt;/a&gt;<br>      {{else}}<br>        &lt;a class=&quot;btn&quot; href=&quot;{{pathFor &#39;yakPage&#39;}}&quot;&gt;{{commentsCount}} comments&lt;/a&gt;<br>        &lt;a class=&quot;btn pull-right btn-small&quot; href=&quot;{{pathFor &#39;accounts&#39;}}&quot;&gt;&lt;i class=&quot;fa fa-chevron-down&quot;&gt;&lt;/i&gt;&lt;/a&gt;<br>        &lt;a class=&quot;btn pull-right&quot; href=&quot;#&quot;&gt; {{score}} &lt;/a&gt;<br>        &lt;a class=&quot;btn pull-right btn-small&quot; href=&quot;{{pathFor &#39;accounts&#39;}}&quot;&gt;&lt;i class=&quot;fa fa-chevron-up&quot;&gt;&lt;/i&gt;&lt;/a&gt;<br>      {{/if}}<br>      &lt;/div&gt;<br>    &lt;/li&gt;<br>  &lt;/div&gt;<br>&lt;/template&gt;</pre><p>And add the commentsCount helper to <strong>yak_item.js</strong> :</p><pre>Template.yakItem.helpers({<br>  commentsCount: function() {<br>    return Comments.find({postId:this._id}).count();<br>  }<br>});</pre><p>You should now see something similar to this :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/863/1*BH9xuL1ZbPPkXYUfhKlxPA.png" /></figure><p>If that’s the case we are good to continue, because there is still something that we’re missing here. You guessed it right, our users still don’t have a way to comment on submitted yaks. Let’s enable it by creating submit form, the process will be pretty similar to how we’ve already allowed users to create yaks. At first let’s add submit box in yakPage template :</p><pre>&lt;template name=&quot;yakPage&quot;&gt;<br> ...<br>      {{/each}}<br>    &lt;/div&gt;</pre><pre>     <strong>{{&gt; commentSubmit}}</strong><br> <br>    &lt;/div&gt;<br>  &lt;/div&gt;<br>&lt;/template&gt;</pre><p>And now we need to create comment form template in <strong>comment_submit.html</strong> :</p><pre>&lt;template name=&quot;commentSubmit&quot;&gt;<br>  &lt;form name=&quot;comment&quot; class=&quot;comment-form form&quot;&gt;<br>    &lt;div class=&quot;form-group&quot;&gt;<br>      &lt;input autofocus=&quot;autofocus&quot; name=&quot;body&quot; id=&quot;body&quot; class=&quot;comment-input form-control&quot; placeholder=&quot;Comment here&quot;&gt;<br>      &lt;input type=&quot;submit&quot; value=&quot;Add comment&quot; class=&quot;btn btn-primary&quot;&gt;<br>    &lt;/div&gt;<br>  &lt;/form&gt;<br>&lt;/template&gt;</pre><p>To submit our comments, create <strong>comment_submit.js</strong> and add following code, we will go through it step by step, because this one is kinda tricky :</p><pre>Template.commentSubmit.events({<br>  &#39;submit form&#39;: function(e, template) {<br>    e.preventDefault();</pre><pre>    var $body = $(e.target).find(&#39;[name=body]&#39;);<br>    var comment = {<br>      body: $body.val(),<br>      postId: template.data._id,<br>      submitted: new Date()<br>    };</pre><pre>    var commentBody = e.target.body.value;<br>    // Check if the comment is not empty<br>    if (commentBody == &quot;&quot;) {<br>      alert(&quot;You can’t insert empty comment. Try to comment something nice instead.&quot;)<br>    } else {<br>      Meteor.call(&#39;commentInsert&#39;, comment);<br>    }</pre><pre>    // clear input field<br>    e.target.body.value = &quot;&quot;;<br>  }<br>});</pre><p>The process here is to find element with the name <em>body </em>and store it in the $body variable. $ indicates it’s jQuery object and we are using jQuery function $.find(). Then we create variable comment and insert 3 different keys with values in it. At frist key body with value of the body element, second postId where we store _id of current yak. Template.data._id is basically the same as this._id. Third value is current time. Then we create an if function to deny users to submit empty comments and call server to insert comment when it’s not empty. Then just clear input field. Sounds pretty easy now, huh ?</p><p>Let’s insert our users’s comments now on <strong>server.js</strong>. It’s pretty easy, just add the <strong>bold</strong> code, don’t forget the coma:</p><pre>Meteor.methods({<br>  yakInsert: function(yak) {<br>    var postId = Yaks.insert({<br>      yak : yak, <br>      score : 0, <br>      submitted : new Date(), <br>    });<br>  }<strong>,<br>  commentInsert: function(comment) {<br>    Comments.insert(comment);<br>  }</strong><br>});</pre><p>I guess that’s it and only thing that left is route to individual yak post, where users comment. Let’s define it then :</p><pre>Router.route(&#39;/yaks/:_id&#39;, {<br>  name: &#39;yakPage&#39;,<br>  data: function() {<br>  return Yaks.findOne(this.params._id);<br>  }<br>});</pre><p>We define route in structure of ‘/yaks/&lt;ID&gt;’ where _id is the particular yak’s _id. Id is specific for every yak. Remember template.data._id from submit comment form ? Now we see how it’s used to create data function. We find one particular yak. To get better explanation jump over to this <a href="http://stackoverflow.com/questions/19937955/what-does-template-data-id-do-in-meteor"><strong>post</strong></a><strong> </strong>on Stackoverflow.</p><p>If you are reading this and I haven’t made lot of typos, I’m sure you can see something similar to this :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/858/1*IEXI-9SMu8X_sAcVol8_hw.png" /><figcaption>Commenting works</figcaption></figure><h4>Deploying our app</h4><p>Let’s make our app live and deploy it on meteor provided free hosting as we did earlier :</p><pre>meteor deploy <em>yourappname</em>.meteor.com</pre><p>Congrats ! We are live and also done ! Our social sharing app still lacks many possible features so I encourage you to add more features or change things as you like and tweet me your creations at <a href="https://twitter.com/mhlavacka">@mhlavacka</a>. I would love to see it. For example it would be nice to add geolocation and get geolocated posts from people around you.</p><blockquote>Few more thoughts about my <a href="https://medium.com/@matejhlavacka/6-weeks-tour-to-learn-meteor-js-49d9e3d21560">challenge to build 6 simple apps in 6 weeks to learn Meteor</a>.</blockquote><p>This week was really hard to manage, I still have to visit classes at college and apparently I have social life too (I don’t). For example I set only half a day to write this tutorial and now I can tell how naive and wrong I was. Let’s say I drank 20 cups of coffee in my whole life and 15 of them just this week, while figuring things out. I built the app three times in total, because after building it for the first time I felt like :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/394/1*XBiCpBDRPQqT6mBWMyxODA.jpeg" /><figcaption>Building the app for the first time</figcaption></figure><p>Then I built it for the second time while taking notes on the process to actually understand what I was doing and also to find a way to explain it in human language in this tutorial. Surprise surprise, it got easier and I think I look like this right now :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/380/1*geaXLY14N_TqOdgcFsyaWQ.jpeg" /><figcaption>Finally I got it</figcaption></figure><p>Keep rocking till the next week and let me know what you think via comments or at @mhlavacka on twitter. See you in week with tutorial to the new app and thanks for following this. I appreciate it ❤</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=81938f3a033e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[6 weeks tour to learn Meteor.js]]></title>
            <link>https://medium.com/@matthlavacka/6-weeks-tour-to-learn-meteor-js-49d9e3d21560?source=rss-5c5853bd4d6e------2</link>
            <guid isPermaLink="false">https://medium.com/p/49d9e3d21560</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[tech]]></category>
            <dc:creator><![CDATA[Matt Ha]]></dc:creator>
            <pubDate>Thu, 12 Mar 2015 22:00:29 GMT</pubDate>
            <atom:updated>2015-11-25T20:39:03.573Z</atom:updated>
            <content:encoded><![CDATA[<h2>6 in 6 Challenge</h2><h3>6 weeks tour to learn Meteor.js by building 6 apps</h3><blockquote><strong>I don’t want to be programmer. I just want to make stuff that works.</strong></blockquote><p>Don’t get me wrong, I’m just trying to say that programming is not my passion. Making things that solve problems is my passion. For almost a year and half I’ve dreamed of being able to take an idea and implement it in less time possible to test its potential.</p><p>I started tweaking with PHP and Python at first, but it was too complex and difficult for me, having none technical skills at that time. Following tutorials let me build some simple stuff, but I had no idea what to do, when I wanted to implement something on my own. I somehow always gave up, when things got harder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*MOYfcb_YobWrJx3ZjyAEfw.jpeg" /></figure><p>As <a href="http://www.paulgraham.com/startupideas.html">Paul Graham</a> said <strong>— </strong>Knowing how to code is really empowering. When you have an idea, you’ll be able to implement it quickly.<strong> </strong>In spite of thinking <strong>“That’s interesting idea”</strong>, you can think instead <strong>“That’s an interesting idea. I’ll try to build an initial version tonight.”</strong> It’s really a big advantage.</p><p>It’s okay to be underground with idea validation in the beginning, but from that point on, you have to move fast. For example, I created a ghetto version of <a href="https://wanderpack.typeform.com/to/Ralwfh">tinder for digital nomads</a> using <a href="http://www.typeform.com/">Typeform</a>(no referral link, I just love using it), to make meeting with people of similar interests in the new city easier. I got first ‘signups’, but I wasn’t able to further developed it on my own, because of my lack of programming skills.</p><p>After complaining about this to my friend Sam, who is working on <a href="http://godiscoverapp.co/">GoDiscover</a>, he showed me <a href="http://meteor.com/"><strong>Meteor</strong></a><strong>.</strong> I gave it a shot during nights on winter vacations and it turned out to be a really powerful thing and still simple to use. You only <strong>need basic understanding of the trio — HTML, CSS and JavaScript</strong> and you can build simple and elegant real-time applications and deploy just in few seconds.</p><h4>Okay, back to original point…</h4><p>After I’ve read <a href="http://javascriptbook.com/">JavaScript &amp; jQuery book</a> and first Meteor tutorials, I felt like learning only a little, so I asked my friend for an advice, which turned out to be — “Forget doing only tutorials and just try to build things. When you got stuck, google or stackoverflow (it’s a verb now) it and repeat.” Probably this sounds really obvious to you, but it really wasn’t obvious to me. Then I stumbled upon popular post on <a href="https://medium.com/@mackenziechild/how-i-finally-learned-rails-95e9b832675b"><strong>How to learn Rails by building simple web apps</strong></a> and decided to challenge myself to do the same.</p><p><strong>Over next 6 weeks, each week I’m going to build a new web application and write or record a step by step tutorial how I build each weeks app.</strong></p><p>{ Each week I’m gonna update this post, with the link to the new tutorial}</p><blockquote>Week 1 — Yik Yak Web Clone Tutorial — <a href="https://medium.com/@matejhlavacka/6-in-6-challenge-week-1-yik-yak-web-clone-81938f3a033e"><strong>Here</strong></a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/831/1*5KAZKfIEIIS3HsRPkvBLHQ.png" /></figure><blockquote><em>Week 2— Ask Five Whys Tutorial — </em><a href="https://medium.com/@matejhlavacka/6-in-6-challenge-week-2-ask-five-whys-6254efa395b0"><strong><em>Here</em></strong></a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8xQHmgJa6ECwwfnRmkxYWA.png" /></figure><blockquote><em>Week 3— Pinterest Like App Tutorial — </em><a href="https://medium.com/@matejhlavacka/6-in-6-challenge-week-3-pinterest-like-app-be0ecfeae698"><strong><em>Here</em></strong></a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xJxKmIVKtaEB48sbS6Nr-Q.png" /></figure><blockquote>Week 4— Instagram Clone Tutorial — <a href="https://medium.com/@matejhlavacka/6-in-6-challenge-week-4-a4c9c1541006"><strong>Here</strong></a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/399/1*sEXuQfvubwXMVzdUWAkWiA.png" /><figcaption>Instagram Clone</figcaption></figure><blockquote>Week 5— Youtube Downloader — <a href="https://medium.com/@matejhlavacka/6-in-6-challenge-week-5-25ba3aea979e">Here</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=49d9e3d21560" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>