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 | |
# coding: utf-8 | |
""" | |
>>> from baralho import Baralho | |
>>> b = Baralho() | |
>>> len(b) | |
52 | |
>>> sorted([Carta('2', 'espadas'), Carta('K', 'copas'), Carta('A', 'copas')]) | |
[<A de copas>, <2 de espadas>, <K de copas>] | |
>>> b.pega_carta('4', 'paus') |
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 math import sqrt | |
class Vector(object): | |
def __init__(self, x=0, y=0): | |
self.x = x | |
self.y = y | |
def __repr__(self): | |
return 'Vector({x}, {y})'.format(x=self.x, y=self.y) |
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
class Quantidade(object): | |
def __init__(self): | |
self.nome_alvo = None | |
self.set_nome(self.__class__.__name__, id(self)) | |
def set_nome(self, prefix, key): | |
self.nome_alvo = '%s_%s' % (prefix, key) | |
def __get__(self, instance, owner): | |
return getattr(instance, self.nome_alvo) |
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
class DBConnection(object): | |
def __init__(self, database, user, password, host, remote_host, port, db_name): | |
self.database = database | |
self.user = user | |
self.password = password | |
self.host = host | |
self.remote_host = remote_host | |
self.port = port | |
self.db_name = db_name |
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
# Author: Eduardo Frazão | |
# OBS: this is for my android phone with Qpython3. | |
# that's my personal trainer \o/ | |
from time import sleep | |
from subprocess import call | |
import sl4a | |
droid = sl4a.Android() | |
call("clear") |
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.auth.models import User, Group | |
from rest_framework import viewsets | |
from core.serializers import UserSerializer, GroupSerializer | |
from django.views.generic.base import TemplateView | |
class UserViewSet(viewsets.ModelViewSet): | |
""" | |
API endpoint that allows users to be viewed or edited. | |
""" |
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.auth.models import User, Group | |
from rest_framework import serializers | |
class UserSerializer(serializers.HyperlinkedModelSerializer): | |
class Meta: | |
model = User | |
fields = ('url', 'username', 'email', 'groups') | |
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.conf.urls import patterns, include, url | |
from rest_framework import routers | |
from core import views | |
from core.views import Home | |
from django.contrib import admin | |
admin.autodiscover() | |
router = routers.DefaultRouter() |
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
<!doctype html> | |
<html lang="en" ng-app="App"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Example DRF and AngularJS</title> | |
</head> | |
<body ng-controller="DemoController as demo"> | |
<div> | |
<ul> | |
<li ng-repeat="user in users">{$ user.email $}</li> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.