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
[alias] | |
st = status | |
br = branch | |
co = checkout | |
cm = commit -m | |
# Pull in remote changes for the current repository and all its submodules | |
pr = !"git pull; git submodule foreach git pull origin master" | |
# Switch to a branch, creating it if necessary |
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
# Prefix key | |
unbind C-b | |
set -g prefix C-a | |
# Pnae switching | |
bind -n M-Left select-pane -L | |
bind -n M-Right select-pane -R | |
bind -n M-Up select-pane -U | |
bind -n M-Down select-pane -D |
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
set nocompatible " be iMproved, required | |
filetype off " required | |
" set the runtime path to include Vundle and initialize | |
set rtp+=~/.vim/bundle/Vundle.vim | |
call vundle#begin() | |
" let Vundle manage Vundle, required | |
Plugin 'VundleVim/Vundle.vim' |
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
from pyspark.sql import functions as F | |
from pyspark.sql.types import DoubleType | |
import pandas as pd | |
from sklearn.externals import joblib | |
def make_predictions(sc, df, feature_cols, model_path): | |
""" | |
Make predictions. | |
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
class TestClass(TestCase): | |
def setUp(self): | |
self.test_response = TEST_RESPONSE | |
self.test_response_reformatted = TEST_RESPONSE_REFORMATTED | |
def test_reformat_json(self): | |
print(self.test_response) | |
test_response_rates = self.test_response["rates"] | |
test_response_updated = reformat_json(self.test_response) |
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
def mocked_requests_get(*args, **kwargs): | |
class MockResponse: | |
def __init__(self, json_data, status_code): | |
self.json_data = json_data | |
self.status_code = status_code | |
def json(self): | |
return self.json_data | |
if args[0] == "http://api.fixer.io/latest?base=GBP": |
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
def reformat_json(response): | |
# rearrange the response to not be nested | |
# i.e. {"rates": {"EUR": 1.2}} -> {"EUR": 1.2} | |
rates = response.pop("rates") | |
response.update(rates) | |
# update response to DynamoDB's required format | |
response_updated = {} | |
for key, val in response.items(): | |
# date and base fields are strings (DynamoDB has no date type) whereas everything else is a |
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
def handle(event, context): | |
# initialise DynamoDB client | |
dynamodb = boto3.client('dynamodb', 'eu-west-2') | |
# perform API call | |
response = requests.get("http://api.fixer.io/latest?base=GBP") | |
# handle bad responses | |
if response.status_code == 200: | |
logger.info("Request to Fixer successful") |