GIT tutorial: Pro GIT

  1. . Getting Started

    1. 1.1 About Version Control
    2. 1.2 A Short History of Git
    3. 1.3 Git Basics
    4. 1.4 The Command Line
    5. 1.5 Installing Git
    6. 1.6 First-Time Git Setup
    7. 1.7 Getting Help
    8. 1.8 Summary
  2. 2. Git Basics

    1. 2.1 Getting a Git Repository
    2. 2.2 Recording Changes to the Repository
    3. 2.3 Viewing the Commit History
    4. 2.4 Undoing Things
    5. 2.5 Working with Remotes
    6. 2.6 Tagging
    7. 2.7 Git Aliases
    8. 2.8 Summary
  3. 3. Git Branching

    1. 3.1 Branches in a Nutshell
    2. 3.2 Basic Branching and Merging
    3. 3.3 Branch Management
    4. 3.4 Branching Workflows
    5. 3.5 Remote Branches
    6. 3.6 Rebasing
    7. 3.7 Summary
  4. 4. Git on the Server

    1. 4.1 The Protocols
    2. 4.2 Getting Git on a Server
    3. 4.3 Generating Your SSH Public Key
    4. 4.4 Setting Up the Server
    5. 4.5 Git Daemon
    6. 4.6 Smart HTTP
    7. 4.7 GitWeb
    8. 4.8 GitLab
    9. 4.9 Third Party Hosted Options
    10. 4.10 Summary
  5. 5. Distributed Git

    1. 5.1 Distributed Workflows
    2. 5.2 Contributing to a Project
    3. 5.3 Maintaining a Project
    4. 5.4 Summary
  6. 6. GitHub

    1. 6.1 Account Setup and Configuration
    2. 6.2 Contributing to a Project
    3. 6.3 Maintaining a Project
    4. 6.4 Managing an organization
    5. 6.5 Scripting GitHub
    6. 6.6 Summary
  7. 7. Git Tools

    1. 7.1 Revision Selection
    2. 7.2 Interactive Staging
    3. 7.3 Stashing and Cleaning
    4. 7.4 Signing Your Work
    5. 7.5 Searching
    6. 7.6 Rewriting History
    7. 7.7 Reset Demystified
    8. 7.8 Advanced Merging
    9. 7.9 Rerere
    10. 7.10 Debugging with Git
    11. 7.11 Submodules
    12. 7.12 Bundling
    13. 7.13 Replace
    14. 7.14 Credential Storage
    15. 7.15 Summary
  8. 8. Customizing Git

    1. 8.1 Git Configuration
    2. 8.2 Git Attributes
    3. 8.3 Git Hooks
    4. 8.4 An Example Git-Enforced Policy
    5. 8.5 Summary
  9. 9. Git and Other Systems

    1. 9.1 Git as a Client
    2. 9.2 Migrating to Git
    3. 9.3 Summary
  10. 10. Git Internals

    1. 10.1 Plumbing and Porcelain
    2. 10.2 Git Objects
    3. 10.3 Git References
    4. 10.4 Packfiles
    5. 10.5 The Refspec
    6. 10.6 Transfer Protocols
    7. 10.7 Maintenance and Data Recovery
    8. 10.8 Environment Variables
    9. 10.9 Summary
  11. A1. Appendix A: Git in Other Environments

    1. A1.1 Graphical Interfaces
    2. A1.2 Git in Visual Studio
    3. A1.3 Git in Eclipse
    4. A1.4 Git in Bash
    5. A1.5 Git in Zsh
    6. A1.6 Git in Powershell
    7. A1.7 Summary
  12. A2. Appendix B: Embedding Git in your Applications

    1. A2.1 Command-line Git
    2. A2.2 Libgit2
    3. A2.3 JGit
  13. A3. Appendix C: Git Commands

    1. A3.1 Setup and Config
    2. A3.2 Getting and Creating Projects
    3. A3.3 Basic Snapshotting
    4. A3.4 Branching and Merging
    5. A3.5 Sharing and Updating Projects
    6. A3.6 Inspection and Comparison
    7. A3.7 Debugging
    8. A3.8 Patching
    9. A3.9 Email
    10. A3.10 External Systems
    11. A3.11 Administration
    12. A3.12 Plumbing Commands



Automate the boring stuff w/Python

