Live coding 5

This topic is for discussion of the 5th live coding session.

<<< session 4session 6 >>>

Links from the walk-thru

What was covered

  • pushd/popd to return script to initial folder
  • vim
    • Inserting
    • Saving & closing
    • Moving around with motions
    • Repeats, commands, and motions
    • ex (:%s, :%g, etc)
    • Using splits
  • ctags
    • Editing a particular class/function
    • Jumping to symbols and back again

Video timeline - thank you @Mattr

00:00 - Intro
02:10 - Demonstration of bash script and text file manipulation using Vim
19:30 - Cleaning up a long text file into something useful for Youtube video markers using Vim and regex
25:55 - Control + Z to put process like vim in background and fg to get back
27:57 - Power vim user move to split vim into multiple windows. Try ‘:sp /run.sh’ without the ’ ’
28:30 - Control + W to move between windows
28:40 - Fixing the pre-run.sh script in Paperspace so the notebooks and /storage/ folder shows up
32:48 - Tips for learning Vim
41:09 - Configuring Vim with a vimrc file : GitHub - fastai/dotfiles
45:00 - Using ctags to navigate a repository to build SUPERPOWERS (one of Radek’s favourite features of Vim)

12 Likes

Wow. Best advice ever: Walkthru 5 - YouTube

3 Likes

:fire:

You have to go slow in order to go fast :slight_smile: This would make for such a good small clip to post to YouTube if Jeremy had the desire to do so :smile: A splendid teaser for these walk-thrus. Though maybe the plan is to not blow the lid on them yet :wink: But once the time comes, this would be quite a magnificent thing to post.

Stealing the link for now and sticking it into my notes, thanks @wyquek for posting it! :pray:

9 Likes

great lesson! thank you Jeremy!

