Skip to content

Instantly share code, notes, and snippets.

https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ReservedWords.html
@keithrozario
keithrozario / manipulate.py
Created June 11, 2019 17:10
ipython doc manipulation
# coding: utf-8
import fitz
doc = fitz.open('outputbase.pdf')
page = doc[0]
rect = fitz.Rect(181,3226,1813,3358)
page.drawRect(rect)
doc.save('latest.pdf')
page.drawRect(50,100,200,300)
rect = fitz.Rect(50, 100, 200,300)
page.drawRect(rect)
$ python -m venv projectname
$ source projectname/bin/activate
(venv) $ pip install ipykernel
(venv) $ ipython kernel install --user --name=projectname
@keithrozario
keithrozario / lambda.py
Created May 26, 2019 06:36
Example of pytesseract in lambda
"""
remember to set the following two layers
arn:aws:lambda:ap-southeast-1:113088814899:layer:Klayers--tesseract:1
arn:aws:lambda:ap-southeast-1:113088814899:layer:Klayers-python37-pytesseract:1
"""
import json
import logging
import pytesseract
@keithrozario
keithrozario / spacy.py
Created April 21, 2019 16:09
spaCy Lambda Layer example
import spacy
import json
def lambda_handler(event, context):
nlp = spacy.load('/opt/en_core_web_sm-2.1.0')
test = 'Keith is one awesome dude'
nlp_test = nlp(test)
output_ner = [(i, i.label_, i.label) for i in nlp_test.ents]
print(output_ner)
@keithrozario
keithrozario / install_confluence.sh
Last active April 27, 2019 08:48
Installing Confluence
#! /bin/bash
wget https://www.atlassian.com/software/confluence/downloads/binary/atlassian-confluence-6.15.2-x64.bin
chmod +x atlassian-confluence-6.15.2-x64.bin
sudo ./atlassian-confluence-6.15.2-x64.bin
sudo apt install postgresql postgresql-contrib
sudo -i -u postgres
createuser --interactive
psql
ALTER USER confluenceuser WITH ENCRYPTED PASSWORD '<password>';
@keithrozario
keithrozario / spacy.py
Created April 17, 2019 17:30
using_spacy
import json
import spacy
def lambda_handler(event, context):
nlp = spacy.load('/opt/en_core_web_sm-2.1.0')
doc = nlp(u"Apple is looking at buying U.K. startup for $1 billion. Keith Rozario doesn't have $1 billion.")
for ent in doc.ents:
print(ent.text, ent.start_char, ent.end_char, ent.label_)
@keithrozario
keithrozario / re_invoke.py
Last active April 17, 2019 15:15
Reinvoke Lambdas
message['ContinuationToken'] = token
if context.get_remaining_time_in_millis() < reinvoke_seconds * 1000:
logger.info(f"Running out of time, invoking new lambda")
response = sqs_client.send_message(QueueUrl=os.environ['sqs_list_bucket_url'],
MessageBody=json.dumps(message),
DelaySeconds=2)
logger.info(f"Called new message with messageId: {response['MessageId']}")
@keithrozario
keithrozario / invoke_populate_s3.py
Created April 13, 2019 05:03
invoke_populate_s3
import boto3
import copy_bucket
import time
if __name__ == '__main__':
region = copy_bucket.get_config()['provider']['region']
client = boto3.client('lambda', region_name=region)
for x in range(199):
time.sleep(0.01)
@keithrozario
keithrozario / new_mac.MD
Last active July 25, 2019 14:21
Got my new mac

Install Brew

https://brew.sh/

  • Install jq

install office

  • Keynote
  • Numbers
  • Pages

Install PIA