This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#first attempt at implementing horizon plots in ggplot2 | |
#pleased with result but code sloppy and inflexible | |
#as always very open to improvements and forks | |
if(!require(reshape2)){ | |
install.packages("reshape2") | |
} | |
if(!require(quantmod)){ | |
install.packages("quantmod") | |
} | |
if(!require(PerformanceAnalytics)){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from rauth.service import OAuth1Service, OAuth1Session | |
# Get a real consumer key & secret from: http://www.goodreads.com/api/keys | |
key = '<API_KEY>' | |
secret = '<API_SECRET>' | |
goodreads = OAuth1Service( | |
consumer_key=key, | |
consumer_secret=secret, | |
name='goodreads', | |
request_token_url='http://www.goodreads.com/oauth/request_token', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def count_walks(graph, u, v, k): | |
if(k == 0 and u == v): return 1 | |
if(k == 1 and graph[u][v]): return 1 | |
if(k <= 0): return 0 | |
count = 0 | |
for i in range(0, 5): | |
if(graph[u][i]): | |
count += count_walks(graph, i, v, k-1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bs4 import BeautifulSoup, SoupStrainer | |
import requests | |
import os | |
import urllib | |
# Could be .png or other image type. | |
match_str = '.webp' | |
# Access many links in sequence. |