Skip to content

Instantly share code, notes, and snippets.


Chris Parmer chriddyp

View GitHub Profile
chriddyp / custom-keybindings.sublime-keymap
Last active Sep 15, 2021
Custom Sublime Text keybindings for rapid code navigation. No arrow keys required!
View custom-keybindings.sublime-keymap
/* Navigate quickly through a file - Move by horizontally words and vertically by blocks */
{ "keys": ["ctrl+l"], "command": "move", "args": {"by": "subwords", "forward": true}},
{ "keys": ["ctrl+j"], "command": "move", "args": {"by": "subwords", "forward": false}},
{ "keys": ["ctrl+option+k"], "command": "move", "args": {"by": "stops", "forward": true, "empty_line": true}},
{ "keys": ["ctrl+option+i"], "command": "move", "args": {"by": "stops", "forward": false, "empty_line": true}},
/* Fine-grained navigation - Move horizontally by characters and vertically by lines */
{ "keys": ["ctrl+option+l"], "command": "move", "args": {"by": "characters", "forward": true}},
{ "keys": ["ctrl+option+j"], "command": "move", "args": {"by": "characters", "forward": false}},
import dash
from dash.dependencies import Input, Output
import dash_core_components as dcc
import dash_html_components as html
import as px
gapminder ="year == 2007")
input_figure = px.scatter(gapminder, x="gdpPercap", y="lifeExp", size="pop",
custom_data=[gapminder.index], # this is the special bit!
anandology /
Created Jun 22, 2017
POC implementation of reactive expressions for Dash
"""Reactive expressions for Dash!
Dash[1] is an interesting project build reactive web applications in Python.
While the ideas are exciting, the syntax for specifying custom code is way
too complicated that it should be.
Here is a sample code to display sum of two input values.
[Input(component_id='x', component_property='value')]
import dash
from dash.dependencies import Input, Output
import dash_core_components as dcc
import dash_html_components as html
from pandas_datareader import data as web
from datetime import datetime as dt
app = dash.Dash('Hello World')
internaut / pcp.R
Created Sep 27, 2016
Comparison of Parallel Coordinate Plots for Discrete and Categorical Data in R
View pcp.R
### generate questionnaire data
q1_d1 <- round(rtriangle(1000, 1, 7, 5))
q1_d2 <- round(rtriangle(1000, 1, 7, 6))
q1_d3 <- round(rtriangle(1000, 1, 7, 2))
mick /
Last active Jan 17, 2017
Use Plotly to generate a chart from Mapbox Analytics

First your need plotly npm package, and a plotly account.

npm install plotly export PLOTLY_USERNAME=<plotly-username> export PLOTLY_APIKEY=<plotly-apikey> export MAPBOX_ACCESS_TOKEN=<your-mapbox-token>

To generate a image: curl --silent "<username>?period=2016-01-01,2016-04-29&access_token=$MAPBOX_ACCESS_TOKEN" | ./render-image.js > chart.png

View restify lets-encrypt
var myURL="";
var restifyOptions={}
restifyOptions.certificate = fs.readFileSync('PathTo:fullchain.pem');
restifyOptions.key = fs.readFileSync('PathTo:privkey.pem');
var server = restify.createServer(restifyOptions);
var nonSecure = restify.createServer({name: 'redirectToSSL'});
nonSecure.get(/.*/,function (req, res, next) {
res.redirect(301, 'https://' + myURL + req._url.href, next);
cpsievert / plotly-docs.R
Last active Aug 20, 2018
Plotly examples
View plotly-docs.R
# install the new/experimental plotly R package
# devtools::install_github("ropensci/plotly@carson-dsl")
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# initiate a 100 x 3 matrix filled with zeros
Couto / webpack.js
Last active Nov 11, 2020
Fetch polyfill with webpack
View webpack.js
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var path = require('path');
var folders = {
APP: path.resolve(__dirname, '../app'),
BUILD: path.resolve(__dirname, '../build'),
BOWER: path.resolve(__dirname, '../bower_components'),
NPM: path.resolve(__dirname, '../node_modules')