Skip to content

Instantly share code, notes, and snippets.

View nfedyashev's full-sized avatar

Nikita Fedyashev nfedyashev

View GitHub Profile
@jgillman
jgillman / restore.sh
Last active March 8, 2024 17:51
pg_restore a local db dump into Docker
# Assumes the database container is named 'db'
DOCKER_DB_NAME="$(docker-compose ps -q db)"
DB_HOSTNAME=db
DB_USER=postgres
LOCAL_DUMP_PATH="path/to/local.dump"
docker-compose up -d db
docker exec -i "${DOCKER_DB_NAME}" pg_restore -C --clean --no-acl --no-owner -U "${DB_USER}" -d "${DB_HOSTNAME}" < "${LOCAL_DUMP_PATH}"
docker-compose stop db
@dannguyen
dannguyen / README.md
Last active December 28, 2023 15:21
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

@jasonzoladz
jasonzoladz / page-transitions.cljs
Last active October 19, 2023 15:33
Animating Page Transitions with Reagent and Re-frame
;; style.css -- basic (lame) transitions, for demonstration
;;________________________________________________________________
.pageChange-enter {
opacity: 0.01;
}
.pageChange-enter.pageChange-enter-active {
opacity: 1;
transition: opacity 500ms ease-in;
@theothermattm
theothermattm / sync-using-gitignore.sh
Created October 7, 2015 20:58
Rsync files using .gitignore
# sync everything excluding things in .gitignore
# delete anything on target not in source
# include dotfiles and symlinks, also use compression
rsync -azP --delete --filter=":- .gitignore" . my-target-host:/my/target/directory
@jcouyang
jcouyang / stop-asking.el
Last active June 29, 2020 14:01
disable emacs asking following git symbolink
; 当要打开一个symbolink的时候,如果symbollink到一个被git(或者其他vc)管理的文件时,emacs老问
; Symbolic link to Git-controlled source file; follow link? (y or n)
; 配置下这个变量就好了
(setq vc-follow-symlinks nil)
; nil 表示 不要问,no
; ask 表示每次都问
; t 表示follow
;; IMPORTANT: knowledge representation system (krs)
(defstruct (knowledge-base (:conc-name kb-))
(facts nil)
(beliefs nil))
(defun new-knowledge-base ()
(let ((base (make-knowledge-base :facts (make-hash-table) :beliefs (make-hash-table))))
base))
@benshimmin
benshimmin / gist:9401836
Created March 6, 2014 23:20
How to raise a validation error in Rails after save
# This probably isn't a good thing to want to do, but it came up for me,
# so in the spirit of helping others with weird problems (and because this
# seems to be documented almost nowhere):
after_save do
if some_failing_condition
errors.add(:something, "some failure happened.")
raise ActiveRecord::RecordInvalid.new(self)
end
@matt448
matt448 / can_sender.ino
Last active August 24, 2023 11:23
Arduino code for CAN bus sender example
// demo: CAN-BUS Shield, send data
#include <mcp_can.h>
#include <SPI.h>
//Pot for adjusting value
int sensorPin = A0;
int sensorValue = 0;
int cantxValue = 0;
void setup()
@rafaelfranca
rafaelfranca / deprecation.rb
Last active March 12, 2024 14:33
Examples of `ActiveSupport::Deprecation`
require 'active_support'
class Foo
def foo
"foo"
end
def bar
ActiveSupport::Deprecation.warn("bar is deprecated")
@bclinkinbeard
bclinkinbeard / release.sh
Created November 1, 2011 20:22
Bash script to automate the Git Flow tag/release process
#!/bin/bash
# current Git branch
branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
# v1.0.0, v1.5.2, etc.
versionLabel=v$1
# establish branch and tag name variables
devBranch=develop