Skip to content

Instantly share code, notes, and snippets.

Avatar

Ofek Lev ofek

View GitHub Profile
View detect if TypeError is due to argument mismatch.py
import sys
import inspect
import re
def called_with_wrong_args(func, locals=None, exc_info=None):
"""
Finds out whether an exception was raised because invalid arguments were passed to a function.
@churro-s
churro-s / LetsEncrypt_HTTPS_plex.MD
Last active Sep 2, 2020
Setup Let's Encrypt certificate for use with Plex Media Server on Ubuntu
View LetsEncrypt_HTTPS_plex.MD
@chris-belcher
chris-belcher / JMalert.md
Last active Jul 25, 2017
JoinMarket release 0.2.0 ameliorates this snooping attack.
View JMalert.md
@dannguyen
dannguyen / README.md
Last active Sep 21, 2020
Using Python 3.x and Google Cloud Vision API to OCR scanned documents to extract structured data
View README.md

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

@seanjensengrey
seanjensengrey / rust-python-cffi.md
Last active Jul 4, 2020
Calling Rust from Python/PyPy using CFFI (C Foreign Function Interface)
View rust-python-cffi.md

This is a small demo of how to create a library in Rust and call it from Python (both CPython and PyPy) using the CFFI instead of ctypes.

Based on http://harkablog.com/calling-rust-from-c-and-python.html (dead) which used ctypes

CFFI is nice because:

  • Reads C declarations (parses headers)
  • Works in both CPython and PyPy (included with PyPy)
  • Lower call overhead than ctypes
View Getting-Cheat-Sheet.md

Git Cheat Sheet

Visit my blog.

Commands

Getting Started

git init

or

@XVilka
XVilka / TrueColour.md
Last active Sep 21, 2020
True Colour (16 million colours) support in various terminal applications and terminals
View TrueColour.md

Terminal Colors

There exists common confusion about terminal colors. This is what we have right now:

  • Plain ASCII
  • ANSI escape codes: 16 color codes with bold/italic and background
  • 256 color palette: 216 colors + 16 ANSI + 24 gray (colors are 24-bit)
  • 24-bit true color: "888" colors (aka 16 milion)
@datagrok
datagrok / gist:2199506
Last active Jan 7, 2020
Virtualenv's `bin/activate` is Doing It Wrong
View gist:2199506
@hrldcpr
hrldcpr / tree.md
Last active Sep 2, 2020
one-line tree in python
View tree.md

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

@dupuy
dupuy / README.rst
Last active Sep 21, 2020
Common markup for Markdown and reStructuredText
View README.rst

Markdown and reStructuredText

GitHub supports several lightweight markup languages for documentation; the most popular ones (generally, not just at GitHub) are Markdown and reStructuredText. Markdown is sometimes considered easier to use, and is often preferred when the purpose is simply to generate HTML. On the other hand, reStructuredText is more extensible and powerful, with native support (not just embedded HTML) for tables, as well as things like automatic generation of tables of contents.

You can’t perform that action at this time.