Skip to content

Instantly share code, notes, and snippets.

@knight76
knight76 / Coursera-Python-Project-pillow-tesseract-opencv(3)
Created November 30, 2019 02:34
Coursera-Python-Project-pillow-tesseract-opencv(3)
import math
import zipfile
from PIL import Image, ImageOps, ImageDraw
import pytesseract
import cv2 as cv
import numpy as np
face_cascade = cv.CascadeClassifier('readonly/haarcascade_frontalface_default.xml')
parsed_img_src = {}
@knight76
knight76 / TupleAccumulator.scala
Created November 20, 2019 07:09
Spark - TupleAccumulator.scala example
import org.apache.spark.util.AccumulatorV2
import scala.collection.mutable
class TupleAccumulator extends AccumulatorV2[((String, String), Long), Map[(String, String), Long]] {
private val underlying: mutable.HashMap[(String, String), Long] = mutable.HashMap.empty
override def isZero: Boolean = underlying.isEmpty
override def copy(): AccumulatorV2[((String, String), Long), Map[(String, String), Long]] = {
@knight76
knight76 / ts2dt.go
Created October 11, 2019 10:53
ts2dt
package main
import (
"fmt"
"time"
"strconv"
"os"
)
func main() {
@knight76
knight76 / pipeline-timestamp(date)
Created September 25, 2019 08:30
elasticsearch
curl -X PUT "http://localhost:9200/_ingest/pipeline/reqlog-monthly-index" -H 'Content-Type: application/json' -d'
{
"description": "monthly index naming for reqlog",
"processors" : [
{
@knight76
knight76 / gist:82d3bf952ec5ae83a93b9f8ce8d3a6f8
Created September 25, 2019 04:36
java array iteration in Scala
scala> java.util.Arrays.asList("1", "2").toArray.foreach(println)
1
2
# read file and apply foreach.
# example - (curl )
for i in $(cat file); do
curl -X GET "http://localhost/api/v1/orders/$i" -H "accept: application/json;charset=UTF-8"
sleep 1
done