Skip to content

Instantly share code, notes, and snippets.

View andyreagan's full-sized avatar

Andy Reagan andyreagan

View GitHub Profile
@andyreagan
andyreagan / tastypie-smarturl.py
Last active June 23, 2020 17:07
Smart url encoder for tastypie
from django.utils.html import smart_urlquote
from tastypie import fields
class SmartUrlField(fields.ApiField):
"""
A field for urls in plain text.
"""
dehydrated_type = 'string'
help_text = 'a field for urls in plain text.'
@andyreagan
andyreagan / jenkins-block.sh
Created May 22, 2020 13:40
Shell script to wait on a upstream jenkins job - a "block" node in an execution graph
# watch multiple jobs, can handle any number of upstreams
virtualenv-3.5 pyenv
pyenv/bin/pip install requests
JENKINS_URI=...
echo "import json
import requests
import time
@andyreagan
andyreagan / karate_club.graphml
Created April 30, 2020 02:38
13.6 Network data
<?xml version='1.0' encoding='utf-8'?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
<key attr.name="name" attr.type="string" for="graph" id="d1" />
<key attr.name="club" attr.type="string" for="node" id="d0" />
<graph edgedefault="undirected">
<node id="0">
<data key="d0">Mr. Hi</data>
</node>
<node id="1">
<data key="d0">Mr. Hi</data>
@andyreagan
andyreagan / .block
Created March 31, 2020 02:40 — forked from john-guerra/.block
US States Cloropleth Reusable module
license: mit
@andyreagan
andyreagan / MC2-parallel-coordinates-pivot.ipynb
Last active March 28, 2020 15:42
W209 Async 11.3 with pivot_table transform
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@andyreagan
andyreagan / week09-live.ipynb
Created March 28, 2020 15:05
w209 week 09 in-class exercise, completed
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@andyreagan
andyreagan / test.sql
Created March 11, 2020 01:14
Test study year and policy year mortality data long format
drop table if exists mortality.sample_exposure_and_events;
create table mortality.sample_exposure_and_events ( policy_id int, dob_date date, start_date date, end_date date, event_date date, covariate_1 varchar(1), covariate_2 varchar(1) );
insert into mortality.sample_exposure_and_events ( policy_id, dob_date, start_date, end_date, event_date, covariate_1, covariate_2 ) ( select 1, '1989-07-25', '2010-01-01', '2012-12-31', NULL, 'M', '5');
insert into mortality.sample_exposure_and_events ( policy_id, dob_date, start_date, end_date, event_date, covariate_1, covariate_2 ) ( select 2, '1990-08-26', '2012-01-01', '2013-12-31', NULL, 'M', '3');
insert into mortality.sample_exposure_and_events ( policy_id, dob_date, start_date, end_date, event_date, covariate_1, covariate_2 ) ( select 3, '1991-08-19', '2014-01-01', '2016-06-30', '2016-06-30', 'F', '3');
select * from mortality.sample_exposure_and_events order by policy_id;
create table mortality.sample_study_years ( study_year int );
insert into mortality.sample_
@andyreagan
andyreagan / chunksize.vg.json
Last active April 11, 2019 19:51
Streaming blog charts
{
"config": {"view": {"width": 400, "height": 300}},
"layer": [
{
"data": {"name": "data-c0a7223f03f36353e594f8f681eb9f0c"},
"mark": {"type": "line", "point": true},
"encoding": {
"x": {"type": "quantitative", "field": "size", "title": "Chunk Size (rows)"},
"y": {"type": "quantitative", "field": "totaltime", "title": "Runtime (s)"}
}
@andyreagan
andyreagan / .block
Last active December 19, 2018 21:00
MM Advisors All Locations
license: mit