Skip to content

Instantly share code, notes, and snippets.

View bede's full-sized avatar

Bede Constantinides bede

View GitHub Profile
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active June 5, 2024 22:16
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@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):
@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
@davfre
davfre / bamfilter_oneliners.md
Last active February 24, 2024 01:23
SAM and BAM filtering oneliners
@DanHerbert
DanHerbert / fix-homebrew-npm.md
Last active June 4, 2024 04:16
Instructions on how to fix npm if you've installed Node through Homebrew on Mac OS X or Linuxbrew

OBSOLETE

This entire guide is based on an old version of Homebrew/Node and no longer applies. It was only ever intended to fix a specific error message which has since been fixed. I've kept it here for historical purposes, but it should no longer be used. Homebrew maintainers have fixed things and the options mentioned don't exist and won't work.

I still believe it is better to manually install npm separately since having a generic package manager maintain another package manager is a bad idea, but the instructions below don't explain how to do that.

Fixing npm On Mac OS X for Homebrew Users

Installing node through Homebrew can cause problems with npm for globally installed packages. To fix it quickly, use the solution below. An explanation is also included at the end of this document.

@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
@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
@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
@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