Skip to content

Instantly share code, notes, and snippets.

View bede's full-sized avatar

Bede Constantinides bede

View GitHub Profile
@GarrettS
GarrettS / usurp-tco.js
Created January 29, 2012 18:58
UsurpTCO
javascript: void(function(){document.addEventListener("mousedown", tcoToLinkTitleURL, true); function tcoToLinkTitleURL(ev) { var target = ev.target; if(/^http(?:s?):\/\/t.co\//.test(target.href)) target.href=target.title; } }());
@jxnblk
jxnblk / mnml.html
Created August 5, 2013 21:05
HTML5 Boilerplate
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
<meta name="author" content="">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" href="/favicon.png" />
<link rel="apple-touch-icon-precomposed" href="/apple-touch-icon.png" />
@rgbkrk
rgbkrk / pyscratch.bash
Last active December 22, 2015 18:09
Python scientific tools from scratch on a mac
# This was the order I installed things for a working scientific computing environment on my Mac.
brew install python
pip install virtualenv virtualenvwrapper
# Also add these to your ~/.bash_profile:
export PATH=/usr/local/bin:/usr/bin:$PATH
source /usr/local/bin/virtualenvwrapper.sh
# Not necessary, but quite nice
@landau
landau / tree.py
Created June 28, 2013 14:33
Lowest Common Ancestor in Python
class Node(object):
def __init__(self, val):
self.val = val
self.left = None
self.right = None
def __lt__(self, val):
return self.val < val
def __gt__(self, val):
@bede
bede / ebi_restful_blast
Last active September 8, 2016 10:13
Serial BLASTing of multifasta sequences using Python3 and EBI's REST API
#!/usr/bin/env python3
import io
import sys
import time
import datetime
import requests
from Bio import SeqIO
@teoliphant
teoliphant / rolling.py
Last active October 23, 2019 19:54
Create a function to make a "sliding_window" output array from an input array and a rolling_window size.
import numpy as np
def array_for_sliding_window(x, wshape):
"""Build a sliding-window representation of x.
The last dimension(s) of the output array contain the data of
the specific window. The number of dimensions in the output is
twice that of the input.
Parameters
@danielecook
danielecook / depth_of_coverage.py
Last active March 29, 2021 14:47
Calculate Depth of Coverage and Breadth of Coverage from a bam file. This function calculates by chromsome and for the entire genome. Additionally, if the mtchr (Mitochondrial chromosome name) is provided, nuclear coverage and the ratio of mtDNA:nuclear DNA is calculated. #bam #stats
#
# This script calculates the depth of coverage and breadth of coverage for a given bam.
# Outputs a dictionary containing the contig/chromosome names and the depth and breadth of coverage for each
# and for the entire genome.
#
# If you optionally specify the name of the mitochondrial chromosome (e.g. mtDNA, chrM, chrMT)
# The script will also generate breadth and depth of coverage for the nuclear genome AND the ratio
# of mtDNA:nuclearDNA; which can act as a proxy in some cases for mitochondrial count within an individual.
#
# Author: Daniel E. Cook
@carlsmith
carlsmith / replace.py
Created April 5, 2017 02:08
A Python function that does multiple string replace ops in a single pass.
import re
def replace(string, substitutions):
substrings = sorted(substitutions, key=len, reverse=True)
regex = re.compile('|'.join(map(re.escape, substrings)))
return regex.sub(lambda match: substitutions[match.group(0)], string)
@rmcelreath
rmcelreath / garden plots.R
Created November 4, 2016 09:34
Code for drawing the forking data gardens in Chapter 2 of "Statistical Rethinking" textbook
# functions for plotting garden of forking data plots
library(rethinking)
polar2screen <- function( dist, origin, theta ) {
## takes dist, angle and origin and returns x and y of destination point
vx <- cos(theta) * dist;
vy <- sin(theta) * dist;
c( origin[1]+vx , origin[2]+vy );
}
@xenophonf
xenophonf / ubuntu-14.04.3-macbookpro8,2-openzfs-luks-refind.md
Last active February 20, 2023 23:31
Dual-boot Mac OS X (FileVault2) and Ubuntu (OpenZFS/LUKS)

Dual-boot Mac OS X (FileVault2) and Ubuntu (OpenZFS/LUKS)

This procedure results in a computer that runs both Mac OS X and Ubuntu in a dual-boot configuration, each operating system using full (whole) disk encryption, and with the Ubuntu root file system stored on a ZFS pool encrypted using LUKS. The specific hardware and software versions used to document this procedure are:

  • MacBookPro8,2