Skip to content

Instantly share code, notes, and snippets.

View duanebester's full-sized avatar

Duane Bester duanebester

View GitHub Profile
@duanebester
duanebester / NowPlayingView.swift
Created January 28, 2020 03:09
Now Playing View
import SwiftUI
struct NowPlayingView: View {
var body: some View {
HStack(spacing: 16) {
Spacer()
ZStack {
Rectangle()
.fill(Color.primary)
.frame(width: 50, height: 50)
@duanebester
duanebester / TabIconsView.swift
Created January 28, 2020 03:05
Tab Icons View
import SwiftUI
struct TabIconsView: View {
var body: some View {
HStack {
Spacer()
Image(systemName: "person.crop.circle")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 25, height: 25)
@duanebester
duanebester / SongListView.swift
Created January 28, 2020 01:30
Song List View
import SwiftUI
struct Song: Identifiable, Codable {
let id: Int
let name: String
let artist: String
}
struct SongListView: View {
let names = ["Bailamos", "Dance Monkey", "One in a million", "Waka Waka", "Macarena"]
@duanebester
duanebester / ContentView1.swift
Created January 28, 2020 01:28
ContentView 01
import SwiftUI
struct ContentView: View {
var body: some View {
NavigationView {
ZStack {
SongListView()
}.navigationBarTitle("Music")
}
}
@duanebester
duanebester / spellCheckMethod.scala
Last active February 12, 2020 04:08
Spell Check Method
def spellCheck = Flow[String].map(ocr => {
import scala.collection.JavaConverters._
val words: Set[String] = ocr.replaceAll("-\n", "")
.replaceAll("\n", " ")
.replaceAll("-"," ")
.split("\\s+")
.map(_.replaceAll(
"[^a-zA-Z'’\\d\\s]", "") // Remove most punctuation
.trim)
.filter(!_.isEmpty).toSet
@duanebester
duanebester / spellCheck.scala
Created January 3, 2020 16:53
Spell Check Trait
trait Spell {
import com.atlascopco.hunspell.Hunspell
lazy val speller = new Hunspell("src/main/resources/en_US.dic", "src/main/resources/en_US.aff")
}
def imageSink(path:String, format:String = "png") = Sink.foreach[BufferedImage](bi => {
ImageIO.write(bi, format, new File(path))
})
val imagePreProcessFlow =
imageToBinaryImage.alsoTo(imageSink("binary.png"))
.via(imageEnhance).alsoTo(imageSink("enhanced.png"))
.via(imageDeSkew()).alsoTo(imageSink("deskew.png"))

Keybase proof

I hereby claim:

  • I am duanebester on github.
  • I am duanebester (https://keybase.io/duanebester) on keybase.
  • I have a public key ASDv_AHTmm_Feq3Wmefj91xFAlcB7yuKoXHiZ-ZFayLfaAo

To claim this, I am signing this object:

@duanebester
duanebester / processStage2.scala
Created December 9, 2019 01:04
Process Stage 2
def processStage(stageNum: Int) = Flow[BufferedImage]
.async
.delay(1 seconds)
.map(bi => {
val info = s"Processing Stage: ${stageNum}"
wsActor ! TextMessage(info)
bi
})
@duanebester
duanebester / ImageRoute.scala
Created December 9, 2019 00:57
Image Route
val imageRoute =
pathPrefix("image") {
path("status") {
get {
handleWebSocketMessages(wsStatusFlow)
}
} ~ path("upload") {
post {
uploadedFile("fileUpload") {
case (_, file) =>