Thanks for the cut

journey-to-greatness tips eric thomas

![tools](https://images.unsplash.com/reserve/oIpwxeeSPy1cnwYpqJ1w_Dufer%20Collateral%20test.jpg?crop=entropy&fit=crop&fm=jpg&ixjsv=2.1.0&ixlib=rb-0.3.5&q=80&w=900) [Photo by Todd Quackenbush, Unsplash](https://unsplash.com/toddquackenbush) By random chance, I met [Sean Callan](https://www.linkedin.com/in/seandcallan), a 15+ year software vet. He was kind enough to let me ask him a few questions. These are great tips I got from him. <br><br> #### 1. Review your own PRs Don't just look at it, but make comments on it. Like notes notes. Imagine the code was written by someone else. Comment on what sucks, what should the author improve upon. I did this yesterday and I saw a lot of room for improvement in my PR. Surprisingly more than I originally thought. In a start-up it's difficult to stop and review your code. It's always about getting features out quick and fast so we can be the first to market. But that isn't sustainable or responsible. You have to stop and review your code, it's just a part of writing software. Much like committing to git. #### 2. Monthly Reviews What have you done in the past 6 months? What have you do in the past 2 months? What could you have done better? This is a great way of celebrating your wins and pointing out your weak spots. The goal isn't to bring these things into light and let them sit there, rather to learn from them. Great I'm getting better at CSS, but man my HTML knowledge sucks. Ok let's work in some HTML exercises next month. How can I show off my CSS strength? I always liked getting reviews from my manager because I saw it as a path to improvement. I like the idea of reviewing yourself, you have to be your own worst critic. Not that getting review from others isn't great either! I just don't have that luxury at this moment. #### 3. Interviews sucks: practice problems Interviews are awkward, difficult, and confusing for both parties. I have been fortunate enough to be on both sides of the table and both sides suck. Good, now lean in. What sucks about interviews? They're difficult, it's like speed dating, and you always feel like you didn't give the right impression. Let's break it down a bit. **- It's difficult** Here in the Bay, interviews usually involve some kind of algorithm, or math or some really abstract problem. It's not because the interviewer is trying to be an asshole. They're trying to get you to a spot where you are not comfortable and then work from there. So how do you get better at being uncomfortable and working your way out? **Get uncomfortable!** Practice algorithms, practice things outside of web development, practice concurrency in Ruby, etc. You know your weak spots, jump in. I'm not saying practice algorithms for the sake of being an algorithm master. I'm saying practice being uncomfortable and work your way out. Whether it's learning a new framework, learning a new language or an algorithm. Get uncomfortable! **- Speed Dating** Any interview, technical or not involves social skills. There are many articles and studies that show, social skills matter. It is true that people will often overlook lack of technical skill over great social skills. No one wants to work with a jerk, even if you're the smartest most talented person in the world. Get social. Ok but how do you do that? There are books! I learned how to improve my social skills when I ran my photography company. I went on the bus and tried to randomly spark conversation with others. I tried to be more engaged in conversations, tried to find a common ground with strangers. It's difficult and uncomfortable, which means if you go through it, you'll come out better than before. **- Facing rejection** We face rejection everyday. No one is counting. It doesn't matter how many times you get rejected. Actually, it has an inverse effect. The more times you've been rejected the more successful you are. Pick any successful person you can think of and do some research on them. How many times have they been rejected? How many haters do they have out there trying to bring them down? Let me put it into perspective. Kim Kardashian, I'll admit I'm a hater. But I got to give it up to her. No matter how many people hate, no matter how many photoshop scandals come out and how many people are against her philosophy and mindset, she still goes out there and does her thing. What's her thing? Making millions with top brands of the world. I read the other day that Snapchat pays her millions of dollars to film her life. You don't get that kind of success without putting yourself out there and getting rejected. So how am I going to hate? I don't make millions, not even close. The kind of rejection she faces on the daily, no every minute, is beyond compare. I often get rejection from my cats and even that I hate. Got rejected? Good! Use that anger, that rage and turn it into motivation to get better. Prove your haters wrong! #### 4. It's a marathon, not a sprint I looked at Sean's linkedin profile and he has years and years of experience. And although I hate comparing skill with time, there is an undeniable truth that Sean has spent time honing his skills. Although I might work on my skills on a daily basis and perhaps more so than my peers, I have to always remember that it will take time for me to get better. I can't just read read read, pop my head up and say yep, I know stuff, give me a pay raise! It's going to take time and dedication. I have to keep on my schedule and grow and grow and grow. I can't just read one book and think, boom! I made it. When you are feeling frustrated that you're not where you want to be. Work towards that goal and remember it's going to take some time. And by time I don't mean sitting around and waiting, but you're going to have to do exercises, and do exercises and fail, and then do more exercises. #### 5. Criticism is great advice Et says it better than I ever can. [ET inspires](http://etinspires.com/wp-content/uploads/2013/11/11.-Shine-Bright.mp3). >Everybody wants to shine bright like a diamond, but nobody wants to get cut.

Pushing Binaries


![binary road way](https://images.unsplash.com/photo-1449182325215-d517de72c42d?crop=entropy&fit=crop&fm=jpg&ixjsv=2.1.0&ixlib=rb-0.3.5&q=80&w=900) [Photo by Jon Ottosson](https://unsplash.com/jonottosson) I've been trying to get better at algorithms and computer science materials. Which lead me to the exploration of binary numbers. While looking into binaries, I saw a really interesting pattern. If you want to push the 1 to a higher number just add by an exponent of 2. I.e. if you're trying to flip the 5th zero in 100,000 ( i.e. turn it to 110,000 ) add 2 ^ 4 power ( 16 ) to your number. I.e. 32 ( 100,000 + 10,000 ) + 16 = 48 ( 110,000 ) ```ruby 16.to_s(2) # => "10000" 32.to_s(2) # => "100000" (32 + 2 ** 4).to_s(2) #= > "110000" ``` If you need to turn off a bit, you'd subtract 2 ^ 4. Where 4 is the position you want to turn off subtracted by one. I wonder if this has any applications? I suppose if I dig deeper I'll find my answers. It's pretty trippy how involved math is with the basis of computers. It makes me realize how super interconnected our universe really is. More so how much we might not know.

Post Message

javascript post message

![ocean](https://images.unsplash.com/photo-1443527216320-7e744084f5a7?crop=entropy&fit=crop&fm=jpg&ixjsv=2.1.0&ixlib=rb-0.3.5&q=80&w=900) Photographer by: [Viktor Jakovlev](https://unsplash.com/apviktor) of [Unsplash](https://unsplash.com) <br> ### Standard Twitter Auth To log a user via Twitter to your platform you normally do a bunch of redirects via popup. For a better UX experience you can do it without reloading the browser. The flow would go something like: - User clicks on "Log in with Twitter" button - Script opens a new popup window ( `window.open('/auth/url');`) which redirects them to Twitter's authentication page. - User logins in and agrees to legal jibber jabber. - Twitter sends the user back to the url we have set up on Twitter. We'll create a token on our application and render a html page. - Browser loads your page and now you can do `window.opener.recordToken('apiTokenFromTwitter')`, assuming you have a global function waiting to accept the the api token you just got from your server. That's right you can access the window that opened the pop up from the pop up using `window.opener`! But that will only work if both windows are on the same domain...cause sa-curity!<br> ![sa-curity](http://media.tumblr.com/tumblr_m6efk3knS71qzqdem.gif) #### Same Origin Policy: The gist of the policy is that scripts are restricted to the domain they were loaded in. I.e. you cannot reach into an iframe loaded with YouTube, unless your script is on YouTube.com too. Geek your heart out on the [MDN](https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy) article. ### Usecase Say we had an existing authentication flow on our main site and we want to spin up a new site on a different domain. There is no time to implement a true single sign-on flow. No problem right? We'll just use window.opener and call some global function that records the api token: ```javascript window.opener.recordToken(apiTokenFromTwitter); //Uncaught DOMException: Blocked a frame with origin "https://authentication.server.com" from accessing a cross-origin frame.(…) ``` NOPE, cause of the same domain policy. We have to use postMessage. PostMessage allows us to communicate between two frames on different domains. And by communicate I mean only send basic data structures. The receiving window decides what to do with the message which allows the web to remain a safe space. The flow would be: - User clicks on login with twitter - We open a popup with the twitter auth flow on our main server. - User signs-in and twitter sends us back to our server. - Server signs user in and renders an html page with some javascript. - Javascript sends a message via postMessage to the new site and waits for a response. - Once new site gets the api token from the popup, we tell the pop to close. From authentication.server.com ( our authentication site ) ```javascript window.postMessage({ api_token: 'asdfasfas' }, www.originalsite.com }); ``` On originalsite.com: ```javascript window.addEventListener('message', function (event) { // check if the message is from our server if (event.origin !== 'https://www.authentication.server.com') return; if (event.data && event.data.api_token) { // do stuff with token } }); ``` ### TLDR Communication between frames on different domains is possible using [Post Message](https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage).

Caught by the Cheese

motivation career eric thomas zig ziglar

![enter image description here](https://images.unsplash.com/photo-1442120108414-42e7ea50d0b5?crop=entropy&fit=crop&fm=jpg&ixjsv=2.1.0&ixlib=rb-0.3.5&q=80&w=900) Photo by: [Eutah Mizushima, Unsplash](https://unsplash.com/eutahm) When I reach goals, it's hard not to celebrate and say "ahh" I made it. But really, I haven't. I just made one step closer to being a better version of me, and that's my true goal: becoming the best I can possibly be. Zig Ziglar said it best: > So many people go to their graves with their music still in them. - [Zig Ziglar](http://www.ziglar.com/) I gotta admit, when I got a new job and pay raise, I got comfortable. I thought to myself, how can this get better? Things were good. I was working from home, I was making more money I than I expected to make during college and I started my career a year and a half ago. Things look good. But good is not the level I want to be at. I want to be at great and I lost sight of that. Instead of reading books, studying algorithms, or writing blog posts, I watched 3rd Rock from the Sun and the Blacklist. I got distracted by the cheese. >Any rat that's smart, they know what the trap is. Unfortunately, sometimes they get caught up on the cheese. And so they get so consumed by the cheese, they forget about the trap! - [Dr. Eric Thomas](http://www.etquotes.com/quotes/dont-focus-on-the-cheese-dont-focus-on-the-limitations-you-focus-on-the-trap-and-you-gonna-be-just-fine/) I was stuck on good because I've never been great. I haven't worked on a project that changes the world, or led a team or built a successful business. I don't know what great is because I'm stuck on good and am not willing to give it up to get to great. [Pearls of Wisdom](https://youtu.be/sQAh7qFep0A?t=164) by [ET](etinspires.com) paints the feeling the best. Entertainment is great, in small doses. But unlike sugar or fatty foods, there is no clear guide to how much is too much. So it's easy to get consumed by it. One more show, one more game and then it's 3o'clock in the morning. Even if it's been 30 minutes, you could have read a chapter of a book or maybe half a chapter. That much closer to your goals and being successful. A goal is not a sprint, it's a marathon. You think marathon runners just one day wake up and decide to run a marathon? It's at least a year commitment, 2-3 times a week depending on the level they're on. Sometimes it's everyday. What am I gonna do about it? I made a schedule. Everyday I wake up at 4AM and I chip away at a book. I write a blog post. I study an algorithm. I have 3 hours to improve myself. And although 3 hours may not seem enough time to get things done, 3 hours times 5 days a week times 52 weeks per year is a lot of hours. If you ever feel like you're at the top of your game and you can chill, just know that there is someone out there who is pissed they're not where you are. And they're working hard to get to your spot. So you better enjoy your break because after you're done, you better start hustling. > What you do off the job is determining factor in how far you will go on the job. - [Zig Ziglar](http://www.ziglar.com/)

Twitter Auth without reload

javascript authentication twitter

To log a user via Twitter to your platform you normally do a bunch of redirects via popup. For a better UX experience you can do it without reloading the browser. When you open Twitter's log in page via popup it will authenticate the user and then redirect to a url you have provided. When the browsers loads the page, you have access to the window that opened the pop up via `window.opener`. The flow would go something like: - User clicks on "Log in with Twitter" button - Script opens a new popup window ( `window.open('/auth/url`) which redirects them to Twitter's authentication page. - User logins in and agrees to legal jibber jabber. - Twitter sends back your application to the url you have provided Twitter. Your app *should* create an api token. - Browser loads your page and now you can do `window.opener.recordToken('apiTokenFromTwitter')`, assuming you have a global function waiting to accept the the api token you just got from your server. That's right you can access the window that opened the pop up from the pop up using `window.opener`! Now that you have the `api token` you can send requests on behalf of the user. ### TLDR Use `window.opener` to reference the parent window from the popup to pass back the user's `api token`.