Skip to content

Instantly share code, notes, and snippets.


Anatoliy Plastinin antlypls

View GitHub Profile
if [ -z "$1" ] ; then
echo 'Project name is empty'
exit 1
antlypls /
Created Feb 28, 2011
transforms pdf to booklet layout (two pages side by side) fixed version of required packages: pdftk and pdfjam (as well as tex-live, pdflatex required by pdfjam)
FILE=$(echo $1 | sed 's/.pdf//')
echo "$ pdfcrop $FILE.pdf --margins 12"
pdfcrop $FILE.pdf --margins 12
echo "$ pdftops $FILE-crop.pdf"
pdftops $FILE-crop.pdf
antlypls /
Created May 2, 2016 — forked from dannguyen/
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

View dynamic_method_spec.rb
require 'spec/support/grep_matcher'
describe do
disallow_presence_of pattern: "send(.*#",
location: "app/",
description: "Do not use dynamic method invocations",
failure: "Please change dynamic method call to something more sane."
View Guardfile
guard 'process', :name => 'shrink-images', :command => 'ruby resize-mobile-images.rb mobileretina' do
watch /^images\/mobileretina\/.+/
View mobile.css.scss
@mixin mobile_bg($file){
background-image: image-url('mobile/standard/#{$file}');
@media screen and (-webkit-min-device-pixel-ratio: 2) {
background-image: image-url('mobile/retina/#{$file}');
background-size: image-width('mobile/standard/#{$file}') image-height('mobile/standard/#{$file}');
// Usage
View Locales.yml
# config/locales/en.yml
title: "Not Found"
description: "The page you were looking for does not exists."
title: "Internal Server Error"
View avatar_uploader.rb
# app/uploaders/avatar_uploader.rb
process :fix_exif_rotation
process :strip
process :resize_to_fill => [1024, 768]
process :quality => 90 # Percentage from 0 - 100
View call_template.rb
# create the template
template =
template.quote = quote
template.pages = quote.build_pages
# Here I render a template with layout to a string then a PDF
pdf = template.render_to_string(:template=>"quotes/review.html.haml")
View passwords_controller.rb
# app/controllers/users/password_controller.rb
class Users::PasswordsController < Devise::PasswordsController
def resource_params
params.require(:user).permit(:email, :password, :password_confirmation)
private :resource_params
You can’t perform that action at this time.