Skip to content

Instantly share code, notes, and snippets.

View davidmashburn's full-sized avatar

David Mashburn davidmashburn

  • Pluralsight, LLC
  • Boston, MA
View GitHub Profile
@rdpoor
rdpoor / .block
Last active June 22, 2023 22:15 — forked from mbostock/.block
Modifying a Force Layout (with comments)
license: gpl-3.0
@dannguyen
dannguyen / README.md
Last active September 10, 2024 19:41
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

@subfuzion
subfuzion / curl.md
Last active April 16, 2025 09:14
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@twolfson
twolfson / README.md
Created November 11, 2015 03:10
Configure PostgreSQL for development in Vagrant

While trying to get a local version of issue_stats running, we ran into a problem we previously experienced with respect to using an MD5 password on a Vagrant box.

Since these commands aren't the most trivial, we figure it would be a good idea to document.

Here's how to add a new user to PostgreSQL in Vagrant:

# Set up PostgreSQL 9.3 configuration
# Modified from https://github.com/twolfson/vagrant-nodebugme/blob/1.0.0/bin/bootstrap.sh#L26-L54
# If we can't open `psql` as `vagrant`
@kylemcdonald
kylemcdonald / ffmpeg_load_audio.py
Last active June 6, 2023 03:06
Load audio from ffmpeg into Python using numpy.
import numpy as np
import subprocess as sp
import os
DEVNULL = open(os.devnull, 'w')
# load_audio can not detect the input type
def ffmpeg_load_audio(filename, sr=44100, mono=False, normalize=True, in_type=np.int16, out_type=np.float32):
channels = 1 if mono else 2
format_strings = {
np.float64: 'f64le',
@jbwhit
jbwhit / post-save-hook.py
Last active September 21, 2023 04:50
Saves Jupyter Notebooks as .py and .html files automatically. Add to the ipython_notebook_config.py file of your associated profile.
import os
from subprocess import check_call
def post_save(model, os_path, contents_manager):
"""post-save hook for converting notebooks to .py and .html files."""
if model['type'] != 'notebook':
return # only do this for notebooks
d, fname = os.path.split(os_path)
check_call(['jupyter', 'nbconvert', '--to', 'script', fname], cwd=d)
check_call(['jupyter', 'nbconvert', '--to', 'html', fname], cwd=d)
@JeffBelback
JeffBelback / docker-destroy-all.sh
Last active May 25, 2024 20:19
Destroy all Docker Containers and Images
#!/bin/bash
# Stop all containers
containers=`docker ps -a -q`
if [ -n "$containers" ] ; then
docker stop $containers
fi
# Delete all containers
containers=`docker ps -a -q`
if [ -n "$containers" ]; then
docker rm -f -v $containers
@davemkirk
davemkirk / Vagrantfile
Created April 4, 2015 20:23
Jupyter (aka IPython Notebook) Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
@stevenbeeckman
stevenbeeckman / Setup Python, IPython and ipython-sql
Last active October 29, 2022 16:11
Setting up IPython Notebook inside of Vagrant
sudo apt-get update
sudo apt-get install build-essential python-dev
sudo apt-get install python-matplotlib
sudo apt-get install python-pip
sudo pip install ipython-sql
sudo pip install --upgrade jinja2 tornado jsonschema pyzmq
sudo apt-get install python-mysqldb
# let's start ipython notebook
ipython notebook --ip=0.0.0.0 # port-forwarding doesn't work without this --ip flag
@eyaler
eyaler / graph.json
Last active December 26, 2023 07:36
Force-Directed Graph with Drag/Zoom/Pan/Center/Resize/Labels/Shapes/Filter/Highlight
{
"graph": [],
"links": [
{"source": 0, "target": 1},
{"source": 0, "target": 2},
{"source": 0, "target": 3},
{"source": 0, "target": 4},
{"source": 0, "target": 5},
{"source": 0, "target": 6},
{"source": 1, "target": 3},