Skip to content

Instantly share code, notes, and snippets.

View bagrow's full-sized avatar

Jim Bagrow bagrow

View GitHub Profile
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# letter_subplots.py
# Jim Bagrow
# Last Modified: 2021-05-07
import numpy as np
import matplotlib.pyplot as plt
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss1full.xsl"?>
<?xml-stylesheet type="text/css" media="screen" href="http://feeds.nature.com/~d/styles/itemcontent.css"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:prism="http://prismstandard.org/namespaces/basic/2.0/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns="http://purl.org/rss/1.0/" xmlns:admin="http://webns.net/mvcb/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">
<channel rdf:about="http://feeds.nature.com/nature/rss/current">
<title>Nature - Issue - nature.com science feeds</title>
<description>Nature is the international weekly journal of science: a magazine style journal that publishes full-length research papers in all disciplines of science, as well as News and Views, reviews, news, features, commentaries, web focuses and more, covering all branches of science and how science i
@bagrow
bagrow / method_chaining.py
Last active August 3, 2023 16:21
A small example of method chaining/cascading in Python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# method_chaining.py
# Jim Bagrow
# Last Modified: 2016-12-05
"""
Method chaining (or cascading) is a technique for making many calls to an
object with less code. Each method should return a reference to the object
#!/usr/bin/env python
# color_stuff.py
# Jim Bagrow
# Last Modified: 2016-12-01
import colorsys
def distinguishable_colors(num, sat=1.0, val=1.0):
"""Generate a list of `num' rgb hexadecimal color strings. The strings are
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# exhaustive_search_linearRegression.py
# Jim Bagrow
# Last Modified: 2015-10-05
import sys, os
import numpy as np
import scipy, scipy.stats
@bagrow
bagrow / annotate_with_graphlayout.py
Created December 10, 2015 13:42
Improve the placement of labels on a busy scatterplot
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# annotate_with_graphlayout.py
# Jim Bagrow
# Last Modified: 2015-12-09
"""
Rough improvement of scatter point label placement using
force-directed graph layout.
@bagrow
bagrow / extract_backbone.py
Created April 22, 2014 14:33
Extract the multiscale backbone of a weighted complex network
#!/usr/bin/env python
# extract_backbone.py
# Jim Bagrow
# Last Modified: 2010-11-18
import sys, os
import networkx as nx
#!/usr/bin/env python
# weather
# Jim Bagrow
# Last Modified: 2014-01-01
"""
This script requires:
1. a weather underground API key
@bagrow
bagrow / weighted_choice.py
Created November 7, 2012 00:23
Sample non-uniformly from a set of choices
#!/usr/bin/env python
# weighted_choice.py
# Jim Bagrow
# Last Modified: 2012-11-06
import random, bisect
import pylab
def weighted_choice(choices, num_draws=1):
@bagrow
bagrow / mutateyoutube.js
Created April 29, 2012 21:08
bookmarklet to reload youtube video at full browser width
javascript:
var youtubeid = getQueryVariable("v");
if (youtubeid != undefined){
window.location="http://youtube.googleapis.com/v/"+youtubeid+"&autoplay=1";
}
function getQueryVariable(variable) {
/* courtesy: http://stackoverflow.com/a/1623707 */
var query = window.location.search.substring(1);
var vars = query.split("&");