Skip to content

Instantly share code, notes, and snippets.

View jefftriplett's full-sized avatar
Living the dream

Jeff Triplett jefftriplett

Living the dream
View GitHub Profile
@jefftriplett
jefftriplett / fetch_dcus.py
Last active December 6, 2016 21:01
This script fetches blog articles off of the DCUS website and converts them to markdown.
import click
import codecs
import dateparser
import frontmatter
import os
import requests
import requests_cache
from bs4 import BeautifulSoup
from unidecode import unidecode
@jefftriplett
jefftriplett / spotify_playlist_export.py
Last active October 24, 2020 02:49
Dump your Spotify playlists to YAML or Markdown using Python.
"""
Formatting based on:
https://en.wikipedia.org/wiki/Wikipedia:WikiProject_Albums/Album_article_style_guide
YAML formatting inspired by:
https://github.com/katydecorah/katydecorah.github.io/blob/master/_data/playlists.yml
Method inspired from:
- https://github.com/plamere/spotipy/blob/master/examples/user_playlists_contents.py
- https://github.com/jacobian/rdio-takeout-importer/blob/master/r2s.py#L68
1204c1204
<
---
>
1338c1338
< warnings.warn(b"".join(errors), RuntimeWarning)
---
> warnings.warn(b"".join(errors).decode(), RuntimeWarning)

2016 NCAA Men's Basketball

South

Team Round 64 Round 32 Round 16 Round 8 Final 4 Final
Kansas (1) 0.9898 0.9252 0.7875 0.5807 0.3594 0.2049
Austin Peay (16) 0.0102 0.0013 0.0001 0.0000 0.0000 0.0000
Colorado (8) 0.6174 0.0513 0.0172 0.0037 0.0005 0.0001
Connecticut (9) 0.3826 0.0223 0.0057 0.0008 0.0001 0.0000
"""
Formatting based on:
https://en.wikipedia.org/wiki/Wikipedia:WikiProject_Albums/Album_article_style_guide
Method inspired from:
- https://github.com/plamere/spotipy/blob/master/examples/user_playlists_contents.py
- https://github.com/jacobian/rdio-takeout-importer/blob/master/r2s.py#L68
Getting started:
import click
import json
from livescrape import ScrapedPage, Css, CssLink, CssMulti
class TeamRosterPage(ScrapedPage):
scrape_url = 'http://stats.ncaa.org/team/roster/%(season_id)s?org_id=%(team_id)s'
scrape_args = ('season_id', 'team_id')
table_contents = CssMulti(
"""
Quick attempt to extract speakers and talks from every DjangoCon US.
To install requirements:
pip install click grab unicodecsv
Goals:

Give a Python a Pony by @kennethlove #djbday

A More Accessible Django Girls @laceynwilliams #djbday

How Django Is Good For Your Health by @craigbruce #djbday

Django: The Conspiracy by @andrewgodwin #djbday

Snakes, Ponies and Balloons: Stories of Teaching Django to Thousands of Women by @olasitarska #djbday

"""
Originaly code was taken from: http://djangosnippets.org/snippets/290/
But I was made some improvements like:
- print URL from what queries was
- don't show queries from static URLs (MEDIA_URL and STATIC_URL, also for /favicon.ico).
- If DEBUG is False tell to django to not use this middleware
- Remove guessing of terminal width (This breaks the rendered SQL)
"""
try:
import cProfile as profile