Skip to content

Instantly share code, notes, and snippets.

@cpatrick
cpatrick / vtkweb_ray_cast.py
Created August 21, 2013 18:22
VTK Web Ray Cast Try
r"""
This module is a VTK Web server application.
The following command line illustrate how to use it::
$ vtkpython .../vtk_web_cone.py
Any VTK Web executable script come with a set of standard arguments that
can be overriden if need be::
--port 8080
@cpatrick
cpatrick / runsearch.py
Last active October 3, 2021 15:18
Sample Python for running a full-text search using PyMongo
from pymongo import Connection
if __name__ == '__main__':
# Connect to mongo
conn = Connection()
db = conn['canepi']
# Set the search term
term = 'foo'
@cpatrick
cpatrick / enable_index.js
Last active December 18, 2015 03:29
Enabling Mongo full-text search and building an index.
// enable text search
db.adminCommand( { setParameter : 1, textSearchEnabled : true } )
// build canepi-specific indices
db.healthmap.ensureIndex({"properties.summary": "text",
"properties.descr": "text",
"properties.country": "text",
"properties.disease": "text"},
{ weights: { "properties.summary": 10,
"properties.descr": 5,
"properties.disease": 10,
@cpatrick
cpatrick / folder_upload_test.html
Created March 27, 2013 18:06
Simple test for folder uploading.
<html>
<head>
<title>HTML5 Folder Upload Test</title>
</head>
<body>
<div id="container">
<input type="file" id="file_input" name="file_input_folder[]"
multiple webkitdirectory="" mozdirectory="true" directory="" />
</div>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
@cpatrick
cpatrick / start_boto_env.sh
Created January 17, 2013 06:41
Starting up a virtual env for boto.
$ virtualenv boto-env
$ source boto-env/bin/activate
(boto-env) $ pip install boto
@cpatrick
cpatrick / reserve_server.py
Last active December 11, 2015 05:39
Setting up a basic EC2 Instance with boto
from boto.ec2.connection import EC2Connection
import secretkeys
conn = EC2Connection(secretkeys.AWS_ACCESS_KEY, secretkeys.AWS_SECRET_KEY)
security_description = 'Security rules for external servers'
repo_sg = conn.create_security_group('external-server', security_description)
repo_sg.authorize('tcp', 80, 80, '0.0.0.0/0')
repo_sg.authorize('tcp', 22, 22, '0.0.0.0/0')
repo_sg.authorize('tcp', 443, 443, '0.0.0.0/0')
@cpatrick
cpatrick / experiments.py
Created December 12, 2012 22:36
Script for generating figures and exploring results for the purposes of my Multi-Velocity LDDMM final project for Comp 775 at UNC (Fall 2012).
import sh
import gen
from matplotlib import pyplot as plt
import matplotlib.cm as cm
import numpy as np
import SimpleITK as sitk
import sys
lddmm_command = "/Users/cpatrick/calatk-build/CalaTK-Build/bin/LDDMM"
apply_map_command = "/Users/cpatrick/calatk-build/CalaTK-Build/bin/applyMap"
@cpatrick
cpatrick / Notification.php
Created August 2, 2012 14:36
Annio Notification
<?php
/*=========================================================================
MIDAS Server
Copyright (c) Kitware SAS. 20 rue de la Villette. All rights reserved.
69328 Lyon, FRANCE.
See Copyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
@cpatrick
cpatrick / NBIAError
Created November 24, 2010 15:56
Error when hitting the NBIA web service from cURL
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing"><soapenv:Header><wsa:MessageID soapenv:mustUnderstand="0">uuid:1757bde0-f7e2-11df-9ea4-e19bd0d21422</wsa:MessageID><wsa:Action soapenv:mustUnderstand="0">http://schemas.xmlsoap.org/ws/2004/03/addressing/fault</wsa:Action></soapenv:Header><soapenv:Body><soapenv:Fault><faultcode>soapenv:Server.userException</faultcode><faultstring>org.globus.wsrf.security.SecurityException: [SEC]Operation name could not be determined</faultstring><detail><ns1:stackTrace xmlns:ns1="http://xml.apache.org/axis/">org.globus.wsrf.security.SecurityException: [SEC]Operation name could not be determined
at org.globus.wsrf.impl.security.util.AuthUtil.getOperationName(AuthUtil.java:259)
at org.globus.wsrf.impl.security.authentication.AuthHandler.handle(AuthHandler.java:58)
at org.globus.wsrf.impl.securi