-
Notifications
You must be signed in to change notification settings - Fork 0
/
feed.xml
466 lines (344 loc) · 37.7 KB
/
feed.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Blog Name</title>
<subtitle>Blog subtitle</subtitle>
<id>http://blog.url.com/blog</id>
<link href="http://blog.url.com/blog"/>
<link href="http://blog.url.com/feed.xml" rel="self"/>
<updated>2016-03-13T08:57:00-05:00</updated>
<author>
<name>Blog Author</name>
</author>
<entry>
<title>Functional Reactive Programming for Beginners</title>
<link rel="alternate" href="http://blog.url.com/blog/2016/03/functional-reactive-programming-for-beginners.html"/>
<id>http://blog.url.com/blog/2016/03/functional-reactive-programming-for-beginners.html</id>
<published>2016-03-13T08:57:00-05:00</published>
<updated>2016-03-13T09:09:00-05:00</updated>
<author>
<name>Article Author</name>
</author>
<content type="html"><iframe width="560" height="315" src="https://www.youtube.com/embed/vLmaZxegahk" frameborder="0" allowfullscreen></iframe>
<p>It is my opinion that functional programming will be huge this year, and thus very beneficial to begin learning. The problem, is that learning functional programming from scratch can be so confusing because of the vast amount of jargon associated with it. After toying with it for a month, I decided to put together an intro for anyone who wants to know what it is all about.</p>
</content>
</entry>
<entry>
<title>How to set up a workflow for local web development</title>
<link rel="alternate" href="http://blog.url.com/blog/2015/11/15-local-web-dev-workflow.html"/>
<id>http://blog.url.com/blog/2015/11/15-local-web-dev-workflow.html</id>
<published>2015-11-20T09:47:00-06:00</published>
<updated>2016-03-08T06:14:36-06:00</updated>
<author>
<name>Article Author</name>
</author>
<content type="html"><iframe width="560" height="315" src="https://www.youtube.com/embed/WD73ZvuoCFQ" frameborder="0" allowfullscreen></iframe>
<p>If you are just starting out and are only familiar with editors such as Codepen, JSFiddle, and Codecademy etc, this tutorial will show you everything you need to know to get set up locally.</p>
</content>
</entry>
<entry>
<title>Power Hour - How to deal with long lists of "unimportant" tasks</title>
<link rel="alternate" href="http://blog.url.com/blog/2015/10/power-hour.html"/>
<id>http://blog.url.com/blog/2015/10/power-hour.html</id>
<published>2015-10-31T07:00:00-05:00</published>
<updated>2016-03-08T06:14:36-06:00</updated>
<author>
<name>Article Author</name>
</author>
<content type="html"><p>In an attempt to get a lot of shit done, I have done what many books and
productivity systems have recommended over the years, which is to create a &ldquo;todo&rdquo; list and I&rsquo;ll do my best to work through that.</p>
<p>The interesting thing is that the longer I stick to one of these systems, the
longer that list gets of things that just don&rsquo;t ever seem to get done. Ughh, how
annoying. </p>
<p>Usually it&rsquo;s the less important tasks, or things I just don&rsquo;t REALLY want to do
and won&rsquo;t have a severe effect if I put them off. It could be something like, &ldquo;write that e-mail to my buddy,&rdquo; or &ldquo;search for a dentist that is closer for my regular checkups.&rdquo;</p>
<p>I have a pretty big procrastinator tendancy, which is helpful when I am given
deadlines and constraints. I can do great work under pressure, but these tiny
tasks just find ways to annoy me week after week as they pile up because I have
&ldquo;other more important&rdquo; things to do.</p>
<p>In order to combat this issue, I have come up with a strategy called <strong>Power Hour.</strong></p>
<h3 id="simple">Simple</h3>
<p>It&rsquo;s really as easy as this&hellip;each day (or sometimes every few days) I&rsquo;ll just
schedule in an hour where I scramble and try to knock out as many of these
little &ldquo;unimportant&rdquo; tasks as possible.</p>
<p>It&rsquo;s actually kind of fun sometimes. I&rsquo;ve made it into a bit of a game to see
how much I can do. There is no real feeling of loss if I don&rsquo;t do these tasks,
but they have a huge happy feeling for marking them off as &ldquo;done.&rdquo;</p>
<p>The way it works, is when you are planning out your days or week, identify when
something isn&rsquo;t extremely important and stick it under a &ldquo;Power Hour&rdquo; list. You
can safely stop staring at that huge list of never complete tasks now, and only
pull it out during your scheduled times.</p>
<p>Woot. Let me know if you guys come up with any similar ways to get through those
small tasks without them bleeding into your main focus or stressing you out each
week.</p>
</content>
</entry>
<entry>
<title>My Journey from Zero to Developer</title>
<link rel="alternate" href="http://blog.url.com/blog/2015/10/zero-to-developer.html"/>
<id>http://blog.url.com/blog/2015/10/zero-to-developer.html</id>
<published>2015-10-09T13:55:00-05:00</published>
<updated>2016-03-08T06:14:36-06:00</updated>
<author>
<name>Article Author</name>
</author>
<content type="html"><p>I often get asked what caused me to give up being a &ldquo;Youtube celebrity&rdquo; and a
life of playing video games for a living to go work at IBM. </p>
<p>Well, discussing reasoning behind some of my life decisions could be a conversation of it&rsquo;s own,
but for now I&rsquo;d love to share the story of my journey from having no idea what I was
doing to landing one of the most amazing jobs I could ever ask for. </p>
<hr>
<h3 id="table-of-contents">Table of Contents</h3>
<p><a href="#recap">Recap</a><br>
<a href="#research-/-exploration-phase">Resarch / Exploration Phase</a><br>
<a href="#learning-strategy">Learning Strategy</a><br>
<a href="#fully-commit">Fully Commit</a><br>
<a href="#community">Community</a><br>
<a href="#job-hunt">Job Hunt</a><br>
<a href="#got-a-job!">Got a Job!</a> </p>
<hr>
<h2 id="recap:">Recap:</h2>
<p>I&rsquo;ll spare you the life story, but I have to start somewhere so I&rsquo;ll just say
that when I made the decision to jump into learning web development&hellip;I was at a
point where I had no idea what I wanted to do in life.</p>
<p>Why did I make the decision? My sister had begun her CS degree (she is 10 years
younger) and I really wanted to help her, so I skimmed a Java book and went
through all of her homework projects with her during that first semester.</p>
<p>I was overjoyed with remembering how awesome building things from scratch and
solving complex problems can be that I just had a lightbulb moment. I knew what
I wanted to be doing with my life going forward.</p>
<h2 id="research-/-exploration-phase">Research / Exploration phase</h2>
<p>I had coded flash games back in 2007, but I knew NOTHING about how the web worked, since all I&rsquo;ve done since then is play video games.</p>
<p>All I knew is that I wanted to make apps that would be viewable on my phone or
the web. For a while, I thought I was going to have to learn Java&hellip;until I
realized that was only used in extremely outdated enterprise software.</p>
<p>My first month was chaotic learning. I kept seeing information pointing me in 5
different directions. I read an entire book on Java, then switched to Python for
a week and read through a book on that.</p>
<p>I signed up for courses to learn &ldquo;Big Data&rdquo;, and algorithms, and AI, and all
kinds of crap. I really had no idea what I was doing or what I needed to learn.</p>
<p>The one thing I am most grateful for, is that I made the decision to install
Linux so that I could learn the Bash command line, and I did some tutorials on
using Vim.</p>
<h2 id="learning-strategy">Learning strategy</h2>
<p>After getting tossed around with my learning, I was getting frustrated. I began
researching code bootcamps, colleges, and various ways of getting this shit
down.</p>
<p>I discovered a local bootcamp teaching PHP, and looked into some colleges.
Eventually, after realizing how bad my credit was and the fact that I couldn&rsquo;t
afford to do any of that, I stumbled across <a href="http://theodinproject.com">The Odin Project</a>.</p>
<p>It was a free self paced online bootcamp stating it could take you from zero
knowledge, to landing a job. PERFECT!</p>
<p>I&rsquo;ve always thrived in self paced conditions, and this is exactly what I needed:
A roadmap.</p>
<blockquote>
<p><strong>NOTE:</strong> For anyone reading this, The Odin Project is a great resource for learning Ruby and Rails,
although now days I would VERY HIGHLY recommend using <a href="http://freecodecamp.com">Free Code Camp</a>
which has become an amazing project with a huge community backing it.</p>
</blockquote>
<h2 id="fully-commit">Fully Commit</h2>
<p>Now that I had a plan, I decided to take the &ldquo;burn all of the ships&rdquo; approach
and fully commit to getting a job in web dev.</p>
<p>At this point I sold my gaming PC, all of my Youtube recording equipment,
deleted all of my TV shows, and vowed to not play any games or watch TV until I
landed a job.</p>
<p>In order to track my progress and stay focused, I wrote out a recap every other
day as well as at the end of each week. I kept many of the recaps public as well
here - <a href="http://colbycheeze.blogspot.com/">http://colbycheeze.blogspot.com/</a></p>
<p>The other thing which I&rsquo;m not 100% about, was I experimented with getting only
5-6 hours of sleep each night so that I could spend more time learning. I
probably wouldn&rsquo;t skip so much sleep based on my recent sleep / learning
research but in the end it worked out.</p>
<h2 id="community">Community</h2>
<p>Getting things going, even with the &ldquo;roadmap&rdquo; was tough! I definitely got stuck
a lot along the way.</p>
<p>The point at which I really accelerated, was when I began joining communities
and meeting people that could help me or visa versa.</p>
<p>I began talking with people from the code buddies and code newbie community, and
joined various active Slack channels.</p>
<p>Having people to reach out to with questions about whether I was on track or not, while also seeing other newbies
with questions I could answer was very encouraging.</p>
<p>Eventually I began to attend as many local meetups as I could, and getting to
know other developers.</p>
<p>Having a strong community, and connections to fall back on is probably one of
the most important things regardless of career path you take. If this is the
only thing you take away from this article, this was a success.</p>
<h2 id="job-hunt">Job hunt</h2>
<p>Finally after about 4 months of hardcore learning, I began tweaking my resume
and sending out messages to various companies.</p>
<p>I wrote down a general description of myself and sort of an intro &ldquo;template&rdquo; so
I wouldn&rsquo;t have to retype things each time, while slowly improving upon it.</p>
<p>While applying at various locations, I was slowly working to improve my personal
website and portfolio to give the best first impression to anyone researching
me.</p>
<p>All in all, I sent out 80 job applications within about a 6 week period and got
turned down or ignored on most. I had a few phone interviews that I was turned
down on for &ldquo;not enough experience&rdquo;.</p>
<p>This can be the most upsetting part of the journey, but my best advice is to
just ask for feedback, and find out what skills people are looking for.
Eventually, you will find somewhere that you are a fit if you keep improving
yourself, and trying to meet new people.</p>
<h2 id="got-a-job!">Got a job!</h2>
<p>Eventually I got accepted to an interview at IBM Design and another startup
based in Austin around the same time. I went to both, and was offered a spot in
either location.</p>
<p>I was very skeptical of being at a big company however I was blown away after
the interview, so I turned down the startup&rsquo;s offer.</p>
<p>Overall, I believe my ability to land a job was in large part due to soft
skills. In other words, I was able to demonstrate not only a bit of knowledge,
but I showed that I had a ton of passion and would be an enjoyable person to
work with.</p>
<p>My best parting advice then would be to work on yourself as a person, not just
your ability to code. Hopefully a look back on my journey was insightful.
Definitely leave a comment or send me an e-mail if you have questions as I&rsquo;d
love to help anyone out that is treading down my path!</p>
</content>
</entry>
<entry>
<title>Achieving the Impossible with Simple Habits and Discipline</title>
<link rel="alternate" href="http://blog.url.com/blog/2015/07/discipline-and-habits.html"/>
<id>http://blog.url.com/blog/2015/07/discipline-and-habits.html</id>
<published>2015-07-15T06:11:00-05:00</published>
<updated>2016-03-08T06:14:36-06:00</updated>
<author>
<name>Article Author</name>
</author>
<content type="html"><p>Have you ever been overwhelmed by the idea of becoming truly great at programming, and accomplishing some of the things that the people you look up to do? I&rsquo;ve spent some time really deconstructing how best to take myself from zero to hero and I&rsquo;d love to discuss what I&rsquo;ve discovered over the years. </p>
<p>Why do you think the majority of people fail at new year&rsquo;s resolutions? There are several answers to that question, but I&rsquo;ll give you the ones that are important to our discussion.</p>
<ul>
<li>The goals are enormous and EASY to fail at.</li>
<li>When messing up, it is usually very self deprecating / painful.</li>
<li>There are no habits or process in place to achieve those goals.</li>
<li>No progress gets tracked</li>
</ul>
<p>Whether it&rsquo;s eating better, working out more, being more empathetic to others, memorizing people&rsquo;s names, or quickly learning a new programming language - all can be achieved by utilizing the power of habit and discipline.</p>
<p>Over the past few years I&rsquo;ve been reading many books, listening to podcasts from successful entrepreneurs, and doing personal study around this and other related topics. What I&rsquo;ve discovered is just how important it is to monitor habit and discipline as a way to continually improve in life.</p>
<p>If you monitor human nature you can discover some interesting things.
* If we &ldquo;achieve&rdquo; a huge goal, it often leaves us with a feeling of emptiness.
* We push hard to be 100% productive and work tirelessly, but become extremely unproductive and sick of work.
* When overcoming huge challenges, we feel really good about ourselves.</p>
<p>So that leads me to my favorite sayings, which I live by:</p>
<blockquote>
<p>&ldquo;If you aren&rsquo;t growing, you&rsquo;re dying.&rdquo;</p>
</blockquote>
<p>and&hellip;</p>
<blockquote>
<p>&ldquo;If you&rsquo;re not failing, you&rsquo;re not trying hard enough.&rdquo;</p>
</blockquote>
<p>I guess all I really wanted to say up to this point now is that, we really have to rethink our definition of success. It is never acheived. It is only strived for. Once you stop reaching for something, that is when you lose. It doesn&rsquo;t matter where you are now, or where you will be in the future.</p>
<p>The only factor is the journey, and what we learn along the way. So in order to truly make strides, stop focusing on that elusive target in the distance and begin looking at how you can work hard TODAY, every day, and find happiness in that.</p>
<p>Okay enough of that, let&rsquo;s actually talk about getting shit done!</p>
<h3 id="discipline-is-the-answer">Discipline is the answer</h3>
<p>Discipline is the KEY to success. But, discipline is hard! Well, not really&hellip; Actually, discipline is hard <em>without habits</em>. Discipline is learned. You teach it to yourself through your habits. <strong>Let&rsquo;s explore that</strong>.</p>
<p>It might seem like you will need a boatload of motivation and willpower to achieve greatness and to sustain the discipline required to overcome your biggest goals but that just isn&rsquo;t the case.</p>
<p>The secret that high achievers know is that willpower and motivation are NOT reliable. They are an emotion, and like all other emotions they depend on many things that are usually outside of our control. Even when we are mostly in control of those emotions, the intensity of them comes in waves.</p>
<p>But guess what? <mark>Habits convey discipline</mark>. That said, forming a new habit can be a brutal experience all in it&rsquo;s own. If you have ever tried forming new habits or even getting rid of BAD habits, then you know I cannot get away with suggesting that lightly. </p>
<p>It can take a consistent effort of up to 30 days to solidify a new habit in our life. Many times, if you falter in that period, your time frame can reset itself and you are back to square one. I don&rsquo;t know many people (including myself) that has the willpower to pull off forming big changes like that consistently.</p>
<p>So what is the trick? </p>
<h3 id="micro-habits">Micro Habits</h3>
<p>Small and hard to fail. Barely noticeable really. That&rsquo;s what I&rsquo;m talking about here.</p>
<p>This is going to feel and sound really weird but the power behind it is ginormous. Please bare with me and you will not regret it.</p>
<p>When I say micro-habit, I really mean MICRO habit. Want to work out or go to the gym every day? Do one pushup. That&rsquo;s your goal. You do ONE pushup and you win.</p>
<p>Want to go to the gym though? Okay, you start by putting on gym shorts and walking out the front door. You win. Maybe you don&rsquo;t make it to the gym. But just put on the clothes and walk out the door.</p>
<p>Sound stupid? Yep, it does. Give it a shot though, because this concept will change your life forever.</p>
<p>The idea is that once you are in the position and you have done one pushup, you are going to say to yourself, &ldquo;Why stop there, maybe I&rsquo;ll do 5 more.&rdquo; The great thing about this also, is that even if you are nasty sick, you can do one pushup. Anyone can put on their shorts and walk out the front door.</p>
<h3 id="how-does-it-work?">How does it work?</h3>
<p>With micro habits you don&rsquo;t experience the pain of failure, and you are constantly winning. The power comes into play when you start compounding all of these micro habits. Over time, you slowly add more and more.</p>
<p>The point is to make it so incredibly easy that it&rsquo;s harder to NOT do it eventually. It needs to be locked into your routine in such a way that you don&rsquo;t even think about it, you just DO it. It&rsquo;s like driving a car. You don&rsquo;t even think about all of the steps involved, it just happens.</p>
<p>Once something is habit, you don&rsquo;t have to think about it. I always used to forget to brush my teeth, so last month I made the habit of &ldquo;pick up my toothbrush every time I go to the bathroom&rdquo;</p>
<p>Guess what, I brush my teeth every day (multiple times) and I don&rsquo;t even think about it any more.</p>
<h3 id="what-next?">What next?</h3>
<p>Eventually, those simple habits are going to become very trivial to you and you will need to ramp up to keep interested. One way to keep improving is to bump up the challenge level. You should always be looking for ways to take yourself out of your comfort zone.</p>
<p>There is REAL research to prove that we derive happiness from diversity and challenge. You never want to get a feeling of comfort, as much as it may <strong>sound</strong> good in theory.</p>
<p>Creating challenging experiences for yourself is an extremely exhilarating experience. I won&rsquo;t get into challenges and comfort zone within the scope of this article, but hopefully I can plant a seed for you to think about it.</p>
<h4 id="need-a-suggestion?-write-code-every-day">Need a suggestion? Write code every day</h4>
<p>Well this is a programming blog after all, are you surprised? I suggested this in a chat recently, and received pushback on the basis of &ldquo;having a life.&rdquo;</p>
<p>Look I get it, people have other things to do. So do I. Coding every day doesn&rsquo;t mean coding ALL day. Anyone can take an hour a day to hone their most important skill, or work on an exciting personal project / portfolio.</p>
<p>John Resig, the creator of JQuery (now a big part of Khan Academy) wrote an <a href="http://ejohn.org/blog/write-code-every-day/">amazing article</a> about this which I recommend you open in a new tab and read after finishing this post.</p>
<h3 id="recap-of-my-recent-habits">Recap of my recent habits</h3>
<p>Alright, just so you don&rsquo;t feel I&rsquo;m blowing some hot smoke at you I&rsquo;d like to share some of my personal successes that I&rsquo;ve had over the past couple of months by utilizing these methods. Hopefully this can give you ideas of your own!</p>
<ul>
<li>Brush teeth every day</li>
<li>Workout every morning</li>
<li>Wake up consistently at 5am</li>
<li>Meditate daily</li>
<li>Hot &amp; Cold alternating Shower (my showers are much shorter and pump me up)</li>
<li>Writing for at least 1 hour every morning after my meditation</li>
<li>Consciously learning something new every day, generally before bed.</li>
<li>Coding at least a little bit each day.</li>
<li>Listen to audiobooks daily (usually get through 4-5 books and multiple podcasts a month)</li>
</ul>
<p>This is a huge topic, and entire books have been written about it but I believe I&rsquo;ve summed up some of the most important takeaways. Don&rsquo;t stop here. Life should be a constant journey of self improvement.</p>
<p>I&rsquo;d love it if you shared your experiences with forming new habits, and let me know if this helps you out by leaving a comment below!</p>
<p>Finally, I&rsquo;ll leave you with this:
<iframe width="560" height="315" src="https://www.youtube.com/embed/AdKUJxjn-R8" frameborder="0" allowfullscreen></iframe></p>
</content>
</entry>
<entry>
<title>The Right Way to Publish User Data</title>
<link rel="alternate" href="http://blog.url.com/blog/2015/06/publishing-user-data.html"/>
<id>http://blog.url.com/blog/2015/06/publishing-user-data.html</id>
<published>2015-06-23T06:04:00-05:00</published>
<updated>2016-03-08T06:14:36-06:00</updated>
<author>
<name>Article Author</name>
</author>
<content type="html"><p>In Meteor, you will always receive the information for the current logged in user, but what happens when you want to display information from other users such as avatar images, names, or other profile specific info? </p>
<p>This isn&rsquo;t immediately obvious with Meteor, and my own confusion when first trying to do this is the reason I&rsquo;m writing this post.</p>
<p>There are several ways of obtaining the information for non-logged in users, however you also have to consider a few security and privacy issues along the way which are very important.</p>
<p>You need to keep in mind that it is important to only publish the very minimal amount of information necessary to achieve your desired result.</p>
<p>Let&rsquo;s start by asking for the user&rsquo;s profile. First we have to actually create a publication for this.</p>
<h5 id="publishing-user-data-is-as-simple-as...">Publishing user data is as simple as&hellip;</h5>
<pre class="highlight javascript"><code><span class="nx">Meteor</span><span class="p">.</span><span class="nx">publish</span><span class="p">(</span><span class="s1">'userData'</span><span class="p">,</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
<span class="k">return</span> <span class="nx">Meteor</span><span class="p">.</span><span class="nx">users</span><span class="p">.</span><span class="nx">find</span><span class="p">();</span>
<span class="p">});</span>
</code></pre>
<p><img alt="Publishing too much data" src="http://cheeze-blog-images.s3.amazonaws.com/Publish_private_data.png" /></p>
<p><mark>Whoa, Danger!</mark> We definitely don&rsquo;t want to be publishing everyone&rsquo;s password hash, email, and whatever other personal info that our app may be storing!</p>
<p>Let&rsquo;s try that again. This time we need to be specific with what we need. For that we can pass in a <code>fields</code> object to our publication.</p>
<h5 id="the-right-way">The right way</h5>
<pre class="highlight javascript"><code><span class="nx">Meteor</span><span class="p">.</span><span class="nx">publish</span><span class="p">(</span><span class="s1">'userData'</span><span class="p">,</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
<span class="k">return</span> <span class="nx">Meteor</span><span class="p">.</span><span class="nx">users</span><span class="p">.</span><span class="nx">find</span><span class="p">({},</span> <span class="p">{</span><span class="na">fields</span><span class="p">:</span> <span class="p">{</span><span class="na">profile</span><span class="p">:</span> <span class="mi">1</span><span class="p">}});</span>
<span class="p">});</span>
</code></pre>
<p>Ah yes, much better. Now all we will receive is the <code>_id</code> and the data within their profile.</p>
<p>Another cool trick that I didn&rsquo;t know when first starting, is that you can drill down further and ask for specific fields within the profile by using a string, such as: <code>{fields: {&#39;profile.specificData&#39;: 1}}</code></p>
<p>Well, it&rsquo;s that simple! There isn&rsquo;t much more to say, but hopefully this saves someone some time because it was a pain for me when first getting started.</p>
<h2 id="bonus-round!-gravatars">Bonus round! Gravatars</h2>
<p>Alright, so what happens if you need to display a Gravatar image which requires the user&rsquo;s e-mail? You COULD publish the <code>&#39;services.emails&#39;</code> field, but that is a no-no also. Not everybody wants their e-mail to be public.</p>
<h5 id="well-there-are-two-options-here:">Well there are two options here:</h5>
<ol>
<li>We store a hash of the e-mail, which can then be sent to the API</li>
<li>We take care of the API call on user creation, and store the actual Gravatar URL in the profile.</li>
</ol>
<p>Well, I&rsquo;d have to say <strong>BINGO!</strong> with number 2. That&rsquo;s the &ldquo;Mongo&rdquo; way. Denormalization as they call it. This also reduces the load times because we aren&rsquo;t making dozens of API calls to Gravatar each time our page loads up.</p>
<p>One thing to keep in mind, is that you may have to create a hook that updates that gravatar url when the e-mail changes. Sacha, the author of Discover Meteor, recently wrote an amazing article about collection hooks and denormalization which you can <a href="https://www.discovermeteor.com/blog/a-look-at-meteor-collection-hooks/">read on his blog here</a>.</p>
<p>Okay, so here is the snippet of code that can handle converting not only a generic e-mail login into an Avatar, but also handle a Google login. This could be extended to other services as well of course.</p>
<pre class="highlight javascript"><code><span class="nx">Accounts</span><span class="p">.</span><span class="nx">onCreateUser</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">options</span><span class="p">,</span> <span class="nx">user</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">attachData</span><span class="p">,</span> <span class="nx">email</span><span class="p">,</span> <span class="nx">picture</span><span class="p">,</span> <span class="nx">profileImageUrl</span><span class="p">,</span> <span class="nx">profilePicture</span><span class="p">,</span> <span class="nx">url</span><span class="p">,</span> <span class="nx">service</span><span class="p">,</span> <span class="nx">allEmails</span><span class="p">,</span> <span class="nx">firstEmail</span><span class="p">;</span>
<span class="nx">profileImageUrl</span> <span class="o">=</span> <span class="kc">undefined</span><span class="p">;</span>
<span class="nx">user</span><span class="p">.</span><span class="nx">profile</span> <span class="o">=</span> <span class="nx">user</span><span class="p">.</span><span class="nx">profile</span> <span class="o">||</span> <span class="p">{};</span>
<span class="c1">//If the google service exists</span>
<span class="k">if</span> <span class="p">((</span><span class="nx">service</span> <span class="o">=</span> <span class="nx">user</span><span class="p">.</span><span class="nx">services</span><span class="p">)</span> <span class="o">!==</span> <span class="kc">undefined</span> <span class="p">?</span> <span class="nx">service</span><span class="p">.</span><span class="nx">google</span> <span class="p">:</span> <span class="kc">undefined</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">user</span><span class="p">.</span><span class="nx">emails</span> <span class="o">=</span> <span class="p">[</span>
<span class="p">{</span>
<span class="na">address</span><span class="p">:</span> <span class="nx">user</span><span class="p">.</span><span class="nx">services</span><span class="p">.</span><span class="nx">google</span><span class="p">.</span><span class="nx">email</span><span class="p">,</span>
<span class="na">verified</span><span class="p">:</span> <span class="kc">true</span>
<span class="p">}</span>
<span class="p">];</span>
<span class="nx">user</span><span class="p">.</span><span class="nx">profile</span><span class="p">.</span><span class="nx">firstName</span> <span class="o">=</span> <span class="nx">user</span><span class="p">.</span><span class="nx">services</span><span class="p">.</span><span class="nx">google</span><span class="p">.</span><span class="nx">given_name</span><span class="p">;</span>
<span class="nx">user</span><span class="p">.</span><span class="nx">profile</span><span class="p">.</span><span class="nx">lastName</span> <span class="o">=</span> <span class="nx">user</span><span class="p">.</span><span class="nx">services</span><span class="p">.</span><span class="nx">google</span><span class="p">.</span><span class="nx">family_name</span><span class="p">;</span>
<span class="nx">user</span><span class="p">.</span><span class="nx">profile</span><span class="p">.</span><span class="nx">avatar</span> <span class="o">=</span> <span class="nx">user</span><span class="p">.</span><span class="nx">services</span><span class="p">.</span><span class="nx">google</span><span class="p">.</span><span class="nx">picture</span><span class="p">;</span>
<span class="p">}</span>
<span class="c1">//No avatar defined from Google service? Okay let's get a Gravatar</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">user</span><span class="p">.</span><span class="nx">profile</span><span class="p">.</span><span class="nx">avatar</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">email</span> <span class="o">=</span> <span class="p">((</span><span class="nx">allEmails</span> <span class="o">=</span> <span class="nx">user</span><span class="p">.</span><span class="nx">emails</span><span class="p">)</span> <span class="o">!==</span> <span class="kc">undefined</span> <span class="p">?</span> <span class="p">(</span><span class="nx">firstEmail</span> <span class="o">=</span> <span class="nx">allEmails</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="o">!==</span> <span class="kc">undefined</span> <span class="p">?</span> <span class="nx">firstEmail</span><span class="p">.</span><span class="nx">address</span> <span class="p">:</span> <span class="kc">undefined</span> <span class="p">:</span> <span class="kc">undefined</span><span class="p">)</span> <span class="o">||</span> <span class="s1">''</span><span class="p">;</span>
<span class="nx">url</span> <span class="o">=</span> <span class="nx">Gravatar</span><span class="p">.</span><span class="nx">imageUrl</span><span class="p">(</span><span class="nx">Gravatar</span><span class="p">.</span><span class="nx">hash</span><span class="p">(</span><span class="nx">email</span><span class="p">));</span>
<span class="nx">user</span><span class="p">.</span><span class="nx">profile</span> <span class="o">=</span> <span class="p">{</span> <span class="na">avatar</span><span class="p">:</span> <span class="nx">url</span> <span class="p">};</span>
<span class="p">}</span>
<span class="k">return</span> <span class="nx">user</span><span class="p">;</span>
<span class="p">});</span>
</code></pre>
<p>So that&rsquo;s it! Want to learn more gotchas around Meteor security? Josh Owens has a great set of posts that really dives into this topic that I suggest you <a href="http://joshowens.me/meteor-security-201/">check out on his blog here</a>.</p>
</content>
</entry>
</feed>