Automate the Boring Stuff with Python

Practical programming for total beginners. Written by Al Sweigart.

(Quick plug! You can buy the Automate the Boring Stuff with Python ebook for $1 in the Humble Bundle until Monday!)

Free to read under a Creative Commons license.

Cover image of Automate the Boring Stuff with Python

“The best part of programming is the triumph of seeing the machine do something useful. Automate the Boring Stuff with Python frames all of programming as these small triumphs; it makes the boring fun.”
Hilary Mason, Founder of Fast Forward Labs and Data Scientist in Residence at Accel

“I’m having a lot of fun breaking things and then putting them back together, and just remembering the joy of turning a set of instructions into something useful and fun, like I did when I was a kid.”
Wil Wheaton, WIL WHEATON dot NET

Automate the Boring Stuff with Python is recommended on the Open Source Summer 2015 Reading List!

Learn to Code

If you’ve ever spent hours renaming files or updating hundreds of spreadsheet cells, you know how tedious tasks like these can be. But what if you could have your computer do them for you?

In Automate the Boring Stuff with Python, you’ll learn how to use Python to write programs that do in minutes what would take you hours to do by hand-no prior programming experience required. Once you’ve mastered the basics of programming, you’ll create Python programs that effortlessly perform useful and impressive feats of automation to:

  • Search for text in a file or across multiple files
  • Create, update, move, and rename files and folders
  • Search the Web and download online content
  • Update and format data in Excel spreadsheets of any size
  • Split, merge, watermark, and encrypt PDFs
  • Send reminder emails and text notifications
  • Fill out online forms

Step-by-step instructions walk you through each program, and practice projects at the end of each chapter challenge you to improve those programs and use your newfound skills to automate similar tasks.

Don’t spend your time doing work a well-trained monkey could do. Even if you’ve never written a line of code, you can make your computer do the grunt work. Learn how in Automate the Boring Stuff with Python.

Note: The programs in this book are written to run on Python 3.

Table of Contents

Additional Content

About the Author

Al Sweigart is a software developer and teaches programming to kids and adults. He has written several books for beginners, including Scratch Programming Playground, Hacking Secret Ciphers with Python, Invent Your Own Computer Games with Python, and Making Games with Python & Pygame.

Support the author by purchasing the print & ebook bundle from No Starch Pressor separately on Amazon.

Construcción de programas

Cuando nos piden que hagamos un programa debemos seguir una cierta cantidad de pasos para asegurarnos de que tendremos éxito en la tarea. La acción irreflexiva (me piden algo, me siento frente a la computadora y escribo rápidamente y sin pensarlo lo que me parece que es la solución) no constituye una actitud profesional (e ingenieril) de resolución de problemas. Toda construcción tiene que seguir una metodología, un protocolo de desarrollo, dado.

Existen muchas metodologías para construir programas, pero en este curso aplicaremos una metodología sencilla, que es adecuada para la construcción de programas pequeños, y que se puede resumir en los siguientes pasos:

1. Analizar el problema. Entender profundamente cuál es el problema que se trata de resolver, incluyendo el contexto en el cual se usará.

Una vez analizado el problema, asentar el análisis por escrito.

2. Especificar la solución. éste es el punto en el cual se describe qué debe hacer el programa, sin importar el cómo. En el caso de los problemas sencillos que abordaremos, deberemos decidir cuáles son los datos de entrada que se nos proveen, cuáles son las salidas que debemos producir, y cuál es la relación entre todos ellos.

Al especificar el problema a resolver, documentar la especificación por escrito.

3. Diseñar la solución. éste es el punto en el cuál atacamos el cómo vamos a resolver el problema, cuáles son los algoritmos y las estructuras de datos que usaremos. Analizamos posibles variantes, y las decisiones las tomamos usando como dato de la realidad el contexto en el que se aplicará la solución, y los costos asociados a cada diseño.

Luego de diseñar la solución, asentar por escrito el diseño, asegurándonos de que esté completo.

4. Implementar el diseño. Traducir a un lenguaje de programación (en nuestro caso, y por el momento, Python) el diseño que elegimos en el punto anterior.

La implementación también se debe documentar, con comentarios dentro y fuera del código, al respecto de qué hace el programa, cómo lo hace y por qué lo hace de esa forma.

