Skip to content

Instantly share code, notes, and snippets.

View FilippoLeone850's full-sized avatar

FilippoLeone850

View GitHub Profile
for attempt in range(attempts):
data = generate_data()
try:
if data:
# Do something with your generated data here, example: push it into a table
# Successfully pulled data via generate data method, breaking loop
break
else:
print(f"An error occurred, retrying (Attempt no: {attempt + 1})...")
continue
@FilippoLeone850
FilippoLeone850 / AsyncRequests.py
Last active April 3, 2020 16:24
Asynchronous HTTP requests via a coroutine that can parallel execution
import time
import asyncio
from aiohttp import ClientSession
class AsyncRequests:
def __init__(self, url, times=None, parallel_items=None, debug=False):
self.executed = 0
self.request = None
self.url = url
self.method = 'get'
import pandas as pd
import re
if __name__ == '__main__':
newdf = pd.DataFrame()
i = 0
dataframe = pd.read_csv('dataset-for-analysis.csv')
while True:
try:
current_row = dataframe.iloc[i]
@FilippoLeone850
FilippoLeone850 / iterable_request.js
Last active November 12, 2019 08:52
Iterable sample request - taken from GTM
<script>
if (
{{GetCookie - iterable_campaignId}} &&
{{GetCookie - iterable_email}} &&
{{GetCookie - iterable_messageId}} &&
{{GetCookie - iterable_templateId}}
) {
var payload = {
"user": {