If you're a developer and you use a calculator to
do math while you're coding, stop doing that. Instead, just
put your math expression right into VS code, highlight it,
and from the command palette, select, emit, evaluate math expression.
It's built right into VS code.
I found my college laptop from 10 years ago. Let's
see if I can still code on it. There wasn't
even a battery in it, so I had to plug
it in. I haven't turned this on in six years,
so I was excited when I got some promising boot
screens. Now I needed to try to remember my password
and couldn't. It was at this point that I realized.
Discussing the screen was but somehow I remembered the backdoor
password. Once it was booted, I connected to Wi-Fi and
tried to load GitHub, but couldn't connect because apparently my
computer time was still set to May 20th, 2013, which
is when I got this laptop. So I had to
manually synchronize with the Windows Time clock. Now that I
could reach GitHub, it wasn't really loading, so I figured
I probably needed to update Chrome. I was at version
58. After updating I went to version 109 and that's
not even the latest because I'm still on Windows 7.
Anyways, now that GitHub look great, I decided to just
use code spaces since I can stay in the browser
to run my code. So I went to create a
new code space and selected my most recent repo and
it started creating it pretty quickly. It took a couple
of minutes to load. Then I tried to run it
and it worked. Once I got my browser updated I
was able to start coding in just a couple of
minutes.
One super annoying thing about HTML is that sometimes you
want to get all of a Div like this Div,
but it's really big and so you Scroll down.
You Scroll down, you Scroll down, you Scroll down and
you're like, which one of these closing tags is it?
You can't remember so you have to scroll back up.
It's a real pain. There's an easier way to do
this. There is a command and vs code called balance
outward. So if you look for balance outward, that will
select the entire thing for you. So that's the whole
Div. You don't have to go hunting for that last
tag there. Now I like to take this a step
further and go to my keyboard mappings.
And do the balance outward command and bind that to
control Alt B. And then there's a balance inward which
does the opposite, it goes the other direction, which I
bind to control Alt V because they're next to each
other on the keyboard. And then I can just control
Alt B and go out as much as I need
to, and then V takes me back in. And of
course up here, if I want this whole thing, just
control Alt B. That's it.
There's this nightmare story on R slash programming horror about
someone who had a bug in their code and it
ended up being a 0 width space character that they
could not see. And I thought can that be true?
So I googled it and yes, there is a 0
width Unicode character. So here's what this looks like in
the editor right here. This looks like code that should
run but it doesn't because there is an unexpected token.
There's a zero with Unicode character somewhere in here but
you can't see it. But we just shipped a feature
that.
Enables you to do Unicode highlighting for invisible characters. If
we go back now, you can see it's highlighted, and
if we mouse over it actually says, hey, this character
is invisible. So we could just drop in here and
then actually remove that invisible character. And now this code
works so that you don't end up making posts on
R slash programming horror. Wrote a program to check.
If a.
Number is.
Even or.
Odd.
What if you ever actually had to write this program
where you literally checked every number up to 10,000? So
the easiest way to do this is probably to have
this program write itself. So let's use a while loop
and justice increment up to 10,000.
And for every number, we're just going to print out
and check to see if that number is equal to
the current value of NUM, which is always going to
be incremented. And below that we'll actually check for even
or odd using the modulus operator which. So if we
divide by two and the remainder is 0, then we
know it's even, otherwise it's odd, and then we'll increment
the NUM variable. Now if we run this in the
terminal, it does work, but we only get the last
100 or so results. It's because we need to set
the scroll back property in VS code to get the
blast. Let's say 25,000 lines. Run this again.
And now we can use the command or control up
or down arrows in the terminal to just get everything
between the last two commands. We'll copy that into the
editor, and then we'll change just the first line here
to make this an if instead of an L if,
and we're done.