Skip to content

Instantly share code, notes, and snippets.

@StayerX
StayerX / ocr-image.sh
Created June 5, 2016 18:19
OCR Images to text
#!/usr/bin/env bash
# Description: OCR images to text
# Requires: tesseract-ocr imagemagick xsel
# Usage: ocr-image <image(s)>
__ocr_image() {
local image
for image in "$@"; do
local tmp_img=$(mktemp)
cp "$image" "$tmp_img.png"
@StayerX
StayerX / full-ffmpeg.sh
Last active May 25, 2016 01:02
Install full ffmpeg in debian wheezy (with aac(m4a) and x264 support)
# Add multimedia source
apt-get install software-properties-common
add-apt-repository "deb http://www.deb-multimedia.org `lsb_release --codename|cut -f2` main non-free"
grep -q -F 'deb-src http://www.deb-multimedia.org' /etc/apt/sources.list|| echo 'deb-src http://www.deb-multimedia.org sid main' >> foo.bar
apt-get update
apt-get install deb-multimedia-keyring # if this aborts, try again
@StayerX
StayerX / parse_yaml.sh
Created April 10, 2016 22:39 — forked from pkuczynski/parse_yaml.sh
Read YAML file from Bash script
#!/bin/sh
parse_yaml() {
local prefix=$2
local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034')
sed -ne "s|^\($s\)\($w\)$s:$s\"\(.*\)\"$s\$|\1$fs\2$fs\3|p" \
-e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 |
awk -F$fs '{
indent = length($1)/2;
vname[indent] = $2;
for (i in vname) {if (i > indent) {delete vname[i]}}