5. Probar el programa. Diseñar un conjunto de pruebas para probar cada una de sus partes por separado, y también la correcta integración entre ellas. Utilizar el depurador como instrumento para descubir dónde se producen ciertos errores.

Al ejecutar las pruebas, documentar los resultados obtenidos.

6. Mantener el programa. Realizar los cambios en respuesta a nuevas demandas.

Cuando se realicen cambios, es necesario documentar el análisis, la especificación, el diseño, la implementación y las pruebas que surjan para llevar estos cambios a cabo.



Python: Beautiful Soup

Beautiful Soup

“A tremendous boon.” — Python411 Podcast

[ Download | Documentation | Hall of Fame | Source | Discussion group ]

If Beautiful Soup has saved you a lot of time and money, the best way to pay me back is to check out Constellation Games, my sci-fi novel about alien video games.
You can read the first two chapters for free, and the full novel starts at 5 USD. Thanks!

If you have questions, send them to the discussion group. If you find a bug, file it.

Beautiful Soup is a Python library designed for quick turnaround projects like screen-scraping. Three features make it powerful:

  1. Beautiful Soup provides a few simple methods and Pythonic idioms for navigating, searching, and modifying a parse tree: a toolkit for dissecting a document and extracting what you need. It doesn’t take much code to write an application
  2. Beautiful Soup automatically converts incoming documents to Unicode and outgoing documents to UTF-8. You don’t have to think about encodings, unless the document doesn’t specify an encoding and Beautiful Soup can’t detect one. Then you just have to specify the original encoding.
  3. Beautiful Soup sits on top of popular Python parsers like lxml and html5lib, allowing you to try out different parsing strategies or trade speed for flexibility.

Beautiful Soup parses anything you give it, and does the tree traversal stuff for you. You can tell it “Find all the links”, or “Find all the links of class externalLink“, or “Find all the links whose urls match “”, or “Find the table heading that’s got bold text, then give me that text.”

Valuable data that was once locked up in poorly-designed websites is now within your reach. Projects that would have taken hours take only minutes with Beautiful Soup.

Interested? Read more.



Python: regular expressions II

Nice guide from Coursera Python course:

Python Regular Expression Quick Guide

^        Matches the beginning of a line
$        Matches the end of the line
.        Matches any character
\s       Matches whitespace
\S       Matches any non-whitespace character
*        Repeats a character zero or more times
*?       Repeats a character zero or more times (non-greedy)
+        Repeats a character one or more times
+?       Repeats a character one or more times (non-greedy)
[aeiou]  Matches a single character in the listed set
[^XYZ]   Matches a single character not in the listed set
[a-z0-9] The set of characters can include a range
(        Indicates where string extraction is to start
)        Indicates where string extraction is to end
^        Matches the beginning of a line
$        Matches the end of the line
.        Matches any character
\s       Matches whitespace
\S       Matches any non-whitespace character
*        Repeats a character zero or more times
*?       Repeats a character zero or more times (non-greedy)
+        Repeats a character one or more times
+?       Repeats a character one or more times (non-greedy)
[aeiou]  Matches a single character in the listed set
[^XYZ]   Matches a single character not in the listed set
[a-z0-9] The set of characters can include a range
(        Indicates where string extraction is to start
)        Indicates where string extraction is to end


Here is Dr. Chuck’s RegEx “cheat sheet”. You can also download it here:

You can view more compete documentation on Python Regular Expressions at


Python: ranges and Lambda

evens_to_50 = [i for i in range(51) if i % 2 == 0]print evens_to_5
dobles_por_3 = [x*2 for x in range(1,6) if (x*2) % 3 == 0]
# Completa la siguiente línea. Usá la línea de arriba como ayuda.
cuadrados_pares = [x*2 for x in range(1,12) if (x*2) % 2 == 0] 
print cuadrados_pares

mi_lista = range(16)
print filter(lambda x: x % 3 == 0, mi_lista)

lenguajes = ["HTML", "JavaScript", "Python", "Ruby"]
print filter(lambda i: i == "Python" , lenguajes)

incomprensible = "!XeXgXaXsXsXeXmX XtXeXrXcXeXsX XeXhXtX XmXaX XI"
mensaje = filter(lambda x: x!='X', incomprensible[::-1])print mensaje