Tonight was the end of my dodgeball season. Here’s a quick list of lessons learned. Some lessons translate to business. Some translate to personal progress.
It’s not about the individual effort, it’s about the team effort.
When you’re the lone dodger out there, you’re team will still be yelling at you.
I’ve been a Javascript developer for the past year and a half. By reading the “You don’t Know Javascript” series, I’m hoping to hone my vanilla Javascript skills and have a deeper knowledge of the language.
In Up & Going, I’m hoping to review the basics and understand more deeply why the language has the set of tools it has, and perhaps a deeper understanding of why we write Javascript the way we do.
When you strive to comprehend your code, you create better work and become better at what you do.
Preface
This You Don’t Know JavaScript book series offers a contrary challenge: learn and deeply understand all of JavaScript, even and especially “The Tough Parts”.
I like this attitude as it focuses on the bits of the language I have to deal with time and time again. It helps me understand the behavior of Javascript without blindly looking at a TypeError with a quizzical expression.
i.e. Cut out the buzzwords. Learn the language
Chapter 1: Into Programming
Explains programming at a high level. I may skip large sections of this.
literal value are values that are itself and are not stored. e.g. in the statement, y = x + 4;, 4 is a literal value.
Expressions are the reference to variables, values, or set of variable(s) and value(s) combined with operators.
Assignment expressions assign a variable to another expression
I’m reviewing this because these basic building blocks can be fundamentally different. In Go, assignments can be completely different
Review later: Javascript compiling in the first two chapters of Scope & Closures
The prompt() function opens an alert with an input. You can assign the function with a variable. age = prompt("What is your age?");
We take it for granted that specifying the variable in an assignment is typically on the left.
Side tangent: Are there languages that do the opposite?
Some lesser known assignments in JS include
Remainder assignment x %= y
Shift assignments x <<= y
Shift bits left or right by a certain amount. The above example shifts bits to the left.
Bitwise assignments x &= y or x = x & y
The above example pertains to bits, using an AND logic.
AND logic table
Bit
Bit
Result
0
0
0
1
0
0
0
1
0
1
1
1
values added to the source code are called literals
Implicit coersion is when you’re making a comparison against two different types. The == operation is ‘loosely equal’ and uses implicit coersion. For this reason, it should be avoided because it can cause unexpected bugs.
More on this later in Chapter 2 of this title & Chapter 4 of Types & Grammar
Code comments help other humans understand your code. It’s a communication point.
Comments should explain why, not what. They can optionally explain how if that’s particularly confusing.
Note to self - focus on why, and less on what.
Static Typing - variables adhere to type enforcement
Dynamic Typing - allows a variable to represent a value regardless of type. Javascript adheres to this.
State is tracking changes to values as the program runs. In redux, we keep a global state to track the user’s progress through the application.
Constants are declared once and don’t change. In ES6, when you declare a constant once, it throws an error if there is an attempt to change it. This is like the static-tying type enforcement.
A group of series of statements strung together are called a block. A block is contained within curly brackets. { .. }
In Ruby, there are different ways to show a block. In fact, there are different types of blocks, like your general block, procs, and lambdas.
Conditions throw an error if its expression between the parentheses are not a boolean.
“Falsy” values are converted to the boolean false. “Truthy” values do the opposite. More on this in Chapter 4 of Types & Grammar
An iteration occurs each time a block is called.
Warning: For a variety of historical reasons, programming languages almost always count things in a zero-based fashion, meaning starting with 0 instead of 1. If you’re not familiar with that mode of thinking, it can be quite confusing at first. Take some time to practice counting starting with 0 to become more comfortable with it!
I rarely use do..while loops. Here’s the syntax.
do { console.log('How may I help you?'); // Help the customer numOfCustomers = numOfCustomers - 1;} while (numOfCustomer > 0);
Like C, the Javascript for loop has three clauses.
The initialization clause
The conditional clause
The update clause
Reusable pieces of code can be gathered into a function
The lexical scope, or scope, is the programming term to tell us where our variables can be accessed.
function outer() { var a = 1; function inner() { var b = 2; // we can access both `a` and `b` here console.log( a + b ); // 3 } inner(); // we can only access `a` here console.log( a ); // 1}outer();
In the example, you can’t call inner(); on the outermost scope. It can only be called within the outer function scope, as shown.
More on lexical scope in the first three chapters of Scope & Closures
Chapter 2. Into Javascript
Note: After reading through the first chapter, I realize I don’t really need to review too much. I’m going to skim this chapter and only note the things that I really think are worthwhile. Otherwise, I will keep notes on this chapter to a minimum.
No value set type is undefined.
I didn’t know null is an object type. Weird bug probably will never get fixed.
typeof null is an interesting case, because it errantly returns “object”, when you’d expect it to return “null”.
To learn: Javascript’s symbols. I’m well aware of Ruby’s implementation of symbols like :symbol_example, which are used in many different contexts like classes. Will elaborate more on this in the ES6 portion.
Arrays and functions are subtypes to objects. In my introduction to JS, I assumed “everything is an object”.
Built-In Type Methods extend the power of Javascript. These methods are like String.prototype.toUpperCase.
Coercion comes in two forms: explicit and implicit
explicit is with both types the same.
implicit is when type conversion can happen.
Coercion is not evil. There are times when you may need to convert types.
List of falsy:
"" (empty string)
0, -0, NaN
null, undefined
false
Things that can be truthy
non-empty strings
non-zero, valid numbers
true
arrays, empty or non-empty
objects, empty or non-empty
functions
== checks for value equality. Coercion allowed.
=== checks for value and type equality. Coercion not allowed. Also known as strict equality
Some simple rules for equality of when to use == or ===.
If either value (aka side) in a comparison could be the true or false value, avoid == and use ===.
If either value in a comparison could be of these specific values (0, "", or [] — empty array), avoid == and use ===.
In all other cases, you’re safe to use ==. Not only is it safe, but in many cases it simplifies your code in a way that improves readability.
I’ve played it safe with this, but I may revisit using == more often, if it doesn’t violate the rules. Important note: think critically before use.
You might think that two arrays with the same contents would be == equal, but they’re not
When comparing numbers with strings, the strings get coerced into a number. When the string contains non-number characters, it gets converted to NaN and when comparing with < or >, NaN is neither greater nor less than a value, hence returns false.
Hoisting is when a variable is moved to the top of the enclosing scope. (conceptually speaking)
Okay to use a function before it is declared as function declarations are hoisted. Generally not good with variables.
Use let for block scoped variables. For example, in an if block, you declare a variable you only want to be used within that block, use let.
function foo() { var a = 1; if (a >= 1) { let b = 2; while (b < 5) { let c = b * 2; b++; console.log( a + c ); } }}foo();// 5 7 9
Strict mode was introduced in ES5. Noted with "use strict".
Strict mode disallows implicit auto-global variable declaration from omitting the var.
I feel computer science needs to put unnecessarily long titles to items. Immediately invoked function expressions (IIFE) are involved upon declaration.
An example use case was with Highcharts and creating an options object. You can’t always assign a key with a function, so this is one way around it.
Closure is a way to “remember” and continue to access a function’s scope.
I think of this as a way to tweak functions without having to write out more functions.
This is least understood by JS developers, and I think I know why. To me, it’s a function generator, although that’s an improper term because Javascript can create a generator function, which is a totally different topic.
The most common usage of closure in Javascript is the module pattern. Modules let you define private implementation details (variables, functions) that are hidden from the outside world, as well as a public API that is accessible from the outside.
Executing the module as a function creates an instance of that module.
The this operator reference depends on how the function is called. That will determine what this is. There are four rules of how this gets set. More on this later in the this & Object Prototype book.
Prototype links allow one object to delegate properties from another object. What this means is a property prototype linked is not attached to that object but to its original object (which could in turn, just be the proto property of Object).
Do not think of applying prototypes as inheritance. It follows a pattern called “behavior delegation”, delegating one part of an object to another.
Bring the old to new with polyfiling and transpiling.
A “polyfill” is to take a definition of a newer feature and produce a piece of code equivalent to the behavior for older JS environments.
An example is lodash that has a bunch of features from ES5 and ES6 which some frameworks utilize, like forEach and map.
Careful writing your own polyfill as you should adhere closely to the specification.
Better yet, use the vetted ones.
Transpiling is great for new syntax. It is a tool that converts your code to older coding environments. You can break down the word “transpiling” into transforming + compiling.
arguments can be used functions to determine which arguments were passed in. It is not a reserved word, so you can assign it to a different value. When calling it, it outputs an array.
The book series doesn’t cover Non-Javascript, like the DOM API. But you need to be aware of it. DOM API could actually be written by the browsers in C/C++.
The document object is a “host object”, a special object that has been implemented by the browser.
Chapter 3: Into YDKJS
This chapter is a preface to the other books. I’ll skip these notes as I’ll be covering this in more detail in those posts.
I ran across the node-glob and realized I didn’t know what a glob is. I read through the node-glob documentation and found out globs are a form of pattern matching. I realized I had been using globs for a long time, like the wildcard notation, without knowing its name.
adventure time glob
Wildcards
There are generally two wildcards you can use for glob functions.
* - “any string of characters”
? - one character
There are also brackets, where the character must be one of the following, or given as a range.
[abc] - one of “a”, “b”, or “c”
[a-z] - between the range of “a” to “z”.
You can also line this up with a ”!” to mean not in the following bracket.
[!abc] - not one of “a”, “b”, or “c”
[!a-z] - not in the range of “a” to “z”
The examples above are used in UNIX-based systems. These commands are slightly different in Window’s Powershell and SQL. For more information about those systems, you can read the Wikipedia article about globs.
Node Example
var glob = require("glob");// options is optionalglob("**/*.js", options, function (er, files) { // files is an array of filenames. // If the `nonull` option is set, and nothing // was found, then files is ["**/*.js"] // er is an error object or null.});
Everybody gets critiqued. Great composers like Beethoven have been critiqued. In this review of Beethoven’s Ninth Symphony, the London Symphony picked up this quote from a Rhode Island newspaper.
The whole orchestral part of Beethoven’s Ninth Symphony I found very wearying indeed.
Several times I had great difficulty in keeping awake … .
It was a great relief when the choral part was arrived at, of which I had great expectations.
It opened with eight bars of a common-place theme, very much like Yankee Doodle … .
As for this part of the famous Symphony, I regret to say that it appeared to be made up of the strange, the ludicrous, the abrupt, the ferocious, and the screechy, with the slightest possible admixture, here and there, of an intelligible melody.
As for following the words printed in the program, it was quite out of the question, and what all the noise was about, it was hard to form any idea.
The general impression it left on me is that of a concert made up of Indian warwhoops and angry wildcats.
Some phrases pop out at me here.
great relief
made up of the strange, the ludicrous, the abrupt, the ferocious, and the screechy
it was hard to form any idea
Indian warwhoops and angry wildcats
What amazes me is easy it was for this critic to put down the famous symphony. The descriptions paint a very bleak picture of Beethoven’s 9th Symphony, painting the part the critic can recognize, the choral part, as a great relief. Yet, the adjectives used for the rest of the piece draws the critic’s point overboard.
For this critic, Beethoven’s music did not try to copy his classical contemporaries like Mozart or Haydn. Instead, Beethoven injected his character in his music, heralding the sense of individualism felt amongst the contemporary thinkers of the time. It was the time of American and French revolution. It was the time of change. It was the time of new ideas and the tearing down of the old. Part of Beethoven’s character are the strange, the ferocious and the screechy. That’s what makes a Beethoven unique. This is the critic’s failings in understanding Beethoven’s music.
Beethoven
Portrait of Ludwig Van
When I’ve listened to the 9th Symphony, I think it’s a masterpiece. Indian warwhoops and angry wildcats do not come to mind. The good news is, the critic’s words haven’t carried over to this century. Beethoven’s 9th Symphony is still played around the world today. Negative criticism for the sake of bitching and moaning from purely subjective responses rarely get carried over as time passes.
If you though Beethoven’s criticism was bad, wait to you hear what this critic says about Anton Bruckner, a Austrian composer from the 19th century. This voiced his opinion to the public, hailing Bruckner as “the greatest living musical peril, a sort of tonal Anti-Christ.” Here’s his argument.
The violent nature of the man is not written on his face—for his expression indicates at most the small soul of the every-day Kapellmeister. Yet he composes nothing but high treason, revolution, and murder. His work is absolutely devoid of art or reason. Perhaps, some day, a devil and an angel will fight for his soul. His music has the fragrance of heavenly roses, but it is poisonous with the sulphurs of hell.
Holy christ! If you give Bruckner’s Symphony No. 7 a listen, you wouldn’t think malice towards to composer who wrote this music. You’d probably shake his hand. Allowing time to pass, we see this critic for who he really is, a hater. It doesn’t matter which century you live in, these haters exist. The critic didn’t recognize the Romantic styling of that century. The sweeping melodies. The dramatic accents and motifs carried over by Beethoven. To Bruckner’s credit, he composed two more symphonies, the ninth unfinished, as well as a smaller pieces for another decade. Like Beethoven, Bruckner is still played today.
Anton Bruckner
A picture of Anton Bruckner
As a side note, you may have already realized it. These two pieces were admired by Hitler. This was not intentional, and I would have missed this reference if it was not for Wikipedia. So, to leave this on a high note, Wikipedia says the adagio from Bruckner’s Symphony No. 7 was played on the official radio announcement of the German defeat at Stalingrad on the 31st of January, 1943. Karma, I guess.
So I ran to the end of the road. And when I got there, I thought maybe I’d run to the end of the town…
— Forrest Gump
I ran across the Golden Gate Bridge, a half marathon, and a full marathon.
Wrote 43 newsletters. Also, I have every one of you to thank to being readers, from the early readers or new subscribers.
According to my calendar, I’ve had dinner with a new stranger, many turned friends, each week from January to June, on average. That means some weeks may be 2 while other weeks may be 0.
Watched 29 movies I had not seen before. This is my lowest number in the last decade. Recommendations: Whiplash, Wolfpack, The Search for General Tso
Read 45 books. See recommendations below.
Went to a number of Maptime meetups and got my intro to map making. I took on my first freelance gig as a result.
My friend took me on my first backpacking trip up in Castle Rock.
Implemented inbox zero.
A former friend broke up with me. Can’t be all shine in 2015.
Counter to that, I made up with old friends. Yes, plural.
Participated in a number hackathons. The exact number eludes me. Didn’t win any of them.
As I flip through my journal, I’m reminded the first few months of 2015 were riddled with Caltrain suicides. I wrote a newsletter about it, and the death count doubled by the end of the year. Very, very sad.
Went to Atlanta for the first time.
My job survived an acquisition.
A friend and I helped my trans friend through facial feminization surgery. In Chicago!
Got to watch some excellent speakers. Highlights: Dr. Silvia Earle, Gavin Aung Than, Gretchen Rubin, Elizabeth Holmes, Nancy Duarte, & John Resig. Note to self: Reflection write-ups would be great journal entries.
Visited a few national parks. First time in Joshua Tree and Zion National Park. Obligatory photo at the end of the post.
Toured the Pier 9 space
Finished 3 large paintings, divided them up to 90 recipients, and included typed letters as Christmas cards
The Book List
The Gift: Creativity and the Artist in the Modern World. Thanks to Helin for the recommendation. Each chapter goes through a different aspect of gift giving, leading up to analysis on the poetry of Walt Whitman and Erza Pound. Perked my interests especially after writing the newsletter post on Nerina Pallot and creativity.
The Crossroads of Should and Must: Find and Follow Your Passion. An extension of Elle Luna’s Medium post. Mixed with her drawings, it really inspires you to find your “must”. This was my first giveaway from the short-lived giveaways I was giving to the subscribers of this newsletter.
40 Days of Dating. I read through the blog. I still picked up this book. On my first read through, I realize this is why I love books. The detail in this book is stunning and it reminds me books are a different medium than the web. Plus, the experiment just draws you in. Two friends who decide to date for 40 days. You can’t stop wondering if they’ll make it past 40 days.
Breaking the Chains of Gravity: The Story of Spaceflight before NASA. Honestly, this isn’t fair to put this on my list. The print copy hasn’t come out in the US yet, so I read it through Audible. I’m a sucker for the history of science. I had no grounding for the pre-cursors to NASA, so this overview made me giddy.
The “Goal”
Last year, I wrote up a list called the “Fuck-it” list. It recognized all the things I didn’t want to do or care about. Instead of a list, I’m going to give myself one goal. Finish research and start writing a novel.
I gave myself this goal 6 years ago, and I accomplished my first novel in 2012. It was about 200 pages and will never see the light of day because of how bad it is. This novel I’m going to write should be publish-able. I’m staying hush-hush about what it will be about. Can’t spoil it for everyone this early on.
Errata
Enjoy this picture I took somewhere between Northern Arizona and Southern Utah.
A few years ago, Radiolab ran an episode called “Finding Emilie”. Emilie Gossiaux and her boyfriend, Alan, were art students in New York City and the story chronicles Emilie’s fatal accident and recovery, where her mother and Alan almost pulled the plug when all hope seemed lost for finding Emilie.
One tragic day, Emilie was hit by a vehicle and was rushed to a hospital. The doctors stabilized her condition, except there was too much damage to her optic nerve where even if she recovered, she would no longer be able to see. When her mother and boyfriend, Alan, made it to the hospital, Emilie was in a coma.
Emilie was partially deaf and had hearing aids. After the accident, the doctors didn’t put her hearing aids back, so for days, the doctors tried to talk to Emilie to see if she was out of her coma, but she did not respond. They did not know Emilie needed hearing aids, and because of this, the doctors thought there was no hope for Emilie. Needless to say, the doctors were wrong, and I won’t spoil the rest of the episode. I’ve placed the link conveniently at the end so you can go listen to it after reading the rest of this letter.
Back in October, Emilie had an art exhibit at the StoreFrontLab in San Francisco. The exhibit was part of a larger series celebrating the life and work of Oliver Sacks. Emilie hosted a spaghetti night where she served spaghetti on a ceramic bowl that wasn’t glazed, and gave out laser cut forks for everyone to twirl and eat their spaghetti with.
The sauce stained the bowl, placing a permanent mark that says, “someone ate spaghetti in me”. The permanent markings of the spaghetti stains reminds Emilie of her childhood. Taking a part of this experience forced me to think of the creativity of blind artists trying to represent what matters to them in a medium besides visuals. The feel of the bowl was raw and unfinished, much like the texture of stone. You can hear the spaghetti splash around as you dig into it. You can smell the generic Preggo sauce and all of its familiarity, even after the local season of tomatoes were on their way out.
Emilie at her art show serving spaghetti
The meal was frustrating. The fork was oddly shaped, and you could twirl the spaghetti with ease. And I imagine that’s the point. Stripped of your sense of sight, what are you left with? I’ll say it again, frustration. Yet, it exposes me another point of reflection about other’s experiences that I would otherwise not have experienced on my own. It showed me another layer of appreciating art, that it can expand beyond the visual aesthetic.
Have you ever felt like you’ve stalled in improving your skills? You reach 20,000 miles driving your car, and you think, “yeah, there’s nothing more I can do to improve my driving skills.” You feel comfortable clocking in at work, mindlessly going through the actions because you’ve done this work a thousand times before, and there’s absolutely nothing that will shock you. I’m not critiquing the boredom one could face droning through work. I’m making an observation that you don’t even notice when you’ve reached a peak in growth.
graph of peak growth
At First, How Much
This week, I read Scott H. Young’s article, “Failures of Intensity”. In the article, Scott argues for skill acquisition advice to be geared towards how much you should do rather than what you should do. Scott mentions there is lack of information about how much time it takes learning a new skill as well as frequency. Almost all advice columns out there are about what to do to learn a new skill.
If I open the top stories on Medium, you’ll find posts titled “These 12 Habits Are Killing Your Productivity”, “Building your design portfolio? Here are 8 things I wish I’d known”, and “How to be like Steve Ballmer”. The last article, it started with the word, “how”, but when you get to the meat of the article, you find out its telling you the “what”, as in “what do you need to do in order to achieve success like Steve Ballmer.” I’m not trashing these articles. I’m sure they’re all a perfectly good read, but Scott was right. They’re focused on telling people the “what” and not of “how much” and “how frequent”.
How much is enough to learn a skill? Last year, I read Josh Kaufman’s book, “The First 20 Hours: How to Learn Anything … Fast!” Like most books, Josh first breaks down the question of what. For this book, it’s the what of of skill acquisition. But unlike other books, the second half is Josh chronicling the first twenty hours of learning a new skill. He breaks down the first twenty hours of learning yoga, programming, touch typing, the game go, the ukulele, and windsurfing. He learned it wasn’t worth pursuing touch typing after twenty hours, but it was worth pursuing programming a bit further.
What we can learn from Josh is to give new skills a shot. Give yourself a goal or milestone to reach by twenty hours. At the end of the twenty hours, you take a moment of reflection. Do you continue to put more effort in this skill or let it go?
Reflection Points
If you decide to continue with your skill, place checkpoints to review the progress. All too often, we don’t reflect on where we are. If you check in with yourself at fixed time intervals, like every week or every month, you can review the progress you’ve made. Then, you can adjust the frequency of how much more practice you’ll need.
When you don’t have checkpoints for reflecting, you could be comfortable with mediocre skills and stop working on growth. This is especially harmful if you wish to continue growing. I have made this mistake repeatedly. Years into my piano lessons, I’d practice with an automated mind, letting myself play the music without thinking about timing, about playing the correct notes or keeping good form. Bad habits such as finger slip mistakes creeped in and stuck, in other words, I learned to adapt to hearing the bad note. Before I knew it, I wasted a good 100 hours practicing music that didn’t sound great. I stalled on my skills and wasn’t going to improve them with more time spent on practice. I had fallen pray to my autopilot mind.
Flow is the balance between doing a task that is challenging while having a high skill level in that task. Deliberate practice is being in that flow state. Regular practice regards all practice, whether deliberate or not. I won’t talk much about flow, as that was the topic of a previous post. If you find yourself in that stalled funk, here are a few tips to help you get out.
Work on something new. In piano practice, this is as easy as playing a new song in a new genre. Last month, I found my fingers tired and sore trying to play improv salsa. It was a genre I hadn’t tackled before, and by the end of my practice, I remembered what a beginner felt like.
Write about the process. This past week, I started using Vim as a text editor. After a year of using Sublime and Atom, I put those aside and took two hours to go through a tutorial called vimtutor. The tutorial taught me the basics of how to use Vim. At the end of the tutorial, I wrote up a piece about my experience with the tutorial, mainly to help myself with what I learned, but with a bonus side effect that it may help someone else just starting out with Vim.
Reflect with a teacher. Whenever I feel I’m not challenged enough, I talk to a teacher, a boss, or a mentor who has a higher skill level. Talking to someone with a higher skill level, you may be able to extract what you could do next. I was at a data visualization unconference two weekends ago and people I talked to pointed me to bunch of new programs to sharpen my toolset.
Be the teacher. If you know the skill well enough, you should be able to teach it to others. A lot of times, you won’t know there’s gaps in your knowledge or skill until you have to teach it to someone else. It makes you reflect on being the beginner again. During Thanksgiving, I tried to teach my 8 year old cousin how to play a 14 and up card game. When I was explaining the rules to my cousin, I used large words he couldn’t understand. Looking at my cousin’s dumbfounded face, I realized I’m still terrible throwing away large words in favor of shorter ones a 8 year old could understand. Reflecting on this situation, I need to work on communicating more clearly to children.
While I’ve recommended this book in the past, it’s a great book to recommend again. “Pragmatic Thinking & Learning. Refactor Your Wetware” by Andy Hunt has more tips about getting out of the rut.
Remember skill acquisition takes time, and you should focus on the journey rather than the destination. Perhaps twenty hours utilizing one of these tips might just be what you need to grow into the master you wish to become.
I got into vim from a co-worker.
I thought it’s that clunky text editor in your terminal you must use when you have ssh into the linux server.
However, I’ve grown to understand vim is much more than a text editor.
It can also be an IDE.
When I first used vim, it just looked plain an boring.
The black screen with hard to understand shortcuts.
There weren’t any line numbers.
I didn’t even know how to exit the damn program for a good 5 minutes.
Then I started figuring it out slowly.
Vim has different modes.
Vim can do macros.
Vim can find things with the same grep commands.
And it’s quite expandable with the limitless plugins.
Vim is an endless rabbithole where you will get sucked in hours just setting it up.
But it’s your customization.
And that’s the beauty of vim.
Best advice - configure vim, and for that matter dotfiles, on your own.
Don’t blindly copy and paste configurations, because you’ll never understand them all.
Modal Editing
Quoted from Nick Nisi
Change the meaning of the keys in each mode of operation
Normal mode - navigate the structure of the file
Insert Mode - editing the file
Visual mode - highlighting portions of the file to manipulate at once
Ex mode - command mode
Line Numbers
Where are my line numbers?
Simply type the following.
:set number
To remove the numbers, you can use this command.
:set nonumber
Configuration
If you’re sick and tired of setting everything up every time you boot up vim, simply place the configuration in your configuration file.
You can find the configuration file at this location.
~/.vimrc
Here’s a truncated version of my general settings.
syntax enable " Enable syntax highlightingset tabstop=2 " set the tab stop at 2 spacesset shiftwidth=2 " set the shift width by 2 spacesset noexpandtab " do not expand tabset number " show line numbers
I’m currently using Monokai, mainly because it was a default I had with Ruby on sublime.
I set it up using vim-monokai, which I actually want to go back and figure out how to hook it up with vundle and have it linked to the repo.
I want to figure out how to do this better, so I placed a todo with the wiki from the vim wikia.
Vim tutor is a great guide to get you started with vim.
Getting Started
To start with Vim Tutor, simply type vimtutor in your terminal.
The tutorial says it should take about 25 to 30 minutes, but because I was also messing around with writing up this post and including their lesson summaries, all trying to use vim, I spend a bit longer with it.
If you’re running low on time, I’d say do each lesson in a 5 to 10 minute window span each day. You’re allowed to take it slow.
I learned it’s about the journey, not about the speed in which it takes for you to pick it up. It’s there where you can start nitpicking on how to do “x” or “y”.
The next following sections are summaries of what vim tutor teaches you. I modified some of the summaries to best fit markdown format.
Lesson 1 Summary
The cursor is moved using either the arrow keys or the hjkl keys.
h (left)
j (down)
k (up)
l (right)
To start Vim from the shell prompt type: vim FILENAME <ENTER>
To exit Vim type: <ESC>:q!<ENTER> to trash all changes.
OR type: <ESC>:wq<ENTER> to save the changes.
To delete the character at the cursor type: x
To insert or append text type:
i type inserted text <ESC> insert before the cursor
A type appended text <ESC> append after the line
NOTE: Pressing <ESC> will place you in Normal mode or will cancel an unwanted and partially completed command.
Lesson 2 Summary
To delete from the cursor up to the next word type: dw
To delete from the cursor to the end of a line type: d$
To delete a whole line type: dd
To repeat a motion prepend it with a number: 2w
The format for a change command is:
operator [number] motion
where:
- **operator** - is what to do, such as d for delete- **[number]** - is an optional count to repeat the motion- **motion** - moves over the text to operate on, such as w (word), (to the end of line), etc.
6. To move to the start of the line use a zero: 0
Undo & redo actions
To undo previous actions, type: u (lowercase u)
To undo all the changes on a line, type: U (capital U)
To undo the undo’s, type: CTRL-R
Lesson 3 Summary
To put back text that has just been deleted, type p . This puts the
deleted text AFTER the cursor (if a line was deleted it will go on the
line below the cursor).
To replace the character under the cursor, type r and then the
character you want to have there.
The change operator allows you to change from the cursor to where the
motion takes you. eg. Type ce to change from the cursor to the end of
the word, c$ to change to the end of a line.
The format for change is:
c [number] motion
Lesson 4 Summary
CTRL-G displays your location in the file and the file status.
G moves to the end of the file.
[number] G moves to that line number.
gg moves to the first line.
Find command
Typing / followed by a phrase searches FORWARD for the phrase.
Typing ? followed by a phrase searches BACKWARD for the phrase.
After a search type n to find the next occurrence in the same direction
or N to search in the opposite direction.
CTRL-O takes you back to older positions, CTRL-I to newer positions.
Typing % while the cursor is on a ( , ), [, ], {, or } goes to its match.
Substitute command
To substitute new for the first old in a line type :s/old/new
To substitute new for all ‘old’s on a line type :s/old/new/g
To substitute phrases between two line #‘s type :#,#s/old/new/g
To substitute all occurrences in the file type :%s/old/new/g
To ask for confirmation each time add c:%s/old/new/gc
Lesson 5 Summary
:!command executes an external command.
Some useful examples are:
(MS-DOS)
(Unix)
description
:!dir
:!ls
shows a directory listing
:!del FILENAME
:!rm FILENAME
removes file FILENAME
:w FILENAME writes the current Vim file to disk with name FILENAME.
v motion :w FILENAME saves the Visually selected lines in file FILENAME.
:r FILENAME retrieves disk file FILENAME and puts it below the cursor position.
:r !dir reads the output of the dir command and puts it below the cursor position.
Lesson 6 Summary
Open a line in insert mode
Type o to open a line BELOW the cursor and start Insert mode.
Type O to open a line ABOVE the cursor.
Append text
Type a to insert text AFTER the cursor.
Type A to insert text after the end of the line.
The e command moves to the end of a word.
The y operator yanks (copies) text, p puts (pastes) it.
Typing a capital R enters Replace mode until <ESC> is pressed.
Typing :set xxx sets the option xxx. Some options are:
icignorecase ignore upper/lower case when searching
isincsearch show partial matches for a search phrase
hlshlsearch highlight all matching phrases
You can either use the long or the short option name.
Prepend no to switch an option off: :set noic
Lesson 7 Summary
Type :help or press <F1> or <Help> to open a help window.
Type :help cmd to find help on cmd.
Type CTRL-W CTRL-W to jump to another window
Type :q to close the help window
Create a vimrc startup script to keep your preferred settings.
When typing a : command, press CTRL-D to see possible completions. Press <TAB> to use one completion.
Post Tutorial Reflection
The tutorial got me through the basics, and only scraps the surface of what you can do with vim. One of the things I found useful after going through this tutorial was saying out loud what the command I was using does.
For example, if I was using the w command, I would say “word”. If I was going to the word, and I was using the diw command, I would say “delete instance word”. Using words instead of letters helps with getting the commands down. It’s the same technique I used when learning the bash terminal, e.g. with pwd, I would say in my head, “print working directory”.
I wrote up a much longer post about vim that I will publish soon.
Let’s keep this a bit informal. I’m thankful for a year of newsletters, thankful for all of you reading, and thankful for all of the support y’all have given me. Without your support, I don’t know if I’d be writing essays every week. This weekly piece of writing is a way to bring together as well as synthesize what I’ve learned throughout the week. Now that it’s been a year, I wanted to look back at what I wrote and take a look at the journey.
The Numbers
Since last year, I’ve sent 45 letters. That tells me I’ve missed 8 letters. Back in October, I announced I would cut back on my load of work by publishing an essay once every other week. However, I want to challenge myself in the month of December to bring to you all original essays once a week again.
Challenge Accepted
When I started, I had six subscribers. Today, as of November 29th at 8
, it’s 36. The thing I love about these letters is I get to share it with all of you. Yes, I’m pandering, but it’s also the truth. I get this thrill that rushes through me when I hit send, and subsequently hit, “Yes, send it now” because Tinyletter wants to make sure I don’t send a bad message to you folks. It’s saved me on two separate occasions.
Combined, the total word count for my letters is 48,476. Keep in mind I love to lift quotes, passages, and re-post other stories my friends have written. That’s pretty close to the NaNoWriMo goal of their 50k word count. To give some perspective, “The Great Gatsby” has a word count of 47,094. “Slaughterhouse-Five” has a word count of 49,4459. You can check out Commonplace Book’s website for more novel word counts.
Reflections
Between December to June, I was releasing these letters on Medium. I stopped posting in June because I wasn’t getting much readership on Medium. When I published on Medium, I hoped more strangers would read what I posted. I tried advertising on social media, but did not have much luck besides two posts, one in which was recommended by Dave Hoover and another which was following the Caltrain suicide news circus. With Tinyletter, it’s guaranteed these emails will reach my particular audience. I will only post to Medium today if I think the post has a clear message and should reach a wider audience. Most of my posts on Medium have on average 5 reads. It should be noted a read is when a user scrolls through the article from top to bottom counter to a page view which could also include a bounce behavior, i.e. a user clicks on the article and immediately goes to a different website or closes the tab or window of the browser.
And it should be noted I’m not trying to write for an unknown audience. I’m writing for my friends and whoever wants to join in on my essays. I’ve stated on the Tinyletter landing page that I’m not going to social media to post a longform essay, because no one will read it there either. On Facebook, we are inundated by the endless scrolling content where a wall of text would not appeal to anyone’s eyes. That post would be surrounded by an environment of short, multimedia content that shouts, click on me, and has a shelf life of two seconds.
The last thing I will say about writing this piece every week is I really enjoy the writing process. I’m selecting my words carefully, trying not to use too many adverbs and quips that add no value to the writing. One of my friend’s pet peeves is the world albeit. “We can go to the store, albeit by the time I get there, I may have to use the restroom.” In this context, albeit was not necessary to get the point across. On that same thought, I try not to use words like “just”, “finally”, and “definitely”, which are overused in my writing.
Again, thanks for all of you for reading my posts. One year goes by so fast, I forget easily how much I’ve written. I hope you continue to join me for the next year as I have more to share with y’all.
“Impostor syndrome can be defined as a collection of feelings of inadequacy that persist even in face of information that indicates that the opposite is true. It is experienced internally as chronic self-doubt, and feelings of intellectual fraudulence.”
— Taken from Caltech Counseling Center
It’s easy to latch on to a concept to answer the question, “What’s wrong with me?” I asked that question about a year into my last job. I knew the ins and outs of laser cutting metal rods. I knew the basics in making jigs and fixtures for manufacturing custom parts. I knew how to break down problems using the scientific method. But my work project was ten weeks late, and I was feeling quite defeated that I wasn’t the right person to do this job, which was a slippery slope in thinking I wasn’t cut out to be in this line of work. I didn’t know it at the time, but I thought what was wrong with me was I had imposter syndrome.
To add insult to injury, it was revealed in my performance review that my boss had given me low marks on competence. Their feedback was unhelpful in giving actionable steps in how to perform better, and I was left with low self-esteem. I thought I didn’t have what it takes to be an engineer, that I was a fraud, and at some point I was going to be fired. It was at that point where I started to really slip up, not making any progress on the project I was working on. My boss, sensing my discomfort, pulled me in a meeting with the CEO and a co-worker and told me to pair up on this project, because two heads are better than one.
But the plan backfired. Three more weeks past by, and neither my co-worker nor I could figure out how to complete the project. Initially on the project, I didn’t ask for much help, so we decided it might be best to get the CTO to help us. But his practice of teaching us in a yoga-like manner did not help either of us in creating a viable solution. We had many false breakthroughs, eventually resulting in my resignation. It would take the company the next year and different engineers to complete the project.
Reflecting back on it, I realized that it wasn’t just my mental performance that was bleak, but also the fact that it really was an incredibly difficult project. This experience wasn’t an attack on my competence, nor is it a tale of imposter syndrome. It is an example of believing self-doubt was a bad attribute to have. This week, I read Alicia Liu’s post on “Imposter Syndrome Is Not Just A Confidence Problem”, which I took away that I need a healthy dose of self-doubt. I’m unable to know everything, so not knowing something is a gut feeling that I should pursue other avenues of exploration rather than just seek within. This could be asking for help, doing research on what other’s have done in the past, or talking to a rubber duck to re-access the problem. And it turns out, experts and masters of their own field can have moments or large lapses of time of self-doubt. That’s when you’re supposed to put on the kettle and think.
For nearly three months, there has been talk about when the rain will come in California. We have started to treat El Niño as the second coming of Christ where nature will save us all. I know those conversations are in the context of the drought, but taking a step back, they sound spiritual, as if nature is our savior. And yet, we don’t know this to be the case. We’re unable to predict the future, especially since nature tends to work in mysterious ways. We call our models predictive because they’re just that, a prediction.
This morning, it started raining for what seems like the first time in a very long time. It rained earlier this year with the same intensity, but it felt like eons ago. I woke up early since I have a hard time adjusting to Daylight Savings Time, and it was dark all around me. I could hear the pitter patter of the raindrops on the roof, and I was shaken up, unable to get a good night’s rest. I find it peculiar yet fascinating how my body can forget how to sleep in a loud environment.
I’m not going to hail this as, “El Niño is here! Let’s praise nature our drought is over!” One downpour can not make up for years of no downpour. Perhaps I’m being a pessimist because I don’t want to believe in one grand event solving everything, a deus ex machina. I guess this is to say I have optimism from the success of small wins rather than one large miracle. You decide what this rain means.
However, I’ll embrace this event. It’s a good shake up to the monotonous routine and the banalities of everyday life. At least, that’s the feeling I got when I woke up today.
I was turned on to audiobooks by accident. I had a free half hour of commuting and didn’t want to waste it staring out the window or listening to the same people on podcasts. I was commuting to and from school at the time, and I kept hearing the same Audible ads on TWiT, a weekly podcast about tech. I decided to give the free subscription a try on Audible and give an audiobook a chance. While the first book I read didn’t change my life, I understood the medium a lot better. I could commute and listen to an audiobook and be excited to continue a story I had left off the day before. It’s a lot like a TV show, and the format is different than what you would find on a podcast, e.g. interviews, round table discussions, and reporter segments.
Some 100 audiobooks later, I owe it to audiobooks to introducing me to authors I now adore and giving me an opportunity to learn something new. On my road trip last year from Dallas to San Jose, I finished reading “The Goldfinch”. I’m in the camp of people who didn’t care too much about the second act of the book as I felt it could’ve been trimmed down from it’s mostly mundane descriptions that parallels a Dickinson novel. During these long and arduous reads, I was glad someone else was reading them to me as I was yelling expletives in the car at how much the main character was an idiot. But that’s the beauty of audiobooks. The reader keeps reading through the audiobook even if you’re excited, in tears, or just plain bored. If it wasn’t for the audiobook version of “A Storm of Swords”, the third book of “A Song of Ice and Fire”, I don’t know how I could’ve mustered to read through the red wedding.
When I talk to a non-audiobook reader, they have a hard time understanding the value of an audiobook. When someone tells me listening to an audiobook is not reading, I ask them whether they used to listen to their teacher read to them, or their parents, or whether they read to their kids. Many famous works came from oral tradition, like the Greek epics “The Iliad” and “The Odyssey”. “The Hitchhiker’s Guide to the Galaxy” was a radio program before it was in print form. When someone tells me they couldn’t sit an hour listening to a book, I ask them how long they commute for or how long a day they sit at a desk. When someone tells me they can’t bear the narrator’s voice, I ask them to try another audiobook. Stephen Fry does great narration in the Harry Potter series, giving each character a unique voice. Granted, non-fiction can be very dry if the narrator’s voice is dry and not vivacious.
When I talk to an audiobook reader, we tend to hit it off about what we enjoy reading, who’s our favorite narrator, what we’re looking forward to read next. If nothing else, you should listen to audiobooks too as a conversation piece at your next dinner party. Entertain your guests with the lore of “A Song of Ice and Fire”. Tell them about your foray into the bibliography of Einstein. Recite what you learned about empathy from Brené Brown. And, if audiobooks don’t work, why not pick up a book?
This past Saturday, I finished my first marathon. To add difficulty to my challenge, it was a trail run marathon. I didn’t realize this detail when I registered. But coming in faster than expected blew me away. I’d like to acknowledge the people that helped me and try to point out it wasn’t a journey done on my own.
Thanks to Megan who started me on a regimented running routine earlier last year. By motivating me to help her running journey by doing couch to 5k, I learned the value in pacing and intervals.
Thanks to Simon for repeated using the phrase, “The Obstacle is the Way.” I chanted that mantra throughout the run, and it helped my inner game by focusing on the run rather than the finish. Conveniently, I read Ryan Holiday’s book by the same name earlier this year. If you want a taste of stoic philosophy, I’d recommend the book.
Thanks to Christin for introducing me to trail running. I found out I get an adrenaline rush running up and down mountains. She also helped pick me up from my half marathon, which I completed earlier this year.
Thanks to Carlos for letting me know about this marathon. He didn’t participate, but is egging me on to do the LA marathon next year. I haven’t made up my mind about that one yet.
Thanks to Victor for helping me train in Arizona. Nothing can capture those four days of wild and crazy trail runs through different terrain.
Thanks to Teagan for taking me to my marathon. Thanks to my dad for picking me up.
And lastly, thanks to the countless people who have given me support on my journey. I really couldn’t have made it without you.
I’m still exhausted and stiff from my run, and I hope to come up with a longer, more cohesive essay next week.
Before I started sending Christmas Cards, I didn’t get the point of sending cards. The only times I sent cards were if I found them funny or I was told to send one. In late 2011, my roommate Teagan asked if I could help her make a Christmas Card to send to her family and close friends. She wanted to show her parents the friends that she lived with. I accepted her task, which started the Christmas Card tradition.
Teagan grew up with them. She told me her parents got all six siblings and her together for one shot. She missed that tradition, being away from family for the four years she had been in college, and really wanted to participate in her family’s tradition. I didn’t grow up with them. My family had a one-way gift exchange, receiving a card from other family or friends.
Teagan and I decided to mock the generic format of the Christmas Card. The card had individual pictures of each roommate in the background followed by a center picture of everyone together. The generic heading, “Merry Christmas”, curved it’s way in on the bottom. I was glad our roommates participated in our absurd card, and I printed enough for each roommate to distribute 6 copies of the card. When I gave it to my family, there had a hoot. I remember they laughed so hard, and I wanted to cherish that moment. However, I was disappointed I didn’t have more to give.
Year 1 of Christmas Cards
The next year, I wanted to continue this gift. I decided this should be a running tradition. I created another card of just myself. On it, there are three panels. In the first panel, I dressed up like Santa Claus, the next panel, I was taking off the costume, and the third panel, I made a “ta-da” pose. Laughing at it for a minute, I thought this would be perfect. With the disappointment of having only 6 cards to distribute last year, I preemptively ordered a hundred copies. To my dismay, only 30 people replied, leaving me with 70 unusable Christmas Cards. But, I shouldn’t say it wasn’t worth it because those who were sent the card gave me their gratitude.
Year 2 of Christmas Cards
Instead of keeping to the same format year after year, the following year, I went all out. Recognizing I probably wouldn’t need to send too many out, I sent out invitations telling everyone I would send pictures of us together on the postcard. By making this simple change, my number of recipients grew by over two-fold. This time, everyone was elated when they received my card and saw their own face on it. I learned personalization is key to making a better Christmas Card with greater emotional weight.
Last year was quite wonderful. I changed it up again, creating hand-drawn card of something that reminded me of them. For one of my friends, I drew a rock climber because I knew that’s an activity she enjoyed. On another card was a petri dish because my friend worked in a lab at UCSF. However, I was worn out when I found out I had to create 140 of these cards. I had just graduated from Dev Bootcamp and wanted to keep in touch with everyone I had met.
Despite feeling worn out, this has been a high point each year. Being able to reach out to people I haven’t talked to in a year and making something meaningful for them. It’s a great feeling, and I wish everyone had the time to do this. I’ve changed my position about gift-giving, and I really want the people I know I am thinking about them.
The Idea
This holiday season, I want to do something new and fresh. Different ideas floated around my head, and I settled on an idea that I think will be really fun and therapeutic. I would like to give every a piece of a large art piece and type-written letters from an old typewriter.
I started water coloring this year, and think it would be really neat to do a few large canvases. I’ll take those canvases and cut them up in card sized squares. The idea is the gift recipient gets a part of a larger masterpiece. I stole the idea from Nerina Pallot who did this as prizes for supporting her new album.
Last year, I learned hand writing 140 letters may result in minor forearm muscle cramps. Instead of hand writing, I wanted some way of showing I wrote the letter with meaningful though. Enter a typewriter. I’m using an Olivetti Praxis 48, an electric typewriter from the late 1960’s. Some of the relic’s buttons don’t function. I’m looking at you, letter z, 2 and shift key! I’ve chosen to use plain dot matrix printer paper with the side perforations. These two items pair well as it shows a world we’ve left behind.
Olivetti Typewriter
Now I know I could send this all digitally. But, there’s something about the physical medium that changes the perception of a gift. An email can whiz by you without a moment’s notice. A physical card is something you must take the time and look at. Instead of that 6 second email interaction, you may take up to a few minutes looking at my Christmas Card. Some websites have caught on to this, such as Reddit Gifts or Metafilter’s CD swap.
Some of you may be wondering why am I starting in October? To be honest, I’m lazy. The administrative tasks, such as asking everyone for their mailing address, filling out each envelope, putting the stamps on it, going to the post office, obtain postage for international letters, and physically mailing them, are boring. Plus, last year, I was late, so I’m hoping that proverb, “The early bird gets the worm,” actually works as implied.
The Value of a Gift
On my friend, Helin, recommendation, I read a book called “The Gift” a few months back. The book has this sector about monetary gifts versus gifts with no inherent price tag. A takeaway I learned was how I should continue this gift giving process without thought about receiving something back. There’s an implicit value that is reciprocated that may not take the form of a tangible gift, like writing a letter of recommendation when asked. The moment the gift has a price tag, the monetary value distracts from the emotional pull of a gift, and the gift recipient use the monetary value of the gift as an indication of the value of the relationship, e.g. a cheap gift means a poor relationship.
In addition to the benefits to the gift recipient, the cards have a major benefit to the gift giver. These Christmas cards are a gift for me to initiate a conversation to my contacts. It’s my lazy excuse to talk to someone I may have not reached out to for a year. It bugs me that people enter and exit your life, while the only thing keeping you from reaching out with a simple phone call, text, or email. I’m reminded of the poem by writer Charles Hanson Towne.
Around the corner I have a friend,
In this great city that has no end;
Yet the days go by, and weeks rush on,
And before I know it a year is gone,
And I never see my old friend’s face,
For Life is a swift and terrible race.
He knows I like him just as well,
As in the days when I rang his bell,
And he rang mine. We were younger then,
And now we are busy, tired men:
Tired with playing a foolish game,
Tired with trying to make a name.
”To-morrow,” I say, “I will call on Jim
”Just to show that I’m thinking of him.”
But to-morrow comes — and to-morrow goes,
And distance between us grows and grows.
Around the corner — yet miles away,…
”Here’s a telegram sir,…"
"Jim died today.”
And that’s what we get, and deserve in the end:
Around the corner, a vanished friend.
— Charles Hanson Towne
I never expected this ritual to occupy so much time. But I think of the benefits make it worthwhile, of catching up with old friends, of being able to go beyond normal gifts, of being creative. I absolutely love doing this, too much to the point this is what I think about on my free time.