Skip to content

Instantly share code, notes, and snippets.

@jakevdp
jakevdp / discrete_cmap.py
Last active March 8, 2024 14:54
Small utility to create a discrete matplotlib colormap
# By Jake VanderPlas
# License: BSD-style
import matplotlib.pyplot as plt
import numpy as np
def discrete_cmap(N, base_cmap=None):
"""Create an N-bin discrete colormap from the specified input map"""
@johndobrien
johndobrien / gist:3101086
Created July 12, 2012 21:21
Using copy_expert to copy rows to a different database
import psycopg2
from psycopg2.extensions import ISOLATION_LEVEL_SERIALIZABLE
conn_str = "dbname='{db}' user='john' host='localhost' password='john'"
table_sql = "CREATE TABLE bigdata (A INT PRIMARY KEY, b TEXT, c TEXT NOT NULL);"
conn1 = psycopg2.connect(conn_str.format(db='test-1'))
conn2 = psycopg2.connect(conn_str.format(db='test-2'))