Skip to content

Instantly share code, notes, and snippets.

View zygm0nt's full-sized avatar
🥑
AFK

Marcin Cylke zygm0nt

🥑
AFK
View GitHub Profile
@zygm0nt
zygm0nt / author stats
Created August 28, 2015 12:39
author contribution count
for i in `cat /tmp/authors`
do
echo $i ; git log --author="$i" --pretty=tformat: --numstat \
| gawk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s removed lines: %s total lines: %s\n", add, subs, loc }' -
done
@zygm0nt
zygm0nt / spray-route.scala
Created March 11, 2014 08:31
scala spray route debugging
trait AbcService with UnhandledRouteDebug {
override def receive: Actor.Receive = runRoute(logRequestResponse(myLog _) {
staticRoute ~ internalRoutes ~ routes
})
}
trait UnhandledRouteDebug {
def myLog(request: HttpRequest): Any => Option[LogEntry] = {
case x: HttpResponse => {
println (s"Normal: $request")
@zygm0nt
zygm0nt / static.spray.scala
Created March 11, 2014 08:46
spray - serve static files
import spray.routing.HttpService
import spray.httpx.SprayJsonSupport
import scala.concurrent.ExecutionContext
trait StaticWebService extends HttpService with SprayJsonSupport {
implicit def executor: ExecutionContext
def staticRoute =
pathPrefix("swagger") {

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert $1 -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 $2

Results

package foo.bar
import spray.routing._
import spray.http._
import spray.http.StatusCodes.Forbidden
// See https://developer.mozilla.org/en-US/docs/HTTP/Access_control_CORS
case class Origin(origin: String) extends HttpHeader {
@zygm0nt
zygm0nt / logging-monoid.scala
Created April 15, 2014 07:54
Logging via monoid
trait Monoid[A] {
def append(a1: A, a2: A): A
def empty: A
}
object Monoid {
implicit def ListMonoid[A]: Monoid[List[A]] = new Monoid[List[A]] {
def append(a1: List[A], a2: List[A]) = a1 ::: a2
def empty = Nil
}
@zygm0nt
zygm0nt / gist:0ec12209d02b2c284efb
Created May 26, 2014 12:46
sonar-scoverage-plugin.error
SonarQube Runner 2.4
Java 1.7.0_55 Oracle Corporation (64-bit)
Linux 3.8.0-38-generic amd64
INFO: Error stacktraces are turned on.
INFO: Runner configuration file: /home/user/Downloads/sonar-runner-2.4/conf/sonar-runner.properties
INFO: Project configuration file: /tmp/sonar-scoverage-plugin/samples/sbt/multi-module/sonar-project.properties
INFO: Default locale: "en_GB", source code encoding: "UTF-8" (analysis is platform dependent)
INFO: Work directory: /tmp/sonar-scoverage-plugin/samples/sbt/multi-module/./.sonar
INFO: SonarQube Server 4.3
14:39:07.867 INFO - Load batch settings
@zygm0nt
zygm0nt / README.md
Created July 31, 2014 06:33
spark 1.0.1 with akka 2.3.0
@zygm0nt
zygm0nt / s.scala
Last active August 29, 2015 14:14
case class Task(a: Int, b: Int)
case class TaskResult(result: Int)
class Collector(worker: ActorRef) extends Actor {
def receive = {
case task: Task => worker ! task
case TaskResult(r) => println(s"Got result: $r")
}
}
@zygm0nt
zygm0nt / gist:4d31de2f2c933109917d
Created February 18, 2015 10:07
check kafka consumers backlog
./kafka-run-class.sh kafka.tools.ConsumerOffsetChecker -zkconnect zookeeper.host:2181/external/kasia/kafka --group SparkStreamingJob-com.company.PurchaseEventSparkStreaming