This file contains 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
# coding: utf-8 | |
u""" | |
Redimensionamento proporcional de imagem, com base na altura, feito com um simples cálculo de proporção. | |
Ex: | |
+------+ 10 15 (altura desejada para a nova imagem) | |
| | -- x -- | |
| 10x5 | 5 x (largura proporcional a nova altura) | |
| | | |
+------+ (10 x x) = (5 x 15) | |
10x = 75 |
This file contains 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
# coding: utf-8 | |
#!/usr/bin/env python | |
#!C:\Python27\python | |
from Tkinter import * | |
from random import randint | |
def gerador_pis_pasep(): | |
# 9 números aleatórios | |
arNumeros = [] |
This file contains 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 random import randint | |
vogais = 'a e i o u'.split() | |
lst = [] | |
for x in range(20): # Quantos caracteres | |
lst.append(vogais[randint(0, len(vogais) - 1)]) | |
lst.append(' ' if randint(0, 1) == 1 else '') | |
print 'Seu refrão:' | |
for i in range(6): # Quantas repetições | |
print ''.join(lst).capitalize() |
This file contains 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 | |
# Create your models here. | |
class Post(models.Model): | |
title = models.CharField(max_length=120) | |
text = models.TextField() | |
# audit fields | |
pub_date = models.DateTimeField(auto_now_add=True) | |
up_to_date = models.DateTimeField(auto_now=True) |
This file contains 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 xml.dom.minidom import Document | |
>>> doc = Document() | |
>>> wml = doc.createElement("wml") | |
>>> doc.appendChild(wml) | |
<DOM Element: wml at 0x17fbdf0> | |
>>> maincard = doc.createElement("card") | |
>>> maincard.setAttribute("id", "main") | |
>>> wml.appendChild(maincard) | |
<DOM Element: card at 0x17fbe90> | |
>>> paragraph1 = doc.createElement("p") |
This file contains 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
class Owner(models.Model): | |
name = models.CharField(max_length=100) | |
email = models.CharField(max_length=100) | |
class Pet(models.Model): | |
owner = models.ForeignKey(Owner) | |
name = models.CharField(max_length=100) | |
breed = models.CharField(max_length=100) | |
class OwnerForm(forms.ModelForm): |
This file contains 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
pip install -U requests | |
pip install -U git+git://github.com/requests/requests-oauthlib.git |
This file contains 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 | |
# -*- coding: utf-8 -*- | |
import sys, re | |
import itertools | |
from functools import wraps | |
from pyquery import PyQuery as pq | |
class scrape: | |
This file contains 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
<!DOCTYPE html> | |
<html ng-app lang="pt-br"> | |
<head> | |
<title>Lista de compras</title> | |
<style>.comprado-true { background: #eee } tr { cursor: default }</style> | |
<script src="../libs/angular.min.js" type="text/javascript"></script> | |
<script src="script.js" type="text/javascript"></script> | |
</head> | |
<body> | |
<table ng-controller="ComprasController"> |
This file contains 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 posts.models import User, Post, Amigos | |
>>> # Cria joao | |
>>> joao = User(username="joao", first_name="João", email="[email protected]") | |
>>> joao.save() | |
>>> # Cria jose | |
>>> jose = User(username="jose", first_name="José", email="[email protected]") | |
>>> jose.save() |