Chrome console output notes

Below are some cool console.log tricks that I recently have been learning about.

Add CSS using %c

Change Styles: use the %c formatter to style everything that follows.

console.log('%c Hello World', 'color: blue;');
console.log('%c Hello %c World', 'color: blue;', 'font-weight: bold; color: red;');

Each %c acts as a delimiter which means everything following will take the styles added to the next param passed to console.log.

Clear the console

This one just happened for me one day since I use it so often in iTerm2, clearing the console makes it easier to read and digest the console log. To do this just press: Command + K on Mac and Control + K on Windows. Btw, this is the same shortcut for iTerm2.

You can also add it to your code and it’ll work by just adding in clear(). This will help debugging code a bit easier as you’ll only see what your code should be showing. 

Display objects or arrays

If you have an object like below:

user = {
  id: 123,
  twitter: '@usmanity',
  location: 'california'
}

You can print this in an easy to ready format by using console.table() like console.table(user) and it’ll display like this:

Same goes for arrays.

I’ll try to share more tips if I come across more! 😀

Mid-May update

In the past 2-3 months, I’ve been writing way more code and relatively more blog posts than I had before starting this blog. This has been mainly due to my goal of being consistent about things that interest me.

I’m writing this post because I haven’t posted in about 10 days and I was getting anxious to write something. This post is kind of like an intermittent update because I have been busy lately but I think most of those things are not very interesting to post about.

Cycling: I’ve started riding my bike again, after about 11 months of inactivity! My bike was hanging on its hook for so long that it had collected dust on all the components! I had forgotten where my pump was and took me awhile to find it. Below are my stats from Strava for cycling:

Strava stats as of May 16th, 2018

I don’t want to be unrealistic but I do want to ride a couple of hundred miles if I stay consistent.

Books: after finishing The Three-Body Problem, I wanted to read/listen to something non-fiction and I started listening to A Fine Mess by T.R. Reid. It’s a book on taxes and I did enjoy it. I have a draft post about it but I’ll talk more about it in that. I’m also reading a fiction book called Mattimeo by Brian Jacques, it’s a children’s fantasy novel about anthropomorphic mice, second in the Redwall series. After my experience with Watership Down by Richard Adams, I’ve been feeling many different things, like the whole story is so magical and profound yet so dark and simple that it kind of hurts to think about how real it made me feel. 

Code: I’ve been trying to stay consistent about learning Node.js and using it to build something. Also, I’m practicing things like python and javascript when I have some down time, this has been mostly for fun. I’m itching to build something big but I don’t want to misperceive my little bits of new information as newfound confidence.

The Joy of Tidying (and finances): I didn’t really know what to call this part but one thing that’s been part of my everyday thinking has been the notion of “less is more” and also using a recently learned problem solving principle called Occam’s razor to clearly focus on things. I remember when I read The Life-Changing Magic of Tidying Up by Marie Kondo last year, it really opened up a new way of looking at my possessions. It started with just the things I had and how many of them I wasn’t using or wanting yet they all were in my house, taking my room and requiring my time. 
Once I simplified my clothing, books, and other possessions, I started to think of abstract noises and complexities like finances, digital presences, online shopping, and even apps on my phone. This has been a topic of research for me as most people in my generation are dealing with this in various ways, I want to find an approach that’s not Draconian and still lets me enjoy my time with these things and without them. More on this later! 

The Three-body Problem

A few months ago, a friend recommended The Three-body Problem by Liu Cixin (translated by Ken Liu from Chinese to English). I listened to it as an audiobook.

This book is a different kind of science fiction! It starts out with at the Cultural Revolution in China in the 1960s and then sets the beginning there and then it skips ahead to present day for most of the book. 

Without spoiling much, the book does have a good science fiction plot but I got a bit bored with the amount of science that was being explained and some was just too out there to keep up and it started to feel like a textbook than a sci-fi novel. 

I did like how real the book felt through the early chapters with the characters being very well developed and described, later on, the characters started to feel predictable. 

If you’re looking for a sci-fi book, definitely read/listen to this book! 

I’m probably not going to continue the series, but that’s my opinion. 

Hitchhiker’s Guide to the Galaxy – Review

When I first started listening to audiobooks, I tried a couple of different books whose name I don’t even remember and I never got past the first few chapters. Last year, there was something different, I tried listening to the Harry Potter series. All the audiobooks in the Harry Potter series are narrated by Stephen Fry, who also narrated the Hitchhiker’s Guide to the Galaxy

I went in with high expectations, the whole Harry Potter series, over 100+ hours of listening was so easy because of the writing and narration but I think I might’ve made a mistake of putting too much emphasis on Stephen Fry’s voice and not enough on the story itself.

