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
package br.com.savemoney.mastercontas; | |
import android.app.Activity; | |
import android.content.ContentValues; | |
import android.content.Intent; | |
import android.database.Cursor; | |
import android.database.sqlite.SQLiteDatabase; | |
import android.os.Bundle; | |
import android.view.View; | |
import android.widget.EditText; |
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
function criaElemento(tag) { | |
var elemento = document.createElement(tag); | |
elemento.innerText = "Também funciona!!!"; | |
//elemento.onclick = obterAtributosDosElementos; | |
elemento.addEventListener("click", obterAtributosDosElementos); | |
document.getElementById('sec-elementos').appendChild(elemento); | |
} | |
function obterAtributosDosElementos() { |
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="pt-br"> | |
<head> | |
<title>Site dinâmico com JavaScript</title> | |
<meta charset="utf-8"> | |
<style type="text/css"> | |
section article { | |
display: inline-block; | |
height: 100px; | |
} |
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
def get_pacientes(request): | |
if request.is_ajax(): | |
q = request.GET.get('term', '') | |
pacientes = Paciente.objects.filter(nome__icontains = q)[:20] | |
results = [] | |
for paciente in pacientes: | |
paciente_json = {} | |
paciente_json = paciente.nome | |
results.append(paciente_json) | |
data = json.dumps(results) |
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
//Ajax para o agendamento de cliente. | |
$(document).ready(function() { | |
$("#id_paciente").autocomplete({ | |
source: "/consultorio/get-pacientes/", | |
minLength: 2, | |
}); | |
}); |
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
#views.py | |
def home(request): | |
res_list = Restaurante.objects.all() | |
paginator = Paginator(res_list, 9) | |
page = request.GET.get('page') | |
try: | |
res = paginator.page(page) | |
except PageNotAnInteger: | |
res = paginator.page(1) | |
except EmptyPage: |
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
#forms.py | |
class AgendaForm(forms.ModelForm): | |
paciente = forms.ModelChoiceField(queryset=Paciente.objects.all(), widget=forms.TextInput()) | |
class Meta: | |
model = Agenda | |
fields = ('paciente', 'medico', 'data_consulta', 'horario', 'observacoes') | |
#views.py | |
def add_agenda(request): | |
if request.method == 'POST': |
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 clipboard | |
import random | |
while True: | |
with open("cpf_vendedores.txt") as f: | |
cpfs = [line.strip() for line in f.readlines()] | |
cpf = random.choice(cpfs) | |
clipboard.copy(cpf) |
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
#Classe que herda de Manager e customiza o comportamento de objects adicionando um método de busca | |
class RestauranteProdutoManager(models.Manager): | |
def buscar(self, query): | |
return self.get_queryset().filter(models.Q(restaurante__icontains=query) | models.Q(produto__produto__icontains=query)) | |
class Restaurante(models.Model): | |
restaurante = models.CharField(u'Restaurante', max_length=255) | |
endereco = models.CharField(u'Endereço', max_length=255) | |
numero = models.CharField(u'Número', max_length=20) |
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
fhand = open('mbox-short.txt') | |
count = 0 | |
total = 0 # acumuladora/totalizadora | |
for line in fhand: | |
line = line.rstrip() | |
if line.startswith('X-DSPAM-Confidence: '): | |
count = count + 1 | |
limit = line.find(':') | |
line = float(line[limit+1:]) | |
total = total + line # cálculo, o valor atual mais o valor de cada linha |