Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Need to change the values extracted, serves as aide-memoire for R <-> Python | |
def parse_robj(obj): | |
"""Extract n, p1 and p2 from R List from power.prop.test. """ | |
return (obj[obj.names.index("n")][0], | |
obj[obj.names.index("p1")][0], | |
obj[obj.names.index("p2")][0]) | |
def call_power_prop_test(p1, n): | |
P__ = %R power.prop.test(p1=$p1, n=$n, power=0.8) | |
return parse_robj(P__) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
brew install proj | |
brew install geos | |
# Assuming normal scipy stack is installed | |
pip3 install Pillow | |
pip3 install cartopy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Based on | |
# http://stackoverflow.com/questions/2720014/upgrading-all-packages-with-pip | |
# pip freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U | |
pip3 list -o | cut -d ' ' -f 1 | xargs -n1 pip3 install -U |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create function f_extract_query_param(query_string VARCHAR, param VARCHAR) | |
returns varchar | |
STABLE | |
AS $$ | |
# Split on ampersand and then on =, ensuring every param has a pair | |
params = query_string.split("&") | |
# split(.., 1) because there might be multiple '=' in the param | |
kp = [p.split("=", 1) for p in params] | |
# create dict, with "" for missing values where the key is not an empty string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://stackoverflow.com/questions/33112020/how-do-i-install-jupyter-ipython-on-dataproc | |
PROJECT_ID=<project_id> | |
CLUSTER_NAME=<cluster_name> | |
# This should be ipython.sh | |
# https://github.com/GoogleCloudPlatform/dataproc-initialization-actions/blob/master/ipython-notebook/ipython.sh | |
INIT_GCS_SCRIPT=<init_gcs_script> | |
CHROME="/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome" | |
gcloud beta dataproc clusters create $CLUSTER_NAME --zone europe-west1-b \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://stackoverflow.com/questions/17490444/import-matplotlib-pyplot-hangs# | |
cd ~/.matplotlib/ | |
fc-list |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Python function template to simulate the effects of a split test | |
-- Returns string with expected uplift and probability of Alt being better than Orig | |
-- as these are the values used to support decision making for UIUX testing | |
create function f_simulate_split_test(completions_orig INTEGER, sessions_orig INTEGER, | |
completions_alt INTEGER, sessions_alt INTEGER) | |
; | |
create function f_simulate_split_test(completions_orig INTEGER, sessions_orig INTEGER, | |
completions_alt INTEGER, sessions_alt INTEGER) | |
returns varchar(2000) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.