Skip to content

Instantly share code, notes, and snippets.

View gavinrozzi's full-sized avatar

Gavin Rozzi gavinrozzi

View GitHub Profile
import numpy as np
from numpy.linalg import norm
class Kmeans:
'''Implementing Kmeans algorithm.'''
def __init__(self, n_clusters, max_iter=100, random_state=123):
self.n_clusters = n_clusters
self.max_iter = max_iter
@Kartones
Kartones / postgres-cheatsheet.md
Last active July 18, 2024 21:39
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@johnjreiser
johnjreiser / DownloadExtractParcels.py
Last active January 24, 2022 18:46
Script to download the GIS parcel and MOD-IV tax assessor databases from NJGIN, the State of New Jersey's online data and metadata repository. Essex and Middlesex are currently in "draft" form and are available through a separate download on NJGIN.
import urllib, os, sys, zipfile
def download(url,name=""):
if(name == ""):
name = url.split('/')[-1]
webFile = urllib.urlopen(url)
localFile = open(name, 'w')
fname = localFile.name
localFile.write(webFile.read())
webFile.close()
@ttscoff
ttscoff / rtftomarkdown.rb
Created October 9, 2012 21:05
Convert RTF/DOC files to Markdown via Textutil
#!/usr/bin/ruby
=begin
Usage: rtftomarkdown.rb FILENAME.rtf
Uses textutil, available on Mac only (installed by default)
Outputs to STDOUT
Notes:
Links are replaced with Markdown references (duplicate links combined).