Skip to content

Instantly share code, notes, and snippets.

View duanebester's full-sized avatar

Duane Bester duanebester

View GitHub Profile
def imageToBinaryImage = Flow[BufferedImage].map(img => {
val bin = ImageHelper.convertImageToBinary(img)
bin
})
object Main extends App with OCR {
implicit val system: ActorSystem = ActorSystem("ocr")
implicit val executor: ExecutionContextExecutor = system.dispatcher
implicit val materializer: ActorMaterializer = ActorMaterializer()
implicit val jsonStreamingSupport = EntityStreamingSupport.json()
import MyJsonProtocol._
def imageDeSkew:Flow[BufferedImage] = ???
def imageToBinaryImage:Flow[BufferedImage] = ???
def bufferedImageToMat:Flow[BufferedImage] = ???
// Dependencies
libraryDependencies += "net.sourceforge.tess4j" % "tess4j" % "4.0.0"
libraryDependencies += "com.typesafe.akka" %% "akka-stream" % "2.5.12"
libraryDependencies += "com.typesafe.akka" %% "akka-http" % "10.1.1"
libraryDependencies += "com.typesafe.akka" %% "akka-http-spray-json" % "10.1.1"
// Plugins
addSbtPlugin("org.bytedeco" % "sbt-javacv" % "1.16")
trait OCR {
val tesseract: Tesseract = new Tesseract
tesseract.setDatapath("/usr/local/Cellar/tesseract/3.05.01/share/")
}
@duanebester
duanebester / svg2png.sh
Created February 10, 2018 13:58
Svg to Png for React Native asset conversion
#!/bin/sh
rsvg-convert -v > /dev/null 2>&1 || { echo "rsvg-convert is not installed, use: brew install librsvg." >&2; exit 1; }
ASSETS_FOLDER=$1
if [ "$ASSETS_FOLDER" == "" ]; then
echo "Usage: $0 /path/to/svg/assets/" >&2
exit 1
fi
@duanebester
duanebester / ObjectIdSerialization.scala
Last active December 11, 2015 21:04
Spray Json to Reactive Mongo ObjectId
import spray.json.DefaultJsonProtocol
/**
* Created by duane on 12/11/2015.
*/
trait ObjectIdSerialization extends DefaultJsonProtocol {
import reactivemongo.bson.BSONObjectID
import spray.json._
@duanebester
duanebester / find-usb-windows.go
Last active October 1, 2015 23:23
Enter your USB Vendor ID and print the "Friendly Name"
package main
/*
#cgo LDFLAGS: -lSetupapi
#ifdef __MINGW32__
#include <ntdef.h>
#endif
#include <windows.h>
#include <setupapi.h>
@duanebester
duanebester / VeryBigSum.scala
Created July 4, 2015 20:02
Hacker Rank Warmup - Very Big Sum
//
// Code for: https://www.hackerrank.com/challenges/a-very-big-sum
//
object Solution {
def main(args: Array[String]) {
val num = readInt()
// See if number is positive or negative
@duanebester
duanebester / MessageOnlyWindow.cs
Created July 1, 2015 19:18
Message Only Window C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace MyAPI
{
@duanebester
duanebester / Merge.sc
Last active August 29, 2015 14:22
Merge Enumerations In Scala Worksheet
import java.util.Enumeration
class Merge(a:Enumeration[Integer], b:Enumeration[Integer]) extends Enumeration[Integer]
{
/**
* Checks to see if either Enumeration has any elements
* @return true if either input Enumeration has an element
* false if both Enumerations have no elements
*/
override def hasMoreElements: Boolean = {