Prática de Shadowing: The easy way to keep your repos tidy. - Aprenda a falar inglês com vídeo

Escolha um modo de prática

Cada modo abre uma sala de prática em tela cheia.

78 frases
Se as frases estiverem muito curtas ou longas, clique em Edit para ajustá-las.
1
Hello and welcome.
2
I'm James Murphy and today we're talking about PreCommit, which is a really cool tool that you can use to keep your codebase tidy
3
and catch some simple mistakes before things ever get committed into Git.
4
It happens.
5
There's a new person on your team that doesn't really know about PEP8, or you just forget to run your code formatter, or you just make a typo in a config file somewhere.
6
But at the time, you don't really notice, so you just go ahead and git commit.
7
Then either something breaks, or just the quality of your codebase has gone down just a little bit.
8
Well, a bad config you can fix, and code you can just reformat.
9
But still, wouldn't it be better if you could just catch those errors before the commit happens?
10
That's what pre-commit is for.
11
Here's the story of pre-commit.
12
Basically, git has a notion of what are called commit hooks.
13
These are things that happen either before you commit or just after you commit or when you push or when you pull, things like that.
14
Git will store this and a whole bunch of other information in the .git folder inside a directory.
15
Depending on your editor, this folder might be hidden, so just look out for that.
16
You might have to unhide it.
17
This hooks folder is where git stores all these different hooks.
18
The ones you see here are just samples.
19
If you were to get rid of that .sample on the end of the file name, then git would actually run that action at that corresponding So if I have a file named pre-commit,
20
then Git will run that script right before a commit happens.
21
But you don't need to go out and waste your time writing something like this yourself.
22
A lot of really good scripts have already been written.
23
The pre-commit project just makes it really easy to pick
24
and choose things that you want to check for your own code base.
25
Let's start simple.
26
All I want to do is make sure that before I commit anything, I run my code formatter on it.
27
Of course, I can just run the code formatter before I commit, but the point is I shouldn't have to remember to do that.
28
Why not just make it automatic?
29
Well, it's super simple to set up.
30
Open up your terminal and just pip install pre-commit.
31
Then, at the root of your project, just make a new file called .precommitconfig.yaml.
32
Then, it's just this easy to add automatic code formatting on every commit.
33
You specify precommit hooks by just giving a git repository.
34
In this case, I'm using GitHub, but you can actually use any git repository, even a local one.
35
You specify the git tag that it's going to use, and then some information about what command to run and what arguments to give it.
36
In this case, I'll be using black to do the actual code formatting.
37
Then you use pre-commit to install the githooks into your githooks folder.
38
Now if we go and look in our githooks folder, we see that we have this new pre-commit file.
39
Alright, now let's add our files to git, commit, and see what happens.
40
As you can see, it ran black and the commit failed because some modifications were made, and it's not going to commit anything automatically.
41
I can go and manually inspect the hello file and see that everything looks good, or just compare the diff like I normally would before a commit.
42
Note that these modifications to the hello file were made after the file was staged.
43
That means I need to git add this file again, or if something went wrong and I don't like the changes that were automatically made,
44
then I can git restore the file to go back to the way it was before.
45
In this case, I'm happy with the changes, so I will add and then try to commit again.
46
This time, since everything passed, the commit went through.
47
Note that some graphical editors like this one, PyCharm, have built-in Git support and they will automatically add tracked files when you try to commit.
48
So if that's the case then it might look more like this.
49
Here I have a spurious space in there and I'm going to go ahead and try and commit.
50
Then I try to commit and I see the commit failed and I can go to the console to see what errors.
51
I see that it deleted the extra space
52
and then I can just go ahead and click commit again and then this time it will succeed.
53
So what else can you do besides automatically formatting your code?
54
Well you can write your own commit hooks so you can pretty much do whatever you want, but there are a ton of really good ones already written on this website here.
55
Here are just a few of my favorites.
56
You can delete trailing whitespace, make sure a file is either empty or ends with a new line, make sure that any yaml files have valid yaml in them,
57
make sure you're not accidentally committing any really big files into your repository, and check for any spurious breakpoints that you forgot to delete before committing.
58
You can also run your linter like flake 8, you can reorder and standardize the order that your imports happen in, you can check for outdated syntax and replace it with its modern equivalent,
59
and this would also be a good place to run your type checker, like MyPy.
60
Pre-commit is most popular in the Python world, but it's not something that's just limited to Python.
61
There are premade scripts for doing things like running clang-tidy or clang-format, or some other code formatter for a different language.
62
You don't have to reinstall anything if you change the YAML file, just go ahead and commit.
63
We see the commit failed because of a MyPy error, telling us that we passed the wrong kind of argument to this function f.
64
Also note that most hooks will only run if an applicable file actually changed.
65
So it's not going to be reformatting code that it already formatted and hasn't changed.
66
Finally, there's the question of safety.
67
How safe is it to automatically run programs on your source code before committing them?
68
Well, this ultimately goes down to the project and whether or not you trust the project to do the right thing.
69
Of course, these little scripts can be written by anyone, so if they put something malicious in, then you're going to be out of luck.
70
You can fix a specific version or even a specific hash in the config file.
71
This helps mitigate things like what if this project gets hacked and an attacker uploads something malicious.
72
But as always, only use projects that you really trust.
73
As far as accidental errors go though, like what if black accidentally changed the meaning of the code?
74
Well, that's something that I haven't actually run into.
75
If something did go wrong, it would really be up to you to catch it in the git diff or by running tests.
76
Of course, for an accidental mistake, you can always revert using the git restore command that I talked about earlier.
77
Well, that's all I've got.
78
I hope this makes your repos better.

