This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Primero hay que instalar las librerias necesarias | |
| # pip install requests beautifulsoup4 | |
| import requests | |
| from bs4 import BeautifulSoup | |
| # Descargamos la pagina del BCP | |
| bcp = requests.get('https://www.bcp.gov.py/webapps/web/cotizacion/monedas', | |
| headers={'user-agent': 'Mozilla/5.0'}, verify=False) | |
| #buscamos todas las etiquetas <td>, elegmos la cuarta, elegimos el texto, reemplazamos el . separador de miles y la coma decimal | |
| cotizacion = float(BeautifulSoup(bcp.text).findAll("td")[3].get_text().replace(".","").replace(",",".")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.db import models | |
| # Un Autor puede tener varios libros | |
| # Un libro puede tener un autor | |
| # Un Libro puede tener varios Generos | |
| # Un Genero puede pertenecer a varios libros | |
| # null=True, blank=True hace que el campo sea opcional | |
| class Autor(models.Model): | |
| nombre = models.CharField(max_length=120) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import sys | |
| import subprocess | |
| diff_requirements = 'git diff ORIG_HEAD HEAD --exit-code -- requirements.txt' | |
| exit_code = subprocess.call(diff_requirements.split()) | |
| if exit_code == 1: | |
| print 'The requirements file has changed! Remember to install new dependencies.' | |
| else: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| apt install -y python3 python3-pip | |
| pip3 install django==1.11.11 netifaces psycopg2-binary gunicorn==19.7.1 gevent | |
| sed -i 's/python/python3.6/g' /usr/bin/gunicorn | |
| sed -i 's/python/python3.6/g' /home/django/django_project/manage.py | |
| /home/django/django_project/manage.py migrate | |
| systemctl restart gunicorn.service |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pkg_resources | |
| import prettytable | |
| def get_pkg_license(pkg): | |
| try: | |
| lines = pkg.get_metadata_lines('METADATA') | |
| except: | |
| lines = pkg.get_metadata_lines('PKG-INFO') | |
| for line in lines: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| SP_PATH=$(python3 -m site --user-site) | |
| URL="https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v2.0/pip/pgadmin4-2.0-py2.py3-none-any.whl" | |
| ICON="https://www.postgresql.org/message-id/attachment/1139/pgAdmin.svg" | |
| FILE=$(echo $URL | sed 's/.*\///') | |
| #Install pip3 | |
| echo "Installing python3-pip if not installed..." | |
| sudo apt install -y python3-pip | |
| #Get pgAdmin4 Python Wheel | |
| echo "Downloading pgAdmin4..." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| BACKUP_DIR=~/backups/git_backups/ | |
| REPOS="git@github.com:melizeche/listaHu.git git@github.com:melizeche/dolarPy.git" | |
| for repo in $REPOS;do | |
| repo_dir=$(echo $repo | sed 's/.*\///') | |
| repo_name=$(echo $repo_dir | sed 's/\.[^.]*$//') | |
| FINAL_BACKUP_DIR=$BACKUP_DIR"`date +\%Y-\%m-\%d`/" | |
| FINAL_REPO_DIR=$FINAL_BACKUP_DIR$repo_name | |
| echo "Backing up "$repo_name in $FINAL_REPO_DIR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| import json | |
| import tweepy | |
| STRING_TO_CHECK = "El texto que queres que este 'escuchando', en el caso del comentabot es su usuario" | |
| ACCESS_TOKEN = "" | |
| ACCESS_TOKEN_SECRET = "" | |
| CONSUMER_KEY = "" | |
| CONSUMER_SECRET = "" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| git for-each-ref --format '%(refname:short)' | grep -v master | sed 's/^origin\///' | sed 's/^/ git push origin :/' | bash |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.contrib.sessions.models import Session | |
| from django.contrib.auth.models import User | |
| # grab the user in question | |
| user = User.objects.get(username='johndoe') | |
| [s.delete() for s in Session.objects.all() if s.get_decoded().get('_auth_user_id') == user.id] | |
| user.is_active = False | |
| user.save() |