Skip to content

Instantly share code, notes, and snippets.

View kindofluke's full-sized avatar

Luke Shulman kindofluke

  • Boston, MA
View GitHub Profile
@kindofluke
kindofluke / .gitignore
Created July 22, 2021 16:14
Preferred Python and Development Gitignore
*.swp
*.db
*.code-workspace
venv
vevn
input
node_modules
bchApp
output
*.csv
@kindofluke
kindofluke / read-access.sql
Created December 3, 2020 20:51 — forked from oinopion/read-access.sql
How to create read only user in PostgreSQL
-- Create a group
CREATE ROLE readaccess;
-- Grant access to existing tables
GRANT USAGE ON SCHEMA public TO readaccess;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO readaccess;
-- Grant access to future tables
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readaccess;
@kindofluke
kindofluke / .gitignore
Created May 18, 2020 14:14
Algorex Standard Gitignore
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
*.db
analysis/**/*.csv
input/
ouput/
venv
.vscode
@kindofluke
kindofluke / node_directory.js
Created June 3, 2019 15:33
Node List all files in directory.
var fs = require('fs');
if (process.argv.length <= 2) {
console.log("Usage: " + __filename + " path/to/directory");
process.exit(-1);
}
var path = process.argv[2];
@kindofluke
kindofluke / SeattleWeather.py
Created August 23, 2018 21:23
Seattle Weather Adapted for Altair
bar_click = alt.selection_single(fields=['weather'], on="click")
brush = alt.selection(type='interval', encodings=['x'])
## See functionality in vega editor http://bit.ly/2o28r02
color = alt.Color(
field='weather',
import pygal
from pygal.style import Style
custom_style = Style(
colors=colors,
legend_font_size = 4,
title_font_size = 5,
value_font_size=4)
sources_pygal_pie = pygal.Pie(width=150, height=150, style=custom_style, legend_box_size=4
from altair import Row, Column, Chart, Text, Scale, Color
source_altair_chart = Chart(source_df).mark_text(
applyColorToBackground=True
).mark_bar().encode(x='FoodCode',y='Source', color=Color('Source', scale=Scale(range=colors)))
#"scale": {"scheme": "bluepurple"} doesn't work
flavor_altair_chart = Chart(flavor_df).mark_text(
applyColorToBackground=True
@kindofluke
kindofluke / PieHoloviews.py
Created March 1, 2018 18:28
PieHoloviews
%%opts Bars [xrotation=90 width=600 height=500 show_legend=False tools=['hover'] invert_axes=True ]
%%opts Bars (fill_color=Cycle('Spectral'))
%%opts Layout [shared_axes=False]
import holoviews as hv
hv.extension('bokeh')
pie_raw_holo_table = hv.Table(pie_raw, kdims=['Source', 'FoodCode'])
sources_chart = pie_raw_holo_table.aggregate('Source', function=np.count_nonzero).to.bars(group='Sources of Pie Consumption ')
flavors_chart = pie_raw_holo_table.aggregate('FoodCode', function=np.count_nonzero).to.bars(group='Flavors of Pie Consumption ')
#Calculate the Angles
from math import pi
source_pct_df = pd.DataFrame(source_counts/source_counts.sum()).reset_index().sort_values(by='FoodCode')
flavor_pct_df = pd.DataFrame(flavor_counts/flavor_counts.sum()).reset_index().sort_values(by='Source')
source_starts = [p*2*pi for p in source_pct_df.cumsum().FoodCode[:-1]]
source_ends = [p*2*pi for p in source_pct_df.cumsum().FoodCode[1:]]
source_legends = source_pct_df.Source.values.tolist()[1:]
@kindofluke
kindofluke / PieCufflinks
Created March 1, 2018 18:26
PieCufflinks