Baixar aplicativo

Tudo o que você precisa para falar fluentemente

Pronúncia com IANota em cada frase
Prática de IPADomine cada som
VocabulárioMonte seu banco de palavras
Jogo de vocabulárioAprenda brincando
FOR YOU

Vídeo recomendado

Vocabulário e dicas de fala para esta lição

Este vídeo tem 78 frases e 1244 palavras para praticar shadowing. A fala dura 5:52. O falante fala rápido, cerca de 212 palavras por minuto, então espere sons ligados e reduzidos. Apenas 80% das palavras estão entre as 3.000 mais comuns do inglês, por isso o vocabulário é exigente.

Vocabulário principal deste vídeo

15 palavras do vídeo que vale a pena aprender, com pronúncia e significado:

PalavraPronúnciaSignificado
hook substantivo/hʊk/gancho
format substantivo/ˈfɔːɹ.mæt/formato
folder substantivo/ˈfoʊldɚ/pasta
script substantivo/skɹɪpt/escrito
delete verbo/dɪˈliːt/apagar, excluir
automatic adjetivo/ˌɔː.təˈmæt.ɪk/automático
accidentally advérbio/ˌæk.sɪˈdɛnt(ə)li/acidentalmente
restore verbo/ɹɪˈstoɹ/restaurar
install verbo/ɪnˈstɔl/instalar
specify verbo/ˈspɛs.əˌfaɪ/especificar
malicious adjetivo/məˈlɪʃəs/malicioso, maldoso
tidy adjetivo/ˈtaɪ.di/limpo, ordenado
compare verbo/kəmˈpɛɚ/comparar
trail substantivo/tɹeɪl/rasto, rastro
valid adjetivo/ˈvælɪd/válido

Phrasal verbs que você vai ouvir

PalavraPronúnciaSignificado
go ahead verbo/ˌɡoʊ əˈhɛd/vai em frente
go down verbodescer
go out verbosair
set up verbo/ˌsɛt ˈʌp/preparar

Pronúncia para ficar de olho

O falante usa 18 contrações e formas reduzidas, como don't, I'm, you're. Diga-as na forma curta, do jeito que você ouve.

  • Os sons de “sh” e “zh”: modification /ˌmɑdɪfɪˈkeɪʃən/, malicious /məˈlɪʃəs/, notion /ˈnoʊʃən/, hash /ˈhæʃ/
  • Palavras longas — acerte a sílaba tônica: automatic /ˌɔː.təˈmæt.ɪk/, accidentally /ˌæk.sɪˈdɛnt(ə)li/, modification /ˌmɑdɪfɪˈkeɪʃən/, applicable /əˈplɪk.ə.bəl/, directory /dɪˈɹɛktəɹi/

Como praticar com este vídeo

  1. Ouça o vídeo inteiro uma vez sem falar e anote as palavras que você não conhece.
  2. Comece na velocidade 0,75×, faça shadowing frase por frase e volte à velocidade normal quando ficar fácil.
  3. Grave a sua voz e compare com o original, prestando atenção a palavras como hook, format, folder.

Gramática neste vídeo

As estruturas que o falante mais usa, com as palavras exatas do vídeo:

EstruturaNo vídeo
Voz passiva be + particípio passado — o foco está no que acontece, não em quem fazare called · might be hidden · been written
Present perfect have/has + particípio passado — uma ação passada que ainda importa agorahas gone · have already been written · have built

O que é a Técnica de Shadowing?

Shadowing é uma técnica de aprendizado de idiomas com base científica, originalmente desenvolvida para o treinamento de intérpretes profissionais. O método é simples, mas poderoso: você ouve áudio em inglês nativo e repete imediatamente em voz alta — como uma sombra seguindo o falante com 1-2 segundos de atraso. Pesquisas mostram melhora significativa na precisão da pronúncia, entonação, ritmo, sons conectados, compreensão auditiva e fluência na fala.

Técnica de shadowing: leia o guia completo passo a passo →