Skip to content

Instantly share code, notes, and snippets.

View Zsailer's full-sized avatar

Zachary Sailer Zsailer

View GitHub Profile
@Zsailer
Zsailer / README.md
Last active May 27, 2016 00:22
Resample the output a function until the value convergences to given tolerance

Resample function until convergence

Python function that will rerun a function until its output convergences. The output must be numerical values. It can been an int, float, list, or array. Requires numpy.

This method runs the function in chunks (N=sample_size). It calculates the mean and standard deviation of the total set of samples after each chunk. If the mean and standard deviation of the total set is relatively close (see rtol) the last iteration, the sampling is assumed to have converged.

@Zsailer
Zsailer / draw_networkx_nodes_ellipses.py
Last active July 27, 2020 14:52
Drawing NetworkX plots with ellipses for nodes
import networkx as nx
def draw_networkx_nodes_ellipses(G, pos,
nodelist=None,
node_height=1,
node_width=2,
node_angle=0,
node_color='r',
node_shape='o',
alpha=1.0,
@Zsailer
Zsailer / prettify.py
Last active February 20, 2018 19:58
Make matplotlib plots pretty and standard
import matplotlib
def prettify(ax, legend_loc=4):
""" A simple wrapper to make matplotlib figures prettier."""
# Change default colors to something softer.
colors = {
'b': '#0066CC',
'r': '#CC0000',
'm': '#660066',
@Zsailer
Zsailer / template.tex
Last active November 19, 2015 00:44
Latex template for mathy paper supplement documents
%% Document type
\documentclass[12pt]{article}
%% Start of preamble
\usepackage{amsmath} % Advanced math extension
\usepackage{amssymb} % Advanced math symbols
\usepackage{array} % Advanced tables
%\usepackage{bm} % Allows bold greek letters in math mode
%\usepackage{caption} % Allows customization of caption appearance
\usepackage[margin=1in]{geometry} % Management of document margins and size
@Zsailer
Zsailer / data.js
Last active August 29, 2015 14:27
metadata
// Metadata for networks and trajectories from the following paper:
// "Darwinian Evolution Can Follow Only Very Few Mutational Paths to Fitter Proteins"
// Weinreich, D., et.al
// http://www.sciencemag.org/content/312/5770/111.short
{
"directed": true,
"nodes": [
{
"value": 1.0152510120727598,

Tasks for the day

  1. Read the introduction to D3.js here.
  2. Work through these tutorials:

Try to implement these bar charts directly in the d3app boilerplate code you've been using. Download a fresh project if you need here 3. Read about D3 transitions here.

Creating an open source D3-Backbone app on Github

Github is where you'll host all your projects publically. It's the platform we'll use to write and share applications, and it allows us to work on these projects in parallel. It will make it easier for me to help you, since all your code is availabe for me to oversee online.

Getting started.

Navigate to the directory where you'd like to keep all your projects. The commands below will download the boilerplate code and prepare it for development. Anytime you see <project_name>, replace it with whatever name you're like to give the project (no spaces!).

git clone https://github.com/Zsailer/d3app 
@Zsailer
Zsailer / reveal_problem_nb.ipynb
Last active August 29, 2015 14:13
Example notebook that caused problems in live reveal of Jupyter Notebook
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Zsailer
Zsailer / webservicedoc.md
Last active December 18, 2015 10:18
IPython's new web-service documentation

IPython Web Services

This documentation describes the current API for IPython Notebook's web-services. In handling HTTP request, we pass all information between the server and client using JSON standard models. Each standard model is shown at the beginning of the sections below. This format adheres to the principles described in RESTful web-services.

  • Notebooks
    • List notebooks in root directory
    • Create new notebook
    • List notebooks in named directory
    • Open the named noteboko in subdirectory
    • Change notebook's standard model and save modified notebook
    • Delete a notebook in subdirectory
@Zsailer
Zsailer / notebooks.py
Created April 11, 2013 23:28
List of dicts returned in IPython's multi-directory webservice ~ "/notebooks/foo/bar"
{ "path": "foo/bar",
"notebooks":[{{"kernel_id":"###","name":"Notebook1","notebook_id":"###"}},{...}],
"directories": ["sub-directory1", "sub-directory2", ...],
"files":["file1","file2",...]
}