Shadowing Practice: The easy way to keep your repos tidy. - Learn English Speaking with Video

Elige un modo de práctica

Cada modo abre una sala de práctica a pantalla completa.

78 oraciones
Si las oraciones son demasiado cortas o largas, haz clic en Editar para ajustarlas.
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.

Descargar app

Todo lo que necesitas para hablar con fluidez

Pronunciación con IAEvalúa cada oración
Práctica de IPADomina cada sonido
VocabularioConstruye tu banco de palabras
Juego de vocabularioAprende mientras juegas
FOR YOU

Recomendar Video

Vocabulario y notas de pronunciación para esta lección

Este vídeo tiene 78 frases y 1244 palabras para practicar shadowing. La parte hablada dura 5:52. El hablante habla rápido, unas 212 palabras por minuto, así que espera sonidos enlazados y reducidos. Solo el 80 % de las palabras está entre las 3.000 más comunes del inglés, por lo que el vocabulario es exigente.

Vocabulario clave de este vídeo

15 palabras del vídeo que vale la pena aprender, con su pronunciación y significado:

PalabraPronunciaciónSignificado
commit verbo/kəˈmɪt/encomendar
hook sustantivo/hʊk/gancho, garfio
format sustantivo/ˈfɔːɹ.mæt/formato
folder sustantivo/ˈfoʊldɚ/carpeta, fólder
script sustantivo/skɹɪpt/escrito, escripto
delete verbo/dɪˈliːt/deletear
automatic adjetivo/ˌɔː.təˈmæt.ɪk/automático
accidentally adverbio/ˌæk.sɪˈdɛnt(ə)li/accidentalmente, sin querer
restore verbo/ɹɪˈstoɹ/restablecer
install verbo/ɪnˈstɔl/instalar
specify verbo/ˈspɛs.əˌfaɪ/especificar, circunstanciar
malicious adjetivo/məˈlɪʃəs/maligno
tidy adjetivo/ˈtaɪ.di/pulcro, prolijo
compare verbo/kəmˈpɛɚ/comparar, parangonar
trail sustantivo/tɹeɪl/rastro, pista

Phrasal verbs que vas a escuchar

PalabraPronunciaciónSignificado
go ahead verbo/ˌɡoʊ əˈhɛd/venga, adelante
go out verbosalir
go through verboatravesar

Pronunciación a tener en cuenta

El hablante usa 18 contracciones y formas reducidas, como don't, I'm, you're. Dilas en su forma corta, tal como las oyes.

  • Los sonidos de “sh” y “zh”: modification /ˌmɑdɪfɪˈkeɪʃən/, malicious /məˈlɪʃəs/, notion /ˈnoʊʃən/, hash /ˈhæʃ/
  • Palabras largas — cuida el acento: 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/

Cómo practicar con este vídeo

  1. Escucha el vídeo entero una vez sin hablar y anota las palabras que no conoces.
  2. Empieza a velocidad 0,75×, haz shadowing frase por frase y vuelve a la velocidad normal cuando te resulte fácil.
  3. Grábate y compara con el original, prestando atención a palabras como commit, hook, format.

Gramática en este vídeo

Las estructuras que más usa el hablante, con las palabras exactas del vídeo:

EstructuraEn el vídeo
Voz pasiva be + participio pasado — importa lo que ocurre, no quién lo haceare called · might be hidden · been written
Present perfect have/has + participio pasado — una acción pasada que sigue importando ahorahas gone · have already been written · have built

¿Qué es la Técnica de Shadowing?

Shadowing es una técnica de aprendizaje de idiomas respaldada por la ciencia, desarrollada originalmente para la formación de intérpretes profesionales y popularizada por el políglota Dr. Alexander Arguelles. El método es simple pero poderoso: escuchas audio en inglés nativo y lo repites en voz alta de inmediato, como una sombra que sigue al hablante con solo 1-2 segundos de retraso. A diferencia de la escucha pasiva o los ejercicios de gramática, el shadowing obliga a tu cerebro y músculos de la boca a procesar y reproducir simultáneamente patrones de habla reales. Las investigaciones muestran que mejora significativamente la precisión de la pronunciación, la entonación, el ritmo, el habla conectada, la comprensión auditiva y la fluidez al hablar, convirtiéndola en una de las metodologías más efectivas para la preparación del IELTS Speaking y la comunicación en inglés en el mundo real.

Técnica de shadowing: lee la guía completa paso a paso →