Skip to content

Instantly share code, notes, and snippets.

@pshapiro
pshapiro / internal-pagerank.r
Last active March 29, 2023 16:36
Calculate Internal PageRank from Screaming Frog Crawl
library("igraph")
# Swap out path to your Screaming Frog All Outlink CSV. For Windows, remember to change backslashes to forward slashes.
links <- read.csv("C:/Documents/screaming-frog-all-outlinks.csv", skip = 1) # CSV Path
# This line of code is optional. It filters out JavaScript, CSS, and Images. Technically you should keep them in there.
links <- subset(links, Type=="AHREF") # Optional line. Filter.
links <- subset(links, Follow=="true")
links <- subset(links, select=c(Source,Destination))
g <- graph.data.frame(links)
pr <- page.rank(g, algo = "prpack", vids = V(g), directed = TRUE, damping = 0.85)
values <- data.frame(pr$vector)
@pshapiro
pshapiro / class-amp-post-template.php
Last active March 15, 2016 20:55
Fix for publisher logo in AMP WP Plugin
/* Edit the class-amp-post-template.php file, either via FTP or within your WordPress Dashboard (go to Plugins > Editor and then select “AMP”) and change this:
if ( $site_icon_url ) {
$metadata['publisher']['logo'] = array(
'@type' => 'ImageObject',
'url' => $site_icon_url,
'height' => self::SITE_ICON_SIZE,
'width' => self::SITE_ICON_SIZE,
);
}
@pshapiro
pshapiro / class-amp-post-template.php
Last active March 15, 2016 20:54
Fix Schema Validation for WordPress AMP Plugin where posts don't have a featured image.
# Edit AMP Plugin file: amp/includes/class-amp-post-template.php
/*
Change this bit of code to the below uncommented code:
$image_metadata = $this->get_post_image_metadata();
if ( $image_metadata ) {
$metadata['image'] = $image_metadata;
}
@pshapiro
pshapiro / amp-post-template-actions.php
Last active March 7, 2016 15:44
SEL - Enable Google Analytics for AMP WordPress Plugin
add_action( 'amp_post_template_head', 'amp_post_template_add_analytics_js' );
function amp_post_template_add_analytics_js( $amp_template ) {
$post_id = $amp_template->get( 'post_id' );
?>
<script async custom-element="amp-analytics" src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js"></script>
<?php
}
add_action( 'amp_post_template_footer', 'xyz_amp_add_analytics' );