Muestra las diferencias entre dos versiones de la página.
| Ambos lados, revisión anterior Revisión previa Próxima revisión | Revisión previa | ||
|
wiki2:shortcuts [2019/06/29 08:39] alfred [Find in files] |
wiki2:shortcuts [2020/09/10 18:37] (actual) |
||
|---|---|---|---|
| Línea 1: | Línea 1: | ||
| ====== Shortcuts ====== | ====== Shortcuts ====== | ||
| - | ===== Dockers ===== | + | ===== Docker ===== |
| + | Start Postgres | ||
| <code> | <code> | ||
| - | sudo docker run -p 5432:5432 -v /home/alfred/tmp/postgresdata:/var/lib/postgresql/data -e POSTGRES_PASSWORD=mysecretpassword postgres | + | docker run --rm -d -p 5432:5432 -v /home/alfred/tmp/postgresdata:/var/lib/postgresql/data -v /tmp:/tmp --name postgres -e POSTGRES_PASSWORD=mysecretpassword postgres |
| </code> | </code> | ||
| + | |||
| + | Logs: | ||
| + | <code> | ||
| + | docker logs --since 30s -f <container_name_or_id> | ||
| + | docker logs --tail 20 -f <container_name_or_id> | ||
| + | </code> | ||
| + | ===== Git ===== | ||
| + | <code> | ||
| + | git config credential.helper store | ||
| + | </code> | ||
| + | |||
| ===== Linux ===== | ===== Linux ===== | ||
| + | |||
| + | ==== Links ==== | ||
| + | |||
| + | * [[wiki2:linux_commands#apt]]-get install|reinstall|update | ||
| + | |||
| + | === Date === | ||
| + | Format date in the way you like it: | ||
| + | <code> | ||
| + | $(date +%y%m%d) | ||
| + | </code> | ||
| ==== Cheat ==== | ==== Cheat ==== | ||
| - | Havig the next ALIAS: | + | You can define the next alias: |
| <code> | <code> | ||
| function cheat() { curl cht.sh/$1 } | function cheat() { curl cht.sh/$1 } | ||
| </code> | </code> | ||
| - | You can do ''cheat rename'' to see examples. | + | With it you can launch something like ''cheat rename'' to see its examples. |
| Línea 20: | Línea 42: | ||
| ==== Rename ==== | ==== Rename ==== | ||
| <code> | <code> | ||
| - | rename 's/old/new/' files | ||
| rename 's/perl/pl/' *.perl | rename 's/perl/pl/' *.perl | ||
| - | </code> | + | # Sample outputs: |
| - | Sample outputs: | + | # 'bar.perl' renamed to 'bar.pl' |
| - | <code> | + | # 'foo.perl' renamed to 'foo.pl' |
| - | 'bar.perl' renamed to 'bar.pl' | + | |
| - | 'foo.perl' renamed to 'foo.pl' | + | |
| - | 'input.perl' renamed to 'input.pl' | + | |
| - | 'output.perl' renamed to 'output.pl' | + | |
| - | 'test.perl' renamed to 'test.pl' | + | |
| - | </code> | + | |
| - | From cheat: | + | |
| - | <code> | + | |
| # Lowercase all files and folders in current directory | # Lowercase all files and folders in current directory | ||
| rename 'y/A-Z/a-z/' * | rename 'y/A-Z/a-z/' * | ||
| Línea 54: | Línea 67: | ||
| </code> | </code> | ||
| + | ==== Merge two folders ==== | ||
| + | <code> | ||
| + | rsync -a /path/to/source/ /path/to/destination | ||
| + | </code> | ||
| ===== PostgreSQL ===== | ===== PostgreSQL ===== | ||
| <code> | <code> | ||
| Línea 68: | Línea 85: | ||
| </code> | </code> | ||
| + | ===== SQL ===== | ||
| + | Update | ||
| + | <code> | ||
| + | UPDATE T | ||
| + | SET C1 = 9, | ||
| + | C3 = 4 | ||
| + | WHERE C2 = 'a' | ||
| + | </code> | ||
| ===== Mongo ===== | ===== Mongo ===== | ||
| <code>docker run -p 27017:27017 -v /home/alfred/mongodata:/data/db -d mongo</code> | <code>docker run -p 27017:27017 -v /home/alfred/mongodata:/data/db -d mongo</code> | ||
| + | |||
| + | ====== Python Gotchas ====== | ||
| + | |||
| + | * [[wiki2:python3#venv_para_crear_entornos_virtuales|Creación de entornos virtuales con venv]] | ||
| + | ===== Serving your current directory by HTTP ===== | ||
| + | For Python 3 run: | ||
| + | <code> | ||
| + | python3 -m http.server | ||
| + | </code> | ||
| + | For Python 2 run: | ||
| + | <code> | ||
| + | python -m SimpleHTTPServer | ||
| + | </code> | ||
| + | |||
| + | ===== Prettify JSON ===== | ||
| + | <code> | ||
| + | cat file.json | python -m json.tool | ||
| + | </code> | ||