Skip to content

Instantly share code, notes, and snippets.

View moacirmoda's full-sized avatar

Moacir Moda moacirmoda

View GitHub Profile
@moacirmoda
moacirmoda / poc.py
Last active August 1, 2023 19:38
PoC to get Ad Insights from Facebook
from time import sleep
from facebook_business.api import FacebookAdsApi
from facebook_business.adobjects.adaccount import AdAccount
from django.conf import settings
my_app_id = settings.SOCIAL_AUTH_FACEBOOK_KEY
my_app_secret = settings.SOCIAL_AUTH_FACEBOOK_SECRET
user = User.objects.get(email="moacir.moda@codevance.com.br")
from rider.models import *
rides_with_ck_ids = CheckRide.objects.all().values_list('ride_id', flat=True)
rides_ids = Ride.objects.all().values_list('id', flat=True)
rides_without_ck_ids = []
for id in rides_ids:
if id not in rides_with_ck_ids:
rides_without_ck_ids.append(id)
class Foo:
def bar(self):
print(1)
class Mixin:
def bar(self):
print(2)
class New(Foo, Mixin):
pass
# demandas duplicadas
from api.models import *
from datetime import timedelta
ids_duplicated = []
for diligencia in Diligencia.objects.all().order_by('-id'):
if diligencia.id in ids_duplicated:
continue
user = diligencia.user
@moacirmoda
moacirmoda / gist:cf89f8e58b1f987020796005f35cf7d3
Created September 20, 2018 12:36
Digitalocean Consulta CNPJ
1 sudo apt update
2 sudo apt install apt-transport-https ca-certificates curl software-properties-common
3 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
4 sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
5 sudo apt update
6 apt-cache policy docker-ce
7 sudo apt install docker-ce
8 sudo systemctl status docker
9 sudo apt-get install git -y
10 git clone git@github.com:codevance/consulta_cnpj.git git
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
<soap-env:Header>
<ns0:User xmlns:ns0="http://www.b2breservas.com.br/b2bws/types/">xxx</ns0:User>
<ns1:Password xmlns:ns1="http://www.b2breservas.com.br/b2bws/types/">xxx</ns1:Password>
</soap-env:Header>
<soap-env:Body>
<ns0:OTA_PingRQ EchoToken="1234" Version="3.000" xmlns:ns0="http://www.opentravel.org/OTA/2003/05/alpha">
<ns0:EchoData>1</ns0:EchoData>
</ns0:OTA_PingRQ>
</soap-env:Body>
from django import models
from django.test import TestCase
class Person(models.Model):
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=30, null=True)
age = models.PositiveIntegerField()
def __str__(self):
return '{} {}'.format(self.first_name, self.last_name)
from django.test import TestCase
from myapp.models import Person
class PersonTestCase(TestCase):
def test_should_return_attributes(self):
self.assertTrue(hasattr(Person, 'first_name'))
self.assertTrue(hasattr(Person, 'last_name'))
self.assertTrue(hasattr(Person, 'age'))
def test_should_create_item(self):
from django.test import TestCase
from myapp.models import Person
class PersonTestCase(TestCase):
def test_should_return_attributes(self):
self.assertTrue(hasattr(Person, 'first_name'))
self.assertTrue(hasattr(Person, 'last_name'))
self.assertTrue(hasattr(Person, 'age'))
try:
Person.objects.get(id=1)
except Person.DoesNotExists:
print('não existe')