Skip to content

Instantly share code, notes, and snippets.

View antlypls's full-sized avatar
🤘

Anatoliy Plastinin antlypls

🤘
View GitHub Profile
#!/bin/bash
if [ -z "$1" ] ; then
echo 'Project name is empty'
exit 1
fi
PROJECT_NAME="$1"
SCALA_VERSION="${2-2.11.8}"
SCALATEST_VERSION="${3-2.2.6}"
@antlypls
antlypls / booklet.sh
Created February 28, 2011 08:44
transforms pdf to booklet layout (two pages side by side) fixed version of http://lembra.wordpress.com/2010/02/21/create-a-script-to-print-a-pdf-booklet/ required packages: pdftk and pdfjam (as well as tex-live, pdflatex required by pdfjam)
#!/bin/bash
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
antlypls / README.md
Created May 2, 2016 21:38 — forked from dannguyen/README.md
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

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."
end
@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
guard 'process', :name => 'shrink-images', :command => 'ruby resize-mobile-images.rb mobileretina' do
watch /^images\/mobileretina\/.+/
end
# config/locales/en.yml
en:
exception:
show:
not_found:
title: "Not Found"
description: "The page you were looking for does not exists."
internal_server_error:
title: "Internal Server Error"
# app/uploaders/avatar_uploader.rb
process :fix_exif_rotation
process :strip
process :resize_to_fill => [1024, 768]
process :quality => 90 # Percentage from 0 - 100
# create the template
template = PageOfflineTemplate.new
template.quote = quote
template.pages = quote.build_pages
# Here I render a template with layout to a string then a PDF
pdf = PDFKit.new template.render_to_string(:template=>"quotes/review.html.haml")
# app/controllers/users/password_controller.rb
class Users::PasswordsController < Devise::PasswordsController
def resource_params
params.require(:user).permit(:email, :password, :password_confirmation)
end
private :resource_params
end