27 de noviembre de 2013

How to setup you repo GIT and local instance (like for GitLab) and not to fall in despair

How to setup you repo GIT and local instance (like for GitLab) and not to fall in despair

For a while now, while collaborating with several projects, I noticed that having issues to generated and setup the public keys and configuring the access to GIT repositories was giving a bit of a harsh time to lots of people.

And when in comes to recurring problems there’s nothing better suited than a little reference tutorial to blaze the trail. So, let’s get to it!

#1: generate your SSH key-pair and set it up


Step #1: Check if you don’t already have a key pair


Open a terminal and run the following command:

1
2
3
cd ~/.ssh
ls
# Lists the files in your .ssh directory



Check the directory listing to see if you have a file named either id_rsa.pub or id_dsa.pub. If you don't have either of those files go to step 2. Otherwise, you already have an existing keypair, and you can skip to step 3.

Step #2: Generate new SSH keys

To generate a new SSH key, enter the code below in the terminal. We want the default settings so when asked to enter a file in which to save the key, just press enter.

1
2
3
4
5
$ ssh-keygen -t rsa -C "your_email@example.com"
# Creates a new ssh key, using the provided email as a label
# Generating public/private rsa key pair.
# Enter file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter]
ssh-add id_rsa





Now you need to enter a passphrase.

1
2
Enter passphrase (empty for no passphrase): [Type a passphrase]# Enter same passphrase again: [Type passphrase again]



Which should give you something like this:

1
2
3
4
Your identification has been saved in /Users/you/.ssh/id_rsa.# Your public key has been saved in /Users/you/.ssh/id_rsa.pub.
# The key fingerprint is:
# 01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db your_email@example.com



Step #3: Add your SSH key to GitLab

  1. Go to your account settings:
  1. Now go to the SSH keys section:

  1. Click “Add SSH key”
  1. Give it a title you like (in the “Title” field) and paste your public key in the bigger “Key” field:
  1. Click “Add key” and we are done with loading the SSH public key in GitLab!

Step #4: Check everything worked

Now we should have the key pair generated and set up locally and the public key loaded in GitLab. Let’s now make sure this is the case and that everything went fine.

To achieve such a certainty, run the following command:

1
$ ssh -T git@git.santexgroup.com




If everything went well, you should see an output like this:

1
2
$ ssh -T git@git.santexgroup.com
Welcome to GitLab, !




#2: Some extra hints

Now we have the keys and our GitLab repo set up and ready to work. Now you should be able to clone, push/pull and do all sorts of thing with your GIT repos without being prompted for your username and password. If GIT, after making a command, asks you for your username or password, it means something at some point went wrong.

Go back and make sure you didn’t miss any steps or ask someone for help.

Done with this and want to learn some new tricks? Take a look at this link!

Hope this saves you of annoyances and frustrations in the future!

14 de noviembre de 2013

Python Violations Tool: Check

Si bien seguramente cada uno ya tiene sus herramientas para chequear violaciones en código Python, esta puede ser de utilidad, check.

Correr pep8 y pyflakes en tódos los archivos que queramos:
check.py models.py tests/
Lo que tiene de novedoso/útil, es que sirve para verificar los errores introducidos sólo por nosotros basándose en el VCS, sin tener en cuenta las violaciones ya existentes en el código.

Para GIT, se puede agregar un pre-commit hook, para que aborte un commit si introdujimos errores: use-as-a-git-pre-commit-hook

Ejemplo
$ git commit -a -m"Test"
test_module.py:2: redefinition of unused 'logging' from line 1
test_module.py:42:1: E303 too many blank lines (22)
test_module.py:487:1: W391 blank line at end of file
Aborting commit.  Fix above errors or do 'git commit --no-verify'.

Instalación

# Después de crear el archivo pre-commit:
$ chmod 0755 .git/hooks/pre-commit

Saludos!

5 de noviembre de 2013

List merge conflicts with GIT


Made a merge, particularly, a big one and you want to know which where the files that had conflicts?

Then, this command might come handy:



You can also make a GIT alias this way:



and then use it like this:

4 de octubre de 2013

Ding! "El comando está listo"

Buenas!

A pedido de Mati les comparto algo simple pero tal vez útil!


Cansado de fijarme a cada rato si un comando que tarda mucho terminó o no, hice una función "beep" en sh:

$ beep  # Reproduce sonido de "éxito"
$ beep command arg1 arg2 ... # Reproduce sonido de éxito si command termina con éxito, sino sonido de fallo

Para usarlo tienen que poner este código en "./bashrc" o "./bash_profile", y la próxima vez que abran una consola lo van a tener disponible.

Obiamente pueden cambiar los sonidos que se ejecutan en cada caso a gusto, el primero es el de éxito y el segundo el de fallo.

Faltaría mejorarlo para que tome una sequencia de comandos.

UBUNTU




MAC



Saludos!

25 de septiembre de 2013

Nice app for Mac OS X

Aloha!

I came across this app, that is very useful for cleaning up your Mac menu bar layout and have a cleaner visual landscape: http://www.macbartender.com/

Aloha! [1]



[1] "Since the middle of the 19th century, it also has come to be used as anEnglish greeting to say goodbye and hello."
Source: http://en.wikipedia.org/wiki/Aloha

Unix exit status code reference

0    # successful termination 
64   # base value for error messages 
64   # command line usage error 
65   # data format error 
66   # cannot open input     
67   # addressee unknown     
68   # host name unknown 
69   # service unavailable 
70   # internal software error 
71   # system error (e.g., can't fork) 
72   # critical OS file missing 
73   # can't create (user) output file 
74   # input/output error 
75   # temp failure; user is invited to retry 
76   # remote error in protocol 
77   # permission denied 
78   # configuration error

