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
#!/bin/bash | |
# Generates a pdf invoice from a text file. | |
# | |
# Usage: | |
# ./generate_invoice invoice_0000.txt | |
BASE=$(basename -s .txt $@) | |
echo "${BASE}" | |
enscript -B $@ -o "${BASE}".ps | |
ps2pdf "${BASE}".ps out/"${BASE}".pdf |
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: | |
Company Name | |
Address 1 | |
Address 2 | |
Phone number | |
Sold To: | |
Company Name | |
Address 1 |
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 _ from 'lodash'; | |
export const getHighestRank = (ranks) => _.maxBy(ranks, 'rank') | |
// export const getSomeValue... |
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 _ from 'lodash'; | |
export const getHighestRank = (ranks) => { | |
return _.reduce(ranks, (acc, e) => { | |
if (e.rank > acc.rank) { | |
return e; | |
} | |
return acc; | |
}, ranks[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
import _ from 'lodash'; | |
export const getSomeValue = () => { | |
// some code ... | |
const highestRank = _.reduce(ranks, (acc, e) => { | |
if (e.rank > acc.rank) { | |
return e; | |
} | |
return acc; |
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
# memento_pull.py | |
import boto3, os, sys | |
has_messages = True | |
sqs = boto3.resource('sqs', region_name='us-east-1') | |
queue_url = os.environ['AWS_SQS_URL'] | |
while has_messages: | |
response = sqs.meta.client.receive_message(QueueUrl=queue_url, MaxNumberOfMessages=10) |
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
@application.route('/sqs', methods=['POST']) | |
@auth.validate_authenticated(token=application.config['AUTHENTICATION_TOKEN']) | |
def sqs_create(): | |
text = flask.request.get_json()['text'] | |
sqs.meta.client.send_message( | |
QueueUrl=application.config['AWS_SQS_URL'], | |
MessageBody=(text) | |
) | |
return flask.Response(text, mimetype='text/plain') |
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
# tests/test_myresources.py | |
@unittest.mock.patch('lib.myresources.myreqs') | |
def test_get_resources_calls_one(self, myreqs): | |
myresources.get_resources() | |
myreqs.fetch_thing_1.assert_called_once() | |
@unittest.mock.patch('lib.myresources.myreqs') | |
def test_get_resources_calls_two(self, myreqs): | |
myresources.get_resources() |
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
# tests/test_myreqs.py | |
# ... test_fetch_thing_* methods | |
@unittest.mock.patch.object(myreqs, 'fetch_thing_1') | |
@unittest.mock.patch.object(myreqs, 'fetch_thing_2') | |
@unittest.mock.patch.object(myreqs, 'fetch_thing_3') | |
def test_get_resources_calls_one(self, thing_3, thing2, thing1): | |
myreqs.get_resources() | |
thing1.assert_called_once() |
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
# tests/test_myreqs.py | |
# ... test_fetch_thing_* methods | |
@unittest.mock.patch.object(myreqs, 'fetch_thing_1') | |
@unittest.mock.patch.object(myreqs, 'fetch_thing_2') | |
@unittest.mock.patch.object(myreqs, 'fetch_thing_3') | |
def test_get_resources(self, thing_3, thing2, thing1): | |
myreqs.get_resources() | |
thing1.assert_called_once() | |
thing2.assert_called_once() |