so i was using vscode-vim extension to bring some of the vim goodness to vscode, but was somewhat unhappy with otherwise nice experience. The reason being that not all the vim features were implemented in the extension. Also some of the keybinding conflicted with the vscode keybindings. so i followed Jeremy’s advice and switched off the extension, to discover that i can move cursor in vscode in emacs like way: ctr-b (one char back), ctr-f (one char forward). i will need to try more of these to have better idea how this would work for me. however this solves one of my issues: to use keyboard arrow keys to move around the code (i quess that’s larry wall’s lazy thing :slight_smile: which i also learned from Jeremy’s walk-thru :slight_smile:

i also use vimium extension for firefox to reduce a need for mouse when browsing. it kind of follows vim way of working but for browser. it woks nice most of the time. but, i would need to try and switch it off one day and see if i can do most of the stuff i need in firefox native way :wink:

2 Likes

This was an uplifting way to start the day. My group/team at work has a weekly tech talk to chew the fat informally on technical topics we’d other not share across projects. It can get a bit stale. This walk-through reminded me how and what we could do to foster “osmotic knowledge sharing”. When the video is made public I’ll definitely share this resource.

1 Like

Walk-thru 5 Youtube links:

02:10 - Demonstration of bash script and text file manipulation using Vim
19:30 - Cleaning up a long text file into something useful for Youtube video markers using Vim and regex
25:55 - Control + Z to put process like vim in background and fg to get back
27:57 - Power vim user move to split vim into multiple windows. Try ‘:sp /run.sh’ without the ’ ’
28:30 - Control + W to move between windows
28:40 - Fixing the pre-run.sh script in Paperspace so the notebooks and /storage/ folder shows up
32:48 - Tips for learning Vim
41:09 - Configuring Vim with a vimrc file : GitHub - fastai/dotfiles
45:00 - Using ctags to navigate a repository to build SUPERPOWERS (one of Radek’s favourite features of Vim)

5 Likes

The thing about unix is their collection of integrated systems, while you can use :g^/d in vim you can also do grep '^[0-9]' tmp at command line and get the same result with walk-thru 2

Users-Mac-Pro:course22 mac$ grep  '^[0-9]' tmp
00:00 People intro and questions to address later
03:27 Switch users in Linux
04:48 Introduction to Github
08:32 Build a website with github
19:00 Clone your repo with SSH
39:01 Using tmux for better terminal productivity
48:54 Create a notebook in jupyter lab
54:26 Committing and pushing to git
58:55 Fork a repo
1:01:31 Installing fastai and fastbook

and use redirect standard output to file

EDIT:

To refine I found this on the subject of redirecting directly from the system clipboard

Universal copy paste from system clipboard

I used the mac specific commands directly to try this out, so I selected the shown text in WT 5, as I can’t use the edit function( not my post) I just highlighted it and place it in the clipboard. then as you see below I piped the pbpaste stdout into grep stdin to get the timings.

Users-Mac-Pro:course22 mac$ pbpaste | grep '^[0-9]'
00:00 People intro and questions to address later
03:27 Switch users in Linux
04:48 Introduction to Github
08:32 Build a website with github
19:00 Clone your repo with SSH
39:01 Using tmux for better terminal productivity
48:54 Create a notebook in jupyter lab
54:26 Committing and pushing to git
58:55 Fork a repo
1:01:31 Installing fastai and fastbook

I don’t think there is a native way. Most browsers don’t really seem built for power users. I almost mentioned that browsers are the one place I think vim key binding extensions are useful, but I was worried it’s a distraction - so I’m glad you brought it up!

1 Like

emacs equivalents

If there are any other weirdos like me out there who use emacs and would like to learn how to do some of these same things (some would argue the only proper, true way :grin:) in emacs, just like or let me know in the comments and I’ll put together an equivalent post / blog post if there’s interest!

Make Friends with Intimidating Concepts

Jeremy’s thoughts today about confronting the chasm between one’s “day 0” skills and where one would like to be when watching a pro reminded me of this great video by Neil deGrasse Tyson. He suggests a great way to reframe those challenges so they help you rather than intimidate you (in this case, through his experience with learning calculus)

Stick with it, friends. I’m doing things today that, quite honestly, I couldn’t conceive of doing when I first began. What’s more, there are concepts I’m trying to learn today that feel just as intimidating as those first initial, stumbling steps into the basics. Things that I once thought were horrifically beyond my capacity I now do regularly without a second thought. Such is the nature of the journey. Stay connected to your dreams, grow your talent brick by brick and, as Neil suggests, make friends with what intimidates you.

13 Likes

I need to do exactly what Jeremy mentioned in WT5 with Python. For my day job I need to automate things here and there and my go-to has always been bash or other Unix utilities because they’re always available, and I find myself stumped by having to do things that seem simple in bash scripting but daunting in Python. Like iterating through a list of files in a directory and renaming them, or connecting to a bunch of servers and running certain commands etc.

I will just need to ban myself from using Bash and force myself to use Python. :sweat_smile:

1 Like

Allow me to get you started:

https://automatetheboringstuff.com/

6 Likes

Thank you Nick! I’ve been meaning to get into this book. I have a copy. I feel I have a very transactional relationship with automation. Being sort of lazy and impatient at the same time, I always go for the easiest way to get something done, and in corporate environments, bash / vi are usually always available. This tendency has always stopped me from doing the sort of deliberate practice that builds knowledge as Jeremy mentioned in the last walkthrough (WT5) but thank you for the link, it’s hight time I took this leap!! :slight_smile:

2 Likes

You’ll find that as you add tools to your skillset the tools themselves fade in importance compared with the ‘computational thinking’ that goes into thinking-through, architecting and implementing the mathematical logic of a solution – especially as you scale. Remember, that’s the main game. Language and tool choices will just become a function of the constraints you face to build the logical representation you have in mind.

3 Likes

BTW, @radek thanks for mentioning vim-adventures.com , it’s a pretty addictive game. I played through it. The first 3 levels are free, but I think they’re a very nice and engaging way of getting people used to the vim commands.

1 Like

There’s Qutebrowser for users that really want a full-blown* vim experience, with a slightly dated? browser engine. I’ve used it every now and then, but I tend to fall back to Firefox with Vim vixen, which seems to be good enough for my usage.

Most pages I tend to use implement their own keyboard shortcuts(gmail,github,discourse etc.) so the whole thing ends up being overriding/disabling things here and there.

That is a really nice talk, Nick, thanks for sharing :slight_smile: I love how he talks, so many emotions, amazing :slight_smile:

On the fog clearing, I would like to add, that this is the magic of working on something continuously for a longer period of time. As we do, the neural connections continue to form ever so slowly. But soon enough this makes a world of a difference.

By that token, cramming for exams is one of the silliest things one can do.

The one thing I am trying to teach my daughter is the value of this process. We have been learning fractions together. Not the most complicated thing in the world, right? But we discuss some aspect of it, spend 20 minutes working through an example, and I can see it is not clicking for her and there is nothing I can do. I tell her “let’s sleep on it, let the connections in your brain form, we’ll try again tomorrow”. And the next day the performance is substantially different. Amazing. And that is just a single night of sleep.

If anyone would like to learn a bit more about this process, I highly recommend this book with a very misleading name. From what I recall, it has a forward by someone of ML fame :slight_smile:

And if we are discussing useful tools, I would like to tell you about something from a completely different category – a note taking tool. I am quite a big fan of Obsidian. It is the only note taking tool where I feel at home (because it feels just like using vim). Yeah, it supports vim keybindings that I use, but the feeling goes beyond just that. It is all very keyboard shortcut driven and just a great experience.

Writing is important, because it allows us to spend more time with our thoughts, to reflect on experience. Posting to this forum is priceless. But generally the more venues you can find where you can do meaningful writing, speaking to things you are learning and find fun, probably the batter.

This is all very tangential, for which I apologize, but sharing this in the hope that maybe some of this can be useful to someone.

9 Likes

Thank you for sharing Obsidian. It looks great. $10/month is right price for sync option i think. But i wonder if there are any free sync options for it?

1 Like

I am not sure if there is anything that would work well with mobile that would be free.

On a PC I initially used github for syncing and backup using a cron job (cron jobs would be great to cover in the walk-thrus :slight_smile: ), but I then switched to onedrive, it makes more sense as I started to include more images in my notes.

Having said that, the ability to access Obsidian on a mobile is only a nice to have in my experience (though nice for reviewing notes while lying or on the go).

1 Like

I downloaded Obsidian when I was looking into taking more efficient notes using the Zettelkasten method, but I really haven’t done anything serious with it.

Using regex for editing text with movements in Vim

This is my favourite learning about Vim from Walk-thru 5. The walk-thrus are causing a revolution in my thinking!!! The gif doesn’t show the key bindings used so to replicate in Vim. I’m doing this in 2 steps:

Step 1: Create the movement

  • To delete and move to the start of the next digit type d /^\d

Step 2: Replicate the movement

  • Then move down a row using j (or down arrow) and type dot ‘.’ to repeat the movement: j .


vim-regex-movements

5 Likes