Skip to content

Instantly share code, notes, and snippets.

View roymartinezblanco's full-sized avatar

Roy Martinez roymartinezblanco

View GitHub Profile
@roymartinezblanco
roymartinezblanco / First_vs_Third.py
Created July 31, 2020 14:44
First vs Third Party
tmp = dat_clean
tmp = tmp.groupby(['host','host-type','url']).size().reset_index(name='Count')
tmp = tmp.groupby(['host-type']).sum().reset_index()
tmp = tmp.sort_values(by=['Count'],ascending=False)
plt.pie(tmp['Count'],labels=tmp['host-type'],shadow=False,autopct='%1.1f%%')
plt.title('First vs Third Party')
plt.axis('equal')
plt.tight_layout()
plt.show()
tmp = dat_clean
tmp = tmp[tmp['host-type'] == 'Third Party']
tmp = tmp[["host", "send","ttfb", "receive"]]
tmp = tmp.groupby('host')[ "send", "ttfb", "receive"].mean().reset_index()
tmp.plot(x="host", kind="bar", stacked=True,label='Series')
plt.title('Third Party Timings')
plt.xlabel('Domains')
plt.ylabel('Milliseconds')
plt.show()
del tmp
@roymartinezblanco
roymartinezblanco / python har clearner.py
Created July 31, 2020 14:27
Extracts Data and cleans it from HAR
colmms = ['url','host','host-type','method','status','ext','cpcode','ttl','server','cdn-cache','cdn-cache-parent','cdn-cache-key','cdn-req-id','vary','appOrigin','content-length','content-length-origin','blocked','dns','ssl','connect','send','ttfb','receive','edgeTime','originTime'
]
dat_clean = pd.DataFrame(columns=colmms)
for r in har['log']['entries']:
u = str(r['request']['url']).split('?')[0]
host = re.search('://(.+?)/', u, re.IGNORECASE).group(0).replace(':','').replace('/','')
cachekey = str(findHeader(r,'response','x-cache-key','eq'))
if not cachekey == 'None':
cachekey = cachekey.split('/')
@roymartinezblanco
roymartinezblanco / python pandas helper.py
Created July 31, 2020 13:38
Helper Function to fund headers in har
def findHeader(req,headertype,headername,op = None):
value = "None"
if headertype == 'response':
for h in req['response']['headers']:
if op == 'in':
if headername in h['name']:
value = h['value']
break
else:
if headername == h['name']:
akamai_property.myProperty: Still modifying... [id=prp_xxxx, 10s elapsed]
Error: Error - Invalid Property Rules
Rule validation error: https://problems.luna.akamaiapis.net/papi/v0/validation/attribute_required The Normalize Path option on the `Path` match is required.
Rule validation error: https://problems.luna.akamaiapis.net/papi/v0/validation/attribute_required The Normalize Path option on the `Path` match is required.
Rule validation error: https://problems.luna.akamaiapis.net/papi/v0/validation/attribute_required The Normalize Path option on the `Path` match is required.
Rule validation error: https://problems.luna.akamaiapis.net/papi/v0/validation/attribute_required The Normalize Path option on the `Path` match is required.
Rule validation error: https://problems.luna.akamaiapis.net/papi/v0/validation/attribute_required The Normalize Path option on the `Path` match is required.
on property.tf line 20, in resource "akamai_property" "myProperty":
pipeline {
agent {
docker {
image 'akamai/property:latest'
}
}
stages {
stage('Fetch Template Configuration') {
steps {
@roymartinezblanco
roymartinezblanco / purgeURL()
Last active May 18, 2019 01:12
Akamai-on-AWS-Lambda
def purgeCPCODE(CP=None):
#Fetch Credentials from Env Variables from AWS
AO_ACCESS_TOKEN = os.environ['AO_ACCESS_TOKEN']
AO_CLIENT_SECRET = os.environ['AO_CLIENT_SECRET']
AO_API_HOST = os.environ['AO_API_HOST']
AO_CLIENT_TOKEN = os.environ['AO_CLIENT_TOKEN']
apiRequest = requests.Session()
@roymartinezblanco
roymartinezblanco / main.py
Last active May 18, 2019 01:12
Akamai-on-AWS-Lambda
import json, os, requests, boto3
# Akamai Open Libs
from akamai.netstorage import Netstorage, NetstorageError
from akamai.edgegrid import EdgeGridAuth
def purgeCPCODE(CP=None):
#Fetch Credentials from Env Variables from AWS