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
""" | |
A series of functions to extract just the text from html page articles | |
""" | |
from lxml import etree | |
default_encoding = "utf-8" | |
def newyorker_fp (html_text, page_encoding=default_encoding): | |
"""For the articles found on the 'Financial Page' section of the New Yorker's website |
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
#!/usr/bin/env python | |
""" | |
An implementation in python, inspired by the haskell version via | |
Cormen | |
(https://github.com/dpapathanasiou/algorithms-unlocked-haskell/blob/master/algorithms-for-sorting-and-searching/MergeSort.hs) | |
""" | |
def merge (a, b, c=[]): |
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
#!/usr/bin/env python | |
""" | |
An implementation in python, inspired by the version in "Learn You | |
a Haskell for Great Good!" | |
(http://learnyouahaskell.com/recursion#quick-sort) | |
""" | |
def quicksort (a): |
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
#!/usr/bin/env python | |
""" | |
A binary search tree implementation, from: | |
"Python Algorithms: Mastering Basic Algorithms in the Python Language" | |
by Magnus Lie Hetland | |
ISBN: 9781484200551 |
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
alias pdftk='$HOME/.pdftk.sh' |
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
#!/usr/bin/env python | |
""" | |
An implementation of the "sliding window" technique to find shortest matching subarrays, inspired by: | |
https://leetcode.com/problems/find-all-anagrams-in-a-string/discuss/92007/sliding-window-algorithm-template-to-solve-all-the-leetcode-substring-search-problem | |
""" | |
from sys import maxint |
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 datetime import datetime | |
import pytz | |
def is_dst (): | |
"""Determine whether or not Daylight Savings Time (DST) | |
is currently in effect""" | |
x = datetime(datetime.now().year, 1, 1, 0, 0, 0, tzinfo=pytz.timezone('US/Eastern')) # Jan 1 of this year | |
y = datetime.now(pytz.timezone('US/Eastern')) |
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
#!/usr/bin/env python | |
""" | |
A ternary search tree implementation, inspired by: | |
http://www.drdobbs.com/database/ternary-search-trees/184410528 and | |
https://lukaszwrobel.pl/blog/ternary-search-tree/ | |
https://github.com/djtrack16/tst/blob/master/ternarysearchtree.py | |
""" |
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
''' | |
A simple python script to reduce or reformat a csv file, producing a | |
csv with a specific sub-set of columns, stripping out any undesired | |
characters from the individual row values. | |
''' | |
import csv |
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
#!/usr/bin/env python | |
""" | |
A breadth-first search implementation from: | |
"MIT Open CourseWare: Introduction to Algorithms" | |
Lecture 13: Breadth-First Search | |
https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-006-introduction-to-algorithms-fall-2011/lecture-videos/lecture-13-breadth-first-search-bfs/ |