Skip to content

Instantly share code, notes, and snippets.

View dpwrussell's full-sized avatar

Douglas Russell dpwrussell

View GitHub Profile
@dpwrussell
dpwrussell / json_encode_set.py
Last active August 29, 2015 13:58
Encode Set into JSON
from json import JSONEncoder
class JSONSetEncoder(JSONEncoder):
def default(self, obj):
if isinstance(obj, set):
return list(obj)
return JSONEncoder.default(self, obj)
json.dumps(thing_to_encode, cls=JSONSetEncoder)
@dpwrussell
dpwrussell / btrfs-snapshot
Created April 9, 2014 12:25
BTRFS Snapshot
#!/bin/bash
set -e
if grep -qs '/media/btrfs-root' /proc/mounts; then
echo "It's mounted"
else
mount /media/btrfs-root
fi
cd /media/btrfs-root
@dpwrussell
dpwrussell / cohort_intersection.py
Last active August 29, 2015 13:59
Calculate intersection of variants
# Copyright 2014 Douglas Russell
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@dpwrussell
dpwrussell / hyperselect.html
Created April 16, 2014 11:05
Smart selector for hyperlinks based on url
<script type="text/javascript">
$(document).ready(function()
{
$('#webadmin_main_tabs a[href*="' + location.pathname.split("/")[2] + '"]').addClass('selected_admin_tab');
});
</script>
@dpwrussell
dpwrussell / snoopy_submodules
Created May 7, 2014 14:11
snoopy submodules
#wmoore@jabber.lifesci.dundee.ac.uk
#What I do...
brew install hub
git submodule foreach hub remote add snoopycrimecop
git submodule foreach git fetch snoopycrimecop
Then each time I want to build….
git fetch snoopycrimecop
git checkout develop-latest
git reset --hard snoopycrimecop/merge/develop/latest
git submodule foreach hub remote update snoopycrimecop
@dpwrussell
dpwrussell / preexec.bash
Created May 28, 2014 09:12
preexec hook in bash
#!/bin/bash
# Courtesy of http://hints.macworld.com/dlfiles/preexec.bash.txt
# preexec.bash -- Bash support for ZSH-like 'preexec' and 'precmd' functions.
# The 'preexec' function is executed before each interactive command is
# executed, with the interactive command as its argument. The 'precmd'
# function is executed before each prompt is displayed.
@dpwrussell
dpwrussell / views.py
Created July 3, 2014 18:54
Calculate the tree of objects that will chgrp and any other objects which might be affected by this change
def getAllObjects(conn, project_ids, dataset_ids, image_ids, screen_ids,
plate_ids):
"""
Given a list of containers and images, calculate all the descendants
and necessary siblings (for any filesets)
"""
#TODO Handle None inputs, maybe add defaults
params = omero.sys.ParametersI()
# params.addId(experimenter_id)
qs = conn.getQueryService()
@dpwrussell
dpwrussell / test_graph_ops.py
Last active August 29, 2015 14:03
Working graph test
from omero.gateway import BlitzGateway
from omero.sys import Parameters, ParametersI
from omero.model import *
from omero.rtypes import *
from omero import ValidationException
import ConfigParser
from omero.model import ExperimenterI, ProjectI, DatasetI, ImageI, \
ScreenI, PlateI, \
ProjectDatasetLinkI, DatasetImageLinkI, \
@dpwrussell
dpwrussell / test_show.py
Created July 29, 2014 09:34
Broken Multiple Link
@pytest.fixture(scope='function')
def project_broken_multi(conn, request, itest, update_service):
# Create a project and dataset and link them
project1 = ProjectI()
project1.name = rstring(itest.uuid())
dataset1 = DatasetI()
dataset1.name = rstring(itest.uuid())
project1.linkDataset(dataset1)
@dpwrussell
dpwrussell / pytest_tree.py
Created September 10, 2014 13:51
pytest_tree.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (C) 2014 Glencoe Software, Inc.
# All rights reserved.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.