Skip to content

Instantly share code, notes, and snippets.

View briandk's full-sized avatar

Brian A. Danielak briandk

View GitHub Profile
@briandk
briandk / college-majors.ipynb
Created April 17, 2017 22:48
Beginning analysis of 538's college majors data
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@briandk
briandk / create_and_plot_forest.py
Last active April 10, 2017 19:20
Basic plotting and forest creation functions for the forest fire model in CMSE 201 Spring 2017
```python
import matplotlib.pyplot as plt
from matplotlib import colors
import numpy as np
def make_forest( height, width, density ):
'''
This function will take in a width, height, and density specified by the user and use those values
to generate a forest (2-d numpy array) matching those characteristics. A 0 will represent an empty
space, a 1 will represent a tree
@briandk
briandk / generate_package_citations.R
Created April 9, 2017 18:21
Wil Doane's system for automatically generating bibliography entries for the R packages you're using
# Early in the script
pkgs_pre_script <- try(devtools::loaded_packages(), silent = TRUE)
# Late in the script
pkgs_used_during_script <- try(devtools::loaded_packages(), silent = TRUE)
cat("* ")
print(citation(), style="text") # or Bibtex or LaTeX
@briandk
briandk / uninstall-r-on-osx.sh
Created March 27, 2017 14:22
Completely (or as completely as I can) uninstalling R on OS X
sudo rm -rf /Library/Frameworks/R.framework \
/Applications/R.app \
/usr/bin/R /usr/bin/Rscript
pkgutil --regexp --forget org\.r-project*
@briandk
briandk / letsMakeADeal.ipynb
Created February 23, 2017 18:25
Let's make a deal
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@briandk
briandk / installingSeabornOnJupyterhub.py
Created February 21, 2017 19:59
Dirk Colbry's solution for installing Seaborn on JupyterHub
%matplotlib inline
try:
import seaborn as sns
print('seaborn is already installed')
except:
try:
import sys
sys.path
sys.path.insert(0,'./packages')
@briandk
briandk / Day09preclass.ipynb
Created February 7, 2017 05:08
Day 09 pre-class assignment for CMSE 201 Spring 2017
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import pandas as pd
import seaborn as sns
flint_data = pd.DataFrame.from_csv(
'https://raw.githubusercontent.com/ComputationalModeling/intro-to-computational-modeling/master/201-spring-2017/day05-flint-water-data-analysis-day1/flint_data_with_simplified_column_names.csv?token=AAUJNLxtLQZh8meM0qSXyn4U1REp-PLAks5Ym3SjwA%3D%3D'
)
sns.distplot(flint_data['zipCode'])
@briandk
briandk / parsingBibfiles.js
Last active December 19, 2016 18:32
How to handle operations on large arrays in ECMAScript6, say for parsing bibfiles
const parseRecord = function (rawRecord) {
// Parsing logic goes here
}
const fs = require('fs')
const records = fs.readFileSync('myBibfile.bib')
.split('@') // @ is the delimiter in bibfiles
// Array.from() takes an iterable argument *and* a mapping function
// if you want to map elements from the source array
@briandk
briandk / functions-and-function-invocations.md
Last active November 17, 2016 16:51
How I explained to Lauren the difference between a function and its invocation

$$ f(x) = x + 3 $$

y = x + 3

function f turns x into x + 3

we apply function f by saying f(something)

f = function (x) { return(x + 3) }