Skip to content

Instantly share code, notes, and snippets.

View gavinmh's full-sized avatar

Gavin Hackeling gavinmh

View GitHub Profile
@gavinmh
gavinmh / example.ipynb
Created August 14, 2020 16:31
example.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file has been truncated, but you can view the full file.
<html><head><meta charset="utf-8" /></head><body><script type="text/javascript">window.PlotlyConfig = {MathJaxConfig: 'local'};</script><script type="text/javascript">/**
* plotly.js v1.43.1
* Copyright 2012-2018, Plotly, Inc.
* All rights reserved.
* Licensed under the MIT license
*/
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).Plotly=t()}}(function(){return function(){return function t(e,r,n){function i(o,s){if(!r[o]){if(!e[o]){var l="function"==typeof require&&require;if(!s&&l)return l(o,!0);if(a)return a(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var u=r[o]={exports:{}};e[o][0].call(u.exports,function(t){return i(e[o][1][t]||t)},u,u.exports,t,e,r,n)}return r[o].exports}for(var a="function"==typeof require&&require,o=0;o<n.length;o++)i(n[o]);return i}}()({
@gavinmh
gavinmh / socks_proxy.sh
Created February 23, 2018 01:42
SOCKS Proxy
ssh -D 1337 -f -C -q -N user@remote -p 22
@gavinmh
gavinmh / psql.md
Created September 5, 2017 02:47 — forked from cimmanon/psql.md
PostgreSQL cheat sheet for MySQL users

I use PostgreSQL via the psql client. If you use a different client (eg. pgAdmin, etc.), I don't know how much will translate over.

One nice difference between psql and mysql (cli) is that if you press CTRL+C, it won't exit the client.

User administration

Login as superuser (via shell)

psql -U postgres
@gavinmh
gavinmh / pil_to_numpy.py
Created July 18, 2017 00:23
PIL to NumPy to PIL
import numpy
import PIL
# Convert Image to array
img = PIL.Image.open("foo.jpg").convert("L")
arr = numpy.array(img)
# Convert array to Image
img = PIL.Image.fromarray(arr)
@gavinmh
gavinmh / download_img.py
Created July 18, 2017 00:15
Download image into buffer
import requests
from PIL import Image
from StringIO import StringIO
r = requests.get('https://example.com/image.jpg')
i = Image.open(StringIO(r.content))
import csv
lines = set()
outfile = open('Train.csv.cr.dedupe', 'wb')
outwriter = csv.writer(outfile, delimiter=',', quotechar='"', quoting=csv.QUOTE_ALL)
counter = 0
with open('Train.csv.CR_cleaned', 'rb') as csvfile:
reader = csv.reader(csvfile, delimiter=',', quotechar='"', skipinitialspace=True)
header = reader.next()
outwriter.writerow(header)
#header {
position: fixed;
}
#TOC {
position: fixed;
margin-top: 100px;
overflow-y: scroll;
height: 80%;
}

Training Data

1 | kmeans process that
3 | the cat
2 | the nexus process that
1 | kmeans that
1 | kmeans process
2 | nexus process
2 | that nexus

3 | cat kmeans the

@gavinmh
gavinmh / cassandra-notes.md
Last active July 1, 2024 18:25
Cassandra Notes

Cassandra Notes

Introduction

Apache Cassandra is an open source, distributed database management system. Cassandra is designed to handle large amounts of data across many commodity servers. Cassandra uses a query language named CQL.

Cassandra's data model is a partitioned row store; Cassandra combines elements of key-value stores and tabular/columnar databases. Like a relational database, Cassandra stores data in tables, called column families, that have defined columns and associated data types. Each row in a column family is uniquely identified by a key. Each row has multiple columns, each of which has a timestamp, name, and value. Unlike a relational database, each row in a column family does not need to have the same set of columns. At any time, a column may be added to one or more rows. If this explanation is unclear, you might think of column families instead as sets of key-value pairs, in which the values are nested sets of key-value pairs.

The following depicts two rows of a column-family fro