Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View myles's full-sized avatar
🦖

Myles Braithwaite myles

🦖
View GitHub Profile
@myles
myles / README.md
Last active December 13, 2023 22:52
Backwards port of Django 5.0's update_or_create function

Backwards port of Django's 5.0 update_or_create

The update_or_create model function was updated in Django 5.0 with a create_defaults argument that allows only used during create operations.

@myles
myles / README.md
Last active September 15, 2023 23:02
Colly & Go vs. BeautifulSoup & Python

Colly & Go vs. BeautifulSoup & Python

> time go run cryptocoinmarketcap.go
2017/12/19 17:26:38 Scraping finished, check file "cryptocoinmarketcap-go.csv" for results
        2.24 real         0.84 user         0.45 sys

> time python3 cryptocoinmarketcap.py
WARNING:root:Scraping finished, check file cryptocoinmarketcap-py.csv for results
 3.51 real 2.94 user 0.07 sys
@myles
myles / keybase.md
Last active December 28, 2022 19:59
keybase.md

Keybase proof

I hereby claim:

  • I am myles on github.
  • I am myles (https://keybase.io/myles) on keybase.
  • I have a public key ASDdUR3w8haibPH-nGAJrwbnYONKwSQVACkpDwI1wM7qrAo

To claim this, I am signing this object:

@myles
myles / twitter_list_to_opml.py
Created June 28, 2011 16:24
A simple python script that creates an OPML file of a Twitter user's lists.
#!/usr/bin/env python
"""
A simple script that creates an OPML file of the RSS feeds to
a Twitter user's lists.
python twitter_list_to_opml.py mylesb
Copyright (c) 2010, Myles Braithwaite <me@mylesbraithwaite.com>
All rights reserved.
@myles
myles / ted_transcript_extractor.py
Created January 19, 2011 20:54
A simple Python scrape to extract the transcript from a TED talk.
#!/usr/bin/env python
"""
A simple script that extracts transcripts from <http://www.ted.com>
HOWTO:
python ted_tracscript_extractor.py john_hodgman_s_brief_digression.html
or
@myles
myles / gtalug_ics.py
Last active March 22, 2019 12:11
A simple Python script that generates the GTALUG ICS (or iCal) file at <http://gtalug.org/gtalug.ics>.
#!/usr/bin/env python
import vobject
import datetime
from pytz import timezone
from dateutil import rrule
TIME_ZONE = timezone('US/Eastern')
TODAY = datetime.date.today() - datetime.timedelta(days=31)
MEETING_START_TIME = datetime.time(19, 30, tzinfo=TIME_ZONE)
@myles
myles / playing.py
Last active February 5, 2019 20:28
Get the current track playing in iTunes on OS X
#!/usr/bin/env python3
import subprocess
def osascript(script):
"""
This is a bridge between Python and AppleScript using the `osascript`
comamnd line app.
"""
@myles
myles / json_rss_feed.py
Created November 21, 2013 21:11
Generate JSON based RSS 2.0 feeds in Django.
import json
from django.utils.feedgenerator import SyndicationFeed, rfc2822_date
class JSONFeed(SyndicationFeed):
mime_type = 'application/json; charset=utf-8'
def write(self, outfile, encoding):
data = {}
@myles
myles / pptx-to-png.sh
Last active November 9, 2017 18:23
Convert a bunch of PowerPoint files to PNG files.
for pptx in *.pptx;
do
libreoffice --headless --convert-to pdf $pptx
convert -density 400 `basename $pptx`.pdf -resize 2000x1500 `basename $pptx`%d.jpg
rm `basename $pptx`.pdf
done
@myles
myles / csv_spliter.py
Last active August 14, 2017 15:31
Quick Python script for splitting large CSV files using Pandas and NumPy.
#!/usr/bin/env python3
import argparse
import math
import os.path
import pandas as pd
import numpy as np
def main(filepath):