Skip to content

Instantly share code, notes, and snippets.

@johndavidsimmons
johndavidsimmons / pyaa.py
Created February 1, 2017 16:09
The main function for checking Adobe Analytics
def main():
global target_url
global HTML_string
global driver
relative_anchors = findAllAnchors(target_url)
# Iterate the relative anchors and collect data
for anchor in relative_anchors:
anchorHref = str(anchor['href'])
def visitPage(url, relativeUrl):
global driver
global HTML_string
# Visit the page
driver.get(url+relativeUrl)
# Turn on staging and debug (Optional)
# driver.execute_script(stagingScript)
# driver.execute_script(debugScript)
@johndavidsimmons
johndavidsimmons / findAllAnchors.py
Created January 30, 2017 21:39
Return a set of the relative anchors on the given page
def findAllAnchors(url):
# Use requests to get page source without using driver
r = requests.get(url)
# Turn the page source into soup for parsing
soup = bs4(r.text, "html5lib")
# Return a Set of relative anchors tags from a given
return set([anchor for anchor in soup.find_all('a', href=True) if anchor['href'].startswith('/') and not anchor['href'].endswith(('.com', '.org', '.net'))])
@johndavidsimmons
johndavidsimmons / browser.py
Created January 27, 2017 15:00
Setting up the Selenium Chromedriver
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
import os
def chromeDriver():
if os.path.exists('.env'):
for line in open('.env'):
var = line.strip().split('=')
if len(var) == 2:
@krisbulman
krisbulman / countCSSRules.js
Last active February 27, 2025 22:33 — forked from psebborn/countCSSRules.js
Count the number of rules and selectors for CSS files on the page. Flags up the >4096 threshold that confuses IE. — This snippet has been modified to count more than just the first level of CSSStyleRule objects within CSSMediaRule.
function countCSSRules() {
var results = '',
log = '';
if (!document.styleSheets) {
return;
}
for (var i = 0; i < document.styleSheets.length; i++) {
countSheet(document.styleSheets[i]);
}
function countSheet(sheet) {
@jdevalk
jdevalk / .htaccess
Last active January 7, 2025 07:26
These three files together form an affiliate link redirect script.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^index\.php$ - [L]
RewriteRule (.*) ./index.php?id=$1 [L]
</IfModule>
@dciccale
dciccale / README.md
Last active October 22, 2021 21:52
Tiny Cross-browser DOM ready function in 111 bytes of JavaScript

DOM Ready

Tiny Cross-browser DOM ready function in 111 bytes of JavaScript.

<!doctype html>
<!-- http://taylor.fausak.me/2015/01/27/ios-8-web-apps/ -->
<html>
<head>
<title>iOS 8 web app</title>
<!-- CONFIGURATION -->
@narenranjit
narenranjit / VelToJSON
Created January 24, 2012 20:23
Convert objects in Velocity templates to JSON
#macro(VelListToJSON $list )
#set($myList = $list )## dereference
{
#foreach($key in $myList.keySet())
"$key":
#set($x = $myList.get($key))
#VelToJSON($x)
#if($foreachCount != $myList.keySet().size()) , #end
#end
}
@nathansmith
nathansmith / config.rb
Created August 29, 2011 21:00
Example config.rb file for Compass
preferred_syntax = :sass
http_path = '/'
css_dir = 'assets/stylesheets'
sass_dir = 'assets/sass'
images_dir = 'assets/images'
javascripts_dir = 'assets/javascripts'
relative_assets = true
line_comments = true
# output_style = :compressed