Skip to content

Instantly share code, notes, and snippets.

View neosergio's full-sized avatar
🤓
Happy Coding!

Sergio Infante neosergio

🤓
Happy Coding!
View GitHub Profile
@neosergio
neosergio / gui
Created June 14, 2012 01:42
interfaz gráfica de ejemplo de Tkinter con Python
#-*- coding:utf-8 -*-
from Tkinter import *
#funciones de procesamiento
def procesar():
resultado = peso.get() + altura.get()
print resultado
#Instancia de la clase Tk
ventana = Tk()
@neosergio
neosergio / install_pyenv.sh
Created October 31, 2021 21:11 — forked from jmvrbanac/install_pyenv.sh
Install pyenv on Ubuntu
#!/bin/bash
sudo apt-get install git python-pip make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev curl
sudo pip install virtualenvwrapper
git clone https://github.com/yyuu/pyenv.git ~/.pyenv
git clone https://github.com/yyuu/pyenv-virtualenvwrapper.git ~/.pyenv/plugins/pyenv-virtualenvwrapper
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
@neosergio
neosergio / sum_n_numbers.md
Last active August 19, 2021 17:28
Python unit testing exercise

Sum of N numbers

Write a function that can sum up numbers:

  • It should receive a sequence of n numbers.
  • If no argument is provided, return sum of numbers 1..100.
  • Look closely to the type of the function's default argument ...

Proposed solution

def sum_numbers(numbers=None):

Parse a list of Names

For the following list of names:

NAMES = ['arnold schwarzenegger', 'alec baldwin', 'bob belderbos',
         'julian sequeira', 'sandra bullock', 'keanu reeves',
         'julbob pybites', 'bob belderbos', 'julian sequeira',
         'al pacino', 'brad pitt', 'matt damon', 'Brad pitt']

Write a simple property

  • Write a simple Promo class. Its constructor receives two variables: name (which must be a string) and expires (which must be a datetime object).

  • Add a property called expired which returns a boolean value indicating whether the promo has expired or not.

Proposed solution

from datetime import datetime, timedelta

NOW = datetime.now()
git diff --no-prefix --ignore-space-at-eol | sed -e "s/^diff --git [^[:space:]]*/Index:/" -e "s/^index.*/===================================================================/" > changes.patch
python -c 'import random; result = "".join([random.choice("abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)") for i in range(50)]); print(result)'
@neosergio
neosergio / PY0101EN-3-4-Classes.ipynb
Created July 20, 2019 16:09
Created on Cognitive Class Labs
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@neosergio
neosergio / PY0101EN-3-3-Functions.ipynb
Created July 20, 2019 15:59
Created on Cognitive Class Labs
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@neosergio
neosergio / PY0101EN-3-2-Loops.ipynb
Created July 20, 2019 15:26
Created on Cognitive Class Labs
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.