Skip to content

Instantly share code, notes, and snippets.

View chriddyp's full-sized avatar

Chris Parmer chriddyp

View GitHub Profile
@chriddyp
chriddyp / custom-keybindings.sublime-keymap
Last active October 19, 2021 15:10
Custom Sublime Text keybindings for rapid code navigation. No arrow keys required!
[
/* 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 plotly.express as px
gapminder = px.data.gapminder().query("year == 2007")
input_figure = px.scatter(gapminder, x="gdpPercap", y="lifeExp", size="pop",
custom_data=[gapminder.index], # this is the special bit!
@anandology
anandology / rdash.py
Created June 22, 2017 06:21
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.
@app.callback(
[Input(component_id='x', component_property='value')]
# See official docs at https://dash.plotly.com
# pip install dash pandas
from dash import Dash, dcc, html, Input, Output
import plotly.express as px
import pandas as pd
df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/gapminderDataFiveYear.csv')
@internaut
internaut / pcp.R
Created September 27, 2016 13:07
Comparison of Parallel Coordinate Plots for Discrete and Categorical Data in R
### generate questionnaire data
library(triangle)
set.seed(0)
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
mick / readme.md
Last active January 17, 2017 17:02
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 "https://api.mapbox.com/analytics/v1/accounts/?period=2016-01-01,2016-04-29&amp;access_token=$MAPBOX_ACCESS_TOKEN" | ./render-image.js &gt; chart.png

var myURL="mydomain.com";
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);
@gtallen1187
gtallen1187 / slope_vs_starting.md
Created November 2, 2015 00:02
A little bit of slope makes up for a lot of y-intercept

"A little bit of slope makes up for a lot of y-intercept"

01/13/2012. From a lecture by Professor John Ousterhout at Stanford, class CS140

Here's today's thought for the weekend. A little bit of slope makes up for a lot of Y-intercept.

[Laughter]