Skip to content

Instantly share code, notes, and snippets.

@fordhamedu
fordhamedu / index.html
Created January 21, 2018 07:26
Tableau JS API getData() Demo
<div class="page-header">
<p>This demo gets the underlying data from a viz to create a collapsible menu. <br>
Click the menu to set parameters that change the view.</p>
</div>
<div id="menuNav">
<ul><li>Show Top Level</li></ul>
<div id="menuTree"></div>
</div>
<div id="vizContainer"></div>
# this lives in superset_config.py
class AirbnbAuthRemoteUserView(AuthRemoteUserView):
def add_role_if_missing(self, sm, user_id, role_name):
found_role = sm.find_role(role_name)
session = sm.get_session
user = session.query(sm.user_model).get(user_id)
if found_role and found_role not in user.roles:
user.roles += [found_role]
session.commit()
@shanealynn
shanealynn / python batch geocoding.py
Last active January 6, 2024 13:48
Geocode as many addresses as you'd like with a powerful Python and Google Geocoding API combination
"""
Python script for batch geocoding of addresses using the Google Geocoding API.
This script allows for massive lists of addresses to be geocoded for free by pausing when the
geocoder hits the free rate limit set by Google (2500 per day). If you have an API key for paid
geocoding from Google, set it in the API key section.
Addresses for geocoding can be specified in a list of strings "addresses". In this script, addresses
come from a csv file with a column "Address". Adjust the code to your own requirements as needed.
After every 500 successul geocode operations, a temporary file with results is recorded in case of
script failure / loss of connection later.
Addresses and data are held in memory, so this script may need to be adjusted to process files line
import urllib2
import json
import csv
import pandas as pd
import numpy as np
import decimal
D = decimal.Decimal
url = "https://www.wework.com/locations/all"
data = urllib2.urlopen(url).read()
@gaearon
gaearon / connect.js
Last active April 11, 2024 06:46
connect.js explained
// connect() is a function that injects Redux-related props into your component.
// You can inject data and callbacks that change that data by dispatching actions.
function connect(mapStateToProps, mapDispatchToProps) {
// It lets us inject component as the last step so people can use it as a decorator.
// Generally you don't need to worry about it.
return function (WrappedComponent) {
// It returns a component
return class extends React.Component {
render() {
return (