Skip to content

Instantly share code, notes, and snippets.

@dmcghan
dmcghan / db-config.js
Created July 13, 2017 01:08
How to get, use, and close a DB connection using async functions
module.exports = {
user: 'hr',
password: 'oracle',
connectString: 'localhost:1521/orcl',
poolMax: 20,
poolMin: 20,
poolIncrement: 0
};
@dmcghan
dmcghan / db-config.js
Last active June 18, 2018 16:31
How to get, use, and close a DB connection using promises
module.exports = {
user: 'hr',
password: 'oracle',
connectString: 'localhost:1521/orcl',
poolMax: 20,
poolMin: 20,
poolIncrement: 0
};
@yefim
yefim / Dockerrun.aws.json
Last active April 7, 2023 16:11
Build a Docker image, push it to AWS EC2 Container Registry, then deploy it to AWS Elastic Beanstalk
{
"AWSEBDockerrunVersion": "1",
"Image": {
"Name": "<AWS_ACCOUNT_ID>.dkr.ecr.us-east-1.amazonaws.com/<NAME>:<TAG>",
"Update": "true"
},
"Ports": [
{
"ContainerPort": "443"
}
FROM python:2.7-alpine
MAINTAINER Nick Janetakis <[email protected]>
ENV INSTALL_PATH /bsawf
RUN mkdir -p $INSTALL_PATH
WORKDIR $INSTALL_PATH
COPY requirements.txt requirements.txt
RUN apk add --no-cache --virtual .build-deps \
@dannguyen
dannguyen / README.md
Last active September 10, 2024 19:41
Using Python 3.x and Google Cloud Vision API to OCR scanned documents to extract structured data

Using Python 3 + Google Cloud Vision API's OCR to extract text from photos and scanned documents

Just a quickie test in Python 3 (using Requests) to see if Google Cloud Vision can be used to effectively OCR a scanned data table and preserve its structure, in the way that products such as ABBYY FineReader can OCR an image and provide Excel-ready output.

The short answer: No. While Cloud Vision provides bounding polygon coordinates in its output, it doesn't provide it at the word or region level, which would be needed to then calculate the data delimiters.

On the other hand, the OCR quality is pretty good, if you just need to identify text anywhere in an image, without regards to its physical coordinates. I've included two examples:

####### 1. A low-resolution photo of road signs

@alexaleluia12
alexaleluia12 / compiler.py
Created January 10, 2016 21:30
compiler / compilador / sintatico / in python
# font
# http://chimera.labs.oreilly.com/books/1230000000393/ch02.html#_writing_a_simple_recursive_descent_parser
"""
grammar
expr ::= expr + term
| expr - term
| term
@alexaleluia12
alexaleluia12 / finditer-version.py
Last active June 23, 2021 22:59
token / tokenizer / lexico / tokenizing in python
# Can I use finditer ?
# Yes
# ...
def generate_tokens(pat, text):
scanner = pat.finditer(text)
for i in scanner:
yield Token(i.lastgroup, i.group())
@alexaleluia12
alexaleluia12 / file.cpp
Created December 30, 2015 13:08
error: cannot convert ‘std::vector<float*>’ to ‘float*’ in assignment
// I want to share a tricky thing that happened with me
// * I was programming in C style using feature of C++ (on g++)
// I have this structure
typedef struct {
vector<float *> * lst_vertices;
vector<int *> * lst_faces;
float referencia[3];// o ponto sobre o qual vai ser realizadas as transformacoes
} Obj3d;
@alexaleluia12
alexaleluia12 / cleaner.sh
Last active December 30, 2015 12:33
Exclude executable files but not .sh files nor directories
#!/bin/bash
# to get the list of files to exclude
# ls -al | grep ^- | egrep "^[a-z-]+x " | grep -v .sh$ | cut -d' ' -f 9 > arq_exc
# then
for i in $(cat arq_exc); do
rm - $i
done