Instantly share code, notes, and snippets.

View README.md

Two way iframe communication

The main difference between the two pages is the method of sending messages. Recieving messages is the same in both.

Parent

Send messages to iframe using iframeEl.contentWindow.postMessage Recieve messages using window.addEventListener('message')

iframe

View MediawikionHeroku.md
git clone https://github.com/caseywatts/mediawiki
heroku apps:create MYAPPNAME
echo "web: vendor/bin/heroku-hhvm-apache2" >> Procfile
curl -sS https://getcomposer.org/installer | php
php composer.phar update
# add & commit composer.lock

heroku buildpacks:add heroku/php
heroku ps:scale web=1
View Spark Dataframe Cheat Sheet.py
# A simple cheat sheet of Spark Dataframe syntax
# Current for Spark 1.6.1
# import statements
#from pyspark.sql import SQLContext
#from pyspark.sql.types import *
#from pyspark.sql.functions import *
from pyspark.sql import functions as F
#SparkContext available as sc, HiveContext available as sqlContext.
View index.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><META http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body>
View useful_pandas_snippets.py
# List unique values in a DataFrame column
pd.unique(df.column_name.ravel())
# Convert Series datatype to numeric, getting rid of any non-numeric values
df['col'] = df['col'].astype(str).convert_objects(convert_numeric=True)
# Grab DataFrame rows where column has certain values
valuelist = ['value1', 'value2', 'value3']
df = df[df.column.isin(valuelist)]