Skip to content

Instantly share code, notes, and snippets.

Avatar

Douglas Russell dpwrussell

  • MathWorks
  • Cambridge, UK
View GitHub Profile
@dpwrussell
dpwrussell / lda.sh
Created Nov 30, 2012
ldap experiment to determine how to query LDAP without basing with an OU
View lda.sh
#!/bin/bash
(
set -e
set -u
export CLASSPATH=.:`echo lib/server/*.jar | sed 's/ /:/g'`
cat > ldap.xml <<EOF
View omero_stats.py
#!/usr/bin/env python
import psycopg2
import datetime
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
import matplotlib.cbook as cbook
conn = psycopg2.connect("dbname=omerodb user=omerouser host=localhost")
@dpwrussell
dpwrussell / dict_of_dict.py
Last active Dec 24, 2015
Dictionary of Dictionaries, for Tara.
View dict_of_dict.py
dict1 = {'data1':'Lorem', 'data2':'ipsum', 'data3':'dolor'}
dict2 = {'data1':'sit', 'data2':'amet', 'data3':'consectetur'}
dict3 = {'data1':'adipisicing', 'data2':'elit', 'data3':'sed'}
#Basically just offically names each dictionary to the same as it's variable name,
dict_of_dict = {'dict1':dict1, 'dict2':dict2,'dict3':dict3}
# To find 'dict1_data2'
thing_to_find = 'dict1_data2'
@dpwrussell
dpwrussell / fast_lookup_filter.py
Created Oct 7, 2013
Fast lookup index which writes lines to a file if they have a matching id in the index. For Tara.
View fast_lookup_filter.py
test = set([])
keep = 'keep.txt'
all = 'input.txt'
out = 'output.txt'
outputfile = open(out, 'w')
with open(keep, 'rb') as file:
for line in file:
View bash_prompt.sh
#!/bin/bash
#
# DESCRIPTION:
#
# Set the bash prompt according to:
# * the active virtualenv
# * the branch/status of the current git repository
# * the return value of the previous command
# * the fact you just came from Windows and are used to having newlines in
# your prompts.
@dpwrussell
dpwrussell / web-dev-runserver
Created Nov 10, 2013
omero-web-dev scripts. To setup and run django dev server in the OMERO environment.
View web-dev-runserver
#!/bin/bash
export OMERO_PREFIX=~/Checkouts/openmicroscopy/dist # Example server build path
# Make sure the Django code etc can be imported
#export PYTHONPATH=$OMERO_PREFIX/lib/python/
cd $OMERO_PREFIX
# need to remove the built omeroweb code so it doesn't get imported
rm -rf lib/python/omeroweb/
@dpwrussell
dpwrussell / ice01.make
Last active Dec 28, 2015
Homebrew ice 3.5 with xcode tools and homebrew python 2.7
View ice01.make
dpwrussell@bioch3117 ~
$ cat /Users/dpwrussell/Library/Logs/Homebrew/ice/01.make
making all in config
echo ""
making all in src
making all in IceUtil
making all in ca
cp iceca ../../bin/iceca
cp ImportKey.class ../../lib/ImportKey.class
@dpwrussell
dpwrussell / test1.py
Last active Dec 28, 2015
Demonstration of method_decorator failure
View test1.py
from functools import update_wrapper
from django.utils.decorators import method_decorator
class MyDecorator(object):
def __init__(self):
print 'MyDecorator init'
def __call__(self, f):
print 'MyDecorator call'
@dpwrussell
dpwrussell / .gitignore
Last active Dec 29, 2015
Python sendmail
View .gitignore
email_details.cfg
@dpwrussell
dpwrussell / .gitignore
Last active Dec 29, 2015
OMERO basic setup for quick tests
View .gitignore
omero_details.cfg
*.pyc