Skip to content

Instantly share code, notes, and snippets.

Denis Papathanasiou dpapathanasiou

Block or report user

Report or block dpapathanasiou

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@dpapathanasiou
dpapathanasiou / SchemaSpy-HOWTO.md
Last active May 15, 2020
How to use SchemaSpy to generate the db schema diagram for a PostgreSQL database
View SchemaSpy-HOWTO.md

SchemaSpy is a neat tool to produce visual diagrams for most relational databases.

Here's how to use it to generate schema relationship diagrams for PostgreSQL databases:

  1. Download the jar file from here (the current version is v6.1.0)

  2. Get the PostgreSQL JDBC driver (unless your installed version of java is really old, use the latest JDBC4 jar file)

  3. Run the command against an existing database. For most databases, the schema (-s option) we are interested in is the public one:

@dpapathanasiou
dpapathanasiou / .bash_aliases
Created Mar 15, 2020
Scripting the pdftk-java jar to work like the pdftk binary
View .bash_aliases
alias pdftk='$HOME/.pdftk.sh'
@dpapathanasiou
dpapathanasiou / dst.py
Created Aug 16, 2014
How to tell if Daylight Savings Time is in effect using Python
View dst.py
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'))
View breadth_first_search.py
#!/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/
View depth_first_search.py
#!/usr/bin/env python
"""
An iterative implementation of depth-first search from:
"Python Algorithms: Mastering Basic Algorithms in the Python Language"
by Magnus Lie Hetland
ISBN: 9781484200551
View sliding_window.py
#!/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
@dpapathanasiou
dpapathanasiou / bellman_ford.py
Created Apr 20, 2019
Bellman Ford Algorithm
View bellman_ford.py
#!/usr/bin/env python
"""
An implementation of the Bellman-Form algorithm from:
"Python Algorithms: Mastering Basic Algorithms in the Python Language"
by Magnus Lie Hetland
ISBN: 9781484200551
@dpapathanasiou
dpapathanasiou / breadth_first_search.py
Created Apr 2, 2019
Breadth-First Search in Python
View breadth_first_search.py
#!/usr/bin/env python
"""
A breadth-first search implementation from:
"Python Algorithms: Mastering Basic Algorithms in the Python Language"
by Magnus Lie Hetland
ISBN: 9781484200551
@dpapathanasiou
dpapathanasiou / binary_search_tree.py
Last active Mar 31, 2019
Binary Search Tree in Python
View binary_search_tree.py
#!/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
View quicksort.py
#!/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):
You can’t perform that action at this time.