Skip to content

Instantly share code, notes, and snippets.

View samstewart's full-sized avatar

Sam Stewart samstewart

  • New York, New York
View GitHub Profile
@samstewart
samstewart / photos.sh
Created August 5, 2017 01:43
organize photos by year and date
stat -f "%Sc" . | awk '// { print $4"/"$1 }' | xargs -I{} mkdir -p "{}"
db.employees.aggregate(
[
{ $group: { _id: { college: "$college", department: "$department" },
salary: {$sum : "$salary"}
}},
{$out: "college_and_departments"}
])
{
name: 'Bob Jones',
salary: 40000,
department: 'Mathematics',
job_title: 'assistant professor'
college: 'Science and Engineering, College of'
}
{
name: 'Lisa Smith',
department: 'Mathematics',

A simple visualization of the publicly available salary data from the University of Minnesota. My goal is to highlight the absurd income disparity between the highest and lowest paid at the university.

Notes on the data processing: The raw data was pulled from UMN's human resource page

We filter out anyone who makes below $10,000 per year because they tend to be temporary workers and thus uninteresting. The only danger is that we also ignore those adjuncts who are teaching only a few courses.

@samstewart
samstewart / SocialForces.cpp
Created February 28, 2017 15:25
OpenSteer plugin for social forces model for crowd behavior
// ----------------------------------------------------------------------------
//
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
@samstewart
samstewart / jacobi_method.m
Created November 18, 2016 20:14
Jacobi method in matlab
% Method to solve a linear system via jacobi iteration
% A: matrix in Ax = b
% b: column vector in Ax = b
% N: number of iterations
% returns: column vector solution after N iterations
function sol = jacobi_method(A, b, N)
diagonal = diag(diag(A)); % strip out the diagonal
diag_deleted = A - diagonal; % delete the diagonal
@samstewart
samstewart / abs.tex
Created October 10, 2016 16:06
Absolute value in latex
\delimitershortfall-1sp
\newcommand\abs[1]{\left|#1\right|}
@samstewart
samstewart / latex_norm.tex
Created October 10, 2016 16:01
Latex norm
\newcommand{\norm}[1]{\left\lVert#1\right\rVert}
@samstewart
samstewart / plot_scalar_field.m
Created October 6, 2016 22:44
Plots a heatmap of a scalar field
% plots a scalar field as a heat map
function plot_scalar_field(field)
colormap('hot');
imagesc(field);
end
@samstewart
samstewart / plot_vector_field.m
Created October 6, 2016 22:38
Plot a 3D array representing a vector field
% plots a 3D array representing a vector field in grid coordinates (1, 1),
% (1, 2), etc.
function plot_vector_field(field)
N = size(field, 1);
M = size(field, 2);
[x,y] = meshgrid(1:1:N, 1:1:M)
u = field(:, :, 1);
v = field(:, :, 2);