Skip to content

Instantly share code, notes, and snippets.

View willcritchlow's full-sized avatar

Will Critchlow willcritchlow

View GitHub Profile
@willcritchlow
willcritchlow / generate-site-orphaned-page.ipynb
Created May 22, 2019 11:43
Run PageRank on a small example site to show the PR of an orphaned page -- one with no links
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@willcritchlow
willcritchlow / personalized-pr.py
Last active November 28, 2018 18:40
Networkx snippet with personalization
import networkx as nx
site = nx.DiGraph()
# load links from crawl into a list of dictionaries called edges with keys 'Source' and 'Destination'
for edge in edges:
site.add_edges_from([(edge['Source'], edge['Destination'])])
# set norm_mr to be an array of normalized raw mozranks for the nodes in site
@willcritchlow
willcritchlow / wp-commenters.sql
Created October 20, 2011 14:07
SQL for getting WordPress commenters' email addresses
select a.comment_author_email, max(a.comment_date) as date, b.comment_author from wp_comments a, wp_comments b where a.comment_author_email = b.comment_author_email and a.comment_date = b.comment_date and a.comment_approved=1 and a.comment_author_email <> "" and a.user_id = 0 and a.comment_author_email not like '%YOUREMAILDOMAIN%' group by a.comment_author_email;
@willcritchlow
willcritchlow / basic-gdata.py
Created May 11, 2011 22:11
The most basic Google Analytics access in python
import gdata.analytics.service
from datetime import date, timedelta
from xml.dom.minidom import parseString
def main():
client = gdata.analytics.service.AnalyticsDataService()
client.ClientLogin('<your email here>', '<your password here>')
today = date.today()