24 de septiembre de 2013

Where to start to learn GIT

Many times I was asked: Where to start to learn GIT?

It is not usual to have a good answer to questions like this in the area of software engineering.

But when it comes to the case of GIT, there is one. This is a great place to start: http://try.github.io/

This is the official GitHub "Got 15 minutes and want to learn Git?" Git tutorial.

Pimp my GIT: mejorando la interfaz para el uso de GIT

Siguiendo con el post de ayer, acá les comparto otras cosas del setup que tengo para git.

El setup este, y va dentro del .git/config de su clone git:


Con esto seteado, verán, por ejemplo, los git status con colores:




Podrán usar abreviaciones de los comandos, como:

- "git st" en vez de "git status"
- "git ci" en vez de "git commit"

Podrán ver un log más interesante y con colores con git log.

Verán los diff coloreados y con formato piola:



Git branch muestra coloreado el branch actual (los branches locales aparecen en amarillo):



Y los branches remotos aparecen en verde:

Inline image 4


Saludos!

23 de septiembre de 2013

Mostrar el branch de GIT y el status actual en el shell prompt y más!

Algunos trucos para configurar nuestro setup local de GIT:

Hace algunos años encontré algo como eso y, con el tiempo, armé una serie de scripts (algunas cosas que hice yo, algunas cosas que fui encontrando en la web), que hacen varias cosas con bash, que están piolas.

¿Qué cosas?

- que se detecte automáticamente si se está en una carpeta perteneciente a un repo git, y que, en el caso que sí lo sea, el prompt muestre información relevante del repo en que se está: branch y estado. Ejemplo:



en ese caso, estoy en el branch "master" y tengo archivos modificados (por eso la "m") y archivos que borré (por eso la "d").

- otra cosa muy piola es tener tab completion (que al apretar tab, con un comando a medio escribir, se muestren opciones para completar ese comando -o que se completen, si hubiera una opción posible). Imaginen eso aplicado a nombres de branch, comandos git y comandos de django (como "python manage.py runserver", por ejemplo).

- Algunas cosas más, como:
-- aumentar el tamaño del history de bash, pero eliminando duplicados, para que al hacer "ctrl r" en la consola, podamos buscar en el historial de los comandos que hicimos y encontrar resultados interesantes.
-- Una larga lista de colores definidos, para directamente poder usarlos en la definición del prompt.

Etc!

Les paso adjuntas las scripts para hacer todo esto:


Las dos primeras las ponen derecho en el home. El .profile pueden ponerlo derecho en el home (si usan Mac y no tienen otro .profile armado) o copiar su contenido a su .profile existente. Si usan Linux, pueden hacer esto mismo con el archivo .bashrc.
(notar que tienen un underscore los archivos, a propósito, para que no sobreescriban cosas sin querer y para que no los tome el file browser como archivos ocultos).


Un abrazo y may the bash be with you (?),


Find out when a line was introduced or deleted in GIT history

Hi!

Did you ever come across a line of code that you d *really* like to know when was introduced/deleted ?

Well, if you are using GIT for your project this might come handy.

Let's say the piece of text you are investigating is this:

a = get_something(some_var)

and it is located in the file some_folder/some_file.py

Then, try this command:

git log -S "a = get_something(some_var)" some_folder/some_file.py

Then, GIT will look for the string we specified string within the commit history and output something like this:

commit
Author: Some Dude <
some.dude@mail.com>
Date:   Fri Feb 15 14:09:18 2013 -0300
    The commit message of this commit.

This came quite handy to me recently. Hope it helps!

13 de septiembre de 2013

Happy programmer's day!

A man flying in a hot air balloon suddenly realizes he’s lost. He reduces height and spots a man down below. He lowers the balloon further and shouts to get directions, "Excuse me, can you tell me where I am?"

The man below says: "Yes. You're in a hot air balloon, hovering 30 feet above this field."

"You must work in Information Technology," says the balloonist.

"I do" replies the man. "How did you know?"

"Well," says the balloonist, "everything you have told me is technically correct, but It's of no use to anyone."

The man below replies, "You must work in management."

"I do," replies the balloonist, "But how'd you know?"*

"Well", says the man, "you don’t know where you are or where you’re going, but you expect me to be able to help. You’re in the same position you were before we met, but now it’s my fault."

6 de junio de 2013

Cuento de Joaco

Mientras Joaco ( http://focojoaco.blogspot.com ), un gran amigo, me daba una mano con un proyecto en Haskell, tuvimos que esperar un ratito que se descargara un archivo. En ese momento, Joaco improvisó un mini cuento.



Les comparto:

cuando la nutria sale de su madriguera, se puede oler el olor a coco rayado de los caramelos m&m que su mama le compraba de pequeña, su mama mandril y su papa oso  listo


Brillante :) 

Haskell in TextMate

How to install the bundle:
$ mkdir -p /Library/Application\ Support/TextMate/Bundles
$ cd /Library/Application\ Support/TextMate/Bundles
$ git clone https://github.com/textmate/haskell.tmbundle
That's it!

3 de junio de 2013

Santex Tech Meetup: Python en el mundo real




Python en en mundo real



Se expondrán brevemente proyectos y empresas que han encarado proyectos exitosos a nivel mundial con Python, comparando ventajas, ecosistema, comunidad y desventajas del lenguaje.
La charla apuntará a ser bien de alto nivel (en el sentido de que no requiere más que nociones básicas de programación) y se mostrarán ejemplos prácticos de programas y librerías de computación científica, motores para hacer juegos, aplicaciones web, frameworks, etc.

UPDATE:

Material de la charla! https://github.com/matiasherranz/talks/tree/master/Real_world_Python

Fotos del evento! link.