Skip to content

Instantly share code, notes, and snippets.

@Jae-Myeong
Jae-Myeong / request-logging.scala
Created November 9, 2016 07:16 — forked from calvinlfer/request-logging.scala
Logging request duration, path, status code using Akka HTTP
// Setup
val rejectionHandler = RejectionHandler.default
val logDuration = extractRequestContext.flatMap { ctx =>
val start = System.currentTimeMillis()
// handling rejections here so that we get proper status codes
mapResponse { resp =>
val d = System.currentTimeMillis() - start
logger.info(s"[${resp.status.intValue()}] ${ctx.request.method.name} ${ctx.request.uri} took: ${d}ms")
resp
} & handleRejections(rejectionHandler)
@Jae-Myeong
Jae-Myeong / python_property.py
Created April 7, 2012 15:57
usage of python property
class Silly:
@property
def silly(self)
print("You are getting silly")
return self._silly
@silly.setter
def silly(self, value):
print("You are making silly {}".format(value))
self._silly = value
@Jae-Myeong
Jae-Myeong / tsearch_hsearch.c
Created April 7, 2012 15:54
usage of tsearch and hsearch_r(hsearch)
#include <stdio.h>
#define __USE_GNU
#include <search.h>
#include <sys/time.h>
#define NEL 512
typedef struct
{
char keyword[256];