Skip to content

Instantly share code, notes, and snippets.

View ryanjdillon's full-sized avatar
👨‍🚀

Ryan J. Dillon ryanjdillon

👨‍🚀
View GitHub Profile
@phobson
phobson / process_cursor.py
Created July 5, 2012 23:34
Process a pyodbc database cursor into a numpy record array or pandas dataframe
import pyodbc
import numpy as np
import datetime
import pandas
def processCursor(cur, dataframe=False):
datatypes = []
colinfo = cur.description
for col in colinfo:
if col[1] == unicode:
import numpy as np
class ConfusionMatrix:
"""
Simple confusion matrix class
row is the true class, column is the predicted class
"""
def __init__(self, n_classes, class_names=None):
self.n_classes = n_classes
if class_names is None:
self.class_names = map(str, range(n_classes))
@BigglesZX
BigglesZX / Dreamhost.Python.installation.textile
Created January 14, 2012 10:49
Installing a custom version of Python on Dreamhost

Dreamhost supplies a fairly old version of Python in their shared hosting environments. It recently became necessary for me to use a newer version, and since this involved a bit of juggling, and since I’m also likely to forget how I did it, I thought I’d detail the steps here. These instructions should work with any Dreamhost shared hosting user, but follow them at your own risk.

The end result of this process is being able to run a current version of Python from your shared hosting user’s shell. It requires compiling, installing and running Python from your home directory rather than the system bin directories.

1. Create a helpful working directory
I chose to install all Python-related stuff in a python/ directory under my user’s home directory.

$ mkdir ~/python
$ cd ~/python
@zed
zed / .gitignore
Created September 22, 2011 18:14
Build 1d array of unknown size in Cython
/build/
*.so
*.cpp
/cachegrind.out.profilestats
/profilestats.prof
/build1darray.s
@bsamuel-ui
bsamuel-ui / serverless-deploy-user.yaml
Last active June 5, 2019 17:20
Cloudformation template to deploy permissions for deploying a serverless project.
AWSTemplateFormatVersion: 2010-09-09
Description: >
Constructs a managed IAM policy to deploy a serverless project.
This template assumes the stack is being deployed in the current region and account.
You can then attach this policy to other IAM objects, such as users or roles.
Based on the work done in: https://github.com/serverless/serverless/issues/1439
@maptastik
maptastik / MultipleGeometryGDF.ipynb
Created April 3, 2019 02:25
Creating and working with multiple geometry columns in a single GeoDataFrame
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@saghul
saghul / pyqt_opencv.py
Created June 29, 2011 22:22
Render OpenCV video on a PyQt widget
# coding=utf8
# Copyright (C) 2011 Saúl Ibarra Corretgé <saghul@gmail.com>
#
# Some inspiration taken from: http://www.morethantechnical.com/2009/03/05/qt-opencv-combined-for-face-detecting-qwidgets/
import cv
import sys
@svrist
svrist / cf_create_or_update.py
Created February 7, 2017 21:34
Update or create a CloudFormation stack given a name and template + params'
'Update or create a stack given a name and template + params'
from __future__ import division, print_function, unicode_literals
from datetime import datetime
import logging
import json
import sys
import boto3
import botocore
@Luzifer
Luzifer / README.md
Last active November 18, 2023 17:22
Running docker-compose as a systemd service

Running docker-compose as a systemd service

Files

File Purpose
/etc/compose/docker-compose.yml Compose file describing what to deploy
/etc/systemd/system/docker-compose-reload.service Executing unit to trigger reload on docker-compose.service
/etc/systemd/system/docker-compose-reload.timer Timer unit to plan the reloads
/etc/systemd/system/docker-compose.service Service unit to start and manage docker compose
@huytd
huytd / .gitconfig
Created August 4, 2016 16:26
Use neovim as diff tool
[merge]
tool = vimdiff
[mergetool]
prompt = true
[mergetool "vimdiff"]
cmd = nvim -d $LOCAL $REMOTE $MERGED -c '$wincmd w' -c 'wincmd J'
[difftool]
prompt = false
[diff]
tool = vimdiff