This file contains 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 gspread | |
from google.oauth2.service_account import Credentials | |
from google_auth_oauthlib.flow import InstalledAppFlow | |
from google.auth.transport.requests import Request | |
import os | |
import pickle | |
# Define the scope |
This file contains 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 fetch_paginated_data(url, params,headers): | |
all_results = [] | |
response = requests.get(url, headers=headers, params=params) | |
data = response.json() | |
# print(data) | |
all_results.extend(data['interactions']) | |
# print(all_results) | |
while 'next' in data['links']: |
This file contains 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 requests | |
import datetime | |
import pandas as pd | |
import time | |
from io import StringIO | |
app_ids = [] | |
#set start date to 7 days ago as a date formatted yyyy-mm-dd | |
start_date = datetime.datetime.today() - datetime.timedelta(days=7) |
This file contains 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
# first: mkdir user && cd user && cp /path/to/get_gists.py . | |
# python3 get_gists.py user | |
import requests | |
import sys | |
from subprocess import call | |
user = sys.argv[1] | |
r = requests.get('https://api.github.com/users/{0}/gists'.format(user)) |
This file contains 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 requests | |
from bs4 import BeautifulSoup | |
from urllib.parse import urljoin, urlparse | |
def find_dead_links(base_url, url, visited_urls, counter): | |
# Convert the relative URL to an absolute URL | |
absolute_url = urljoin(base_url, url) | |
# Check if the URL has already been visited | |
if absolute_url in visited_urls: |
This file contains 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 paramiko | |
import urllib.parse | |
import stat | |
import boto3 | |
# import logging | |
import os | |
username = "" | |
password = "" | |
hostname = "sftp.domain.com/" |
This file contains 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 requests | |
from bs4 import BeautifulSoup | |
import pandas as pd | |
from IPython.display import HTML | |
import smtplib | |
from email.mime.multipart import MIMEMultipart | |
from email.mime.application import MIMEApplication | |
from email.mime.text import MIMEText | |
import smtplib |
This file contains 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 pandas as pd | |
import boto3 | |
from io import StringIO | |
import datetime | |
import warnings | |
#suppress warnings | |
warnings.filterwarnings("ignore") | |
def main(): |
This file contains 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 json | |
import boto3 | |
from datetime import datetime, timedelta | |
import requests | |
import base64 | |
username = '' | |
password = "" | |
# Encode the credentials in base64 |
This file contains 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
SELECT | |
PARSE_DATE("%Y%m%d", event_date) as date, | |
geo.country as country, | |
case | |
WHEN DATE(TIMESTAMP_MICROS(user_first_touch_timestamp)) = DATE(TIMESTAMP_MICROS(event_timestamp)) THEN 'New Visitor' | |
ELSE 'Returning Visitor' | |
END AS user_type, | |
COALESCE(collected_traffic_source.manual_medium) as medium, | |
COALESCE(collected_traffic_source.manual_source) as source, | |
COALESCE(collected_traffic_source.manual_campaign_name) as campaign, |
NewerOlder