# Pull the necessary images:
docker pull nathanleclaire/curl:latest
docker pull openjdk:8u111-jre-alpine
# Start the controller container, note that it has RW access to the Docker API socket:
docker run \
-ti \
--rm \
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
import pyspark.sql.functions as F | |
from pyspark.sql import DataFrame | |
from pyspark.sql import Window as W | |
from pyspark.sql.window import WindowSpec | |
__all__ = ["forward_fill"] | |
def _window_all_previous_rows(partition, order) -> WindowSpec: | |
"""Select the window on which values are filled in a forward manner.""" |
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
# Convert Treasury price to decimal in python | |
# calculating US treasury pricing in python | |
def treasury_to_decimal(price): | |
""" | |
Converts a treasury priced in 32nds into a decimal. This works for | |
treasurys priced up to 3dp i.e. "99-126" | |
""" | |
price_split = price.split("-") | |
integer_part = int(price_split[0]) |
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 functools import reduce | |
from operator import methodcaller | |
import pyspark.sql.functions as F | |
_ts = lambda dataFrame, col: methodcaller('withColumn', f'{col}TimeStamp', F.to_timestamp(F.col(col)/1000))(dataFrame) | |
reduce(lambda a,b: _ts(a,b), ['start','stop'], df).select('startTimeStamp', 'stopTimeStamp').show(truncate=False) |
This gist will drive you through creating a Docker 1.12 Swarm cluster (with Swarm mode) on AWS infrastructure.
You need a few things already prepared in order to get started. You need at least Docker 1.12 set up. I was using the stable version of Docker for mac for preparing this guide.
$ docker --version
Docker version 1.12.0, build 8eab29e
You also need Docker machine installed.
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 hashlib import md5 as xx | |
from collections import namedtuple | |
import os | |
import re | |
# Environment parametes | |
COLUMN_SEPARATOR = chr(os.getenv('SEPARATOR', 449)) | |
FILE_NAME = os.getenv('FILE', 'hashed.csv') | |
# Regular expression to capture JSESSIONID |
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
import matplotlib.pyplot as plt | |
# create data | |
names='Failed: 20', 'Passed: 80', | |
size=[11.8, 98.2] | |
# Create a circle for the center of the plot | |
my_circle=plt.Circle( (0,0), 0.7, color='white') | |
plt.pie(size, labels=names, colors=['#f56262', '#23d993']) |
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
rg ".*I wait for (\d+) secon.*$" -N -r '$1' | rg "\d+" | awk -F: '{s[$1]+=$2}END{for (i in s) print i,s[i]}' | sort -n -k2 | awk '{s+=$2}END{print s}' |
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
browser.execute( | |
() => { | |
return Array.from(document.querySelectorAll("*")).map(e=>e.tagName.toLowerCase()) | |
}) | |
.reduce((a,b) => {a[b]=(a[b] || 0)+1; return a}, {}) |