This file contains 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
# This file may be used to create an environment using: | |
# $ conda create --name <env> --file <this file> | |
# platform: osx-64 | |
@EXPLICIT | |
https://repo.anaconda.com/pkgs/main/osx-64/blas-1.0-mkl.conda | |
https://repo.anaconda.com/pkgs/main/osx-64/ca-certificates-2020.1.1-0.conda | |
https://repo.anaconda.com/pkgs/main/osx-64/intel-openmp-2019.4-233.conda | |
https://repo.anaconda.com/pkgs/main/osx-64/jpeg-9b-he5867d9_2.conda | |
https://repo.anaconda.com/pkgs/main/osx-64/libcxx-10.0.0-1.conda | |
https://repo.anaconda.com/pkgs/main/osx-64/libgfortran-3.0.1-h93005f0_2.conda |
This file contains 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
from tkinter import HIDDEN, NORMAL, Tk, Canvas | |
def toggle_eyes(): | |
current_color = c.itemcget(eye_left,'fill') | |
new_color = c.body_color if current_color == 'white' else 'white' | |
current_state = c.itemcget(pupil_left,'state') | |
new_state = NORMAL if current_state == HIDDEN else HIDDEN | |
c.itemconfigure(pupil_left,state=new_state) | |
c.itemconfigure(pupil_right,state=new_state) | |
c.itemconfigure(eye_left,fill=new_color) |
This file contains 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
# faster/vectorized replacement for getting monthly cohort | |
df['months_elapsed'] = (df['stats_date'].dt.month - df['first_date'].dt.month) + (12 * (df['stats_date'].dt.year - df['first_date'].dt.year)) | |
# for handy functions (pandas, seaborn, etc.) where you need to reshape the dataframe first | |
df.query('some_filter == "2020-01-01" & another_filter != "error"').pipe(lambda x: pd.crosstab(x['variation'],x['customers'])) |
This file contains 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
# https://www.reddit.com/r/datascience/comments/7ggdlz/what_do_you_hate_about_pandas/dqj6kaw/ | |
# some_df %>% | |
# mutate(new_column = do_something(old_column)) %>% | |
# group_by(new_column) %>% | |
# summarize(some_means = mean(other_column)) | |
df.assign(new_column = do_something(lambda x: x.old_column)) \ | |
.groupby('new_column') \ | |
.agg({'other_column':'mean'}) | |
.rename(columns={'mean':'some_means'}) |
This file contains 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
var vals = {'one':1,'two':2}; | |
Object.keys(vals).forEach(function(i) {console.log('key:' + i + ', value:' + vals[i]);}); |
This file contains 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
<html> | |
<head> | |
</head> | |
<body> | |
<p>Here is my image:</p> | |
<img id="img" src=""/> | |
<script type="text/javascript"> | |
document.getElementById('img').setAttribute( 'src', 'data:image/png;base64,PASTE_THE_BASE64_OUTPUT_HERE' ); | |
</script> | |
</body> |
This file contains 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
<script> | |
// all the marketo from 2.0 javascript has successfully loaded, so we can continue | |
MktoForms2.whenReady(function (form) { | |
// the user has just submitted the form | |
form.onSubmit(function(){ | |
// marketo provides a form object with a nifty method to get the values from the form | |
// we'll store those values in a "vals" variable | |
var vals = form.vals(); | |
// now we can push to the dataLayer | |
dataLayer.push({ |
This file contains 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
<script> | |
MktoForms2.whenReady(function (form) { | |
form.onSubmit(function(){ | |
var vals = form.vals(); | |
dataLayer.push({ | |
'event': 'marketoFormSubmit', | |
'marketoCompany': vals['Company'], | |
'marketoLeadSource': vals['LeadSource'], | |
'marketoOriginalSource': vals['Original_Source_Detail__c'], | |
'marketoCurrentSource': vals['Source_Detail__c'] |
This file contains 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
MktoForms2.loadForm("//app-sjst.marketo.com", "785-UHP-775", 1057, function(form) { | |
// Add an onSubmit handler | |
form.onSubmit(function(){ | |
// Get the form field values | |
var vals = form.vals(); | |
// You may wish to call other function calls here, for example to fire google analytics tracking or the like | |
// callSomeFunction(vals); | |
// We'll just alert them to show the principle | |
alert("Submitted values: " + JSON.stringify(vals)); | |
}); |
This file contains 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
// all of this is made possible by the optimizely javascript api, specifically: | |
// http://developers.optimizely.com/javascript/reference/#the-data-object | |
function getExperiments() { | |
var experimentInfo = {}; | |
var wasRedirected = false; | |
/* | |
* create an array of experiments that are active on the page | |
* you must pass two tests to be placed in an active experiment: | |
* 1) url targeting: https://help.optimizely.com/hc/en-us/articles/200040835-URL-Targeting-Choose-where-your-experiment-runs |
NewerOlder