Skip to content

Instantly share code, notes, and snippets.

@keithshep
keithshep / tristate.js
Last active August 29, 2015 14:03
A little javascript class to help out with tri-state checkboxes.
/**
* A little "class" to help out with tri state checkboxes.
*/
function TriStateCheckbox(checkbox) {
var self = this;
var checkedVal = checkbox.prop("checked");
var indeterminatePropName = "indeterminate";
/**
@keithshep
keithshep / cppcheats.cpp
Created September 27, 2014 03:16
c++ cheats
// creating a priority queue with a lambda less operator
auto pt_less = [&mat](const cv::Point& pt1, const cv::Point& pt2) -> bool {
return mat.at<uint8_t>(pt1) < mat.at<uint8_t>(pt2);
};
priority_queue<cv::Point, vector<cv::Point>, decltype(pt_less)> erosion_candidates(pt_less);
@keithshep
keithshep / filedropify.js
Last active August 29, 2015 14:15
some code to simplify file drag-and-drop implementation in JavaScript
/**
* This callback will be called with the file that was dropped.
* @callback dropCallback
* @param file the file object
*/
/**
* Create a file drop area
* @param activeElement
* the element that the user can drop on to trigger a callback
* @param highlightElement
import csv
import requests
def build_ensembl_biomart_dict(dataset_name, key_attr, val_attr):
# see http://ensembl.org/biomart/martview/ for the web application
biomart_request_url_template = \
'''http://ensembl.org/biomart/martservice?query=''' \
'''<?xml version="1.0" encoding="UTF-8"?>''' \
'''<!DOCTYPE Query>''' \
'''<Query virtualSchemaName="default" formatter="CSV" header="0" uniqueRows="0" count="" datasetConfigVersion="0.6">''' \
@keithshep
keithshep / tidyAll.R
Created June 11, 2010 02:12
reformat R source
#!/usr/bin/Rscript
library("animation")
# reformat a directory full of R source files
tidy.all <- function(inDir = NULL, outDir = NULL, ...) {
if (is.null(inDir) || is.na(outDir))
stop("inDir can't be null or NA")
if (!file.info(inDir)$isdir)
stop("inDir must be a directory")
@keithshep
keithshep / strip-N-H-calls.bash
Created June 14, 2010 13:49
strip rows with N or H calls from a dir full of genotype CSV files
#!/bin/bash
echo "input directory: $1"
echo "output directory: $2"
for i in `ls $1` ; do echo "striping N and H calls from: $i" && egrep -v '(,N,)|(,N$)|(,H,)|(,H$)|(,n,)|(,n$)|(,h,)|(,h$)' $1/$i > $2/$i; done
@keithshep
keithshep / svn-tkdiff-modified.pl
Created June 14, 2010 13:47
Scans svn dir for modified files and tkdiffs them
#!/usr/bin/perl
use strict;
use warnings;
my $status_output = `svn status @ARGV`;
my @split_status_lines = split(/\n/, $status_output);
foreach(@split_status_lines)
{
if($_ =~ /^M.{5}\s+(.*)$/)
@keithshep
keithshep / liftover-csv.rb
Created June 14, 2010 13:32
liftover and sort a CSV file
#!/usr/bin/ruby -w
################################################################################
# Created By: Keith Sheppard (keith.sheppard@jax.org)
# Modification History:
# July 7, 2008: Initial revision created to run the liftover utility on
# the CGD (cgd.jax.org) imputed SNP data in comma-separated format
#
# This is a ruby script for running liftover to map SNPs in a source
# comma-separated file to a destination file using a different NCBI genome
@keithshep
keithshep / r-cheats.txt
Created June 14, 2010 19:54
Cheat-sheet for R
# attach and detach a package:
library("MouseDivGeno")
detach(package:MouseDivGeno)
# start in 64 bit mode:
R --arch x86_64
# Stack-trace in R:
traceback()
@keithshep
keithshep / liftover-links.txt
Created June 14, 2010 19:46
links for using liftover