Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
I may be slow to respond.

Spencer Lyon sglyon

💭
I may be slow to respond.
View GitHub Profile
View GrowthProject.toml
[deps]
BasisMatrices = "08854c51-b66b-5062-a90d-8e7ae4547a49"
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Optim = "429524aa-4258-5aef-a3af-852621145aeb"
Parameters = "d96e819e-fc66-5662-9728-84c9c7592b0a"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
QuantEcon = "fcd29c91-0bd7-5a09-975d-7ac3f643a60c"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
@sglyon
sglyon / extract_attachments.py
Created Feb 19, 2018
nbconvert preprocessor to extract attachments
View extract_attachments.py
""" A preprocessor that extracts all of the attachments from the notebook file.
The extracted attachments are returned in the 'resources' dictionary.
Based on the ExtractOutputsProcessor in nbconvert... the license for
nbconvert is
# Licensing terms
This project is licensed under the terms of the Modified BSD License
(also known as New or Revised or 3-Clause BSD), as follows:
@sglyon
sglyon / eigen_xtensor_buf.cpp
Last active May 22, 2018
xtensor buffer adaptor for eigen VectorXd and MatrixXd
View eigen_xtensor_buf.cpp
#include <stdexcept>
#include "xtensor/xarray.hpp"
#include "xtensor/xio.hpp"
#include "xtensor/xbuffer_adaptor.hpp"
#include "Eigen/Dense"
auto to_xarray(Eigen::VectorXd& in) {
using buf = xt::xbuffer_adaptor<double>;
using xbuf_arr = xt::xarray_container<buf, xt::layout_type::column_major, std::vector<std::size_t>>;
View dolo_framework.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sglyon
sglyon / get_irs_migration_data.go
Last active May 12, 2017
async file downloads
View get_irs_migration_data.go
package main
import (
"fmt"
"github.com/mitchellh/go-homedir"
"io"
"net/http"
"os"
"path"
"sync"
@sglyon
sglyon / README.md
Last active May 10, 2017
python imports
View README.md

Run with python other_file.py

@sglyon
sglyon / example.jl
Created Apr 7, 2017
PlotlyJS.jl slider example
View example.jl
using PlotlyJS
# set up data
na = 10
nw = 5
zz = rand(1:4, na, nw, nw)
text = similar(z, String)
text[zz .== 1] = "stay, work"
text[zz .== 2] = "move, work"
@sglyon
sglyon / showtime.jl
Created Apr 5, 2017
showtime macros
View showtime.jl
macro showtime(ex)
blk = Expr(:block)
push!(blk.args, :(println($(sprint(Base.show_unquoted,ex)*" = "),
repr(begin value=$(esc(ex)) end))))
push!(blk.args, :value)
quote
local stats = Base.gc_num()
local elapsedtime = Base.time_ns()
@sglyon
sglyon / wunderlist2todoist.py
Created Jan 2, 2017
wunderlist -> todoist -- super ugly, but got the job done for me.
View wunderlist2todoist.py
import json
import os
import time
from collections import OrderedDict
from contextlib import contextmanager
import wunderpy2
import todoist
View coffee_bubble_map.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
You can’t perform that action at this time.