The book is very short compared to most sci-fi books and it’s also pretty short as an audiobook. This meant not a lot of environment building, long stretches of conversations, things moved very quickly so I wasn’t used to that.

The science fiction didn’t connect for me, there were instances like how the characters from other planets were completely fine communicating with Arthur Dent and Ford Prefect even though they had never gone to Earth (except one). I think the comedy was a bit too out of my league and I didn’t get it.

I think it’s a good book and especially when it was written, it must’ve been a very good book but I think now it felt like some things were just not as expected for me. 

I recommend at least given the book a once over but it’s not one of my favorites. 

Goodbye Bilo – December 2nd, 2017

Earlier today, we had to put Bilo to sleep.

Bilo Star (pronounced Be-lo) was born in the first week of February in 2015. He was just a few months short of his 3rd birthday. When he was just a few weeks old, my sister had adopted him and in July of 2015, I brought him to live with us in San Francisco.

Here's a video of Bilo and his sister playing when they were just a couple of months old:

Bilo and Heisenberg became friends and they started to spend time together.

Heisenberg and Bilo on the cat perch, July 2015

From an early age, Bilo was always a little unhealthy but once he came to San Francisco, we fed him on time every day and we started to notice his health and playfulness increase. Spending time with Heisenberg allowed him to get stronger.

Bilo in December of 2015

But slowly, he was starting to get less active and eat less. It started getting bad again where you can see he was sleeping way too much and never eating on time.

About four months ago, Bilo started getting food allergies so we took him to the doctor and they recommended a better food and gave him some allergy medicine. Over the next few months, his eating improved a bit but he was starting to get weak again. We had some other tests done when we took him for that checkup, and nothing conclusive was in the lab results so the doctor recommended we keep feeding him properly and paying attention to him.

This past Tuesday, Kristen pointed out to me that he was starting to sneeze a lot and wasn't touching his food at all. On Wednesday, we took him to the doctor and did some more tests, nothing came out of those. The hospital did give him some fluids and some medicine to decrease his pain.

This morning, we took him to the doctor and they told us he did not look well and his health is not going to improve so the humane thing to do is to put him to sleep. I didn't wake up today thinking I was going to have to do this and I didn't know he would be gone so soon.

Bilo was a mysterious and very loving cat, he loved sitting on people's laps and he loved watching birds on TV. I'm going to miss him a lot.

Here are a few songs for Bilo that remind me of him a lot.

The Boxer by Simon & Garfunkel

Our House by CSNY


This was posted on my previous blog but I wanted to keep this post on this blog because it means a lot to me.

A new topic to explore

On my previous blogs and on this blog so far, I have not talked about finances. I think it's a tough topic, to write about and to talk about. I believe most people around me (Silicon Valley) like making money and talking about companies' finances but are afraid or hesitant to talk about personal money/finances in general. This is anecdotal but over the past 5+ years, I've noticed this being the case with 9/10 people whenever we've gotten slightly close to the topic of money.

This is understandable, people in the US have always been a bit closed up about personal finances in my experience. This article sums up some thoughts about the Money Taboo, the idea that people shouldn't talk about money publicly with most people. 

The problem

But, having a taboo about something that's not wrong to do is incorrect, in my opinion. It leads to misinformation, ignorance of better options, and most of all, it's not good to stay quiet about finances. 

Money is a weird thing, it runs the world, for most people it runs their lives. We can't be lying to ourselves that we don't get up to go to work because money is involved. Even if you love your job, you'll take the bad and ugly days because there's money involved. And for this reason, I think there's some weight to the opinion that you should talk about money.

Another problem with this is debt, Americans don't know how to deal with debt and I believe it's also due to the lack of talking about finances. Debt is complicated and expensive, the latter being the primary reason for the former.

Exploring

Money is complicated, money is powerful, and money runs this world. But to get an understanding of your personal finances, getting comfortable talking about this isn't going to require you to go through college. Everyone's situation is different but there are some basics to get right.

Of course, there's this notion passed around "don't live beyond your means". This is good but it's halfway there. Of course, don't live beyond your means, but  where is that line where you can decide it's time to not spend this money? This is also tough from person to person but I think the first thing to do is get to your monthly spending below your monthly income. This would be more clear to me and everyone else if someone said "don't spend more than 80% of your paychecks, save the rest for various different things". But…it doesn't roll off the tongue as nicely.

When there's silence about finances, it leads to higher prices, it leads to desperate situations, it can also lead to confusion and fear of talking about money. And one of my nightmares is when a new-grad moves to Silicon Valley and gets a nice salary and then turns around and pays a crapload of their paycheck towards rent. If that's not living paycheck to paycheck, I don't know what it is.

