Skip to content

Instantly share code, notes, and snippets.

@dpapathanasiou
dpapathanasiou / SchemaSpy-HOWTO.md
Last active June 3, 2026 09:17
How to use SchemaSpy to generate the db schema diagram for a PostgreSQL database

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 / dst.py
Created August 16, 2014 15:42
How to tell if Daylight Savings Time is in effect using Python
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'))
@dpapathanasiou
dpapathanasiou / julia_plus_jupyter.md
Created March 7, 2026 16:20
No fuss Julia and Jupyter Notebook setup on macOS and linux

No fuss Julia and Jupyter Notebook setup on macOS and linux

After installing julia (using the standard curl ... | sh approach), this one-liner does all the project dependency installs, given the existence of a Project.toml file at .:

julia --project=. -e "using Pkg; Pkg.instantiate()"

Then, this one-liner runs jupyter within a new conda environment, which is completely self-contained within julia (i.e., no need to install conda first and create a new environment for this project):

@dpapathanasiou
dpapathanasiou / MatrixDSL.scala
Created July 26, 2015 23:54
DSL processing in Scala
/* This is a scala solution for a mini domain specific language (DSL)
* defining instructions for populating an empty matrix.
*
* Input consists of a single string separated by spaces:
* - the first number represents the size of the matrix, NxN
* - the rest of the input consists of one or more strings defining
* the range of cells and how each of their populations will be
* incremented
*
* Increment pattern possibilities:
@dpapathanasiou
dpapathanasiou / RidePATH.md
Created January 18, 2025 21:21
This is a simple way of using the real time json format feed from the Port Authority Trans-Hudson (PATH) rail system to get a list of when the next trains are arriving per station.

This is a simple way of using the real time json format feed from the Port Authority Trans-Hudson (PATH) rail system to get a list of when the next trains are arriving per station.

This gist uses both curl and jq, which are typically pre-installed on most computers.

curl -s https://www.panynj.gov/bin/portauthority/ridepath.json | \
jq -r \
--arg STATION "HOB" \
'.results[] | select (.consideredStation == $STATION) | .destinations[] | .messages[] | (.arrivalTimeMessage | (" " * (8 - length)) +.)  + " => " + .headSign' 
@dpapathanasiou
dpapathanasiou / HOWTO.md
Created November 4, 2018 15:53
How to connect to a USB Armory via ssh on linux

Based on the Host communication instructions, but with a tweak for when the usb0 address is not found:

$ /sbin/ip link set usb0 up
Cannot find device "usb0"

Because of the predictable network interface name scheme, though, usb0 may be renamed to something else:

@dpapathanasiou
dpapathanasiou / breadth_first_search.py
Created April 2, 2019 23:13
Breadth-First Search in Python
#!/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 / gist:4329613
Created December 18, 2012 16:47
Simple Social Media "Share" Buttons
<div><!-- social media share buttons -->
<a href="http://www.facebook.com/" onclick="window.location = 'http://www.facebook.com/share.php?u=' + encodeURIComponent(window.location); return false"><img src="http://i.imgur.com/aLnZg.png" alt="Share on Facebook" border="0" /></a>
<a href="http://twitter.com/" onclick="window.location = 'http://twitter.com/home/?status=' + encodeURIComponent(window.location); return false"><img src="http://i.imgur.com/oFrLG.png" alt="Tweet This" border="0" /></a>
<a href="http://www.linkedin.com/" onclick="window.location = 'http://www.linkedin.com/shareArticle?mini=true&url=' + encodeURIComponent(window.location); return false"><img src="http://i.imgur.com/mwHNU.png" alt="Share on LinkedIn" border="0" /></a>
<a href="https://plus.google.com/" onclick="window.location = 'https://plus.google.com/share?url=' + encodeURIComponent(window.location); return false"><img src="http://i.imgur.com/tzMMp.png" alt="Share on Google+" border="0" /></a>
@dpapathanasiou
dpapathanasiou / RaspberryPi_A_Plus_Wifi.md
Created January 10, 2015 19:49
How to setup a usb wifi dongle on the Raspberry Pi Model A+

Rationale

The Raspberry Pi Model A+ has just a single usb port, so getting the wifi configured has to done by editing /etc/network/interfaces from a command line prompt.

These instructions assume the Raspbian OS on the SD card, and a usb wifi adapter that supports the RTL8192cu chipset, since the current Raspbian has built-in support for it.

Before the first boot

  1. Put a keyboard in the usb slot
  2. Connect the HDMI slot to a monitor
@dpapathanasiou
dpapathanasiou / ComodoSSL_HOWTO.md
Last active March 11, 2023 12:15
Installing Comodo SSL Certificates

Create the Certificate Signing Request (CSR) file

openssl req -nodes -newkey rsa:4096 -keyout example_com.key -out example_com.csr

Prepare the Bundle file

Unzip the file Comodo sends back and create a single certificate bundle file.