Skip to content

Instantly share code, notes, and snippets.

View nicogaspa's full-sized avatar

Nicolò Gasparini nicogaspa

View GitHub Profile
@nicogaspa
nicogaspa / knowledge_search.py
Last active May 15, 2021 09:52
Google Knowledge Search API class
import requests
from typing import List
API_KEY = "" # TODO
VERSION = "v1"
class GoogleKnowledgeSearchService:
def __init__(self):
self.api_key = API_KEY
@nicogaspa
nicogaspa / factcheck.py
Last active May 15, 2021 09:52
Google FactCheck API class
import requests
API_KEY = "" # TODO
VERSION = "v1alpha1"
class GoogleFactCheckService:
def __init__(self):
self.api_key = API_KEY
self.base_url = f"https://factchecktools.googleapis.com/{VERSION}"
@nicogaspa
nicogaspa / pagespeed.py
Last active May 15, 2021 09:52
Google PageSpeed API class
import requests
API_KEY = "" # TODO
VERSION = "v5"
class GooglePageSpeedService:
def __init__(self):
self.api_key = API_KEY
self.base_url = (
# requirements
# google-cloud-pubsub==1.7.0
import json
import time
from datetime import datetime
from random import random
from google.auth import jwt
from google.cloud import pubsub_v1
# --- Base variables and auth path
#!/usr/bin/env python
import argparse
import json
import os
import logging
import apache_beam as beam
from apache_beam.options.pipeline_options import PipelineOptions, StandardOptions
logging.basicConfig(level=logging.INFO)
logging.getLogger().setLevel(logging.INFO)
@nicogaspa
nicogaspa / fb_upload_offline_events.py
Created July 9, 2019 21:53
simple class with function to upload offline events in an offline event set using facebook python sdk
from facebook_business.adobjects.offlineconversiondataset import OfflineConversionDataSet
from facebook_business.api import FacebookAdsApi
class FacebookService:
def __init__(self):
self.api = FacebookAdsApi.init(app_id='your_app_id', app_secret='your_app_secret',
access_token='your_access_token')
self.offline_dataset = OfflineConversionDataSet('offline_set_id')
def upload_offline_conversion(self, csv_filename):
@nicogaspa
nicogaspa / fb_create_offline_event_set.py
Last active July 9, 2019 21:26
simple class with function to create an offline event set using facebook python sdk
from facebook_business.adobjects.offlineconversiondataset import OfflineConversionDataSet
from facebook_business.api import FacebookAdsApi
class FacebookService:
def __init__(self):
self.api = FacebookAdsApi.init(app_id='your_app_id', app_secret='your_app_secret',
access_token='your_access_token')
def create_offline_event_set(self, name):
params = {
@nicogaspa
nicogaspa / google_handler.py
Created June 22, 2019 08:52
Snippet of python code using ASK SDK initializing a Google API service
from ask_sdk_core.utils import is_intent_name, is_request_type
from ask_sdk_core.dispatch_components import AbstractRequestHandler
from ask_sdk_model.ui import LinkAccountCard
import httplib2
from googleapiclient.discovery import build
from oauth2client.client import AccessTokenCredentials, AccessTokenCredentialsError
class SummaryHandler(AbstractRequestHandler):
def can_handle(self, handler_input):
@nicogaspa
nicogaspa / index.html
Last active June 22, 2019 08:36
Simple Login redirect to Google Auth
<!DOCTYPE html>
<html lang="en-us">
<head>
<title>Your Skill</title>
</head>
<body>
<div>
<p>Welcome to the skill</p>
<p>Click on the button to continue</p>
</div>