I hope to use this blog to share some techniques, approaches, and concepts related to finances, in case they might help you too. This will help me talk more about money, publicly and hopefully will lead you to do the same.


Please let me know what you would like to talk about and learn more about related to finances.

Building a Chrome extension using Vue.js

I have been using Vue.js for awhile now, and when I started working on the Coins extension I wanted to be able to quickly prototype and find a build process that makes it really easy for development and deployment. It was fun creating the Coins extension using the power of Vue.js and I wanted to share what worked for me.

Here's the template I created to get started: vue-chrome-template

Overview

This template includes a webpack config that will build to local and production. In this case, production means that it will be ready for the Chrome web store. Vue.js extensions are easy if you have the build process figured out (see webpack.config.js in template). 

There's a manifest.json file that you'll want to edit to set up your extensions details for Chrome. Currently, it contains only a few required fields.

Getting started

Follow these steps to get your local development environment up and running:

  • Download or fork the template
  • Run npm install
  • Once npm installs everything properly, run npm run dev
  • If you'd like to test the extension, run npm run build, this will build into a folder called extension/. Load this folder in Chrome's extensions page.
  • (Optional) Use nvm to manage your node version

Tips for development

When working on your Chrome extension, I suggest using the pre-configured npm run dev command and just testing it inside a regular tab. You can access it at http://localhost:8081 and it'll refresh as you make changes too. 

When doing local development, you'll want to make sure to put everything inside the src directory in which the existing Vue app lives.

Use a fixed width in the app when doing local development, I usually put a 1px border around my app so it's easier to tell what the size will be. 

Make sure to set your app's details properly in manifest.json and you'll notice the template is set up for a browser action (Chrome dev docs).

Building for Production

When you're ready to deploy your app to the Chrome web store, you'll want to run npm run build and then zip up the extension/ directory (Chrome requires that all extensions are uploaded as a .zip). Whenever you're ready to upload, Chrome will require that the extension have a different version than what's been uploaded before


Please leave feedback and questions as comments below. This is one of my posts that's a tutorial and I would love to get constructive feedback. 

My goal for Yelp in 2018

In the past, I’ve never written about Yelp, restaurants, and even food on my blog. But some time in 2017, I had this thought that I should write reviews for places I’ve visited.

But last year, I hardly wrote any reviews. This year, I have been on a slow but consistent flow to write reviews on Yelp.

My goal is 127 reviews by the end of the year. Why 127? I started the year with 27 reviews, I think setting a goal of 100 reviews this year should be achievable.

As of this writing, I’m at 42 reviews.

There are some basic stats given to Yelp users on their reviews and photos, views in the last 90 days. You can see this by going to your profile on Yelp. Once a month, Yelp sends an email with the last month’s stats. I’m sitting at around 10k views of my reviews in the last 90 days and about 15k views of my photos. These are pretty good compared to anywhere else I post anything.

I will be cross-posting some reviews but I will try to keep most of the reviews on Yelp.

Introducing Treefingers

When I was writing the code for the laravel version of my blog, I had created a repo, usmanity/treefingers, and I used it to keep track of my changes. 

I was really excited when I had started working on it so I decided to create a brand for it but it never was public and so now I'm going to make that brand part of this blog.

Treefingers comes from a song by Radiohead. You can hear it here: Treefingers by Radiohead (Spotify) .

I wanted to base the brand off something related to trees and fingers, there's no real meaning for the word and the song so I'm interpreting it myself.

From the sun to the trees

Before I came up with the final design, I went through a couple of iterations. My initial representation for my blog was going to be the sol character in Unicode: ☉ 

And based off this concept I created the following:

Some were more for the mix of colors and some just because they represented the unicode character in a bit more detail. Then I wanted to keep going and trying to experiment and below are some concepts that now look ridiculous but I was just playing around at this point:

These represented something but not what my blog was, I think "simple solar"  would be a great one for a blog about space or something. The "unicode characters only" version looks weird now but at the time I thought it looked like a spaceship.

Below are some more but after these come the final ones.

After trying all these, I decided to step away from my computer and I wanted to rethink about what the name "Treefingers" meant and how I can properly represent it.

Without being too assuming, unaware, or insensitive, I did some research on a character that I had seen before, it's a CJK character for half a tree trunk in CJK languages (Chinese, Japanese, and Korean). It looks like this: . As far as I can tell, this character doesn't directly translate to anything except.

Treefingers

So below are the final ones that I had to pick from:

As you'll notice, it's the ⺦character on it's side, this is to make sure I'm not directly using the character and modifying it enough to be its own thing.

From here on, you'll see this as the branding for this blog.