Skip to content

Instantly share code, notes, and snippets.

View bpostlethwaite's full-sized avatar

Ben Postlethwaite bpostlethwaite

View GitHub Profile
@bpostlethwaite
bpostlethwaite / app.py
Last active February 10, 2020 19:05
Fast Finance - Fast App
import base64
import io
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output, State
from dash.exceptions import PreventUpdate
import dash_table
@bpostlethwaite
bpostlethwaite / iris-solution.py
Created September 25, 2018 20:03
Sharing state between callbacks solution
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output, State
import csv
import random
import json
def get_data():
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output, State
import csv
import random
def get_data():
@bpostlethwaite
bpostlethwaite / app.py
Last active September 24, 2018 20:21
possible solution for 2 input graph
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
DATA = [
{"value": "MTL", "label": "Montreal", "x": [1, 2, 3], "y": [4, 1, 2]},
{"value": "NYC", "label": "New York", "x": [1, 2, 3], "y": [2, 4, 5]},
{"value": "SF", "label": "San Fransisco", "x": [1, 2, 3], "y": [1, 8, 3]},
{"value": "HOU", "label": "Houston", "x": [1, 2, 3], "y": [3, 4, 12]},

Additional auth cookies:

  • dash_user
    • signed with itsdangerous.
    • the username appears in clear text in the cookie as user.TOKEN
  • dash_user_data
    • json web signature with itsdangerous.
    • The json web signature is not entirely safe, do not add sensitive data.

The users cookies have no expiry, they are validated by the python package itsdangerous.

@bpostlethwaite
bpostlethwaite / deployment.yml
Last active October 18, 2017 03:17
kube potato
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: sentimentextor
spec:
replicas: 1
template:
metadata:
labels:
app: sentimentextor
@bpostlethwaite
bpostlethwaite / backup
Created January 1, 2017 00:39
curlable backup script
#!/bin/bash
if [ -z ${1} ]; then
echo "usage: backup [static|dynamic]"
exit 1
fi
# see https://sipb.mit.edu/doc/safe-shell/
set -euf -o pipefail
$(function(){
'use strict';
var payload;
function getPlotlyGraphData() {
return [{x:[1,2,3],y:[2,4,3]},{x:[1,2,3],y:[9,7,8]}];
}
function getPlotlyGraphLayout() {
return {};
@bpostlethwaite
bpostlethwaite / post.js
Last active August 29, 2015 14:05
post to plotly /datacache endpoint
$(function(){
var payload;
function getPlotlyGraphData() {
return [{x:[1,2,3],y:[2,4,3]},{x:[1,2,3],y:[9,7,8]}];
}
function getPlotlyGraphLayout() {
return {};
}
Section "ServerLayout"
Identifier "layout"
Screen 0 "nvidia"
Inactive "intel"
EndSection
Section "Device"
Identifier "nvidia"
Driver "nvidia"
BusID "PCI:PCI address determined earlier"