Skip to content

Instantly share code, notes, and snippets.

View nfedyashev's full-sized avatar

Nikita Fedyashev nfedyashev

View GitHub Profile
@nfedyashev
nfedyashev / gist:1294822
Created October 18, 2011 07:34 — forked from nicholasjhenry/gist:1110289
Sandi Metz - Less - The Path to Better Design
# Sandi Metz - Less - The Path to Better Design
# http://vimeo.com/26330100
# http://less-goruco.heroku.com/
#
# Abstractions are more stable than concretions.
class Trip
attr_reader :bicycles, :customers, :vehicle
def prepare(preparers)
@nfedyashev
nfedyashev / gist:2864944
Created June 3, 2012 20:38
Ruby's Exception Hierarchy
Exception
NoMemoryError
ScriptError
LoadError
NotImplementedError
SyntaxError
SignalException
Interrupt
StandardError
ArgumentError
@nfedyashev
nfedyashev / deploy.rb
Created June 21, 2012 15:33 — forked from LRDesign/deploy.rb
Capistrano recipe to sync rails database and files, using remote database.yml instead of local for remote credentials
set :sync_directories, ["public/assets", "public/galleries"]
set :sync_backups, 3
From a3f0b363e4e943dd8d15a1b097822a81c86e9b82 Mon Sep 17 00:00:00 2001
From: Nikita Fedyashev <loci.master@gmail.com>
Date: Sun, 22 Jul 2012 00:04:47 +0600
Subject: [PATCH] Remove autotest dependency
---
autotest/discover.rb | 2 --
retryable.gemspec | 1 -
2 files changed, 3 deletions(-)
delete mode 100644 autotest/discover.rb
@nfedyashev
nfedyashev / gist:3377341
Created August 17, 2012 09:20
Make strong_parameters work nice with rails_admin
class ApplicationController < ActionController::Base
before_filter :skip_strong_parameters, :if => :rails_admin_path?
def skip_strong_parameters
params.select { |key, value| params[key].kind_of?(ActionController::Parameters) }.map { |key, value| params[key].permit! }
end
privaate
def rails_admin_path?
#!/usr/bin/env bash
apt-get -y update
apt-get -y install build-essential zlib1g-dev libssl-dev libreadline5-dev libyaml-dev
cd /tmp
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p194.tar.gz
tar -xvzf ruby-1.9.3-p194.tar.gz
cd ruby-1.9.3-p194/
./configure --prefix=/usr/local
make
make install
@nfedyashev
nfedyashev / heroku_run.sh
Created May 16, 2013 15:18
"heroku run" fix which respects rake task exit status
#Usage: heroku_run 'rake db:migrate' veeqo-staging
function heroku_run() {
buffer_file=/tmp/last_heroku_run_`date +%N`
heroku run "$1; echo \$?" --app $2 2>&1 | tee $buffer_file
return `tail -1 $buffer_file`
}
@nfedyashev
nfedyashev / master.sh
Created June 13, 2013 00:47
Continuous deployment script
# Disable NewRelic pinging
curl https://heroku.newrelic.com/accounts/xxxxx/applications/yyyyyyyy/ping_targets/disable -X POST -H "X-Api-Key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
heroku maintenance:on --app yourapp-staging
heroku pg:reset DATABASE --confirm yourapp-staging --app yourapp-staging
heroku pgbackups:restore DATABASE `heroku pgbackups:url --app yourapp-production` --app yourapp-staging --confirm yourapp-staging
git remote add heroku_yourapp-staging git@heroku.com:yourapp-staging.git
git push heroku_yourapp-staging $COMMIT_ID:master -f
heroku_run 'rake db:migrate' yourapp-staging
heroku restart --app yourapp-staging
heroku maintenance:off --app yourapp-staging

Keybase proof

I hereby claim:

  • I am nfedyashev on github.
  • I am nfedyashev (https://keybase.io/nfedyashev) on keybase.
  • I have a public key ASDinTHZ0p1CqRzPQVphLzIPY6iqBCZ1G0BbtuDhHj0TRQo

To claim this, I am signing this object:

@nfedyashev
nfedyashev / README.md
Created March 24, 2016 19:50 — forked from dannguyen/README.md
Using Google Cloud Vision API to OCR scanned documents to extract structured data

Using 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