Skip to content

Instantly share code, notes, and snippets.

class Day(object):
def __init__(self, visits, contacts):
self.visits = visits
self.contacts = contacts
def __add__(self, other):
total_visits = self.visits + other.visits
total_contacts = self.contacts + other.contacts
return Day(total_visits, total_contacts)
# Pon aquí el identificador de tu lista
LIST_ID = 000
def get_number_of_contacts_in_list(list_id):
endpoint = "/contacts/v1/lists/" + str(list_id)
url = BASE + endpoint + "?hapikey=" + APIKEY_VALUE
response = urllib2.urlopen(url).read()
list_info = json.loads(response)
return list_info["metaData"]["size"]
import urllib2, json
# Aquí tienes que poner el valor de tu Clave API
APIKEY_VALUE = "example-api-key-value-0000"
BASE = "https://api.hubapi.com"
def get_total_number_of_contacts():
# Primero, construimos la URL
endpoint = "/contacts/v1/contacts/statistics"
<html>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['date', 'data1', 'data2', 'percentage'],
[ "1 Mar", 289, 94, 0.10], [ "2 Mar", 295, 96, 0.20], [ "3 Mar", 300, 104, 0.30],
[ "4 Mar", 306, 124, 0.40], [ "5 Mar", 311, 142, 0.50], [ "6 Mar", 317, 153, 0.60],
# -*- coding: utf-8 -*-
import nose.tools as nt
import factory
from django.test import TestCase
from myapp.models import House
class HouseFactory(factory.DjangoModelFactory):
FATORY_FOR = House
location = "Barcelona"
rooms = 3
# -*- coding: utf-8 -*-
from django.db import models
from django.utils.translation import ugettext_lazy as _
class House(models.Model):
location = models.CharField(
max_length=200,
verbose_name=_("Location"),
help_text=_("Enter the location of the house"),
from django.test import TestCase
class TestExample(TestCase):
"""
Here you can define multiple tests, but all must begin
with test_
"""
def setUp(self):
"""
Optional. Define here your initial setup for your tests
# Based on Example in https://docs.djangoproject.com/en/1.5/topics/testing/doctests/
from django.db import models
class Animal(models.Model):
"""
An animal that makes noise
# Create an animal
>>> lion = Animal.objects.create(name="lion", sound="roar")
# -*- coding: utf-8 -*-
from celery.task.schedules import crontab
from celery.decorators import periodic_task
from celery.utils.log import get_task_logger
from datetime import datetime
from myapp.models import TaskHistory
logger = get_task_logger(__name__)
# -*- coding: utf-8 -*-
from django.db import models
from django.utils.translation import ugettext_lazy as _
import jsonfield
class TaskHistory(models.Model):
# Relations
# Attributes - mandatory
name = models.CharField(